/// <summary> /// Generate UpdateItemDefinitions Form /// </summary> public UpdateItemDefinitions(InvoiceManager im) { InitializeComponent(); // creates a reference to our main(parent) form mainForm = im; drawForm(); }
/// <summary> /// Constructor for the Search Invoice Form /// </summary> /// <param name="im">Call how we associate this form with the main form</param> public SearchInvoices(InvoiceManager im) { InitializeComponent(); try { // Search Invoice Grid View DataGridViewTextBoxColumn Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); DataGridViewButtonColumn Column4 = new System.Windows.Forms.DataGridViewButtonColumn(); Column1.DataPropertyName = "InvoiceID"; Column1.HeaderText = "Invoice Number"; Column1.Name = "InvoiceID"; Column1.Width = 140; Column2.DataPropertyName = "Date"; Column2.HeaderText = "Invoice Date"; Column2.Name = "Date"; Column2.DefaultCellStyle.Format = "d";//date Column2.Width = 140; Column3.DataPropertyName = "Total"; Column3.HeaderText = "Invoice Total"; Column3.Name = "Total"; Column3.DefaultCellStyle.Format = "c"; // currency Column3.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; Column3.Width = 140; Column4.HeaderText = "Select Invoice"; Column4.Name = "Select"; Column4.Text = "Select"; Column4.UseColumnTextForButtonValue = true; Column4.Width = 88; //adding the colums to the date grid view dgvSearchInvoice.Columns.Add(Column1); dgvSearchInvoice.Columns.Add(Column2); dgvSearchInvoice.Columns.Add(Column3); dgvSearchInvoice.Columns.Add(Column4); //number of rows returned int iRet = 0; //get the invoice numbers from the database for the Combobox ds = db.ExecuteSQLStatement("SELECT InvoiceNum FROM Invoices", ref iRet); for (int i = 0; i < iRet; i++) { cbInvoiceNum.Items.Add(ds.Tables[0].Rows[i][0].ToString()); } //setting the rows to 0 again iRet = 0; //getting each invoice date from the data base while checking for duplicates, also converting it into datetime view to get rid of the extra 12:00 am that it adds on. ds = db.ExecuteSQLStatement("SELECT DISTINCT InvoiceDate FROM Invoices", ref iRet); for (int i = 0; i < iRet; i++) { cbInvoiceDate.Items.Add(Convert.ToDateTime(ds.Tables[0].Rows[i][0].ToString())); } //setting it to 0 again iRet = 0; //getting the distinct total charge ammounts from the database also converting it to decimal so that it will print out as a total amount. ds = db.ExecuteSQLStatement("SELECT DISTINCT TotalCharge FROM Invoices", ref iRet); for (int i = 0; i < iRet; i++) { cbTotalCharge.Items.Add(Convert.ToDecimal(ds.Tables[0].Rows[i][0].ToString())); } // creates a reference to our main(parent) form mainForm = im; } catch (Exception ex) { MessageBox.Show("Exception: " + ex.ToString() + "\nMessage: " + ex.Message, "Exception Thrown"); } }