Example #1
0
 private void autoFillRo(RO ro)
 {
     this.Text    = "RO#" + ro.getId().ToString();
     tbRONum.Text = ro.getId().ToString();
     tbRONum.Text = ro.getId().ToString();
     autoFillBike(ro.bike);
     autoFillCustomer(ro.customer);
     autoFillParts(ro.parts);
     autoFillServices(ro.services);
     dataGridViewTotalPrice.Rows[0].Cells[5].Value = ro.deposit;
     nudTires.Value         = ro.tires;
     dateTimePickerIn.Value = ro.dateIn;
     if (ro.dateOut > DateTime.Now.AddYears(-10))
     {
         dateTimePickerOut.Value   = ro.dateOut;
         dateTimePickerOut.Enabled = true;
         cbOut.Checked             = true;
     }
     tbDescOfWork.Text   = ro.descriptionOfWork;
     nudHourlyRate.Value = ro.hourlyRate;
     cbSaveParts.Checked = ro.saveOldParts;
     tbGOG.Text          = ro.gasOilGreas.ToString();
     lbTakenBy.Text      = "Taken by " + ro.takenBy;
     lbTakenBy.Location  = new Point(groupBoxCustomer.Right - lbTakenBy.Width, lbTakenBy.Location.Y);
     calculateTotalPrice();
 }
Example #2
0
        private void dgvRo_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar.Equals((char)Keys.Escape))
            {
                HashSet <DataGridViewRow> deletedRows = new HashSet <DataGridViewRow>();
                foreach (DataGridViewCell cell in dgvRo.SelectedCells)
                {
                    DataGridViewRow currentRow = cell.OwningRow;
                    if (!deletedRows.Contains(currentRow) && !currentRow.IsNewRow)
                    {
                        int roId = Convert.ToInt32(currentRow.Cells[0].Value);
                        if (roId < 1)
                        {
                            return;
                        }
                        RO editRO = DataManager.getRoById(roId);

                        DialogResult res = MessageBox.Show("Are you sure you want to delete RO #" + roId.ToString() + " " + editRO.customer.name + "?", "Warrning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                        if (res == DialogResult.OK)
                        {
                            dgvRo.Rows.Remove(currentRow);
                            deletedRows.Add(currentRow);
                            editRO.delete();
                        }
                    }
                }
                fillRos();
            }
        }
Example #3
0
 public RoForm(RO roToEdit)
 {
     init();
     ro = roToEdit;
     autoFillRo(ro);
     cbPrintSigningPage.Checked = false;
 }
Example #4
0
 public RoForm()
 {
     init();
     Text               = "RO#" + (DataManager.getCurrentRoId() + 1).ToString();
     lbTakenBy.Text     = "Taken by " + Core.logedIn.getName();
     lbTakenBy.Location = new Point(groupBoxCustomer.Right - lbTakenBy.Width, lbTakenBy.Location.Y);
     tbRONum.Text       = (DataManager.getCurrentRoId() + 1).ToString();
     cbOut.Checked      = false;
     isNewRo            = true;
     ro = new RO();
 }
