Example #1
0
 private void dgvGia_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if ((mUser.isAdmin == 1 || mUR.isEdit.Value) && e.ColumnIndex == (tempSua - 7)) // nut sua
         {
             Price EditPrice = new Price();
             EditPrice.ID            = int.Parse(dgvGia["ID", e.RowIndex].Value.ToString());
             EditPrice.PriceName     = dgvGia["PriceName", e.RowIndex].Value.ToString();
             EditPrice.ElectricPrice = decimal.Parse(dgvGia["ElectricPrice", e.RowIndex].Value.ToString().Replace(".", ""));
             EditPrice.WaterPrice    = decimal.Parse(dgvGia["WaterPrice", e.RowIndex].Value.ToString().Replace(".", ""));
             ThemGia mThemGia = new ThemGia(mUser, EditPrice);
             mThemGia.mUCGia            = this;
             this.Parent.Parent.Enabled = false;
             mThemGia.Show();
         }
         if ((mUser.isAdmin == 1 || mUR.isRemove.Value) && e.ColumnIndex == (tempXoa - 7)) // click nút xóa
         {
             var result = MessageBox.Show($"Bạn có muốn xóa {dgvGia["PriceName", e.RowIndex].Value.ToString().ToUpper()}?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
             {
                 if (new PriceLDM().Delete(int.Parse(dgvGia["ID", e.RowIndex].Value.ToString())))
                 {
                     ReloadDataGia();
                     MessageBox.Show("Xóa thành công");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
 private void btnThemGia_Click(object sender, EventArgs e)
 {
     try
     {
         ThemGia mThemGia = new ThemGia(mUser);
         mThemGia.mUCGia            = this;
         this.Parent.Parent.Enabled = false;
         mThemGia.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }