PDA

View Full Version : سوال: مشكل با combobox



yshahab
یک شنبه 14 تیر 1388, 09:47 صبح
بچه ها من خط فرمانهاي قرمز رو به اين دستورات اضافه كردم . در ديتا بيسم هم فيلدهاي لازم را اضافه كردم و كلا همه چيز درسته ولي چيزي كه هست اينه كه ذخيره نمي شه و ارور آخرين خط فرمان خط آبي رو ميده .

Private Sub CmndCalculate_Click()
'// Calculate Value(s)
Call Calculate
End Sub

Private Sub CmndSave_Click()

Dim OleDb As New ClassOleDb
Dim Cmnd As String
Cmnd = "INSERT INTO Piece (Code,Description,Process,Article,Filet,basteh,Wid th,Lenght,Quantity,Quantity1,Width3,Width4,tolid,t 0,t1,t2,t3,feeee,feenavar,feemadeh,QU,Tax) Values ('" & _
TxtBoxCode.Text & "','" & _
TxtBoxDescription.Text & "','" & _
TxtBoxProcess.Text & "','" & _
CmboArticle.Text & "','" & _
CmboFilet.Text & "'," & _
Combobasteh.Text & "'," & _
TxtBoxWidth.Text & "," & _
TxtBoxLenght.Text & "," & _
TxtBoxQuantity.Text & "," & _
TxtBoxQuantity1.Text & "," & _
TxtBoxWidth3.Text & "," & _
TxtBoxWidth4.Text & "," & _
txt.Text & "," & _
total0.Text & "," & _
total1.Text & "," & _
total2.Text & "," & _
total3.Text & "," & _
TxtBoxTotalFee.Text & "," & _
TxtBoxFiletAmount.Text & "," & _
TxtBoxArticleAmount.Text & "," & _
txtqu.Text & "," & _
TxtBoxTax.Text & ")"

'// Run Query
If OleDb.ExecuteQuery(Cmnd) = True Then
MsgBox "با موفقيت ذخيره شد", vbOKOnly
Unload Me
End If

'//Release Memory
Set OleDb = Nothing

End Sub

Private Sub Form_Load()
'// Load Captions
Call LoadFormCaption(Me)

'// Load ArticlesAndFilets
Call LoadArticlesAndFilets
End Sub

Sub LoadArticlesAndFilets()

Dim OleDb As New ClassOleDb
Dim rs As New Recordset
Dim Cmnd As String
Dim i&, j&



'// Load Available Article(s)

Cmnd = "SELECT * From Article"
Set rs = OleDb.Fill(Cmnd)


If Not (rs.EOF) Then

i = 0
rs.MoveFirst
Do
CmboArticle.AddItem rs.Fields("Type").Value

'// Move to next record
i = i + 1
rs.MoveNext
Loop Until rs.EOF

'// Select 1st Item
CmboArticle.ListIndex = 0

End If



'// Load Available Filet(s)

Cmnd = "SELECT * From Filet"
Set rs = OleDb.Fill(Cmnd)


If Not (rs.EOF) Then

i = 0
rs.MoveFirst
Do
CmboFilet.AddItem rs.Fields("Type").Value

'// Move to next record
i = i + 1
rs.MoveNext
Loop Until rs.EOF

'// Select 1st Item
CmboFilet.ListIndex = 0

End If

'// Load Available basteh(s)

Cmnd = "SELECT * From Basteh "
Set rs = OleDb.Fill(Cmnd)


If Not (rs.EOF) Then

i = 0
rs.MoveFirst
Do
Combobasteh.AddItem rs.Fields("Name").Value

'// Move to next record
i = i + 1
rs.MoveNext
Loop Until rs.EOF

'// Select 1st Item
Combobasteh.ListIndex = 0
End If



'//Release Memory
Set rs = Nothing
Set OleDb = Nothing

End Sub

Sub Calculate()

On Error GoTo ErrHandler

Dim OleDb As New ClassOleDb
Dim rs As New Recordset
Dim Cmnd As String



'// Calculate Value(s)

Dim ArticleAmount, FiletAmount, mb, mn, ms, msh, majmoo As Double
Dim Width, Width3, Width4, Lenght, Quantity, Quantity1, Quantity3, Quantity4, Quantity5, tolid As Long

Width = CLng(TxtBoxWidth.Text)
Width3 = CLng(TxtBoxWidth3.Text)
Width4 = CLng(TxtBoxWidth4.Text)
Lenght = CLng(TxtBoxLenght.Text)
Quantity = CLng(TxtBoxQuantity.Text)
Quantity1 = CLng(TxtBoxQuantity1.Text)
tolid = CLng(txt.Text)

mb = ((Width * 2) + (Lenght * 2)) * 2
mn = (3000 * ((Width * Quantity) + (Lenght * Quantity1))) / 1000
ms = 1500 * Width3
msh = 2000 * Width4
majmoo = ((((Width * 2) + (Lenght * 2)) * 2) + (mn) + (1500 * Width3) + (2000 * Width4))
ArticleAmount = ((Width * Lenght) / 1000000) * (txtqu.Text)
FiletAmount = (((Width * Quantity) + (Lenght * Quantity1)) / 1000) * (txtqu.Text)

TxtBoxArticleAmount.Text = Abs(ArticleAmount)
TxtBoxFiletAmount.Text = Abs(FiletAmount)
total0.Text = Int(mb)
total1.Text = Int(mn)
total2.Text = Int(ms)
total3.Text = Int(msh)
txt.Text = Int(majmoo)








'// Load Selected Article Fee

Dim ArticleFee As Double

Cmnd = "SELECT * From Article WHERE Type='" & CmboArticle.Text & "'"
Set rs = OleDb.Fill(Cmnd)

ArticleFee = rs.Fields(1).Value



'// Load Selected Filet Fee

Dim FiletFee As Double

Cmnd = "SELECT * From Filet WHERE Type='" & CmboFilet.Text & "'"
Set rs = OleDb.Fill(Cmnd)

FiletFee = rs.Fields(1).Value

'// Load Selected basteh Fee

Dim bastehFee As Double

Cmnd = "SELECT * From Basteh WHERE Name='" & Combobasteh.Text & "'"
Set rs = OleDb.Fill(Cmnd)

bastehFee = rs.Fields(1).Value




'// Calculate Total Fee

Dim TotalFee As Double
TotalFee = ((ArticleAmount * ArticleFee) + (mb) + (mn) + (ms) + (msh) + (FiletAmount * FiletFee) + CLng(Val(TxtBoxTax.Text))) * (txtqu.Text)

TxtBoxTotalFee.Text = Abs(TotalFee)



'//Release Memory
Set rs = Nothing
Set OleDb = Nothing

Exit Sub

ErrHandler:
MsgBox "اشكال در ذخيره اطلاعات ", vbOKOnly

End Sub

yshahab
یک شنبه 14 تیر 1388, 11:12 صبح
اساتيد كسي كمك نمي كنه ؟

yshahab
یک شنبه 14 تیر 1388, 22:47 عصر
بچه ها يه نگاهي بندازين