示例#1
0
        private void DeleteEntry()
        {
            if (jobInfoDataGrid.SelectedRows.Count > 0)
            {
                int    selectedRowIndex = jobInfoDataGrid.SelectedCells[0].RowIndex;
                int    Id        = (int)jobInfoDataGrid.Rows[selectedRowIndex].Cells[0].Value;
                string jobNumber = jobInfoDataGrid.Rows[selectedRowIndex].Cells[2].Value.ToString();
                string item      = jobInfoDataGrid.Rows[selectedRowIndex].Cells[3].Value.ToString();
                if (MessageBox.Show($"Are you sure you want to delete line Item {item} for Job# {jobNumber}", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    PrepAndPaintModel deleteId = new PrepAndPaintModel()
                    {
                        Id = Id
                    };
                    PrepAndPaintDB.Delete(deleteId);

                    GetInfo();
                    //if (selectedRowIndex > 0)
                    //{
                    //    jobInfoDataGrid.Rows[selectedRowIndex - 1].Cells[1].Selected = true;
                    //}
                }
            }
            else
            {
                MessageBox.Show("Sorry you need to select an entry to delete!", "Error", MessageBoxButtons.OK);
            }
        }
示例#2
0
 private void DeleteEntry()
 {
     if (dataGridView.SelectedRows.Count > 0)
     {
         int    selectedRowIndex = dataGridView.SelectedCells[0].RowIndex;
         int    Id  = (int)dataGridView.Rows[selectedRowIndex].Cells[0].Value;
         string job = dataGridView.Rows[selectedRowIndex].Cells[1].Value.ToString();
         if (MessageBox.Show($"Are you sure you want to delete job #{job}?", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             PrepAndPaintModel deleteId = new PrepAndPaintModel()
             {
                 Id = Id
             };
             PrepAndPaintDB.Delete(deleteId);
             GetInfo();
             if (selectedRowIndex > 0)
             {
                 dataGridView.Rows[selectedRowIndex - 1].Cells[1].Selected = true;
             }
         }
     }
     else
     {
         MessageBox.Show("Sorry you need to select an entry to delete!", "Error", MessageBoxButtons.OK);
     }
 }
示例#3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (IsValidate())
            {
                var selectedItems = itemsListBox.SelectedItems;
                foreach (var item in selectedItems)
                {
                    PrepAndPaintModel newJob = new PrepAndPaintModel()
                    {
                        JobNumber   = txtJobNumber.Text,
                        StartDate   = "",
                        Prepper     = "",
                        PaintDate   = "",
                        Painter     = "",
                        BodyOrDoors = item.ToString(),
                        Booth       = "",
                        Colour      = cmboColour.Text,
                        Comments    = "",
                        NewProcess  = checkNewProcess.Checked,
                        WashBay     = checkBoxWashBay.Checked
                    };

                    CheckIfExist(newJob);
                }
            }
        }
示例#4
0
        private void EditJob()
        {
            if (jobInfoDataGrid.SelectedRows.Count > 0)
            {
                // This checks for null value in colour cell.
                string colourValue;
                int    selectedRowIndex = jobInfoDataGrid.SelectedCells[0].RowIndex;
                if (jobInfoDataGrid.Rows[selectedRowIndex].Cells[8].Value == null)
                {
                    colourValue = null;
                }
                else
                {
                    colourValue = jobInfoDataGrid.Rows[selectedRowIndex].Cells[9].Value.ToString();
                }


                PrepAndPaintModel editJob = new PrepAndPaintModel()
                {
                    Id          = (int)jobInfoDataGrid.Rows[selectedRowIndex].Cells[0].Value,
                    ItemNumber  = jobInfoDataGrid.Rows[selectedRowIndex].Cells[1].Value.ToString(),
                    JobNumber   = jobInfoDataGrid.Rows[selectedRowIndex].Cells[2].Value.ToString(),
                    BodyOrDoors = jobInfoDataGrid.Rows[selectedRowIndex].Cells[3].Value.ToString(),
                    StartDate   = jobInfoDataGrid.Rows[selectedRowIndex].Cells[4].Value.ToString(),
                    Prepper     = jobInfoDataGrid.Rows[selectedRowIndex].Cells[5].Value.ToString(),
                    PaintDate   = jobInfoDataGrid.Rows[selectedRowIndex].Cells[6].Value.ToString(),
                    Painter     = jobInfoDataGrid.Rows[selectedRowIndex].Cells[7].Value.ToString(),
                    Booth       = jobInfoDataGrid.Rows[selectedRowIndex].Cells[8].Value.ToString(),
                    Colour      = colourValue,
                    NewProcess  = (bool)jobInfoDataGrid.Rows[selectedRowIndex].Cells[10].Value,
                    WashBay     = (bool)jobInfoDataGrid.Rows[selectedRowIndex].Cells[11].Value,
                    Comments    = jobInfoDataGrid.Rows[selectedRowIndex].Cells[12].Value.ToString(),
                };
                AddJob addJob = new AddJob();
                addJob.editJob = editJob;
                addJob.edit    = true;
                DialogResult results = addJob.ShowDialog();
                if (results == DialogResult.OK)
                {
                    GetInfo();
                    foreach (DataGridViewRow row in jobInfoDataGrid.Rows)
                    {
                        if (row.Cells[0].Value.Equals(editJob.Id))
                        {
                            row.Cells[1].Selected = true;
                            jobInfoDataGrid.FirstDisplayedScrollingRowIndex = row.Index;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("No Record selected to edit!", "No Records selected");
            }
        }
示例#5
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (IsValidate())
            {
                if (edit)
                {
                    CheckStartDate();
                    CheckPaintDate();
                    PrepAndPaintModel edited = new PrepAndPaintModel()
                    {
                        Id          = editJob.Id,
                        StartDate   = startDate,
                        JobNumber   = txtJobNumber.Text,
                        Prepper     = txtPrepper.Text,
                        PaintDate   = paintDate,
                        Painter     = txtPainter.Text,
                        BodyOrDoors = cmboBodyDoors.Text,
                        Booth       = cmboBooth.Text,
                        Colour      = cmboColour.Text,
                        NewProcess  = checkNewProcess.Checked,
                        WashBay     = checkWashBay.Checked,
                        Comments    = txtComments.Text
                    };
                    PrepAndPaintDB.EditnewJob(edited);
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    CheckStartDate();
                    CheckPaintDate();
                    PrepAndPaintModel newJob = new PrepAndPaintModel()
                    {
                        StartDate   = startDate,
                        JobNumber   = txtJobNumber.Text,
                        Prepper     = txtPrepper.Text,
                        PaintDate   = paintDate,
                        Painter     = txtPainter.Text,
                        BodyOrDoors = cmboBodyDoors.Text,
                        Booth       = cmboBooth.Text,
                        Colour      = cmboColour.Text,
                        NewProcess  = checkNewProcess.Checked,
                        WashBay     = checkWashBay.Checked,
                        Comments    = txtComments.Text
                    };

                    CheckIfExist(newJob);
                }
            }
        }
示例#6
0
        private void CheckIfExist(PrepAndPaintModel newJob)
        {
            List <PrepAndPaintModel> prepAndPaintModels = PrepAndPaintDB.GetNewData();

            foreach (var item in prepAndPaintModels)
            {
                if (item.JobNumber == newJob.JobNumber && item.BodyOrDoors == newJob.BodyOrDoors)
                {
                    MessageBox.Show($"Item: {newJob.BodyOrDoors} already exist for Job# {newJob.JobNumber} in the database!",
                                    "Entry Exist!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            PrepAndPaintDB.AddnewJob(newJob);
            jobId        = newJob.Id;
            DialogResult = DialogResult.OK;
            Close();
        }