コード例 #1
0
        private void btnEstimateCost_Click_1(object sender, EventArgs e)
        {
            if (grdAddedParts.RowCount > 0)
            {
                DataGridViewRow selectedPart = grdAddedParts.Rows[grdAddedParts.CurrentCell.RowIndex];
                //instantiate part Object
                RepairParts myRepairParts = new RepairParts();

                myRepairParts.setRepID(Convert.ToInt32(txtRepID.Text));

                myRepairParts.deleteRepairParts();
                foreach (DataRow row in ds.Tables["Repair_Parts"].Rows)
                {
                    int pId      = Convert.ToInt32(row[0]);
                    int quantity = Convert.ToInt32(row[2]);

                    myRepairParts.setPartID(pId);
                    myRepairParts.setQuantity(quantity);
                    myRepairParts.addToRepairParts();
                    grdListRepair.ClearSelection();
                }

                Repair.updateRepairCost(myRepairParts.getRepairID(), Convert.ToDouble(lblCostNum.Text));
                Repair.updateRepairStatus(myRepairParts.getRepairID(), "Estimated");



                Repair.sendInvoice(lblCustEmail.Text, "Revised", lblCostNum.Text);

                MessageBox.Show("Parts added to Repair: " + txtRepID.Text + "\n Customer has been notified by email", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);

                lblEstimateTitle.Visible = false;
                pnlRepDesc.Visible       = false;
                grdAddedParts.DataSource = null;
                grdShowParts.DataSource  = null;
                grdListRepair.DataSource = null;
                pnlQuantity.Visible      = false;
                grpSelectParts.Enabled   = false;
                grpSelectRepair.Enabled  = true;
                btnSelectRepair.Visible  = false;
                grpSelectRepair.Visible  = true;
                lblCostNum.Text          = "";
                ds = null;
                lblEstimateTitle.Text   = titletext;
                rdoEstimated.Checked    = false;
                rdoProcessing.Checked   = false;
                btnReviseRepair.Visible = false;
            }

            DialogResult dialogResult = MessageBox.Show(" Would you like to change the description of the selected repair?", "Repair Description", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (dialogResult == DialogResult.Yes)
            {
                updaeRepDesc(this, txtRepairDesc.Text);
            }

            txtRepID.Text = "";
        }
コード例 #2
0
        private void btnEstimateCost_Click(object sender, EventArgs e)
        {
            if (grdAddedParts.RowCount > 0)
            {
                DataGridViewRow selectedPart  = grdAddedParts.Rows[grdAddedParts.CurrentCell.RowIndex];
                RepairParts     myRepairParts = new RepairParts();

                myRepairParts.setRepID(Convert.ToInt32(txtRepID.Text));
                myRepairParts.deleteRepairParts();

                foreach (DataRow row in repairParts.Rows)
                {
                    int pId      = Convert.ToInt32(row[0]);
                    int quantity = Convert.ToInt32(row[2]);

                    myRepairParts.setPartID(pId);
                    myRepairParts.setQuantity(quantity);
                    myRepairParts.addToRepairParts();
                    grdListRepair.ClearSelection();
                }

                Repair.updateRepairCost(myRepairParts.getRepairID(), Convert.ToDouble(lblCostNum.Text));
                Repair.updateRepairStatus(myRepairParts.getRepairID(), "Estimated");
                Repair.sendInvoice(lblCustEmail.Text, "Estimated", "0");

                MessageBox.Show("Parts added to Repair: " + txtRepID.Text + "\n Customer has been notified by email", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);


                pnlRepDesc.Visible         = false;
                grdAddedParts.DataSource   = null;
                grdShowParts.DataSource    = null;
                pnlQuantity.Visible        = false;
                grpSelectParts.Enabled     = false;
                grpSelectRepair.Enabled    = true;
                cboListParts.SelectedIndex = -1;
                grdShowParts.DataSource    = null;
                lblCostNum.Text            = "";
                txtRepID.Text            = "";
                lblEstimateTitle.Text    = titletext;
                pnlAddedParts.Visible    = false;
                grdListRepair.DataSource = null;
                lblCustEmail.Text        = "";
                grdListRepair.Visible    = true;
                btnSelectRepair.Visible  = false;


                DataSet dsReload = new DataSet();
                dsReload = Repair.getRepairStatus(dsReload, "Pending");
                grdListRepair.DataSource = dsReload.Tables["status_List"];

                if (grdListRepair.RowCount <= 0)
                {
                    grdListRepair.Dispose();
                }
            }
        }