Exemple #1
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         int    selectedRowIndex = colourDataGridView.SelectedCells[0].RowIndex;
         int    id       = (int)colourDataGridView.Rows[selectedRowIndex].Cells[0].Value;
         string itemname = colourDataGridView.Rows[selectedRowIndex].Cells[1].Value.ToString();
         if (MessageBox.Show($"Are you sure you want to delete Item: {itemname}?", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             JobColoursModel deleteId = new JobColoursModel()
             {
                 Id = id
             };
             PrepAndPaintDB.DeleteColour(deleteId);
             PopulateDataGrid();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Nothing selected to delete!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #2
0
 private void BtnAddColour_Click(object sender, EventArgs e)
 {
     if (IsValidate())
     {
         string          colourAndCode = $"{txtColourCode.Text.ToUpper()} - {txtColour.Text.ToUpper()}";
         JobColoursModel newJobColour  = new JobColoursModel()
         {
             Colour = colourAndCode
         };
         List <JobColoursModel> colours = PrepAndPaintDB.GetJobColours();
         foreach (var item in colours)
         {
             if (item.Colour == newJobColour.Colour)
             {
                 MessageBox.Show($" Colour: {newJobColour.Colour} already exist", "Exist already!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtColourCode.Focus();
                 return;
             }
         }
         colourName   = PrepAndPaintDB.AddColour(newJobColour);
         DialogResult = DialogResult.OK;
     }
 }