Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[Constant.USERNAME] != null && !string.IsNullOrEmpty(Session[Constant.USERNAME].ToString()))
            {
                using (Promotion.DataModel.User_BO objUser_BO = new User_BO())
                {
                    Promotion.DataModel.User objUser = objUser_BO.GetByUserName(Session[Constant.USERNAME].ToString());
                    if (objUser != null)
                    {
                        if (objUser.Permisions != null)
                        {
                            bool hasPer = false;
                            foreach (Promotion.DataModel.Permision item in objUser.Permisions)
                            {
                                if (item != null && item.Permision1 == Constant.PERMISION_ADMIN)
                                {
                                    hasPer = true;
                                    break;
                                }
                            }
                            if (!hasPer)
                            {
                                log.Info(Session[Constant.USERNAME].ToString() + " không có quyền truy cập trang " + Page.Title);
                                Page.Response.Redirect(Common.GetRootRequest() + "Account/Login.aspx");
                            }
                        }
                    }
                }
            }
            else
            {
                Page.Response.Redirect(Common.GetRootRequest() + "Account/Login.aspx");
            }

            if (!IsPostBack)
            {
                if (Session[Constant.FULLNAME] != null)
                {
                    lblWelcome.Text = Session[Constant.FULLNAME].ToString();
                }
            }
        }
Beispiel #2
0
 private void BindBranch()
 {
     using (COMPANY_BO objT24_COMPANY_BO = new COMPANY_BO())
     {
         List <COMPANY> lstData = objT24_COMPANY_BO.GetAll().ToList();
         foreach (COMPANY item in lstData)
         {
             cboBranch.Items.Add(new ListItem(item.COMPANY_CODE + "-" + item.COMPANY_NAME, item.COMPANY_CODE));
         }
         cboBranch.Items.Insert(0, new ListItem("--Chọn chi nhánh--", string.Empty));
         if (Session[Promotion.Commons.Constant.DAO_CODE] != null)
         {
             cboBranch.ClearSelection();
             if (cboBranch.Items.FindByValue(Session[Promotion.Commons.Constant.DAO_CODE].ToString()) != null)
             {
                 cboBranch.Items.FindByValue(Session[Promotion.Commons.Constant.DAO_CODE].ToString()).Selected = true;
             }
         }
         using (Promotion.DataModel.User_BO objUser_BO = new Promotion.DataModel.User_BO())
         {
             Promotion.DataModel.User objUser = objUser_BO.GetByUserName(Session[Promotion.Commons.Constant.USERNAME].ToString());
             if (objUser != null && objUser.Permisions != null)
             {
                 bool hasPer = false;
                 foreach (Promotion.DataModel.Permision item in objUser.Permisions)
                 {
                     if (item != null && item.Permision1 == Constant.PERMISION_ADMIN)
                     {
                         hasPer = true;
                         break;
                     }
                 }
                 if (hasPer)
                 {
                     cboBranch.Enabled = true;
                 }
             }
         }
     }
 }
Beispiel #3
0
 private void BindBranch()
 {
     using (COMPANY_BO objT24_COMPANY_BO = new COMPANY_BO())
     {
         List<COMPANY> lstData = objT24_COMPANY_BO.GetAll().ToList();
         foreach (COMPANY item in lstData)
         {
             cboBranch.Items.Add(new ListItem(item.COMPANY_CODE + "-" + item.COMPANY_NAME, item.COMPANY_CODE));
         }
         cboBranch.Items.Insert(0, new ListItem("--Chọn chi nhánh--", string.Empty));
         if (Session[Promotion.Commons.Constant.DAO_CODE] != null)
         {
             cboBranch.ClearSelection();
             if (cboBranch.Items.FindByValue(Session[Promotion.Commons.Constant.DAO_CODE].ToString()) != null)
             {
                 cboBranch.Items.FindByValue(Session[Promotion.Commons.Constant.DAO_CODE].ToString()).Selected = true;
             }
         }
         using (Promotion.DataModel.User_BO objUser_BO = new Promotion.DataModel.User_BO())
         {
             Promotion.DataModel.User objUser = objUser_BO.GetByUserName(Session[Promotion.Commons.Constant.USERNAME].ToString());
             if (objUser != null && objUser.Permisions != null)
             {
                 bool hasPer = false;
                 foreach (Promotion.DataModel.Permision item in objUser.Permisions)
                 {
                     if (item != null && item.Permision1 == Constant.PERMISION_ADMIN)
                     {
                         hasPer = true;
                         break;
                     }
                 }
                 if (hasPer)
                 {
                     cboBranch.Enabled = true;
                 }
             }
         }
     }
 }