예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (Session[Su_MucLucLogic.SESSION_SEC_ID] != null)
                    {
                        btAddApprover.Text = "Cập nhật";
                        sec = um.getMucLuc(Int32.Parse(Session[Su_MucLucLogic.SESSION_SEC_ID].ToString()));
                        if (sec != null)
                        {
                            tbxName.Text        = sec.Name;
                            tbxDescription.Text = sec.Description;
                            ntbLayer.Text       = sec.Layer.ToString().Trim();
                        }
                    }
                    else
                    {
                        sec = new MucLuc();
                    }

                    listAllSec();
                }
                catch (Exception ex)
                {
                    Logger.logmessage(classobject, "Page_Load", ex.Message + ex.StackTrace); Response.Redirect("~/ThongBaoLoi.aspx", false);
                }
            }
        }
예제 #2
0
        protected bool validateSecurity(MucLuc 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.validateSecLayerNull(sec.Layer.ToString()))
            {
                result = false;
                Response.Write("<script language='javascript'> { alert('Cấp mục lục 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>");
            }

            /*
             * if (!um.validateSecLayer(sec.Layer))
             * {
             *  result = false;
             *  Response.Write("<script language='javascript'> { alert('Cấp mục lục này  đã có trong hệ thống. Xin chọn một mức khác khác');}</script>");
             * }*/
            return(result);
        }
예제 #3
0
 protected void btAddApprover_Click(object sender, EventArgs e)
 {
     try
     {
         if (!isUpdate())
         {
             sec             = new MucLuc();
             sec.Name        = tbxName.Text;
             sec.Description = tbxDescription.Text;
             sec.Layer       = Int32.Parse(ntbLayer.Text);
         }
         else
         {
             sec             = um.getMucLuc(Int32.Parse(Session[Su_MucLucLogic.SESSION_SEC_ID].ToString()));
             sec.Name        = tbxName.Text;
             sec.Description = tbxDescription.Text;
             sec.Layer       = Int32.Parse(ntbLayer.Text);
         }
         if (validateSecurity(sec))
         {
             if (!isUpdate())
             {
                 um.addMucLuc(sec);
                 tbxDescription.Text = "";
                 tbxName.Text        = "";
                 ntbLayer.Text       = "0";
             }
             else
             {
                 um.updateMucLuc(sec);
                 tbxDescription.Text = "";
                 tbxName.Text        = "";
                 ntbLayer.Text       = "0";
             }
         }
         Session[Su_MucLucLogic.SESSION_SEC_ID] = null;
         Response.Redirect("QLMucLuc.aspx", false);
     }
     catch (Exception ex)
     {
         Logger.logmessage(classobject, "btAddApprover_Click", ex.Message + ex.StackTrace); Response.Redirect("~/ThongBaoLoi.aspx", false);
     }
 }