Esempio n. 1
0
        protected void btAddApprover_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isUpdate())
                {
                    Logger.logmessage(classobject, "LoaiVanBan btAddApprover_Click", "Start insert");
                    sec             = new LoaiVanBanObject();
                    sec.Name        = tbxName.Text;
                    sec.Description = tbxDescription.Text;
                }
                else
                {
                    sec.Name        = tbxName.Text;
                    sec.Description = tbxDescription.Text;
                }
                if (!isUpdate())
                {
                    if (validateSecurity(sec))
                    {
                        Logger.logmessage(classobject, "LoaiVanBan btAddApprover_Click", "Before exe logic insert");
                        um.addLoaiVanBan(sec);
                        tbxDescription.Text = "";
                        tbxName.Text        = "";
                    }
                    else
                    {
                        Logger.logmessage(classobject, "LoaiVanBan btAddApprover_Click", "Validate 4 insert fail name " + sec.Name);
                    }
                }
                else if (um.validateSec4Update(sec.Name, sec.ID))
                {
                    Logger.logmessage(classobject, "LoaiVanBan btAddApprover_Click", "Before execute update");
                    um.updateLoaiVanBan(sec);
                    tbxDescription.Text = "";
                    tbxName.Text        = "";
                }
                else
                {
                    Logger.logmessage(classobject, "LoaiVanBan btAddApprover_Click", "Validate 4 update fail name " + sec.Name);
                }

                Session[LoaiVanBanLogic.SESSION_SEC_ID] = null;
                Response.Redirect("LoaiVanBan.aspx", false);
            }
            catch (Exception ex)
            {
                Logger.logmessage(classobject, "btAddApprover_Click", ex.Message + ex.StackTrace);
                Response.Redirect("~/ThongBaoLoi.aspx", false);
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (Session[LoaiVanBanLogic.SESSION_SEC_ID] != null)
                    {
                        btAddApprover.Text = "Cập nhật";
                        sec = um.getLoaiVanBan(Int32.Parse(Session[LoaiVanBanLogic.SESSION_SEC_ID].ToString()));
                        if (sec != null)
                        {
                            tbxName.Text        = sec.Name;
                            tbxDescription.Text = sec.Description;
                        }
                    }
                    else
                    {
                        sec = new LoaiVanBanObject();
                    }

                    listAllSec();
                }
                catch (Exception ex)
                {
                    Logger.logmessage(classobject, "Page_Load", ex.Message + ex.StackTrace); Response.Redirect("~/ThongBaoLoi.aspx", false);
                }
            }
            else
            {
                string tId = "";
                if (Session[LoaiVanBanLogic.SESSION_SEC_ID] != null)
                {
                    tId = Session[LoaiVanBanLogic.SESSION_SEC_ID].ToString();
                    sec = new LoaiVanBanObject();
                    int iId = 0;
                    Int32.TryParse(tId, out iId);
                    sec.ID          = iId;
                    sec.Name        = tbxName.Text;
                    sec.Description = tbxDescription.Text;
                }
            }
        }
Esempio n. 3
0
        protected bool validateSecurity(LoaiVanBanObject sec)
        {
            bool result = true;

            if (!um.validateSecName(sec.Name))
            {
                result = false;
                Response.Write("<script language='javascript'> { alert('Tên này đã có trong hệ thống. Xin chọn một tên khác');}</script>");
            }
            if (!um.validateSecNameNull(sec.Name))
            {
                result = false;
                Response.Write("<script language='javascript'> { alert('Tên không được phép để trống');}</script>");
            }
            if (!um.validateSecNameNull(sec.Description))
            {
                result = false;
                Response.Write("<script language='javascript'> { alert('Mô tả không được phép để trống');}</script>");
            }
            return(result);
        }