Вы находитесь на странице: 1из 36

Software Engineering

Introduction
This project is done to full-fill the requirements for Software Engineering 1st year project. This Project/software is done for a Hole Sale Company (Shop Charlotte) not a real company name and also can be used for a private sales business company. In this project I have used Visual Basic 6.0 programming software to design and coding the software/application for the above mentioned company.

Page 1 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

Logging Page of the Main Program


Logging page have been used as a security feature for this software to keep the software and company details safe and secured always. Every user must enter their user name and password to continue using the program.

Private Sub Command1_Click() connect conn.Open Set rs = New ADODB.Recordset rs.Open "select * from Login where Username='" + Text1.Text + "'", conn, adOpenStatic, adLockOptimistic If rs.RecordCount = 0 Then MsgBox ("please check you user name") Else Dim P, P1 As String P = Text2.Text P1 = rs("Password") If (P = P1) Then If rs("Status") <> "Administrator" Then MDIForm1.pur.Visible = False MDIForm1.St.Visible = False MDIForm1.RO.Visible = False Page 2 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering MDIForm1.AG.Visible = False MDIForm1.co.Visible = False End If MDIForm1.Show Unload Me conn.Close Else MsgBox ("please check your password") End If End If Text1 = "" Text2 = "" End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 4635 Me.Width = 6810 End Sub

Page 3 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

Loading process page


The loading process page is used in this program to provide access to the main programs after entering the user name and password. Without the loading process page the user cant access to the main program.

Private Sub Timer1_Timer() ProgressBar1.Value = Val(Label1.Caption) + 1 Label1.Caption = ProgressBar1.Value If Label1.Caption < 20 Then Label3.Caption = "Welcome" ElseIf Label1.Caption < 60 Then Label3.Caption = "Connecting to Database.." ElseIf Label1.Caption = 100 Then Timer1.Enabled = False Form2.Show Unload Me End If End Sub

Page 4 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

Main program Page. (MDI form)


The MDI form has been used for this program as the GUI or the graphical user working space for the program. In this from or window the user can update, delete, view stock, check the agents...Status of any details of the company.

Private Sub AA_Click() Form8.Show End Sub Private Sub AC_Click() Form9.Show Page 5 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering End Sub Private Sub ADD_Click() Form7.Show End Sub Private Sub APD_Click() Form3.Show End Sub Private Sub APRD_Click() Form6.Show End Sub Private Sub ARD_Click() Form5.Show End Sub Private Sub ASD_Click() Form4.Show End Sub Private Sub ED_Click() Form11.Show End Sub Private Sub EDC_Click() Form12.Show End Sub Private Sub MDIForm_Load() WindowState = 2 End Sub Private Sub PRRR_Click() Form10.Show End Sub

Page 6 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

Sub parts of the (MDI form) or the main window of the program *Purchase
In this window what you are able to see is the purchased items from the company. In this window u will be able to list down or add the required details of the purchased items.

Private Sub Command1_Click() If (Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "") Then MsgBox ("Please enter the details") Else connect Page 7 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering conn.Open Set rs1 = New ADODB.Recordset rs1.Open "insert into Purchase values('" + Text1.Text + "','" + Text2.Text + "'," + Text3.Text + "," + Text4.Text + ",'" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "'," + Text8.Text + ",'" + Text9.Text + "')", conn, adOpenDynamic, adLockOptimistic MsgBox ("purchase details Added") Set rs3 = New ADODB.Recordset rs3.Open "select * from Stock where itemcode='" + Text2.Text + "'", conn, adOpenStatic, adLockOptimistic If (rs3.RecordCount > 0) Then Dim dq, fq, bal As Integer dq = Val(rs3("itemquantity")) fq = Val(Text4.Text) bal = dq + fq Set rs4 = New ADODB.Recordset rs4.Open "update Stock set itemquantity=" & bal & " where itemcode='" + Text2.Text + "'", conn, adOpenStatic, adLockOptimistic MsgBox ("The stock database has been updated") Set rs3 = New ADODB.Recordset rs3.Open "delete from Reorder where itemcode= '" & Text2.Text & "'", conn, adOpenDynaset, adLockOptimistic Else Set rs2 = New ADODB.Recordset rs2.Open "insert into Stock values('" + Text1.Text + "','" + Text2.Text + "','" + Text5.Text + "'," + Text4.Text + ")", conn, adOpenDynaset, adLockOptimistic MsgBox ("New Stock has been added") End If conn.Close End If End Sub Private Sub Command2_Click() Unload Me End Sub

