Exemplo n.º 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)
             {
                 DieuChuyenBoPhanSuDung temp = Utils.DataGridViewRow_to_DieuChuyenBoPhanSuDung(DataGridView.Rows[vtIndex]);
                 int kq = DieuChuyenBoPhanSuDungBiz.DeleteDieuChuyenBoPhanSuDung(temp);
                 if (kq > 0)
                 {
                     MSG.XoaThanhCong();
                 }
                 else
                 {
                     MSG.XoaThatBai();
                 }
                 if (kq <= 0)
                 {
                     MSG.XoaThatBai();
                 }
                 HienThi();
             }
         }
     }
     catch (Exception ex)
     {
         MSG.Error(ex);
     }
 }
        private void btnDongY_Click(object sender, EventArgs e)
        {
            try
            {
                DieuChuyenBoPhanSuDung temp = new DieuChuyenBoPhanSuDung();
                temp.DieuChuyenBoPhanSuDungID = idDieuChuyenBoPhanSuDung;
                temp.MaTaiSan       = txtMaTaiSan.Text;
                temp.Nam            = txtNam.Text;
                temp.Ky             = txtKy.Text;
                temp.MaBoPhanSuDung = txtBoPhanSuDung.Text;
                temp.TKTaiSan       = txtTKTaiSan.Text;
                temp.TKKhauHao      = txtTKKhauHao.Text;
                temp.TKChiPhi       = txtTKChiPhi.Text;

                bool ThatBai = false;
                if (Them)
                {//Thêm
                    if (!CheckLoi(temp))
                    {
                        return;
                    }

                    int kq = DieuChuyenBoPhanSuDungBiz.AddDieuChuyenBoPhanSuDung(temp);
                    if (kq > 0)
                    {
                        MSG.ThemThanhCong();
                    }
                    else
                    {
                        ThatBai = true;
                        MSG.ThemThatBai();
                    }
                }
                else
                {//Sửa
                    temp.DieuChuyenBoPhanSuDungID = idDieuChuyenBoPhanSuDung;
                    int kq = DieuChuyenBoPhanSuDungBiz.EditDieuChuyenBoPhanSuDung(temp);
                    if (kq > 0)
                    {
                        MSG.SuaThanhCong();
                    }
                    else
                    {
                        ThatBai = true;
                        MSG.SuaThatBai();
                    }
                }
                if (ThatBai && MSG.MESSAGE("Bạn có muốn sửa lại dữ liệu không?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    return;
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MSG.Error(ex);
            }
        }
Exemplo n.º 3
0
 private void HienThi()
 {
     Ldata = DieuChuyenBoPhanSuDungBiz.getListDieuChuyenBoPhanSuDung();
     DataGridView.DataSource = Ldata.ToArray();
     FixDataGirdView();
 }