protected void btnSua_Click(object sender, EventArgs e) { pcAddRoles.ShowOnPageLoad = true; Session["Add"] = 0; SYS_Session session = (SYS_Session)Session["SYS_Session"]; CBDN.HD_SanLuongThuongPham cv = (CBDN.HD_SanLuongThuongPham)grdDVT.GetRow(grdDVT.FocusedRowIndex); txtThang.Text = cv.Thang + ""; txtNam.Value = cv.Nam + ""; txtSanLuongDien.Text = cv.SLuongThuongPham + ""; }
protected void btnCapNhat_Click(object sender, EventArgs e) { DM_DVQLYService dm_dviSer = new DM_DVQLYService(); SYS_Session session = (SYS_Session)Session["SYS_Session"]; decimal test = 0; if (!decimal.TryParse(txtSanLuongDien.Text + "", out test)) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Sản lượng thương phẩm là kiểu số');", true); txtSanLuongDien.Focus(); return; } if (Session["Add"] + "" == "0") { CBDN.HD_SanLuongThuongPham qtCT = (CBDN.HD_SanLuongThuongPham)grdDVT.GetRow(grdDVT.FocusedRowIndex); CBDN.HD_SanLuongThuongPham cn = db.HD_SanLuongThuongPhams.SingleOrDefault(x => x.ID == qtCT.ID); cn.SLuongThuongPham = decimal.Parse(txtSanLuongDien.Text); cn.Thang = int.Parse(txtThang.Text); cn.Nam = int.Parse(txtNam.Text); db.SubmitChanges(); } else { if (!checkTrung(int.Parse(txtNam.Text), int.Parse(txtThang.Text), int.Parse(session.User.ma_dviqly))) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Đã có sản lượng thương phẩm tháng này không thể thêm được.');", true); return; } CBDN.HD_SanLuongThuongPham cv = new CBDN.HD_SanLuongThuongPham(); cv.Thang = int.Parse(txtThang.Text); cv.Nam = int.Parse(txtNam.Text); cv.NgayNhap = DateTime.Now; cv.IDMaDviQly = int.Parse(session.User.ma_dviqly); cv.SLuongThuongPham = decimal.Parse(txtSanLuongDien.Text); db.HD_SanLuongThuongPhams.InsertOnSubmit(cv); db.SubmitChanges(); } pcAddRoles.ShowOnPageLoad = false; _DataBind(); }
protected void grdDVT_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { try { SYS_Session session = (SYS_Session)Session["SYS_Session"]; CBDN.HD_SanLuongThuongPham HoatDong = (CBDN.HD_SanLuongThuongPham)grdDVT.GetRow(grdDVT.FocusedRowIndex); CBDN.HD_SanLuongThuongPham cv = new CBDN.HD_SanLuongThuongPham(); cv = db.HD_SanLuongThuongPhams.SingleOrDefault(x => x.ID == HoatDong.ID); db.HD_SanLuongThuongPhams.DeleteOnSubmit(cv); db.SubmitChanges(); _DataBind(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Xoá phương thức giao nhận thành công');", true); } catch (Exception ex) { } finally { e.Cancel = true; } }