protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { List <Su_LoaiTaiLieu> lstLoaiTaiLieu = logic.getAll(); dgvApprover.DataSource = lstLoaiTaiLieu; dgvApprover.DataBind(); if (Session[LoaiTaiLieuLogic.LOAI_TAI_LIEU_LOGIC_SEC_ID] != null) { sec = logic.findById(Int32.Parse(Session[LoaiTaiLieuLogic.LOAI_TAI_LIEU_LOGIC_SEC_ID].ToString())); txtCode.ReadOnly = true; txtCode.Text = sec.Code; tbxName.Text = sec.Name; tbxDescription.Text = sec.Description; btAddApprover.Text = "Cập nhật"; } else { sec = new Su_LoaiTaiLieu(); txtCode.ReadOnly = false; txtCode.Text = ""; tbxName.Text = ""; tbxDescription.Text = ""; btAddApprover.Text = "Thêm mới"; } } else { if (Session[LoaiTaiLieuLogic.LOAI_TAI_LIEU_LOGIC_SEC_ID] != null) { sec = logic.findById(Int32.Parse(Session[LoaiTaiLieuLogic.LOAI_TAI_LIEU_LOGIC_SEC_ID].ToString())); txtCode.ReadOnly = true; sec.Name = tbxName.Text; sec.Description = tbxDescription.Text; } else { sec = new Su_LoaiTaiLieu(); sec.Code = txtCode.Text; sec.Name = tbxName.Text; sec.Description = tbxDescription.Text; sec.Active = 1; } } } catch (Exception ex) { logger.Error("editApprover_Click error: ", ex); Response.Redirect("~/ThongBaoLoi.aspx", false); } }
public int insert(Su_LoaiTaiLieu sec) { try { dataContext.Su_LoaiTaiLieus.InsertOnSubmit(sec); dataContext.SubmitChanges(); } catch (Exception ex) { logger.Error("insert error: ", ex); } return(sec.ID); }
public Su_LoaiTaiLieu findById(int id) { Su_LoaiTaiLieu rs = null; try { rs = dataContext.Su_LoaiTaiLieus.Where(p => ((p.Active > 0 || p.Active == null) && p.ID == id)).First(); } catch (Exception ex) { logger.Error("getAll error: ", ex); } return(rs); }
protected void dgvOnDataBind(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { stt++; Su_LoaiTaiLieu item = (Su_LoaiTaiLieu)e.Row.DataItem; if (item != null) { Label lblSTT = (Label)e.Row.FindControl("lblSTT"); if (lblSTT != null) { lblSTT.Text = stt.ToString(); } } } }
public bool delete(int id) { bool rs = false; try { Su_LoaiTaiLieu attachObj = dataContext.Su_LoaiTaiLieus.Where(p => p.ID == id).First(); attachObj.Active = 0; dataContext.SubmitChanges(); rs = true; } catch (Exception ex) { logger.Error("update error: ", ex); } return(rs); }
public bool update(Su_LoaiTaiLieu sec) { bool rs = false; try { Su_LoaiTaiLieu attachObj = dataContext.Su_LoaiTaiLieus.Where(p => p.ID == sec.ID).First(); attachObj.Name = sec.Name; attachObj.Description = sec.Description; dataContext.SubmitChanges(); rs = true; } catch (Exception ex) { logger.Error("update error: ", ex); } return(rs); }
public bool validateUpdate(Su_LoaiTaiLieu sec) { bool rt = true; try { List <Su_LoaiTaiLieu> rs = dataContext.Su_LoaiTaiLieus.Where(p => (p.ID != sec.ID && p.Name.ToUpper().Equals(sec.Name.ToUpper())) && p.Active > 0).ToList(); if (rs != null && rs.Count > 0) { rt = false; } } catch (Exception ex) { logger.Error("getAll error: ", ex); } return(rt); }