Example #5
0
 public static RO getRoById(int roId)
 {
     try
     {
         RO rets = rosIndexed[roId];
         return(rets);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #6
0
        private void printRo(PrinterSettings settings, RO ro)
        {
            PrintDocument printDoc;

            printDoc = new RoPrint(ro);
            printDoc.PrinterSettings = settings;
            printDoc.DocumentName    = "RO #" + ro.getId();
            printDoc.Print();
            if (cbSignPage.Checked)
            {
                printDoc = new SigningDocumentPrint(ro);
                printDoc.PrinterSettings = settings;
                printDoc.DocumentName    = "Sign RO #" + ro.getId();
                printDoc.Print();
            }
        }
Example #7
0
        private void dgvRo_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (dgvRo.Rows[e.RowIndex].IsNewRow)
            {
                return;
            }
            int roId = Convert.ToInt32(dgvRo.Rows[e.RowIndex].Cells[0].Value);

            if (roId < 1)
            {
                return;
            }
            RO editRO = DataManager.getRoById(roId);

            new RoForm(editRO).ShowDialog();
            fillRos();
        }
Example #8
0
        private void btPrintSelected_Click(object sender, EventArgs e)
        {
            PrintDialog printDlg = new PrintDialog();

            if (dgvRo.SelectedCells.Count > 0)
            {
                if (!dgvRo.SelectedCells[0].OwningRow.IsNewRow)
                {
                    if (printDlg.ShowDialog() == DialogResult.OK)
                    {
                        int id = Convert.ToInt32(dgvRo.SelectedCells[0].OwningRow.Cells[0].Value);
                        RO  ro = DataManager.getRoById(id);
                        printRo(printDlg.PrinterSettings, ro);
                    }
                }
            }
        }
Example #9
0
 private void addRoToDgv(RO ro)
 {
     object[] data = new object[7];
     data[0] = ro.getId();
     data[1] = ro.customer.name;
     data[2] = ro.bike.getMakeModel();
     data[3] = ro.dateIn.ToShortDateString();
     if (!ro.isCLosed())
     {
         data[4] = "n/a";
     }
     else
     {
         data[4] = ro.dateOut.ToShortDateString();
     }
     data[5] = ro.getSubTotal();
     data[6] = ro.getTotal();
     dgvRo.Rows.Add(data);
 }
Example #10
0
        public static void addRO(RO ro)
        {
            if (rosIndexed.ContainsKey(ro.getId()))
            {
                rosIndexed[ro.getId()] = ro;
            }
            else
            {
                rosIndexed.Add(ro.getId(), ro);
                if (ro.getId() > currentRoID)
                {
                    currentRoID = ro.getId();
                }
            }

            ro.improtROData();
            if (writeMode)
            {
                ro.writeToFile();
            }
        }
Example #11
0
 public RoPrint(RO roToPrint) : base()
 {
     currentRo = roToPrint;
     init();
 }
Example #12
0
 public SigningDocumentPrint(RO roToPrint) : base()
 {
     currentRo = roToPrint;
     init();
 }
Example #13
0
        //====================GENERATe
        private bool generateRo()
        {
            if (ro == null)
            {
                ro = new RO();
            }
            int desiredID = -1;

            try
            {
                desiredID = Convert.ToInt32(tbRONum.Text);
                if (desiredID != ro.getId())
                {
                    if (DataManager.getRoById(desiredID) != null)
                    {
                        DialogResult res = MessageBox.Show("RO #" + desiredID.ToString() + " already exists. Do you want to overwrite RO?", "Warrning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                        if (res == DialogResult.OK)
                        {
                            ro.changeID(desiredID);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        ro.changeID(desiredID);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Ro id isnt a integer value!" + e.Message, "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            ro.customer = getCustomer();
            ro.bike     = getBike();
            ro.dateIn   = dateTimePickerIn.Value;
            try
            {
                ro.deposit = Convert.ToDouble(tbDeposit.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Deposit isnt a numerical value!", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (cbOut.Checked)
            {
                ro.dateOut = dateTimePickerOut.Value.Date;
            }
            else
            {
                ro.dateOut = DateTime.MinValue;
            }
            ro.gasOilGreas       = Convert.ToDouble(tbGOG.Text);
            ro.descriptionOfWork = tbDescOfWork.Text;
            ro.hourlyRate        = nudHourlyRate.Value;
            ro.parts             = getParts();
            ro.services          = getServices();
            ro.saveOldParts      = cbSaveParts.Checked;
            ro.takenBy           = Core.logedIn.getName();
            ro.tires             = nudTires.Value;
            ro.deposit           = getDepositFromDgv();
            DataManager.addRO(ro);
            return(true);
        }