Sei sulla pagina 1di 17

Dim a As Integer

Dim TotalPrice As Integer


Dim allPrice As Integer
Dim Productcount As Integer
Dim Stockcount As Integer
Dim States As String
Dim tprice As Integer
Dim TP As Integer
Dim RA As Integer

Private Sub Com_Add_Click()


If Screen.MousePointer = vbHourglass Then Exit Sub
If Trim(Combo_SubCategeryView.Text) = "" Then
MsgBox "Enter Sub Categery", vbInformation
Combo_SubCategeryView.SetFocus
Exit Sub
End If
If Trim(Tx_qty.Text) = "" Then
MsgBox "Enter Quantity", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

If Trim(Combo_InvoiceType.Text) = "" Then


MsgBox "Enter Invoice Type", vbInformation
Combo_InvoiceType.SetFocus
Exit Sub
End If
If Trim(Combo_Client.Text) = "" Then
MsgBox "Enter Client", vbInformation
Combo_Client.SetFocus
Exit Sub
End If
If Val(Tx_oldstock.Text) < Val(Tx_qty.Text) Then
MsgBox "This Much Of Stock May Not Avalible", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

If setSalesHistory.Text = "" Then


mSalesHistoryID = ""
If mSalesHistoryID = "" Then
mSalesHistoryID = GetTranNo("SetSalesHistory", "", "")
End If
setSalesHistory.Text = mSalesHistoryID
End If
Sql = ("Select count(*) as cnt from N_SalesPayment where Sub_Categery ='" &
Trim(Combo_SubCategeryView.Text) & "'and SalesHistory='" &
Trim(setSalesHistory.Text) & "'and Client_No ='" & Trim(setClient.Text) & "'and
Invoice_No ='" & Trim(Tx_Invoice.Text) & "' and Cancelled = 'N' ")
tNo = GetVal(Sql, "cnt", 0, Ftcon)
If tNo > 0 Then
answer = MsgBox("This Product Already Add If U Want Add Again ?", vbYesNo +
vbQuestion)

If answer = "7" Then


Exit Sub
End If
If answer = "6" Then

Set GD = lgConn.Execute("Select * from N_SalesPayment where Sub_Categery ='" &


Trim(Combo_SubCategeryView.Text) & "'and SalesHistory='" &
Trim(setSalesHistory.Text) & "'and Client_No ='" & Trim(setClient.Text) & "'and
Invoice_No ='" & Trim(Tx_Invoice.Text) & "' and Cancelled = 'N' ")
If GD.EOF = False Then
Do While GD.EOF = False

Txoldqty.Text = GD("Quantity")

GD.MoveNext
Loop
End If
quan = (Val(Tx_qty.Text) + Val(Txoldqty.Text))

If Val(Tx_oldstock.Text) < Val(quan) Then


MsgBox "This Much Of Stock May Not Avalible", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

TotalPrice = Val(Tx_retailprice.Text) * Val(quan)


afld = Array("Quantity", "Price", "Total", "UserEditID", "State")
vfld = Array(Val(quan), Trim(Tx_retailprice.Text), TotalPrice, Trim(mCurUserID),
"N")
Sql = GetSQLString("N_SalesPayment", "U", afld, vfld, "Where Sub_Categery ='" &
Trim(Combo_SubCategeryView.Text) & "'and SalesHistory='" &
Trim(setSalesHistory.Text) & "'and Client_No ='" & Trim(setClient.Text) & "'and
Invoice_No ='" & Trim(Tx_Invoice.Text) & "' ")
lgConn.Execute (Sql)

End If
End If
If tNo = 0 Then

Productcount = Productcount + 1

TotalPrice = Val(Tx_retailprice.Text) * Val(Tx_qty.Text)


afld = Array("No", "Categery", "Sub_Categery", "Quantity", "Price", "Total",
"Invoice_No", "SalesHistory", "Client_No", "Cancelled", "UserEditID", "State")
vfld = Array(Productcount, Trim(Combo_CategeryView.Text),
Trim(Combo_SubCategeryView.Text), Trim(Tx_qty.Text), Trim(Tx_retailprice.Text),
TotalPrice, Trim(Tx_Invoice.Text), Trim(setSalesHistory.Text),
Trim(setClient.Text), "N", Trim(mCurUserID), "N")
Sql = GetSQLString("N_SalesPayment", "I", afld, vfld)
lgConn.Execute (Sql)

End If

Set GD = lgConn.Execute("SELECT Categery,Sub_Categery,Quantity,Price,Total


FROM N_SalesPayment where Invoice_No ='" & Trim(Tx_Invoice.Text) & "' and Client_No
='" & Trim(setClient.Text) & "' and SalesHistory='" & Trim(setSalesHistory.Text) &
"' and Cancelled = 'N' ORDER BY ID ASC")
With DataGrid1
Set .DataSource = GD
'.Columns(0).Width = 400
.Columns(0).Width = 2000
.Columns(1).Width = 2000
.Columns(2).Width = 800
.Columns(3).Width = 900
.Columns(4).Width = 900
End With
DataGrid1.Refresh
Call Entry

End Sub

Private Sub Entry()


Combo_CategeryView.Text = ""
Combo_SubCategeryView.Text = ""
Tx_oldstock.Text = ""
Tx_retailprice.Text = ""
Tx_qty.Text = ""
tot = 0
tota = 0
LblTotal.Caption = "0"
Combo_Item.Clear
Txoldqty.Text = ""

Set Trset = lgConn.Execute("Select * from N_SalesPayment where Invoice_No ='" &


Trim(Tx_Invoice.Text) & "' and SalesHistory ='" & Trim(setSalesHistory.Text) & "'
and Cancelled = 'N'order by No")

If Trset.EOF = False Then


Do While Trset.EOF = False

Combo_Item.AddItem Trset("No") & " - " & Trset("Sub_Categery")


tot = Trset("Total")
tota = Val(LblTotal.Caption) + Val(tot)
LblTotal.Caption = tota
Trset.MoveNext
Loop
End If
RA = Val(Lab_RA.Caption) + Val(Tx_rec.Text)
Tx_bal.Text = Val(LblTotal.Caption) - Val(RA)
Set GD = lgConn.Execute("SELECT Categery,Sub_Categery,Quantity,Price,Total
FROM N_SalesPayment where Invoice_No ='" & Trim(Tx_Invoice.Text) & "' and Client_No
='" & Trim(setClient.Text) & "' and SalesHistory='" & Trim(setSalesHistory.Text) &
"' and Cancelled = 'N' ORDER BY ID ASC")
With DataGrid1
Set .DataSource = GD
'.Columns(0).Width = 400
.Columns(0).Width = 2000
.Columns(1).Width = 2000
.Columns(2).Width = 800
.Columns(3).Width = 900
.Columns(4).Width = 900
End With
DataGrid1.Refresh

Com_Add.Enabled = True
End Sub
Private Sub Com_Invoice_Click()
If Screen.MousePointer = vbHourglass Then Exit Sub
If Com_Invoice.ListIndex <> -1 Then

Set Rrset = lgConn.Execute("Select * from N_SalesEntry where Cancelled = 'N' and


Invoice_No = '" & Trim(Com_Invoice.Text) & " ' ")
If Rrset.EOF = False Then
Do While Rrset.EOF = False

Lab_RA.Caption = Rrset("Receive_Amt")
Tx_Invoice.Text = Rrset("Invoice_No")
Tx_bal.Text = Rrset("Balance_Amt")
setClient.Text = Rrset("Client_No")
setSalesHistory.Text = Rrset("SalesHistory")
Combo_InvoiceType.Text = Rrset("Invoice_Type")
Rrset.MoveNext
Loop
End If

Set Rrset = lgConn.Execute("Select * from N_ClientName where Cancelled = 'N'


and SetClient ='" & Trim(setClient.Text) & "'")
If Rrset.EOF = False Then
Do While Rrset.EOF = False
Tx_Clientname.Text = Rrset("Clientname")
Combo_Client.Text = Rrset("Clientname")
Tx_phone.Text = Rrset("ClientPhone")
Tx_mail.Text = Rrset("ClientMail")
Combo_citysel.Text = GetIDtoText(Rrset("SetCity"), "N_City",
"CityName", "SetCity") 'thisID , another TableName , ColumName , ColumnID
Rrset.MoveNext
Loop
End If

Set Trset = lgConn.Execute("Select * from N_SalesPayment where Invoice_No ='" &


Trim(Tx_Invoice.Text) & "' and SalesHistory ='" & Trim(setSalesHistory.Text) & "'
and Cancelled = 'N' order by No")
Productcount = 0
If Trset.EOF = False Then
Do While Trset.EOF = False
Productcount = Productcount + 1
Trset.MoveNext
Loop
End If

Combo_CategeryView.Text = ""
Combo_SubCategeryView.Text = ""
Tx_oldstock.Text = ""
Tx_retailprice.Text = ""
Tx_qty.Text = ""
tot = 0
tota = 0
LblTotal.Caption = "0"
Combo_Item.Clear
Set Trset = lgConn.Execute("Select * from N_SalesPayment where Invoice_No ='" &
Trim(Tx_Invoice.Text) & "' and SalesHistory ='" & Trim(setSalesHistory.Text) & "'
and Cancelled = 'N'order by No")

If Trset.EOF = False Then


Do While Trset.EOF = False

Combo_Item.AddItem Trset("No") & " - " & Trset("Sub_Categery")


tot = Trset("Total")
tota = Val(LblTotal.Caption) + Val(tot)
LblTotal.Caption = tota
Trset.MoveNext
Loop
End If
RA = Val(Lab_RA.Caption) + Val(Tx_rec.Text)
Tx_bal.Text = Val(LblTotal.Caption) - Val(RA)
Set GD = lgConn.Execute("SELECT Categery,Sub_Categery,Quantity,Price,Total
FROM N_SalesPayment where Invoice_No ='" & Trim(Tx_Invoice.Text) & "' and Client_No
='" & Trim(setClient.Text) & "' and SalesHistory='" & Trim(setSalesHistory.Text) &
"' and Cancelled = 'N' ORDER BY ID ASC")
With DataGrid1
Set .DataSource = GD
'.Columns(0).Width = 400
.Columns(0).Width = 2000
.Columns(1).Width = 2000
.Columns(2).Width = 800
.Columns(3).Width = 900
.Columns(4).Width = 900
End With
DataGrid1.Refresh

End If

End Sub

Private Sub Com_Sav_Click()


If Screen.MousePointer = vbHourglass Then Exit Sub

answer = MsgBox("Do you Transtation?", vbYesNo + vbQuestion)


If answer = "7" Then
Exit Sub
End If

RA = Val(Lab_RA.Caption) + Val(Tx_rec.Text)
Tx_bal.Text = Val(LblTotal.Caption) - Val(RA)

If Trim(Com_Invoice.Text) = "" Then

If Combo_InvoiceType.Text = "Cash" Then


States = "C"
tot = Val(Lab_RA.Caption) + Val(Tx_rec.Text)
If Val(tot) < Val(LblTotal.Caption) Then
answer = MsgBox("This Much Of Amount Not Be Acceept On Cash Payment!",
vbOK + vbQuestion)
Exit Sub
End If

End If

If Combo_InvoiceType.Text = "Credit" Then


States = "D"
End If

afld = Array("Invoice_Type", "Receive_Amt", "Balance_Amt", "State")


vfld = Array(Trim(Combo_InvoiceType.Text), Trim(Tx_rec.Text), Trim(Tx_bal.Text),
States)
Sql = GetSQLString("N_SalesPayment", "U", afld, vfld, " where Invoice_No ='" &
Trim(Tx_Invoice.Text) & "' and SalesHistory = '" & Trim(setSalesHistory.Text) & "'
")
lgConn.Execute (Sql)

afld = Array("Total", "Invoice_Type", "Invoice_No", "SalesHistory", "Client_No",


"UserEditID", "Cancelled", "State", "Receive_Amt", "Balance_Amt")
vfld = Array(Trim(LblTotal.Caption), Trim(Combo_InvoiceType.Text),
Trim(Tx_Invoice.Text), Trim(setSalesHistory.Text), Trim(setClient.Text),
Trim(mCurUserID), "N", States, Trim(Tx_rec.Text), Trim(Tx_bal.Text))
Sql = GetSQLString("N_SalesEntry", "I", afld, vfld)
lgConn.Execute (Sql)

mSet_PaymentHistoryID = GetTranNo("Set_PaymentHistory", "", "")


Call Form_Load
Call Entry

Else

afld = Array("Invoice_Type", "Receive_Amt", "Balance_Amt", "State")


vfld = Array(Trim(Combo_InvoiceType.Text), Trim(Tx_rec.Text), Trim(Tx_bal.Text),
States)
Sql = GetSQLString("N_SalesPayment", "U", afld, vfld, " where Invoice_No ='" &
Trim(Tx_Invoice.Text) & "' and SalesHistory = '" & Trim(setSalesHistory.Text) & "'
")
lgConn.Execute (Sql)

TP = Val(Tx_rec.Text) + Val(Lab_RA.Caption)
afld = Array("Total", "Invoice_Type", "Invoice_No", "SalesHistory", "Client_No",
"UserEditID", "Cancelled", "State", "Receive_Amt", "Balance_Amt")
vfld = Array(Trim(LblTotal.Caption), Trim(Combo_InvoiceType.Text),
Trim(Tx_Invoice.Text), Trim(setSalesHistory.Text), Trim(setClient.Text),
Trim(mCurUserID), "N", States, TP, Trim(Tx_bal.Text))
Sql = GetSQLString("N_SalesEntry", "U", afld, vfld, " where Invoice_No ='" &
Trim(Tx_Invoice.Text) & "' and SalesHistory = '" & Trim(setSalesHistory.Text) & "'
")
lgConn.Execute (Sql)

Call Form_Load
Call Entry
End If

End Sub

Private Sub Com_Stock_Click()


If Screen.MousePointer = vbHourglass Then Exit Sub
If Trim(Combo_CategeryView.Text) = "" Then
MsgBox "Enter Categery Name", vbInformation
Combo_CategeryView.SetFocus
Exit Sub
End If
If Trim(Combo_SubCategeryView.Text) = "" Then
MsgBox "Enter Sub Categery Name", vbInformation
Combo_SubCategeryView.SetFocus
Exit Sub
End If

answer = MsgBox("Update Stock Entry", vbYesNo + vbQuestion)


If answer = "6" Then
afld = Array("Stock", "Retail_Price")
vfld = Array(Trim(Tx_oldstock.Text), Trim(Tx_retailprice.Text))
Sql = GetSQLString("N_SubCategery", "U", afld, vfld, "Where SetSubCategery ='" &
Trim(SetStock.Text) & "' ")
lgConn.Execute (Sql)

End If

Tx_oldstock.Enabled = False
Com_Stock.Visible = False
End Sub

Private Sub Combo_CategeryView_Click()


Combo_SubCategeryView.Clear
Combo_SubCategeryView.Text = ""
Tx_oldstock.Text = ""
Tx_retailprice.Text = ""

If Screen.MousePointer = vbHourglass Then Exit Sub


If Combo_CategeryView.ListIndex <> -1 Then

Set Rrset = lgConn.Execute("Select * from N_SubCategery where Cancelled = 'N' and


SetCategery = '" & GetTexttoID(Trim(Combo_CategeryView.Text), "N_Categery",
"CategeryName", "SetCategery") & "' ")
If Rrset.EOF = False Then
Do While Rrset.EOF = False
Combo_SubCategeryView.AddItem Rrset("SubCategeryName")
Rrset.MoveNext
Loop
End If
End If

Exit Sub
End Sub

Private Sub Combo_Client_Click()


Combo_citysel.Text = ""
setClient.Text = ""
Tx_phone.Text = ""
Tx_mail.Text = ""
Com_Invoice.Clear
If Screen.MousePointer = vbHourglass Then Exit Sub
If Combo_Client.ListIndex <> -1 Then
Set Rrset = lgConn.Execute("Select * from N_ClientName where Cancelled = 'N' and
ClientName ='" & Trim(Combo_Client.Text) & "'")
If Rrset.EOF = False Then
Do While Rrset.EOF = False
setClient.Text = Rrset("SetClient")
Tx_Clientname.Text = Rrset("Clientname")
Tx_phone.Text = Rrset("ClientPhone")
Tx_mail.Text = Rrset("ClientMail")
Combo_citysel.Text = GetIDtoText(Rrset("SetCity"), "N_City",
"CityName", "SetCity") 'thisID , another TableName , ColumName , ColumnID
Rrset.MoveNext
Loop
End If
End If

Set Trset = lgConn.Execute("Select Invoice_No from N_SalesEntry where State =


'D' and Client_No ='" & Trim(setClient.Text) & "' order by Invoice_No")
If Trset.EOF = False Then
Do While Trset.EOF = False
Com_Invoice.AddItem Trset("Invoice_No")
Trset.MoveNext
Loop
End If

Exit Sub

End Sub

Private Sub Com_Save_Click(Index As Integer)


If Screen.MousePointer = vbHourglass Then Exit Sub
If Trim(Tx_Clientname.Text) = "" Then
MsgBox "Enter Client Name", vbInformation
Tx_Clientname.SetFocus
Exit Sub
End If
If Trim(Tx_phone.Text) = "" Then
MsgBox "Enter Phone", vbInformation
Tx_phone.SetFocus
Exit Sub
End If
If Trim(Tx_mail.Text) = "" Then
MsgBox "Enter Mail", vbInformation
Tx_mail.SetFocus
Exit Sub
End If

answer = MsgBox("Save", vbYesNo + vbQuestion)


If answer = 7 Then
Exit Sub
End If
If Trim(Combo_Client.Text) = "" Then
Sql = ("Select count(*) as cnt from N_ClientName where ClientName ='" &
Trim(Tx_Clientname.Text) & "' and ClientPhone ='" & Trim(Tx_phone.Text) & "' and
ClientMail ='" & Trim(Tx_mail.Text) & "' and Cancelled = 'N'")
tNo = GetVal(Sql, "cnt", 0, Ftcon)
If tNo > 0 Then
MsgBox "ClientName already exists", vbCritical
Tx_Clientname.SetFocus
Exit Sub
End If
mClientID = ""
If mClientID = "" Then
mClientID = GetTranNo("SetClient", "", "")
End If
setClient.Text = mClientID

afld = Array("ClientName", "ClientPhone", "ClientMail", "SetCity", "Cancelled",


"SetClient")
vfld = Array(Trim(Tx_Clientname.Text), Trim(Tx_phone.Text), Trim(Tx_mail.Text),
GetTexttoID(Trim(Combo_citysel.Text), "N_City", "CityName", "SetCity"), "N",
Trim(setClient.Text))
Sql = GetSQLString("N_ClientName", "I", afld, vfld)
lgConn.Execute (Sql)

Else
answer = MsgBox("Update", vbYesNo + vbQuestion)
lgConn.Execute "Update N_ClientName set ClientName ='" &
Trim(Tx_Clientname.Text) & "' ,ClientPhone ='" & Trim(Tx_phone.Text) & "' ,
ClientMail ='" & Trim(Tx_mail.Text) & "', SetCity ='" &
GetTexttoID(Trim(Combo_citysel.Text), "N_City", "CityName", "SetCity") & "' where
SetClient ='" & Trim(setClient.Text) & "'"
End If
Call Form_Load
End Sub

Private Sub Combo_Item_Click()


Combo_CategeryView.Text = ""
Combo_SubCategeryView.Text = ""
Tx_retailprice.Text = ""
Tx_oldstock.Text = ""
Tx_qty.Text = ""
Com_Add.Enabled = False

If Screen.MousePointer = vbHourglass Then Exit Sub


If Combo_Item.ListIndex <> -1 Then
aq = Mid(Trim(Combo_Item.Text), 1, 2)
Set Rrset = lgConn.Execute("Select * from N_SalesPayment where Cancelled = 'N' and
No = '" & Mid(Trim(Combo_Item.Text), 1, 2) & "' and SalesHistory = '" &
Trim(setSalesHistory.Text) & "'")

If Rrset.EOF = False Then


Do While Rrset.EOF = False
Combo_CategeryView.Text = Rrset("Categery")
Combo_SubCategeryView.Text = Rrset("Sub_Categery")
Tx_qty.Text = Rrset("Quantity")
Rrset.MoveNext
Loop
End If
End If

Set Rrset = lgConn.Execute("Select * from N_SubCategery where Cancelled = 'N' and


SubCategeryName = '" & Trim(Combo_SubCategeryView.Text) & "'")
If Rrset.EOF = False Then
Do While Rrset.EOF = False
Tx_oldstock.Text = Rrset("Stock")
Tx_retailprice.Text = Rrset("Retail_Price")
Rrset.MoveNext
Loop
End If

Exit Sub

End Sub

Private Sub Combo_SubCategeryView_Click()

Tx_retailprice.Text = ""
Tx_oldstock.Text = ""
Txoldqty.Text = ""

If Screen.MousePointer = vbHourglass Then Exit Sub


If Combo_SubCategeryView.ListIndex <> -1 Then

Set Rrset = lgConn.Execute("Select * from N_SubCategery where Cancelled = 'N' and


SubCategeryName = '" & Trim(Combo_SubCategeryView.Text) & "'")
If Rrset.EOF = False Then
Do While Rrset.EOF = False
Tx_oldstock.Text = Rrset("Stock")
Tx_retailprice.Text = Rrset("Retail_Price")
SetStock.Text = Rrset("SetSubCategery")
Rrset.MoveNext
Loop
End If
End If

If Tx_oldstock.Text = "0" Then


Tx_oldstock.Enabled = True
Com_Stock.Visible = True
End If
If Tx_oldstock.Text = " " Then
Tx_oldstock.Enabled = True
Com_Stock.Visible = True
End If

End Sub

Private Sub Command1_Click()

End Sub

Private Sub Command2_Click()


Call Form_Load
Call Entry
End Sub
Private Sub Com_Update_Click()
If Trim(Combo_Item.Text) = "" Then
MsgBox "Select Item No", vbInformation
Combo_Item.SetFocus
Exit Sub
End If

If Trim(Combo_SubCategeryView.Text) = "" Then


MsgBox "Enter Sub Categery", vbInformation
Combo_SubCategeryView.SetFocus
Exit Sub
End If
If Trim(Tx_qty.Text) = "" Then
MsgBox "Enter Quantity", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

If Trim(Combo_InvoiceType.Text) = "" Then


MsgBox "Enter Invoice Type", vbInformation
Combo_InvoiceType.SetFocus
Exit Sub
End If
If Trim(Combo_Client.Text) = "" Then
MsgBox "Enter Client", vbInformation
Combo_Client.SetFocus
Exit Sub
End If
If Val(Tx_oldstock.Text) < Val(Tx_qty.Text) Then
MsgBox "This Much Of Stock May Not Avalible", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

answer = MsgBox("Do U Update?", vbYesNo + vbQuestion)

If answer = "6" Then


TotalPrice = Val(Tx_retailprice.Text) * Val(Tx_qty.Text)

afld = Array("Categery", "Sub_Categery", "Quantity", "Price", "Total",


"Invoice_Type", "Client_No", "Cancelled", "UserEditID")
vfld = Array(Trim(Combo_CategeryView.Text), Trim(Combo_SubCategeryView.Text),
Trim(Tx_qty.Text), Trim(Tx_retailprice.Text), TotalPrice,
Trim(Combo_InvoiceType.Text), Trim(setClient.Text), "N", Trim(mCurUserID))
Sql = GetSQLString("N_SalesPayment", "U", afld, vfld, " where SalesHistory = '" &
Trim(setSalesHistory.Text) & "' and No = '" & Mid(Trim(Combo_Item.Text), 1, 2) &
"'")

lgConn.Execute (Sql)
Call Entry

End If

If answer = "7" Then


Exit Sub
End If
End Sub
Private Sub Command4_Click()
If Trim(Combo_Item.Text) = "" Then
MsgBox "Select Item No", vbInformation
Tx_Acadamic_Yrsname.SetFocus
Exit Sub
End If
answer = MsgBox("Delete", vbYesNo + vbQuestion)

If answer = "6" Then


Sql = "Update N_SalesPayment set Cancelled = 'Y' where SalesHistory = '" &
Trim(setSalesHistory.Text) & "' and No = '" & Mid(Trim(Combo_Item.Text), 1, 2) &
"'"
lgConn.Execute (Sql)
Call Entry

End If

If answer = "7" Then


Exit Sub
End If
End Sub

Private Sub Form_Load()


Call InitConnLogin
Com_Add.Enabled = True

ComboInvoice.Clear
ComboInvoice.Text = ""
Combo_CategeryView.Clear
Combo_CategeryView.Text = ""
Combo_SubCategeryView.Clear
Combo_SubCategeryView.Text = ""
Combo_citysel.Clear
Combo_Client.Clear
Combo_citysel.Text = ""
Combo_Client.Text = ""
Tx_Clientname.Text = ""
setClient.Text = ""
Tx_phone.Text = ""
Tx_mail.Text = ""
LblTotal.Caption = ""
Tx_rec.Text = ""
Tx_bal.Text = ""
setSalesHistory.Text = ""
Combo_InvoiceType.Clear
Combo_InvoiceType.AddItem "Cash"
Combo_InvoiceType.AddItem "Credit"
Combo_InvoiceType.Text = "Cash"
Combo_Item.Clear
Combo_Item.Text = ""
Com_Invoice.Clear
Com_Invoice.Text = ""
Lab_RA.Caption = ""
TP = 0
tprice = 0
TotalPrice = 0
Productcount = 0
Txoldqty.Text = ""

Set Trset = lgConn.Execute("Select CityName from N_City where Cancelled = 'N'


order by CityName")
If Trset.EOF = False Then
Do While Trset.EOF = False
Combo_citysel.AddItem Trset("CityName")
Trset.MoveNext
Loop
End If

Set Trset = lgConn.Execute("Select ClientName from N_ClientName where Cancelled


= 'N' order by ClientName")
If Trset.EOF = False Then
Do While Trset.EOF = False
Combo_Client.AddItem Trset("ClientName")
Trset.MoveNext
Loop
End If

Set Trset = lgConn.Execute("Select * from N_Support where TranType =


'Set_PaymentHistory'")
If Trset.EOF = False Then
Do While Trset.EOF = False
a = Trset("TranNo")
Tx_Invoice.Text = Val(a) + 1
Trset.MoveNext
Loop
End If

Set Trset = lgConn.Execute("Select CategeryName from N_Categery where Cancelled


= 'N' order by CategeryName")
If Trset.EOF = False Then
Do While Trset.EOF = False
Combo_CategeryView.AddItem Trset("CategeryName")
Trset.MoveNext
Loop
End If

Set Trset = lgConn.Execute("Select Invoice_No from N_SalesEntry order by


Invoice_No")
If Trset.EOF = False Then
Do While Trset.EOF = False
Com_Invoice.AddItem Trset("Invoice_No")
Trset.MoveNext
Loop
End If

End Sub

Private Sub Lab132_Click(Index As Integer)


Call Form_Load
Me.Hide
End Sub

Private Sub Label1_Click(Index As Integer)


Stock_frm.Show
End Sub

Private Sub Tx_oldstock_Change()


Dim keychar As String
If KeyAscii > 31 Then
keychar = Chr(KeyAscii)
If Not IsNumeric(keychar) Then
KeyAscii = 0
End If
End If
End Sub

Private Sub Tx_phone_KeyDown(KeyCode As Integer, Shift As Integer)


Dim keychar As String
If KeyAscii > 31 Then
keychar = Chr(KeyAscii)
If Not IsNumeric(keychar) Then
KeyAscii = 0
End If
End If

Combo_citysel.Text = ""
Combo_Client.Text = ""
setClient.Text = ""
Tx_mail.Text = ""

If KeyCode = "13" Then


If Screen.MousePointer = vbHourglass Then Exit Sub

Set Rrset = lgConn.Execute("Select * from N_ClientName where Cancelled = 'N' and


ClientPhone ='" & Trim(Tx_phone.Text) & "'")
If Rrset.EOF = False Then
Do While Rrset.EOF = False
setClient.Text = Rrset("SetClient")
Tx_mail.Text = Rrset("ClientMail")
Combo_Client.Text = Rrset("ClientName")
Combo_citysel.Text = GetIDtoText(Rrset("SetCity"), "N_City",
"CityName", "SetCity") 'thisID , another TableName , ColumName , ColumnID
Rrset.MoveNext
Loop
End If
Exit Sub

End If
End Sub

Private Sub Tx_qty_KeyPress(KeyAscii As Integer)


Dim keychar As String
If KeyAscii > 31 Then
keychar = Chr(KeyAscii)
If Not IsNumeric(keychar) Then
KeyAscii = 0
End If
End If

Select Case KeyAscii


Case 97 To 122
KeyAscii = KeyAscii - 32
End Select

If KeyAscii = "13" And Combo_Item.Text = "" Then


If Screen.MousePointer = vbHourglass Then Exit Sub
If Trim(Combo_SubCategeryView.Text) = "" Then
MsgBox "Enter Sub Categery", vbInformation
Combo_SubCategeryView.SetFocus
Exit Sub
End If
If Trim(Tx_qty.Text) = "" Then
MsgBox "Enter Quantity", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

If Trim(Combo_InvoiceType.Text) = "" Then


MsgBox "Enter Invoice Type", vbInformation
Combo_InvoiceType.SetFocus
Exit Sub
End If
If Trim(Combo_Client.Text) = "" Then
MsgBox "Enter Client", vbInformation
Combo_Client.SetFocus
Exit Sub
End If
If Val(Tx_oldstock.Text) < Val(Tx_qty.Text) Then
MsgBox "This Much Of Stock May Not Avalible", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

If setSalesHistory.Text = "" Then


mSalesHistoryID = ""
If mSalesHistoryID = "" Then
mSalesHistoryID = GetTranNo("SetSalesHistory", "", "")
End If
setSalesHistory.Text = mSalesHistoryID
End If
Sql = ("Select count(*) as cnt from N_SalesPayment where Sub_Categery ='" &
Trim(Combo_SubCategeryView.Text) & "'and SalesHistory='" &
Trim(setSalesHistory.Text) & "'and Client_No ='" & Trim(setClient.Text) & "'and
Invoice_No ='" & Trim(Tx_Invoice.Text) & "' and Cancelled = 'N'")
tNo = GetVal(Sql, "cnt", 0, Ftcon)
If tNo > 0 Then
answer = MsgBox("This Product Already Add If U Want Add Again ?", vbYesNo +
vbQuestion)
If answer = "7" Then
Exit Sub
End If
End If

TotalPrice = Val(Tx_retailprice.Text) * Val(Tx_qty.Text)


afld = Array("No", "Categery", "Sub_Categery", "Quantity", "Price", "Total",
"Invoice_Type", "Invoice_No", "SalesHistory", "Client_No", "Cancelled",
"UserEditID")
vfld = Array(Productcount, Trim(Combo_CategeryView.Text),
Trim(Combo_SubCategeryView.Text), Trim(Tx_qty.Text), Trim(Tx_retailprice.Text),
TotalPrice, Trim(Combo_InvoiceType.Text), Trim(Tx_Invoice.Text),
Trim(setSalesHistory.Text), Trim(setClient.Text), "N", Trim(mCurUserID))
Sql = GetSQLString("N_SalesPayment", "I", afld, vfld)
lgConn.Execute (Sql)
Productcount = Productcount + 1

Set GD = lgConn.Execute("SELECT No,Categery,Sub_Categery,Quantity,Price,Total


FROM N_SalesPayment where Invoice_No ='" & Trim(Tx_Invoice.Text) & "' and Client_No
='" & Trim(setClient.Text) & "' and SalesHistory='" & Trim(setSalesHistory.Text) &
"' ORDER BY ID ASC")
With DataGrid1
Set .DataSource = GD
.Columns(0).Width = 400
.Columns(1).Width = 2000
.Columns(2).Width = 2000
.Columns(3).Width = 800
.Columns(4).Width = 900
.Columns(5).Width = 900
End With
DataGrid1.Refresh
Call Entry
End If

If KeyAscii = "13" And Combo_Item.ListIndex <> -1 Then

If Trim(Combo_Item.Text) = "" Then


MsgBox "Select Item No", vbInformation
Combo_Item.SetFocus
Exit Sub
End If

If Trim(Combo_SubCategeryView.Text) = "" Then


MsgBox "Enter Sub Categery", vbInformation
Combo_SubCategeryView.SetFocus
Exit Sub
End If
If Trim(Tx_qty.Text) = "" Then
MsgBox "Enter Quantity", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

If Trim(Combo_InvoiceType.Text) = "" Then


MsgBox "Enter Invoice Type", vbInformation
Combo_InvoiceType.SetFocus
Exit Sub
End If
If Trim(Combo_Client.Text) = "" Then
MsgBox "Enter Client", vbInformation
Combo_Client.SetFocus
Exit Sub
End If
If Val(Tx_oldstock.Text) < Val(Tx_qty.Text) Then
MsgBox "This Much Of Stock May Not Avalible", vbInformation
Tx_qty.SetFocus
Exit Sub
End If

answer = MsgBox("Do U Update?", vbYesNo + vbQuestion)

If answer = "6" Then


TotalPrice = Val(Tx_retailprice.Text) * Val(Tx_qty.Text)

afld = Array("Categery", "Sub_Categery", "Quantity", "Price", "Total",


"Invoice_Type", "Invoice_No", "Client_No", "Cancelled", "UserEditID")
vfld = Array(Trim(Combo_CategeryView.Text), Trim(Combo_SubCategeryView.Text),
Trim(Tx_qty.Text), Trim(Tx_retailprice.Text), TotalPrice,
Trim(Combo_InvoiceType.Text), Trim(Tx_Invoice.Text), Trim(setClient.Text), "N",
Trim(mCurUserID))
Sql = GetSQLString("N_SalesPayment", "U", afld, vfld, " where SalesHistory = '" &
Trim(setSalesHistory.Text) & "' and No = '" & Trim(Combo_Item.Text) & "'")

lgConn.Execute (Sql)
Call Entry

End If

If answer = "7" Then


Exit Sub
End If

End If
End Sub

Private Sub Tx_rec_Change()


RA = Val(Lab_RA.Caption) + Val(Tx_rec.Text)

Tx_bal.Text = Val(RA) - Val(LblTotal.Caption)


End Sub

Private Sub Tx_rec_KeyPress(KeyAscii As Integer)


Dim keychar As String
If KeyAscii > 31 Then
keychar = Chr(KeyAscii)
If Not IsNumeric(keychar) Then
KeyAscii = 0
End If
End If
End Sub

Private Sub Tx_retailprice_Change()


Dim keychar As String
If KeyAscii > 31 Then
keychar = Chr(KeyAscii)
If Not IsNumeric(keychar) Then
KeyAscii = 0
End If
End If
End Sub