コード例 #1
0
 private void Xoa()
 {
     try
     {
         if (vtIndex != -1)  //khi click lên tiêu đề header của datagrid thì bỏ qua
         {
             if (MSG.BanCoChacChanMuonXoaKhong() == System.Windows.Forms.DialogResult.Yes)
             {
                 ThietBi temp = Utils.DataGridViewRow_to_ThietBi(DataGridView.Rows[vtIndex]);
                 int     kq   = ThietBiBiz.DeleteThietBi(temp);
                 //if (kq > 0) MSG.XoaThanhCong();
                 //else MSG.XoaThatBai();
                 if (kq <= 0)
                 {
                     MSG.XoaThatBai();
                 }
                 HienThi();
             }
         }
     }
     catch (Exception ex)
     {
         MSG.Error(ex);
     }
 }
コード例 #2
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (Them)
            {//Thêm
                ThietBi temp = new ThietBi();
                temp.MaThietBi  = txtMa.Text;
                temp.TenThietBi = txtTen.Text;

                if (!CheckLoi(temp))
                {
                    return;
                }

                int kq = ThietBiBiz.AddThietBi(temp);
                if (kq > 0)
                {
                    MSG.ThemThanhCong();
                }
                else
                {
                    MSG.ThemThatBai();
                }
            }
            else
            {//Sửa
                ThietBi temp = new ThietBi();
                temp.MaThietBi  = txtMa.Text;
                temp.TenThietBi = txtTen.Text;
                int kq = ThietBiBiz.EditThietBi(temp);
                if (kq > 0)
                {
                    MSG.SuaThanhCong();
                }
                else
                {
                    MSG.SuaThatBai();
                }
            }
            this.Close();
        }
コード例 #3
0
 private void HienThi()
 {
     Ldata = ThietBiBiz.getListThietBi();
     DataGridView.DataSource = Ldata.ToArray();
     FixDataGirdView();
 }