public void Insert(DAL.DM_MUCLUONG_NGACH ngach) { if (ngach != null) { dataContext.DM_MUCLUONG_NGACHes.InsertOnSubmit(ngach); Save(); } }
public void Delete(decimal prkey) { DAL.DM_MUCLUONG_NGACH tmp = dataContext.DM_MUCLUONG_NGACHes.SingleOrDefault(t => t.PR_KEY == prkey); if (tmp != null) { dataContext.DM_MUCLUONG_NGACHes.DeleteOnSubmit(tmp); Save(); } }
protected void btnCapNhat_Click(object sender, DirectEventArgs e) { try { if (e.ExtraParams["Command"] != "Edit") { DAL.DM_MUCLUONG_NGACH tmp = new DM_MUCLUONG_NGACHController().GetByNhomNgachBacNgach(hdfMaNhomNgach.Text, hdfMaNgach.Text, int.Parse(hdfBac.Text)); if (tmp != null) { X.Msg.Alert("Thông báo từ hệ thống", "Ngạch và bậc " + tmp.BAC_LUONG + " đã có dữ liệu. Bạn không thể thêm mới dữ liệu khác").Show(); return; } } DAL.DM_MUCLUONG_NGACH ngach = new DAL.DM_MUCLUONG_NGACH() { MA_NHOM_NGACH = hdfMaNhomNgach.Text, MA_NGACH = hdfMaNgach.Text, BAC_LUONG = int.Parse(hdfBac.Text), HS_LUONG = decimal.Parse(txtHeSoLuong.Text.Replace('.', ',')), MUC_LUONG = txtMucLuong.Text, GHI_CHU = txtGhiChu.Text, USERNAME = CurrentUser.DisplayName, DATE_CREATE = DateTime.Now, MA_DONVI = Session["MaDonVi"].ToString() }; //if (!string.IsNullOrEmpty(txtCap.Text)) // ngach.CAP = double.Parse(txtCap.Text.Replace('.', ',')); if (e.ExtraParams["Command"] == "Edit") { ngach.PR_KEY = decimal.Parse(hdfRecordID.Text); new DM_MUCLUONG_NGACHController().Update(ngach); Dialog.ShowNotification("Cập nhật dữ liệu thành công"); wdThemMoiMucLuongNgach.Hide(); } else { new DM_MUCLUONG_NGACHController().Insert(ngach); Dialog.ShowNotification("Thêm mới dữ liệu thành công!"); if (e.ExtraParams["Close"] == "True") { wdThemMoiMucLuongNgach.Hide(); } else { RM.RegisterClientScriptBlock("rs1", "ResetWdThemMucLuongNgach();"); } } GridPanel1.Reload(); } catch (Exception ex) { X.Msg.Alert("Thông báo từ hệ thống", "Có lỗi xảy ra: " + ex.Message).Show(); } }
public void Update(DAL.DM_MUCLUONG_NGACH ngach) { var tmp = dataContext.DM_MUCLUONG_NGACHes.SingleOrDefault(t => t.PR_KEY == ngach.PR_KEY); if (tmp != null) { tmp.MA_NHOM_NGACH = ngach.MA_NHOM_NGACH; tmp.MA_NGACH = ngach.MA_NGACH; tmp.BAC_LUONG = ngach.BAC_LUONG; tmp.CAP = ngach.CAP; tmp.HS_LUONG = ngach.HS_LUONG; tmp.MUC_LUONG = ngach.MUC_LUONG; tmp.GHI_CHU = ngach.GHI_CHU; Save(); } }