Page 8 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering Private Sub Command3_Click() Frame1.Visible = True connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Agents", conn, adOpenStatic, adLockOptimistic Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | Agent Name | Agent ID " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Grid1.TextMatrix(Rowval, 0) = Rowval Grid1.TextMatrix(Rowval, 1) = rs1("Agent_Name") Grid1.TextMatrix(Rowval, 2) = rs1("Agent_ID")

rs1.MoveNext Loop conn.Close End Sub Private Sub Command4_Click() Frame2.Visible = True Frame1.Visible = False Grid2.clear connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Stock ", conn, adOpenStatic, adLockOptimistic Grid2.clear Grid2.Rows = 1 Grid2.FormatString = " | Item Name | Item Code " Do Until rs1.EOF Grid2.Rows = Grid2.Rows + 1 Rowval = Grid2.Rows - 1 Grid2.TextMatrix(Rowval, 0) = Rowval Grid2.TextMatrix(Rowval, 1) = rs1("itemname") Grid2.TextMatrix(Rowval, 2) = rs1("itemcode")

Page 9 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering rs1.MoveNext Loop conn.Close End Sub Private Sub DTPicker1_CloseUp() Text5.Text = DTPicker1.Value End Sub Private Sub Form_Load() Me.Height = 9165 Me.Width = 12375 Frame1.Visible = False Frame2.Visible = False End Sub Private Sub Grid1_Click() Text6.Text = Grid1.TextMatrix(Grid1.Row, 1) Text7.Text = Grid1.TextMatrix(Grid1.Row, 2) Frame1.Visible = False End Sub Private Sub Grid2_Click() Text1.Text = Grid2.TextMatrix(Grid2.Row, 1) Text2.Text = Grid2.TextMatrix(Grid2.Row, 2) Frame2.Visible = False End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Stock where itemcode='" + Text2.Text + "'", conn, adOpenStatic, adLockOptimistic If rs1.RecordCount = 0 Then Text1.Text = "" Text1.SetFocus Else Text1.Text = rs1("itemname") End If End If End Sub

Page 10 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Purchase Return
In this window what u can see is the Purchase Return window. In this window the user can search the items to be returned by faulty or disliked by the company.. And the user can update the purchased items to be returned.

Private Sub Command1_Click() If (Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "") Then MsgBox ("Please enter the details") Else connect conn.Open Set rs1 = New ADODB.Recordset

Page 11 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering rs1.Open "insert into Purchase_Return values('" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "'," + Text4.Text + "," + Text5.Text + ",'" + Text6.Text + "','" + Text7.Text + "','" + Text8.Text + "')", conn, adOpenDynaset, adLockOptimistic MsgBox ("purchase return details Added") Set rs2 = New ADODB.Recordset rs2.Open "update Stock Set itemquantity = " + Label13.Caption + " where itemcode='" + Text2.Text + "'", conn, adOpenDynamic, adLockOptimistic MsgBox "STOCK DATABASE HAS BEEN UPDATED" conn.Close End If End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Command3_Click() Frame1.Visible = True Grid1.clear connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Stock ", conn, adOpenStatic, adLockOptimistic Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | Item Name | Item Code | Stock " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Grid1.TextMatrix(Rowval, 0) = Rowval Grid1.TextMatrix(Rowval, 1) = rs1("itemname") Grid1.TextMatrix(Rowval, 2) = rs1("itemcode") Grid1.TextMatrix(Rowval, 3) = rs1("itemquantity") rs1.MoveNext Loop conn.Close End Sub

Page 12 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering Private Sub Command4_Click() Frame2.Visible = True connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Agents", conn, adOpenStatic, adLockOptimistic Grid2.clear Grid2.Rows = 1 Grid2.FormatString = " | Agent Name | Agent ID " Do Until rs1.EOF Grid2.Rows = Grid2.Rows + 1 Rowval = Grid2.Rows - 1 Grid2.TextMatrix(Rowval, 0) = Rowval Grid2.TextMatrix(Rowval, 1) = rs1("Agent_Name") Grid2.TextMatrix(Rowval, 2) = rs1("Agent_ID") rs1.MoveNext Loop conn.Close End Sub Private Sub DTPicker1_CloseUp() Text3.Text = DTPicker1.Value End Sub Private Sub Form_Load() Me.Height = 9765 Me.Width = 14400 End Sub Private Sub Grid1_Click() Text1.Text = Grid1.TextMatrix(Grid1.Row, 1) Text2.Text = Grid1.TextMatrix(Grid1.Row, 2) Label12.Caption = Grid1.TextMatrix(Grid1.Row, 3) Frame1.Visible = False End Sub Private Sub Grid2_Click() Text6.Text = Grid2.TextMatrix(Grid2.Row, 1) Text7.Text = Grid2.TextMatrix(Grid2.Row, 2) Frame2.Visible = False Page 13 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering End Sub Private Sub Text4_Change() Dim c As Integer c = Val(Label12.Caption) Label13.Caption = c - Val(Text4.Text) End Sub

