public void Delete(int ID)
 {
     DAL.QuyTacTinhNgayPhep item = GetByID(ID);
     if (item != null)
     {
         dataContext.QuyTacTinhNgayPheps.DeleteOnSubmit(item);
         Save();
     }
 }
 public void Update(DAL.QuyTacTinhNgayPhep obj)
 {
     DAL.QuyTacTinhNgayPhep existing = GetByID(obj.ID);
     existing.CreatedBy           = obj.CreatedBy;
     existing.CreatedDate         = obj.CreatedDate;
     existing.IsInUsed            = obj.IsInUsed;
     existing.MaHinhThucLamViec   = obj.MaHinhThucLamViec;
     existing.SoNgayPhepDuocHuong = obj.SoNgayPhepDuocHuong;
     existing.ThamNienDen         = obj.ThamNienDen;
     existing.ThamNienTu          = obj.ThamNienTu;
     existing.TinhTheoNam         = obj.TinhTheoNam;
     Save();
 }
 protected void btnUpdate_Click(object sender, DirectEventArgs e)
 {
     try
     {
         DAL.QuyTacTinhNgayPhep obj = new DAL.QuyTacTinhNgayPhep()
         {
             CreatedBy           = CurrentUser.ID,
             IsInUsed            = chkIsInUsed.Checked,
             TinhTheoNam         = bool.Parse(cbThoiGian.SelectedItem.Value),
             ThamNienTu          = int.Parse(nbfTu.Text),
             MaHinhThucLamViec   = int.Parse(cbHinhThucLamViec.SelectedItem.Value),
             CreatedDate         = DateTime.Now,
             MaDonVi             = Session["MaDonVi"].ToString(),
             SoNgayPhepDuocHuong = int.Parse(nbfSoNPDuocHuong.Text),
         };
         if (!string.IsNullOrEmpty(nbfDen.Text))
         {
             obj.ThamNienDen = int.Parse(nbfDen.Text);
         }
         if (e.ExtraParams["Command"] == "Update")
         {
             obj.ID = int.Parse(RowSelectionModel1.SelectedRow.RecordID);
             new QuyTacTinhNgayPhepController().Update(obj);
             Dialog.ShowNotification("Cập nhật thành công !");
         }
         else
         {
             new QuyTacTinhNgayPhepController().Add(obj);
             Dialog.ShowNotification("Thêm mới thành công !");
         }
         if (e.ExtraParams["Close"] == "True")
         {
             wdTaoQuyTac.Hide();
         }
         else
         {
             //reset các giá trị trên window
             nbfTu.Reset();
             nbfDen.Reset();
             cbThoiGian.Reset();
             nbfSoNPDuocHuong.Reset();
             cbHinhThucLamViec.Reset();
             chkIsInUsed.Reset();
         }
         grpQuyTacTinhNgayPhep.Reload();
     }
     catch (Exception ex)
     {
         X.MessageBox.Alert("Có lỗi xảy ra", ex.Message).Show();
     }
 }
 public void Add(DAL.QuyTacTinhNgayPhep obj)
 {
     dataContext.QuyTacTinhNgayPheps.InsertOnSubmit(obj);
     Save();
 }