void Btn_SubmitPrint_Click(object sender, EventArgs e)
 {
     if (int.TryParse(Txt_CurrentUsage.Text, out int CurrUsage) && CurrUsage >= TOTAL_USAGE)
     {
         DialogResult dialogResult = MessageBox.Show("Are you sure you want to release the " + DateTime.Now.ToShortDateString() + " invoice for the customer #" + CUSTOMER_ID + "?" + Environment.NewLine + "Customer should pay " + Txt_Total.Text + "L.L.", "Adding a new Customer!", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             int INVOICE_ID = GenID("invoice", "invoice_id");
             ExecuteQuery("INSERT INTO invoice VALUES(" + INVOICE_ID + ", date(), " + TOTAL_USAGE + ", " + CurrUsage + ", " + MONTHLY_COST + ", " + (CurrUsage - TOTAL_USAGE) + ", " + PRICE_ID + ", " + CUSTOMER_ID + ")");
             MessageBox.Show("Invoice #" + INVOICE_ID + " release.");
             Frm_Report_Invoice frm = new Frm_Report_Invoice(INVOICE_ID, CUT_HOURS);
             frm.ShowDialog();
             Dispose();
         }
     }
     else
     {
         MessageBox.Show("Please fill all required data correctly!");
     }
 }
Example #2
0
 void DGV_Invoices_Click(object sender, EventArgs e)
 {
     if (ShowingUnreleased)
     {
         if (DGV_Invoices.SelectedRows.Count > 0)
         {
             Frm_ReleaseInvoice frm = new Frm_ReleaseInvoice(int.Parse(DGV_Invoices.SelectedRows[0].Cells[1].Value.ToString()), int.Parse(Txt_CutHours.Text));
             frm.ShowDialog();
             frm.Dispose();
             ShowUnreleased();
             if (DGV_Invoices.Rows.Count == 0)
             {
                 Btn_ShowUnreleased.PerformClick();
             }
             int NumberOfUnreleasedInvoices = getUnreleasedCount();
             if (NumberOfUnreleasedInvoices > 0)
             {
                 Lbl_NoOfUnreleased.Text      = "You have " + NumberOfUnreleasedInvoices + " unreleased invoice(s)";
                 Lbl_NoOfUnreleased.ForeColor = Color.Red;
                 Btn_ShowUnreleased.Enabled   = true;
             }
             else
             {
                 Lbl_NoOfUnreleased.Text      = "All this month's invoices are released!";
                 Lbl_NoOfUnreleased.ForeColor = Color.Green;
                 Btn_ShowUnreleased.Enabled   = false;
             }
         }
     }
     else
     {
         if (DGV_Invoices.SelectedRows.Count > 0)
         {
             Frm_Report_Invoice Frm = new Frm_Report_Invoice(int.Parse(DGV_Invoices.SelectedRows[0].Cells[2].Value.ToString()), int.Parse(Txt_CutHours.Text));
             Frm.ShowDialog();
         }
     }
 }