Page 14 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Stock
The stock of the company. Keeps all the records of the company safe can the user can update any record from this window.

Private Sub Command1_Click() connect conn.Open Set rs2 = New ADODB.Recordset rs2.Open "update Stock Set itemname='" + Text1.Text + "',itemcode='" + Text2.Text + "',Dateofpurchase ='" + Text3.Text + "',itemquantity=" + Text4.Text + " where itemcode='" + Text2.Text + "'", conn, adOpenDynamic, adLockOptimistic MsgBox "STOCK DATABASE HAS BEEN UPDATED" conn.Close

Page 15 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering End Sub Private Sub Command2_Click() Unload Me End Sub

Private Sub Command3_Click() Dim i As String i = InputBox("please enter the item code") connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Stock where itemcode = '" + i + "'", conn, adOpenStatic, adLockOptimistic If rs1.RecordCount = 0 Then MsgBox ("please check you item code") Else Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | ITEM NAME " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Grid1.TextMatrix(Rowval, 0) = Rowval Grid1.TextMatrix(Rowval, 1) = rs1("itemname") Grid1.TextMatrix(Rowval, 2) = rs1("itemcode") Grid1.TextMatrix(Rowval, 3) = rs1("Dateofpurchase") Page 16 of 36 1 Year final Project/ **Muthalib Shareef **
st

| ITEM CODE | DATE OF PURCHASE | NUMBER OF QUANTITY

Software Engineering Grid1.TextMatrix(Rowval, 4) = rs1("itemquantity")

rs1.MoveNext Loop

conn.Close End If End Sub

Private Sub Form_Load()

Me.Height = 9975 Me.Width = 10470

connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Stock", conn, adOpenStatic, adLockOptimistic Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | ITEM NAME " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Grid1.TextMatrix(Rowval, 0) = Rowval Page 17 of 36 1 Year final Project/ **Muthalib Shareef **
st

| ITEM CODE | DATE OF PURCHASE | NUMBER OF QUANTITY

Software Engineering Grid1.TextMatrix(Rowval, 1) = rs1("itemname") Grid1.TextMatrix(Rowval, 2) = rs1("itemcode") Grid1.TextMatrix(Rowval, 3) = rs1("Dateofpurchase") Grid1.TextMatrix(Rowval, 4) = rs1("itemquantity")

rs1.MoveNext Loop

conn.Close Text2.Enabled = False End Sub

Private Sub Grid1_Click() Text1.Text = Grid1.TextMatrix(Grid1.Row, 1) Text2.Text = Grid1.TextMatrix(Grid1.Row, 2) Text3.Text = Grid1.TextMatrix(Grid1.Row, 3) Text4.Text = Grid1.TextMatrix(Grid1.Row, 4) End Sub

Page 18 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Reorder
In this window its shown the records of the companies re ordered or reorder goods.

Private Sub Command1_Click() If (Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "") Then MsgBox ("Please enter the details") Else connect conn.Open

Set rs1 = New ADODB.Recordset rs1.Open "insert into Reorder values('" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "')", conn, adOpenDynaset, adLockOptimistic MsgBox ("Reorder details Added") conn.Close End If End Sub

Page 19 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering Private Sub Command2_Click() Unload Me End Sub

Private Sub Command3_Click() Frame1.Visible = True Grid1.clear connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Stock ", conn, adOpenStatic, adLockOptimistic Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | Item Name | Item Code " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Grid1.TextMatrix(Rowval, 0) = Rowval Grid1.TextMatrix(Rowval, 1) = rs1("itemname") Grid1.TextMatrix(Rowval, 2) = rs1("itemcode")

rs1.MoveNext Loop

Page 20 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering conn.Close End Sub

Private Sub DTPicker1_CloseUp() Text3.Text = DTPicker1.Value End Sub

Private Sub Form_Load() Me.Width = 11760 Me.Height = 5415 End Sub

Private Sub Grid1_Click() Text1.Text = Grid1.TextMatrix(Grid1.Row, 1) Text2.Text = Grid1.TextMatrix(Grid1.Row, 2) Frame1.Visible = False End Sub

Page 21 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Pending Reorder
In this window the user can see the pending reorders of the company.

