private void buttonAdv1_Click(object sender, EventArgs e) // DELETE { if (listView1.SelectedItems.Count == 1) { DialogResult res = MessageBox.Show(null, "Are you sure you want to delete this invoice ?", "Delete Invoice", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { using (igortransDBcontext db = new igortransDBcontext()) { int id = Convert.ToInt32(listView1.SelectedItems[0].Tag); db.invoices.Remove(db.invoices.Where(inv => inv.invoiceid == id).FirstOrDefault()); db.invdets.RemoveRange(db.invdets.Where(invdet => invdet.invoiceid == id)); db.SaveChanges(); } FormHelper.ViewModeButtons(BtnList, FormHelper.ViewMode.View, this.Name); ReloadInvoices(); ReloadInvoicesList(); } } Vmode = FormHelper.ViewMode.View; }
private void buttonAdv2_Click(object sender, EventArgs e) //EDIT { Vmode = FormHelper.ViewMode.Edit; LockFields(false, true); FormHelper.ViewModeButtons(BtnList, FormHelper.ViewMode.Edit, this.Name); panel1.BackColor = Color.WhiteSmoke; panel2.BackColor = Color.WhiteSmoke; }
private void buttonAdv3_Click(object sender, EventArgs e) // CANCEL { LockFields(true, true); FormHelper.ViewModeButtons(BtnList, FormHelper.ViewMode.View, this.Name); ReloadInvoices(); ReloadInvoicesList(); panel1.BackColor = Color.Gainsboro; panel2.BackColor = Color.Gainsboro; Vmode = FormHelper.ViewMode.View; }
private void buttonAdv4_Click(object sender, EventArgs e) // ADD { Vmode = FormHelper.ViewMode.Add; ClearScreen(); ClearSingleCalc(); LockFields(false, true, true); panel1.Visible = true; panel2.Visible = true; FormHelper.ViewModeButtons(BtnList, FormHelper.ViewMode.Add, this.Name); panel1.BackColor = Color.WhiteSmoke; panel2.BackColor = Color.WhiteSmoke; materialSingleLineTextField7.Focus(); }
private void Invoices_Load(object sender, EventArgs e) { this.RecalcAsyncSingleCaller += RecalcAsyncSingle; this.RecalcAsyncTotalCaller += RecalcAsyncTotal; deleteToolStripMenuItem.Click += DeleteToolStripMenuItem_Click; BtnList.Clear(); isItemEditPanelShown(false); BtnList.Add(buttonAdv1); BtnList.Add(buttonAdv2); BtnList.Add(buttonAdv3); BtnList.Add(buttonAdv4); BtnList.Add(buttonAdv5); FormHelper.AreRaisedButtonsVisible(BtnList, false); custSearch.FormClosing += new FormClosingEventHandler(CustomerSearchClosed); listView2.MouseDown += InvdetListMouseClick; ReloadInvoices(); ReloadInvoicesList(); panel1.Visible = false; panel2.Visible = false; panel4.Visible = false; Vmode = FormHelper.ViewMode.View; }
private void ShowInvoice(invoice inv, bool?isNewInvoice = false) { Vmode = FormHelper.ViewMode.View; isItemEditPanelShown(false); selectedInvoiceDetails.Clear(); customer cust; listView2.Items.Clear(); using (igortransDBcontext db = new igortransDBcontext()) { cust = db.customers.Where(c => c.customerid == inv.customerid).FirstOrDefault(); } ShowCustomer(cust); dateTimePickerAdv1.Value = inv.date_created; dateTimePickerAdv1.ForeColor = DefaultForeColor; btnShowInvoice.Visible = true; if (inv.date_paid != null) { dateTimePickerAdv2.Value = inv.date_paid; dateTimePickerAdv2.Format = DateTimePickerFormat.Long; } else { dateTimePickerAdv2.CustomFormat = " "; dateTimePickerAdv2.Format = DateTimePickerFormat.Custom; dateTimePickerAdv2.Text = ""; } materialSingleLineTextField1.Text = inv.invoice_number; materialSingleLineTextField1.Font = new Font(materialSingleLineTextField1.Font, FontStyle.Bold | FontStyle.Italic); currencyTextBox2.ReadOnly = false; currencyTextBox2.DecimalValue = inv.total_paid; txtInvoiceRef.Text = inv.@ref; SelectedInvoice = inv; panel4.Visible = true; ShowInvoiceDetails(inv); }