Esempio n. 1
0
        private void grdAllRepair_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //find repair details
            Repair rep = new Repair();

            rep.getRepair(Convert.ToInt32(grdAllRepairs.Rows[grdAllRepairs.CurrentCell.RowIndex].Cells[0].Value));

            if (rep.getCustomerID().Equals(0))
            {
                MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            //display Repair details
            txtRepairID.Text = (Convert.ToInt32(grdAllRepairs.Rows[grdAllRepairs.CurrentCell.RowIndex].Cells[0].Value)).ToString();
            cmbStatus.Text   = (grdAllRepairs.Rows[grdAllRepairs.CurrentCell.RowIndex].Cells[3].Value).ToString();
        }
Esempio n. 2
0
        private void btnRepairCancel_Click(object sender, EventArgs e)
        {
            //Validation
            if (txtRepairID.Text.Equals(""))
            {
                MessageBox.Show("Field Must Not Be Blank", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRepairID.Focus();
                return;
            }


            // Sets the repair to its new details
            Repair rep = new Repair();

            rep.setRepairID(Convert.ToInt32(grdAllRepairs.Rows[grdAllRepairs.CurrentCell.RowIndex].Cells[0].Value));
            rep.setRepairStatus(cmbStatus.Text);


            //sets the status to the combo box value
            rep.updateRepairCancel();

            if (cmbStatus.Text == "IN PROGRESS")
            {
                rep.setRepairStatus("IN PROGRESS");
            }
            else
            {
                rep.setRepairStatus("CANCELLED");
            }

            //Display Confirmation Message
            MessageBox.Show(grdAllRepairs.Rows[grdAllRepairs.CurrentCell.RowIndex].Cells[4].Value + "\n --------------------------------------------------------\n" + cmbStatus.Text, "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //string status value is COMPLETED
            string status = "CANCELLED";

            //reset UI
            txtRepairID.Text = "";
            cmbStatus.Text   = "";
            DataSet ds = new DataSet();

            grdAllRepairs.DataSource = Repair.getAllRepairs(ds, status).Tables["ss"];
        }
        private void btnIssueInvoice_Click(object sender, EventArgs e)
        {
            //Instantiate customer and repair object
            Customer cust = new Customer();
            Repair   rep  = new Repair();

            //Setting customer ID
            cust.setCustomerID(Convert.ToInt32(grdAllCustomer.Rows[grdAllCustomer.CurrentCell.RowIndex].Cells[0].Value));

            //calculating initial and after cost
            decimal totalCost   = Convert.ToDecimal(lblTotalCostFill.Text);
            decimal initialCost = Convert.ToDecimal(lblCustomerBalance.Text);

            //Sets balance to initial and total cost combined
            cust.setCustomerBalance(totalCost + initialCost);

            //get customer ID
            string cno = grdAllCustomer.Rows[grdAllCustomer.CurrentCell.RowIndex].Cells[0].Value.ToString();;


            //Updates customer balance and repair status
            cust.updateCustomerBalance();
            string status = "'ISSUE INVOICE'";

            rep.updateRepairStatusINVOICE(Convert.ToInt32(cno), status);



            Customer cust1   = new Customer();
            DataSet  DataSet = new DataSet();

            //Gets all customers by name
            grdAllCustomer.DataSource = Customer.getAllCustomerByName(DataSet, txtNameEntered.Text.ToString()).Tables["ss"];

            MessageBox.Show("INVOICE SENT \n-------------------\nBALANCE UPDATED", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);


            grpRepairInfo.Visible  = false;
            grpRepairsDone.Visible = false;
        }
Esempio n. 4
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");
        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //find repair details
            Repair rep = new Repair();

            rep.getRepairDetails(Convert.ToInt32(grdgetRepairDetails.Rows[grdgetRepairDetails.CurrentCell.RowIndex].Cells[0].Value));

            //If no repair, display appropriate message
            if (rep.getRepairID().Equals(0))
            {
                MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            //Get string status value
            string status = grdgetRepairDetails.Rows[grdgetRepairDetails.CurrentCell.RowIndex].Cells[2].Value.ToString();


            //if status d, do not procede with repair
            if (status == "D")
            {
                grpRepairDetails.Visible = false;
                lblCustomerName.Text     = "Select a Customer...";
                txtCustomerID.Text       = "";
                MessageBox.Show("Member NOT ACTIVE \n-----------------------\nPlease activate " + grdgetRepairDetails.Rows[grdgetRepairDetails.CurrentCell.RowIndex].Cells[1].Value + " to Log a Repair...", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);


                return;
            }

            //display Repair details
            txtCustomerID.Text   = rep.getCustomerID().ToString();
            lblCustomerName.Text = rep.getCustomerName();


            grpRepairDetails.Visible = true;
            btnSubmit.Visible        = true;
        }
Esempio n. 6
0
        private void grdRepairs_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //Gets selected repair details
            Repair rep = new Repair();

            rep.getRepairInvoice(Convert.ToInt32(grdRepairs.Rows[grdRepairs.CurrentCell.RowIndex].Cells[0].Value));
            lblRepairIDFill.Text    = rep.getRepairID().ToString();
            lblDescriptionFill.Text = rep.getDescription();
            lblCostFill.Text        = rep.getCost().ToString();

            grpRepairInfo.Visible = true;

            //Sets a string value to the value in the grid at position 3
            string repairStatus = grdRepairs.Rows[grdRepairs.CurrentCell.RowIndex].Cells[3].Value.ToString();

            if (repairStatus == "ISSUE INVOICE")
            {
                //Fill labels with repair details
                lblTotalCostFill.Text    = Repair.getRepairPayment(Convert.ToInt32(grdAllCustomer.Rows[grdAllCustomer.CurrentCell.RowIndex].Cells[0].Value), Convert.ToInt32(grdRepairs.Rows[grdRepairs.CurrentCell.RowIndex].Cells[0].Value)).ToString();
                lblTotalCost.Visible     = true;
                lblTotalCostFill.Visible = true;
                btnIssueInvoice.Visible  = true;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Validation

            Regex characterVal       = new Regex("^[a-zA-Z]*$");
            Regex characterNumberVal = new Regex("^[a-zA-Z0-9 ]*$");


            //////////////////////////Serial//////////////////////////
            if (txtPhoneSerialNumber.Text.Equals(""))
            {
                MessageBox.Show("Field Must Not Be Blank", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneSerialNumber.Focus();
                return;
            }
            else if (!txtPhoneSerialNumber.Text.All(Char.IsDigit))
            {
                MessageBox.Show("Numbers only!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneSerialNumber.Focus();
                txtPhoneSerialNumber.Text = "";
                return;
            }
            else if (txtPhoneSerialNumber.Text.Length > 20)
            {
                MessageBox.Show("Serial Number too long!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhoneSerialNumber.Focus();
                txtPhoneSerialNumber.Text = "";
                return;
            }



            //////////////////////////Password//////////////////////////
            else if (txtPassword.Text.Equals(""))
            {
                MessageBox.Show("Phone password required, if there is none, then Specify NULL", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            else if (!characterNumberVal.IsMatch(txtPassword.Text))
            {
                MessageBox.Show("Name must not contain symbols, Letters and Numbers only!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                txtPassword.Text = "";
                return;
            }
            else if (txtPassword.Text.Length > 20)
            {
                MessageBox.Show("Name Too Long!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                txtPassword.Text = "";
                return;
            }



            //////////////////////////PhoneType(CBO)//////////////////////////
            else if (String.IsNullOrEmpty(cbophonetype.Text))
            {
                MessageBox.Show("Please Select Phone type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //////////////////////////Description(CBO)//////////////////////////
            else if (String.IsNullOrEmpty(cbbDescription.Text))
            {
                MessageBox.Show("Please Select Cause of Repair", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //////////////////////////Description(TXT)//////////////////////////
            else if (!characterNumberVal.IsMatch(txtDescription.Text))
            {
                MessageBox.Show("Please enter a description", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDescription.Focus();
                txtDescription.Text = "";
                return;
            }
            else if (txtDescription.Text.Length > 75)
            {
                MessageBox.Show("Description Too Long!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDescription.Focus();
                txtDescription.Text = "";
                return;
            }



            ///////////////////////////Cost///////////////////////////
            else if (txtCost.Text.Equals(""))
            {
                MessageBox.Show("Field Must Not Be Blank", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtCost.Focus();
                return;
            }
            else if (!txtCost.Text.All(Char.IsDigit))
            {
                MessageBox.Show("Positive, Whole numbers only!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtCost.Focus();
                txtCost.Text = "";
                return;
            }
            else if (txtCost.Text.Length > 5)
            {
                MessageBox.Show("Price too long!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtCost.Focus();
                txtCost.Text = "";
                return;
            }



            //Changes description if its empty
            else if (txtDescription.Text.Equals(""))
            {
                txtDescription.Text.Equals("No Details");
                return;
            }

            //Adds repair to system
            Repair repair = new Repair(Int32.Parse(txtRepairID.Text), txtPhoneSerialNumber.Text, txtPassword.Text, "In Progress", cbophonetype.Text + "  -  " + cbbDescription.Text + "  -  " + txtDescription.Text, Int32.Parse(txtCustomerID.Text), Int32.Parse(txtCost.Text));

            repair.addRepair();

            //Display success message
            MessageBox.Show("Repair Added", "Success");

            //reset UI
            txtPhoneSerialNumber.Text = "";
            txtPassword.Text          = "";
            txtCustomerID.Text        = "";
            lblCustomerName.Text      = "Select a Customer...";
            txtDescription.Text       = "";
            txtRepairID.Text          = Repair.nextRepairID().ToString("0000");
            cbophonetype.Text         = "";
            cbbDescription.Text       = "";

            grpRepairDetails.Visible = false;
            btnSubmit.Visible        = false;
        }