Exemple #1
0
 private void button_Delete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc chắn muốn xóa sân bay này không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         Sanbay sb = new Sanbay();
         //sb.id = _ID;
         sb.masb = textBox_masb.Text;
         if (bllSB.DeleteSanbay(sb))
         {
             ShowAllSanbay();
             textBox_masb.Clear();    // Clear() để xóa hết kí tự khi vừa thêm xong
             textBox_tensb.Clear();
         }
         else
         {
             MessageBox.Show("Có lỗi xảy ra, xin hãy thử lại!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
     }
 }
Exemple #2
0
        private void button_Delete_Click(object sender, EventArgs e)
        {
            //--------------- MINH CHINH SUA

            //int total = dataGridView_Sanbay.Rows.Cast<DataGridViewRow>().Where(p => Convert.ToBoolean(p.Cells["select"].Value) == true).Count();
            //if (total > 0)
            //{
            //    for (int i = dataGridView_Sanbay.RowCount - 1; i >= 0; i--)
            //    {
            //        DataGridViewRow row = dataGridView_Sanbay.Rows[i];
            //        if (Convert.ToBoolean(row.Cells["select"].Value) == true)
            //        {
            //            dataGridView_Sanbay.Rows.Remove(row);
            //        }
            //    }
            //}



            //--------------



            if (MessageBox.Show("Bạn có chắc chắn muốn xóa những sân bay này không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                Sanbay sb = new Sanbay();

                foreach (DataGridViewRow row in dataGridView_Sanbay.SelectedRows)
                {
                    //sb.id = _ID;

                    sb.masb = row.Cells[0].Value.ToString();
                    if (bllSB.DeleteSanbay(sb))
                    {
                        sl_canxoa -= 1;
                        //ShowAllSanbay();
                        textBox_masb.Clear();    // Clear() để xóa hết kí tự khi vừa thêm xong
                        textBox_tensb.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Có lỗi xảy ra, xin hãy thử lại!", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
                if (sl_canxoa == -1)
                {
                    ShowAllSanbay();
                }
                else
                {
                    if (trigger != true)
                    {
                        ShowSB_HoatDong();
                    }
                    else
                    {
                        ShowAllSanbay();
                    }
                    if (sl_canxoa == 0)
                    {
                        button_Delete.Enabled = false;

                        if (MessageBox.Show("Cập nhật số lượng sân bay thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                        {
                            if (UIParent is Thaydoiquydinh)
                            {
                                Thaydoiquydinh frm = UIParent as Thaydoiquydinh;
                                frm.UpdateSoluongSB();
                            }

                            this.Dispose();
                        }
                    }
                }
            }
        }