Exemplo n.º 1
0
 ///<summary>Create a new bill for a reservation</summary>
 private void btnOrderCreateInvoice_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult result = MessageBox.Show("Luodaanko valitulle varaukselle lasku?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             int varaus_id = Convert.ToInt32(dgOrder.SelectedCells[0].Value);
             BillingUtils.CreateInvoice(varaus_id);
             BillingUtils.RefreshDataGridView(dgvBilling);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Odottamaton virhe. Laskun luonti ei onnistunut.", "Virhe", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
        ///<summary>Changes the tab to "laskut" and selects the row which has the parameter (varaus_id) reservation</summary>
        public static void GoToCreatedInvoice(int varaus_id)
        {
            rentCottage.tcMain.SelectedIndex = 5;
            BillingUtils.RefreshDataGridView(rentCottage.dgvBilling);

            //Search for the row which has the created bill
            int rowIndex = -1;

            foreach (DataGridViewRow row in rentCottage.dgvBilling.Rows)
            {
                if (row.Cells[1].Value.ToString().Equals(varaus_id.ToString()))
                {
                    rowIndex = row.Index;
                    break;
                }
            }
            //Select the row
            rentCottage.dgvBilling.CurrentCell = rentCottage.dgvBilling.Rows[rowIndex].Cells[0];
        }
Exemplo n.º 3
0
        ///<summary>All button events occurring on the "Laskut" tab.</summary>
        private void btnBilling_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            //Search for an invoice
            if (btn == btnBillingSearch)
            {
                PopulateDGVBilling();
            }

            //Update the state of payment of a selected invoice
            else if (btn == btnBillingPaid || btn == btnBillingNotPaid)
            {
                try
                {
                    string paymentDate;
                    if (btn == btnBillingPaid)
                    {
                        DateTime myDateTime = DateTime.Now;
                        paymentDate = myDateTime.ToString("yyyy-MM-dd HH:mm:ss");
                        paymentDate = "'" + paymentDate + "'";
                    }
                    else
                    {
                        paymentDate = "NULL";
                    }

                    int selectedRow = dgvBilling.CurrentCell.RowIndex;
                    int lasku_id    = Convert.ToInt32(dgvBilling.SelectedCells[0].Value);
                    BillingUtils.SetPaymentState(lasku_id, paymentDate);
                    BillingUtils.RefreshDataGridView(dgvBilling);
                    dgvBilling.ClearSelection();
                    dgvBilling.CurrentCell = dgvBilling.Rows[selectedRow].Cells[0];
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Odottamaton virhe. Laskun maksutilanteen päivitys epäonnistui.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //Delete a selected invoice
            else if (btn == btnBillingDelete)
            {
                DialogResult result = MessageBox.Show("Halutko varmasti poistaa valitun laskun?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    int lasku_id = Convert.ToInt32(dgvBilling.SelectedCells[0].Value);
                    BillingUtils.DeleteSelectedInvoice(lasku_id);
                    BillingUtils.RefreshDataGridView(dgvBilling);
                    dgvBilling.ClearSelection();
                }
            }

            //Create a PDF document of a selected bill
            else if (btn == btnBillingPDF)
            {
                try
                {
                    int lasku_id = Convert.ToInt32(dgvBilling.SelectedCells[0].Value);
                    BillingUtils.CreatePdfDocument(lasku_id);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("PDF:n muodostaminen epäonnistui. Onko aiempi lasku vielä auki?", "Virhe", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //Show all invoices
            else if (btn == btnBillingShowAll)
            {
                txtboxBillingCustomerID.Text = "";
                txtboxBillingEmail.Text      = "";
                txtboxBillingInvoiceID.Text  = "";
                txtboxBillingLastname.Text   = "";
                txtboxBillingOrderID.Text    = "";
                txtboxBillingPhone.Text      = "";
                txtboxBillingSurname.Text    = "";
                cbBillingPaid.SelectedIndex  = 2;
                PopulateDGVBilling();
            }
        }