Private Sub Form_Load() Me.Width = 5835 Me.Height = 5355 Grid2.clear connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Reorder ", conn, adOpenStatic, adLockOptimistic Grid2.clear Grid2.Rows = 1 Grid2.FormatString = " | Item Name | Item Code | Date of Reoder " Do Until rs1.EOF Grid2.Rows = Grid2.Rows + 1 Rowval = Grid2.Rows - 1 Grid2.TextMatrix(Rowval, 0) = Rowval Grid2.TextMatrix(Rowval, 1) = rs1("itemname") Grid2.TextMatrix(Rowval, 2) = rs1("itemcode") Grid2.TextMatrix(Rowval, 3) = rs1("dateofreorder") rs1.MoveNext Loop conn.Close End Sub

Page 22 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Distribution
In this form the user can able to see, add, the details of the company distribution list. For another partnership companies or shops etc.

Private Sub Command1_Click() connect If (Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "") Then MsgBox ("Please enter the details") Else conn.Open Set rs1 = New ADODB.Recordset rs1.Open "insert into Distribution values('" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "'," + Text5.Text + ",'" + Text6.Text + "')", conn, adOpenDynaset, adLockOptimistic MsgBox ("Distribution details Added") Set rs2 = New ADODB.Recordset rs2.Open "update Stock Set itemquantity = " + Label7.Caption + " where itemcode='" + Text2.Text + "'", conn, adOpenDynamic, adLockOptimistic MsgBox "STOCK DATABASE HAS BEEN UPDATED" Page 23 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering conn.Close End If End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Command3_Click() Frame1.Visible = True connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Stock ", conn, adOpenStatic, adLockOptimistic Grid2.clear Grid2.Rows = 1 Grid2.FormatString = " | Item Name | Item Code | Stock " Do Until rs1.EOF Grid2.Rows = Grid2.Rows + 1 Rowval = Grid2.Rows - 1 Grid2.TextMatrix(Rowval, 0) = Rowval Grid2.TextMatrix(Rowval, 1) = rs1("itemname") Grid2.TextMatrix(Rowval, 2) = rs1("itemcode") Grid2.TextMatrix(Rowval, 3) = rs1("itemquantity") rs1.MoveNext Loop conn.Close End Sub Private Sub Command4_Click() Frame2.Visible = True connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Companies", conn, adOpenStatic, adLockOptimistic Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | Company Name | Company ID " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Page 24 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering Grid1.TextMatrix(Rowval, 0) = Rowval Grid1.TextMatrix(Rowval, 1) = rs1("Company_Name") Grid1.TextMatrix(Rowval, 2) = rs1("Company_ID")

rs1.MoveNext Loop conn.Close End Sub Private Sub Command5_Click() connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Distribution", conn, adOpenStatic, adLockOptimistic Grid3.clear Grid3.Rows = 1 Grid3.FormatString = " | ITEM NAME | ITEM CODE | COMPANY NAME | COMPANY ID | QUANTITY | DATE " Do Until rs1.EOF Grid3.Rows = Grid3.Rows + 1 Rowval = Grid3.Rows - 1 Grid3.TextMatrix(Rowval, 0) = Rowval Grid3.TextMatrix(Rowval, 1) = rs1("itemname") Grid3.TextMatrix(Rowval, 2) = rs1("itemcode") Grid3.TextMatrix(Rowval, 3) = rs1("companyname") Grid3.TextMatrix(Rowval, 4) = rs1("companyID") Grid3.TextMatrix(Rowval, 5) = rs1("quantity") Grid3.TextMatrix(Rowval, 6) = rs1("Date") rs1.MoveNext Loop conn.Close End Sub Private Sub DTPicker1_CloseUp() Text6.Text = DTPicker1.Value End Sub Private Sub Form_Load() Page 25 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering Me.Width = 14490 Me.Height = 11550 End Sub Private Sub Grid1_Click() Text3.Text = Grid1.TextMatrix(Grid1.Row, 1) Text4.Text = Grid1.TextMatrix(Grid1.Row, 2) Frame2.Visible = False End Sub Private Sub Grid2_Click() Text1.Text = Grid2.TextMatrix(Grid2.Row, 1) Text2.Text = Grid2.TextMatrix(Grid2.Row, 2) Label8.Caption = Grid2.TextMatrix(Grid2.Row, 3) Frame2.Visible = False End Sub Private Sub Text5_Change() Dim a As Integer a = Val(Label8.Caption) Label7.Caption = a - Val(Text5.Text) End Sub

Page 26 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Add Company
In this window the user can add the agents for the company use.

