Beispiel #1
0
 private void EditButton_Click(object sender, EventArgs e)
 {
     try
     {
         //List<int> blankCertIds = (from DataGridViewRow r in BlankCertDataGridView.Rows
         //                          where Convert.ToBoolean(r.Cells[1].Value) == true
         //                          select Convert.ToInt32(r.Cells[0].Value)).ToList();
         List <int> blankCertIds = new List <int>();
         blankCertIds.Add(Convert.ToInt32(BlankCertDataGridView.Rows[BlankCertDataGridView.SelectedCells[0].RowIndex].Cells[0].Value));
         if (blankCertIds.Count == 1)
         {
             int blankCertId = blankCertIds.FirstOrDefault();
             EditBlankCertForm editBlankCertForm = new EditBlankCertForm(blankCertId);
             editBlankCertForm.ShowDialog();
         }
         else if (blankCertIds.Count == 0)
         {
             //MessageBox.Show("Bạn chưa chọn phôi nào", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             NotificationForm notificationForm = new NotificationForm("Bạn chưa chọn phôi nào", "Cảnh báo", MessageBoxIcon.Warning);
             notificationForm.ShowDialog();
         }
         else
         {
             //MessageBox.Show("Chỉ được chọn 1 phôi để sửa", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             NotificationForm notificationForm = new NotificationForm("Chỉ được chọn 1 phôi để sửa", "Cảnh báo", MessageBoxIcon.Warning);
             notificationForm.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Warning);
         notificationForm.ShowDialog();
     }
 }
Beispiel #2
0
 private void BlankCertDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == BlankCertDataGridView.Columns["Edit"].Index && e.RowIndex >= 0)
     {
         int certId = int.Parse(BlankCertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
         EditBlankCertForm editBlankCertForm = new EditBlankCertForm(certId);
         editBlankCertForm.ShowDialog();
     }
     else if (e.ColumnIndex == BlankCertDataGridView.Columns["Delete"].Index && e.RowIndex >= 0)
     {
         DialogResult dialogResult = MessageBox.Show("Đồng ý xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dialogResult == DialogResult.Yes)
         {
             try
             {
                 int certId = int.Parse(BlankCertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
                 int result = managingBlankCertService.Delete(certId);
                 if (result > 0)
                 {
                     //MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     NotificationForm notificationForm = new NotificationForm("Xóa thành công", "Thông báo", MessageBoxIcon.Information);
                     notificationForm.ShowDialog();
                     LoadListBlankCert();
                 }
                 else
                 {
                     //MessageBox.Show("Xóa không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     NotificationForm notificationForm = new NotificationForm("Xóa không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                     notificationForm.ShowDialog();
                 }
             }
             catch (Exception ex)
             {
                 //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                 notificationForm.ShowDialog();
             }
         }
         else if (dialogResult == DialogResult.No)
         {
             //no delete
         }
     }
 }