コード例 #1
0
        private void grdAllCustomer_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //Gets all customer details and displays them
            Customer cust = new Customer();

            cust.getCustomerInvoice(Convert.ToInt32(grdAllCustomer.Rows[grdAllCustomer.CurrentCell.RowIndex].Cells[0].Value));
            lblCustomerID.Text      = cust.getCustomerID().ToString();
            lblSurname.Text         = cust.getCustomerSurname();
            lblCustomerBalance.Text = cust.getCustomerBalance().ToString();
            lblPhoneNumber.Text     = cust.getCustomerPhoneNumberD();

            //sets a string status value to ISSUE INVOICE
            string status1 = "'COMPLETED'";

            Repair  rep = new Repair();
            DataSet ds  = new DataSet();

            //Get repair details
            grdRepairs.DataSource = Repair.getCustomerRepair(ds, Convert.ToInt32(grdAllCustomer.Rows[grdAllCustomer.CurrentCell.RowIndex].Cells[0].Value), status1).Tables["ss"];

            //if repair grid is empty, givve warning message
            if (grdRepairs.RowCount == 0)
            {
                grpRepairsDone.Visible = false;
                MessageBox.Show("* * * WARNING * * * \n--------------------------------------------------------------\nCustomer has No COMPLETED Repairs, awaiting INVOICE...", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //display a group box
            else
            {
                grpRepairsDone.Visible = true;
            }


            //hide some ui
            lblTotalCostFill.Text    = "";
            grpRepairInfo.Visible    = false;
            btnIssueInvoice.Visible  = false;
            lblTotalCost.Visible     = false;
            lblTotalCostFill.Visible = false;



            //Set column size in grid
            DataGridViewColumn column0 = grdRepairs.Columns[0];

            column0.Width = 60;

            DataGridViewColumn column1 = grdRepairs.Columns[1];

            column1.Width = 365;

            DataGridViewColumn column2 = grdRepairs.Columns[2];

            column2.Width = 50;
        }
コード例 #2
0
        private void btnIssueInvoice_Click(object sender, EventArgs e)
        {
            grpRepairsDone.Visible = false;

            //Gets current date
            string d = DateTime.Now.ToString("d-MMM-yyyy");

            //Adds a payment to payments table
            Payments p = new Payments(Int32.Parse(txtPaymentID.Text), Int32.Parse(lblTotalCostFill.Text), d, Int32.Parse(lblCustomerID.Text));

            p.addPayment();

            //Confirmation msg
            MessageBox.Show("PAYMENT RECIEVED\n-------------------\nBALANCE UPDATED", "SUCCESS!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

            //stores status value
            string status = "'PAID'";

            //Getting repair and customer ID
            int cno = Convert.ToInt32(grdAllCustomer.Rows[grdAllCustomer.CurrentCell.RowIndex].Cells[0].Value);
            int rno = Convert.ToInt32(grdRepairs.Rows[grdRepairs.CurrentCell.RowIndex].Cells[0].Value);

            //Updates customer balance and repair status
            Repair rep = new Repair();

            Repair.updateCustomerBalance(Convert.ToInt32(lblCostFill.Text), Convert.ToInt32(lblCustomerID.Text));
            rep.updateRepairStatusPAYMENT(Convert.ToInt32(cno), Convert.ToInt32(rno), status);
            DataSet DataSet = new DataSet();

            grdAllCustomer.DataSource = Customer.getAllCustomers(DataSet).Tables["ss"];
            string status2 = "'ISSUE INVOICE'";


            DataSet ds = new DataSet();

            grdRepairs.DataSource = Repair.getCustomerRepair(ds, Convert.ToInt32(grdAllCustomer.Rows[grdAllCustomer.CurrentCell.RowIndex].Cells[0].Value), status2).Tables["ss"];

            txtPaymentID.Text = Payments.nextPaymentID().ToString("0000");
        }