Private Sub Command1_Click() If (Text1.Text = "" Or Text2.Text = "") Then MsgBox ("Please enter the details") Else connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "insert into Agents values('" + Text1.Text + "','" + Text2.Text + "')", conn, adOpenDynamic, adLockOptimistic MsgBox ("New Agent added") Text1.Text = "" Text2.Text = "" End If End Sub Private Sub Command2_Click() Page 27 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering Unload Me End Sub Private Sub Form_Load() Me.Height = 4755 Me.Width = 6945 End Sub

Page 28 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Edit/ Delete Agents


In this window the user can be able to see the useful agents of the company and also can search agents by id or agent name.

Private Sub Command1_Click() connect conn.Open Set rs2 = New ADODB.Recordset rs2.Open "update Agents set Agent_Name='" + Text2.Text + "' where Agent_ID='" + Text1.Text + "'", conn, adOpenStatic, adLockOptimistic MsgBox ("The Agent has been updated") display clear conn.Close End Sub Private Sub Command2_Click() connect conn.Open Page 29 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering Set rs3 = New ADODB.Recordset rs3.Open "delete from Agents where Agent_ID= '" & Text1.Text & "'", conn, adOpenDynaset, adLockOptimistic MsgBox ("The Agent has been deleted") display clear conn.Close End Sub Private Sub Command3_Click() Unload Me End Sub Private Sub Form_Load() Me.Width = 6750 Me.Height = 7215 display conn.Close Text1.Enabled = False End Sub Private Sub Grid1_Click() Text2.Text = Grid1.TextMatrix(Grid1.Row, 1) Text1.Text = Grid1.TextMatrix(Grid1.Row, 2) End Sub Private Sub display() connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Agents", conn, adOpenStatic, adLockOptimistic Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | AGENT NAME | AGENT ID " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Grid1.TextMatrix(Rowval, 0) = Rowval Grid1.TextMatrix(Rowval, 1) = rs1("Agent_Name") Grid1.TextMatrix(Rowval, 2) = rs1("Agent_ID") rs1.MoveNext Page 30 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering Loop End Sub Private Sub clear() Text1.Text = "" Text2.Text = "" End Sub

Page 31 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Add Companies
In this window the user can add the company name and id to the data base.

Private Sub Command1_Click() If (Text1.Text = "" Or Text2.Text = "") Then MsgBox ("Please enter the details") Else connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "insert into Companies values('" + Text1.Text + "','" + Text2.Text + "')", conn, adOpenDynamic, adLockOptimistic MsgBox ("A New company has been added to the database") Text1.Text = "" Text2.Text = "" End If End Sub Private Sub Command2_Click() Page 32 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering Unload Me End Sub Private Sub Form_Load() Me.Width = 6660 Me.Height = 4710 End Sub

Page 33 of 36 1 Year final Project/ **Muthalib Shareef **


st

Software Engineering

*Edit/ Delete Companies


In this window the user can edit, view or delete any records that are stored in the database of the company.

Private Sub Command1_Click() connect conn.Open Set rs2 = New ADODB.Recordset rs2.Open "update Companies set Company_Name='" + Text2.Text + "' where Company_ID='" + Text1.Text + "'", conn, adOpenStatic, adLockOptimistic MsgBox ("The Company has been updated") display clear conn.Close End Sub Private Sub Command2_Click() Page 34 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering connect conn.Open Set rs3 = New ADODB.Recordset rs3.Open "delete from Companies where Company_ID= '" & Text1.Text & "'", conn, adOpenDynaset, adLockOptimistic MsgBox ("The company has been deleted") display clear conn.Close End Sub Private Sub Command3_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 7890 Me.Width = 7875 display Text1.Enabled = False conn.Close End Sub Private Sub display() connect conn.Open Set rs1 = New ADODB.Recordset rs1.Open "SELECT*FROM Companies", conn, adOpenStatic, adLockOptimistic Grid1.clear Grid1.Rows = 1 Grid1.FormatString = " | COMPANY NAME | COMPANY ID " Do Until rs1.EOF Grid1.Rows = Grid1.Rows + 1 Rowval = Grid1.Rows - 1 Grid1.TextMatrix(Rowval, 0) = Rowval Grid1.TextMatrix(Rowval, 1) = rs1("Company_Name") Grid1.TextMatrix(Rowval, 2) = rs1("Company_ID") rs1.MoveNext Loop End Sub Private Sub Grid1_Click() Page 35 of 36 1 Year final Project/ **Muthalib Shareef **
st

Software Engineering Text2.Text = Grid1.TextMatrix(Grid1.Row, 1) Text1.Text = Grid1.TextMatrix(Grid1.Row, 2) End Sub Private Sub clear() Text1.Text = "" Text2.Text = "" End Sub

Page 36 of 36 1 Year final Project/ **Muthalib Shareef **


st

Вам также может понравиться