コード例 #1
0
ファイル: tabproduct.aspx.cs プロジェクト: mvtcode/g9webs
        private void Detail(int id)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                return;
            }
            DIV_1.Style["display"] = "block";
            var o = ServiceFactory.GetInstanceProductDetail().GetProductDetailInfo(id);

            if (o != null)
            {
                HD_ID.Value   = o.id.ToString();
                TB_Title.Text = o.sTitle;
                Content.Text  = o.sContent;
                HD_File.Value = o.sFile;
                //LB_File.Text = o.sFile;
                if (TB_Title.Text.ToLower() != "download")
                {
                    TR_Upload_File.Visible = false;
                }
                else
                {
                    TR_Upload_File.Visible = true;
                }
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginAdmin.IsLoginAdmin();

            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            if (!IsPostBack)
            {
                lblMsg.Text = "";

                //BindDDL();

                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    EditData();
                }
                else
                {
                    Response.Redirect("contact_manager.aspx");
                }
            }
        }
コード例 #3
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserDelete)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }
            try
            {
                int       i   = 0;
                AdminImpl obj = new AdminImpl();
                foreach (GridViewRow row in grvView.Rows)
                {
                    var status = (CheckBox)row.FindControl("StatusCheck");

                    if (status.Checked)
                    {
                        int adminID = int.Parse(grvView.DataKeys[i].Value.ToString());

                        obj.Delete(adminID);
                    }

                    i++;
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
            BindGird();
        }
コード例 #4
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserDelete)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }
            try
            {
                int i = 0;
                CategoryTypeImpl obj = new CategoryTypeImpl();
                foreach (GridViewRow row in grvView.Rows)
                {
                    var status = (CheckBox)row.Cells[2].FindControl("StatusCheck");

                    if (status.Checked)
                    {
                        int ID = int.Parse(grvView.DataKeys[i].Value.ToString());
                        obj.Delete(ID);
                        //
                        DeleteCache(ID);
                    }

                    i++;
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
            BindGird();
            //search(Convert.ToInt32(ddlNewType.Text), txtTim.Text.Trim());
            //        BindGird(int.Parse(ddlNewType.Text), 0);
        }
コード例 #5
0
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int userID = 0;

                CategoryTypeImpl obj = new CategoryTypeImpl();
                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    try
                    {
                        userID = int.Parse(Request.QueryString["ID"]);


                        CategoryTypeInfo item = obj.GetInfo(userID);

                        if (item == null)
                        {
                            Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                            return;
                        }
                        else
                        {
                            item.s_CategoryName = txtName.Text;
                            obj.Update(item);

                            //reset cache
                            DeleteCache(item.pk_ID);
                        }
                    }
                    catch
                    {
                        Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                        return;
                    }
                }
                else
                {
                    CategoryTypeInfo item = new CategoryTypeInfo();
                    item.s_CategoryName = txtName.Text;

                    obj.Insert(item);

                    //reset cache
                    DeleteCache(item.pk_ID);
                }
                Response.Redirect("newtype_manager.aspx", false);
            }
            catch
            {
                lblMsg.Text = "Tên loại tin đã tồn tại. Bạn chạy chọn một tên khác";
            }
        }
コード例 #6
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            PanelMenu1.Items.Clear();

            string sCurr = Request.Url.AbsoluteUri;

            int appID = 0;

            string linkCur = sCurr.Substring(sCurr.LastIndexOf("/") + 1);

            linkCur = linkCur.Substring(0, linkCur.IndexOf(".aspx") + 5);

            appID = UserRightImpl.GetParentID(linkCur);

            var obj = new UserRightImpl();

            var objAdmin = (AdminInfo)Session[Constant.SessionNameAccountAdmin];

            if (objAdmin == null)
            {
                Response.Redirect(Utility.UrlRoot + Config.LoginAdmin, true);
            }

            DataTable dt;

            DataTable dtMain = obj.GetParentMenuByID(appID);

            dt = objAdmin.Status == 2 ? obj.GetFullMenuByParentID(appID) : obj.GetMenuByAdminIDAndParentID(objAdmin.ID, appID);

            ltTitleMenuLeft.Text = lbTitleMain.Text = dtMain.Rows[0]["Name2"].ToString();

            item = new RadPanelItem {
                Text = dtMain.Rows[0]["Name2"].ToString(), Value = "view", Expanded = true
            };

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                item.Items.Add(new RadPanelItem(dt.Rows[i]["Name"].ToString(),
                                                Utility.UrlRoot + Config.PathAdmin + dt.Rows[i]["Link"]));

                if (sCurr.IndexOf(dt.Rows[i]["Link"].ToString()) != -1)
                {
                    lbTitleMain.Text = dt.Rows[i]["Name3"].ToString();
                }
                //   item.Items.Add(new RadPanelItem("Thêm mới người dùng", "~/admin_add.aspx?AppID=1"));
            }

            if (Request.QueryString["ID"] != null)
            {
                lbTitleMain.Text = lbTitleMain.Text.Replace("Thêm mới", "Sửa");
            }

            PanelMenu1.Items.Add(item);
        }
コード例 #7
0
        //load grid
        private void Load_Grid()
        {
            int iPageIndex = UntilityFunction.IntegerForNull(HD_Page.Value);
            int iPageSize  = UntilityFunction.IntegerForNull(Config.PageSizeAdmin);//get page size
            int iTotalRow;
            var oList = ServiceFactory.GetInstanceProduct().SelectListProducts(iPageIndex, iPageSize, out iTotalRow);

            sProducHTML = BuildContentListProduct(oList, UserRightImpl.CheckRightAdminnistrator().UserEdit);
            //Page
            sPage = HtmlUtility.BuildPagerScript(iTotalRow, iPageSize, iPageIndex, "Page", "chon", 5, "product");
        }
コード例 #8
0
        private void Delete(int id)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserDelete)
            {
                return;
            }
            int i = ServiceFactory.GetInstanceNews().Delete(id);

            LB_Messenger.Text      = i > 0 ? "Đã xóa bản ghi" : "Có lỗi phát sinh";
            DIV_1.Style["display"] = "none";
            Load_Grid();
            DeleteCache(id);
        }
コード例 #9
0
        private void SetAttribute()
        {
            DIV_2.Style["display"] = "none";
            BT_Save.Attributes.Add("onclick", "javascript:return CheckData();");
            //TB_Price.Attributes.Add("onkeypress", "javascript:return EnsureIntegerKeyEntry(this.value,event);");
            //TB_Price.Attributes.Add("onkeyup", "javascript:FormatNum(this, 0);");
            //TB_SortField.Attributes.Add("onkeypress", "javascript:return EnsureIntegerKeyEntry(this.value,event);");
            BT_IMG.Attributes.Add("onclick", "javascript:return ShowPupup();");
            IMG.Attributes.Add("onclick", "javascript:return ShowPupup();");

            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                BT_Add.Visible = false;
            }
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginAdmin.IsLoginAdmin();

            if (!UserRightImpl.CheckRightAdminnistrator().UserRead)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            if (!IsPostBack)
            {
                BindGird();
            }
        }
コード例 #11
0
 protected void BT_Add_Click(object sender, EventArgs e)
 {
     if (!UserRightImpl.CheckRightAdminnistrator().UserDelete)
     {
         return;
     }
     DIV_1.Style["display"] = "block";
     HD_ID.Value            = "0";
     TB_Title.Text          = "";
     TB_Description.Text    = "";
     HD_IMG.Value           = "";
     IMG.ImageUrl           = "~/Images/NoImage.jpg";
     TB_Sort.Text           = "";
     CB_Active.Checked      = true;
     Content.Text           = "";
     //SetFocus()
     ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "SetFocus()", true);
 }
コード例 #12
0
        protected void btUpdate_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int       i   = 0;
                AdminImpl obj = new AdminImpl();
                foreach (GridViewRow row in grvView.Rows)
                {
                    var status = (CheckBox)row.Cells[3].FindControl("IsLogin");

                    if (status.Checked)
                    {
                        int adminID = int.Parse(grvView.DataKeys[i].Value.ToString());

                        AdminInfo item = obj.GetAdmin(obj.SelectOne(adminID))[0];
                        item.IsLogin = 1;
                        obj.Update(item);
                    }
                    else
                    {
                        int adminID = int.Parse(grvView.DataKeys[i].Value.ToString());

                        AdminInfo item = obj.GetAdmin(obj.SelectOne(adminID))[0];
                        item.IsLogin = 0;
                        obj.Update(item);
                    }
                    i++;
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }

            BindGird();
        }
コード例 #13
0
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int userID = 0;
                Utility.SendEmail(txtEmail.Text, "Re: " + txtTitle.Text, txtAnswer.Text, string.Empty, Config.UsernameSendMail, Config.PassSendMail);
                Response.Redirect("contact_manager.aspx", false);
            }
            catch
            {
                lblMsg.Text = "Có lỗi xảy ra";
            }
        }
コード例 #14
0
ファイル: admin_add.aspx.cs プロジェクト: mvtcode/g9webs
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginAdmin.IsLoginAdmin();

            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            if (!IsPostBack)
            {
                txtUsername.Text = "";
                txtPass.Text     = "";

                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    if (Utility.IsInteger(Request.QueryString["ID"]))
                    {
                        _adminID = int.Parse(Request.QueryString["ID"]);
                        //_isEdit = true;
                        EditData();
                        RequiredFieldValidator2.Enabled = false;
                        RequiredFieldValidator3.Enabled = false;
                    }
                }
            }

            if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
            {
                if (Utility.IsInteger(Request.QueryString["ID"]))
                {
                    _adminID = int.Parse(Request.QueryString["ID"]);
                    _isEdit  = true;
                    //EditData();
                }
            }

            lblMsg.Text = "";
        }
コード例 #15
0
        private void BindGrid(int type)
        {
            try
            {
                UserRightImpl obj = new UserRightImpl();
                if (_adminID == 0)
                {
                    _adminID = int.Parse(ddlUser.Text.ToString());
                }
                _dtRight = obj.GetQuyenByAdminID(_adminID, type);

                grvView.DataSource = _dtRight;
                grvView.DataBind();

                SetUserRight();
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
        }
コード例 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginAdmin.IsLoginAdmin();

            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            if (Page.Request["ID"] == null)
            {
            }
            else
            {
                _adminID = int.Parse(Page.Request["ID"]);
            }
            if (!IsPostBack)
            {
                BindDropDownList();
                BindGrid(0);
            }
        }
コード例 #17
0
        private void Detail(int id)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                return;
                //Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
            }
            DIV_1.Style["display"] = "block";
            NewsInfo o = ServiceFactory.GetInstanceNews().GetInfo(id);

            if (o != null)
            {
                HD_ID.Value         = o.pk_Id.ToString();
                TB_Title.Text       = o.s_Title;
                TB_Description.Text = o.s_Description;
                HD_IMG.Value        = o.s_Image;
                IMG.ImageUrl        = GetPathImgThumb(o.s_Image);
                TB_Sort.Text        = o.SortField.ToString();
                CB_Active.Checked   = o.Active;
                Content.Text        = o.s_Content;
                //SetFocus()
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "focus", "SetFocus()", true);
            }
        }
コード例 #18
0
ファイル: customer_add.aspx.cs プロジェクト: mvtcode/g9webs
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginAdmin.IsLoginAdmin();

            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            if (!IsPostBack)
            {
                lblMsg.Text = "";

                IMG.Attributes.Add("onclick", "javascript:return ShowPupup();");
                BT_IMG.Attributes.Add("onclick", "javascript:return ShowPupup();");
                //BindDDL();

                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    EditData();
                }
            }
        }
コード例 #19
0
ファイル: support_add.aspx.cs プロジェクト: mvtcode/g9webs
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int userID = 0;

                SupportImpl obj = new SupportImpl();
                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    try
                    {
                        userID = int.Parse(Request.QueryString["ID"]);

                        SupportInfo item = obj.GetInfo(userID);

                        if (item == null)
                        {
                            Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                            return;
                        }
                        else
                        {
                            item.s_Name   = txtName.Text;
                            item.s_Email  = txtEmail.Text;
                            item.s_Mobile = txtMobile.Text;
                            item.s_Skype  = txtSkype.Text;
                            item.s_Yahoo  = txtYahoo.Text;
                            obj.Update(item);
                            //Delete cache
                            CacheController.GetListSupport_Delete();
                        }
                    }
                    catch
                    {
                        Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                        return;
                    }
                }
                else
                {
                    SupportInfo item = new SupportInfo();
                    item.s_Name   = txtName.Text;
                    item.s_Email  = txtEmail.Text;
                    item.s_Mobile = txtMobile.Text;
                    item.s_Skype  = txtSkype.Text;
                    item.s_Yahoo  = txtYahoo.Text;

                    obj.Insert(item);
                    //Delete cache
                    CacheController.GetListSupport_Delete();
                }
                Response.Redirect("support_manager.aspx", false);
            }
            catch
            {
                lblMsg.Text = "Tên người hỗ trợ đã tồn tại. Bạn chạy chọn một tên khác";
            }
        }
コード例 #20
0
        protected void Page_Init(object sender, EventArgs e)
        {
            Page.Title = "..:G9 - Content Management System:..";

            var linkTag = new Literal();

            linkTag.Text =
                string.Format(
                    @"<link href=""{0}css/layout.css"" rel=""stylesheet"" type=""text/css"" />
                    <link href=""{0}css/css.css"" rel=""stylesheet"" type=""text/css"" />
                    <link href=""{0}css/style_repeater.css"" rel=""stylesheet"" type=""text/css"" />
                    <link href=""{0}css/paper.css"" rel=""stylesheet"" type=""text/css"" />
                    ", UrlRoot);

            Page.Header.Controls.Add(linkTag);

            if (Session[Constant.SessionNameAccountAdmin] == null ||
                Session[Constant.SessionNameAccountAdmin].ToString() == string.Empty)
            {
                return;
            }
            ltlUserID.Text        = ((AdminInfo)Session[Constant.SessionNameAccountAdmin]).Username;
            hlChangePwd.InnerText = "Đổi mật khẩu";
            hlChangePwd.HRef      = UrlRoot + "ChangePass.aspx";
            hlSignOut.InnerText   = "Thoát";
            //hlSignOut.HRef = DBConfig.LoginURL + "?act=out";
            hlSignOut.HRef = UrlRoot + "Logout.aspx";

            if (!IsPostBack)
            {
                var obj = new UserRightImpl();

                var objAdmin = (AdminInfo)Session[Constant.SessionNameAccountAdmin];

                DataTable dt;
                if (objAdmin.Status == 2)
                {
                    dt = obj.GetFullParentMenu();
                }
                else
                {
                    dt = obj.GetParentMenuByAdminID(objAdmin.ID);
                }

                string sCurr = Request.Url.AbsoluteUri;

                int appID = 0;

                string linkCur = sCurr.Substring(sCurr.LastIndexOf("/") + 1);

                appID = UserRightImpl.GetParentID(linkCur);

                string sHtml     = string.Empty;
                bool   bSelected = false;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int    id      = Convert.ToInt32(dt.Rows[i]["ID"].ToString());
                    string caption = dt.Rows[i]["Name"].ToString();

                    string link = Utility.UrlRoot + Config.PathAdmin + dt.Rows[i]["Link"];

                    if (!bSelected & (id == appID))
                    {
                        sHtml += "<td style=\"width: 4px; height: 20px\" class=\"spacerTab\">&nbsp;</td>";
                        sHtml += "<td id='left" + i +
                                 "' style=\"width: 4px; height: 20px\" valign=\"top\" class=\"selTabLeft\">";
                        sHtml += "<img alt=\"\" style=\"border:0px\" src=\"" + UrlRoot +
                                 "css/selectedTab_leftCorner.gif\" width=\"4\" height=\"3\" alt=\"\" /></td>";
                        sHtml += "<td style=\"width:" + _itemW +
                                 "px; height: 20px;\" align=\"center\" nowrap valign=\"middle\" class=\"selTabCenter\" >" +
                                 caption + "</td>";
                        sHtml += "<td id='right" + i +
                                 "' style=\"width: 4px; height: 20px\" align=\"right\" valign=\"top\" class=\"selTabRight\">";
                        sHtml += "<img src=\"" + UrlRoot +
                                 "css/selectedTab_rightCorner.gif\" width=\"4\" height=\"3\" alt=\"\" style=\"border:0px\" /></td>";
                        bSelected = true;
                    }
                    else
                    {
                        sHtml += "<td style=\"width: 4px; height: 20px\" class=\"spacerTab\">&nbsp;</td>";
                        sHtml += "<td id='left" + i +
                                 "' style=\"width: 4px; height: 20px\" valign=\"top\" class=\"deSTabLeft\">";
                        sHtml += "<img src=\"" + UrlRoot +
                                 "css/unSelectedTab_leftCorner.gif\" width=\"4\" height=\"3\" alt=\"\" style=\"border:0px\" /></td>";
                        sHtml += "<td style=\"width:" + _itemW +
                                 "px; height: 20px;cursor:hand;cursor:pointer;\" align=\"center\" nowrap valign=\"middle\" class=\"deSTabCenter\" onclick='window.location = \"" +
                                 link + "\"' onmouseover=\"this.className='hoverTabCenter';document.getElementById('left" +
                                 i + "').className='hoverTabLeft';document.getElementById('right" + i +
                                 "').className='hoverTabRight';\" onmouseout=\"this.className='deSTabCenter';document.getElementById('left" +
                                 i + "').className='deSTabLeft';document.getElementById('right" + i +
                                 "').className='deSTabRight';\" onkeypress=\"__keyPress(event, '" + link + "');\">" +
                                 caption + "</td>";
                        sHtml += "<td id='right" + i +
                                 "' style=\"width: 4px; height: 20px\" align=\"right\" valign=\"top\" class=\"deSTabRight\">";
                        sHtml += "<img src=\"" + UrlRoot +
                                 "css/unSelectedTab_rightCorner.gif\" style=\"width: 4px; height: 3px; border: 0px\" alt=\"\" /></td>";
                    }
                }
                ltlMenu.Text = sHtml;
            }
        }
コード例 #21
0
ファイル: customer_add.aspx.cs プロジェクト: mvtcode/g9webs
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int userID = 0;

                var obj = new CustomerImpl();
                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    try
                    {
                        userID = int.Parse(Request.QueryString["ID"]);
                        CustomerInfo item = obj.GetInfo(userID);

                        if (item == null)
                        {
                            Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                            return;
                        }
                        var objAdmin = (AdminInfo)Session[Constant.SessionNameAccountAdmin];

                        //string imgName = IMGName();

                        item.s_CustomerName = txtName.Text;
                        item.s_Email        = txtEmail.Text;
                        item.s_Address      = txtAddress.Text;
                        item.s_Mobile       = txtMobile.Text;
                        item.s_Homepage     = txtHomepage.Text;
                        item.s_Logo         = UntilityFunction.StringForNull(HD_IMG.Value);

                        obj.Update(item);
                        //Delete cache
                        CacheController.GetListCus_Delete();
                    }
                    catch
                    {
                        Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                        return;
                    }
                }
                else
                {
                    var item = new CustomerInfo();
                    item.s_CustomerName = txtName.Text;
                    item.s_Email        = txtEmail.Text;
                    item.s_Address      = txtAddress.Text;
                    item.s_Mobile       = txtMobile.Text;
                    item.s_Homepage     = txtHomepage.Text;
                    item.s_Logo         = UntilityFunction.StringForNull(HD_IMG.Value);// IMGName();

                    obj.Insert(item);
                    //Delete cache
                    CacheController.GetListCus_Delete();
                }
                Response.Redirect("customer_manager.aspx", false);
            }
            catch
            {
                lblMsg.Text = "Tên khách hàng. Bạn chạy chọn một tên khác";
            }
        }
コード例 #22
0
        protected void btPhanQuyen_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }
            if (ddlUser.Text.Equals("0"))
            {
                lbMess.Text = "<p><font color='red'>Bạn phải chọn username phân quyền trước.</font></p>";
                return;
            }
            try
            {
                int           menuIndex = ddlMenu.SelectedIndex;
                int           i         = 0;
                UserRightImpl obj       = new UserRightImpl();
                foreach (GridViewRow row in grvView.Rows)
                {
                    var chkRead   = (CheckBox)row.FindControl("chkRead");
                    var chkEdit   = (CheckBox)row.FindControl("chkEdit");
                    var chkDelete = (CheckBox)row.FindControl("chkDelete");

                    UserRightInfo item = new UserRightInfo();

                    item.MenuID = int.Parse(grvView.DataKeys[row.RowIndex].Value.ToString());
                    if (_adminID == 0)
                    {
                        _adminID = int.Parse(ddlUser.Text.ToString());
                    }
                    item.AdminID = _adminID;

                    item.UserRead = chkRead.Checked;
                    if (menuIndex == 1)
                    {
                        item.UserEdit   = chkEdit.Checked;
                        item.UserDelete = chkDelete.Checked;
                    }
                    else
                    {
                        item.UserEdit   = true;
                        item.UserDelete = true;
                    }
                    UserRightInfo item2 = obj.GetRightByMenuAndAdmin(item.MenuID, item.AdminID);
                    if (item2 != null)
                    {
                        item.ID = item2.ID;
                        obj.Update(item);
                    }
                    else
                    {
                        obj.Insert(item);
                    }
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
        }
コード例 #23
0
ファイル: admin_add.aspx.cs プロジェクト: mvtcode/g9webs
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            string mk   = txtPass.Text;
            string reMk = txtRePass.Text;

            if (txtUsername.Text.Trim().Contains(" "))
            {
                lblMsg.Text    = "Tên đăng nhập không được chứa khoảng trống.";
                lblMsg.Visible = true;
                return;
            }
            if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
            {
                if (!mk.Equals(""))
                {
                    if (mk.Length < 6 || mk.Length > 20)
                    {
                        lblMsg.Text    = "Mật khẩu từ 6 đến 20 ký tự.";
                        lblMsg.Visible = true;
                        return;
                    }

                    if (!checkPassEqualSoVaChu(mk))
                    {
                        lblMsg.Text    = "Mật khẩu phải bao gồm cả số và chữ.";
                        lblMsg.Visible = true;
                        return;
                    }
                }
            }
            else
            {
                if (mk.Length < 6 || mk.Length > 20)
                {
                    lblMsg.Text    = "Mật khẩu từ 6 đến 20 ký tự.";
                    lblMsg.Visible = true;
                    return;
                }

                if (!checkPassEqualSoVaChu(mk))
                {
                    lblMsg.Text    = "Mật khẩu phải bao gồm cả số và chữ.";
                    lblMsg.Visible = true;
                    return;
                }
            }

            if (mk.StartsWith(" ") || mk.EndsWith(" "))
            {
                lblMsg.Text    = "Mật khẩu không được bao gồm khoảng trắng ở đầu và cuối.";
                lblMsg.Visible = true;
                return;
            }


            if (!mk.Equals(reMk))
            {
                lblMsg.Text    = "Nhập lại mật khẩu chưa đúng.";
                lblMsg.Visible = true;
                return;
            }



            string pattern      = @"([a-z|A-Z|\d]+)$";
            Regex  myRegex      = new Regex(pattern);
            Match  match        = myRegex.Match(mk);
            Match  mathUsername = myRegex.Match(txtUsername.Text.Trim());

            if (!mathUsername.Success)
            {
                lblMsg.Text    = "Tên đăng nhập không được chứa ký tự đặc biệt.";
                lblMsg.Visible = true;
                return;
            }

            try
            {
                AdminInfo item = new AdminInfo();

                item.Username = txtUsername.Text.Trim().ToLower();

                item.FullName = txtFullName.Text;
                item.Status   = 1;
                item.IsLogin  = Convert.ToInt16(chkLogin.Checked ? 1 : 0);
                AdminImpl obj = new AdminImpl();

                if (_isEdit)
                {
                    item.ID = _adminID;

                    if (!mk.Equals(""))
                    {
                        if (!match.Success)
                        {
                            lblMsg.Text    = "Mật khẩu chứa những ký tự không hợp lệ, xin kiểm tra lại.";
                            lblMsg.Visible = true;
                            return;
                        }

                        item.Password = txtPass.Text.Trim();//Sercurity.Encrypt.MD5Admin(txtPass.Text.Trim() + txtUsername.Text.ToLower().Trim());
                    }
                    else
                    {
                        DataTable dt = obj.SelectOne(_adminID);
                        if (dt == null || dt.Rows.Count == 0)
                        {
                            Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                            return;
                        }
                        else
                        {
                            AdminInfo item2 = obj.GetAdmin(dt)[0];

                            item.Password = item2.Password;
                        }
                    }

                    obj.Update(item);
                }
                else
                {
                    if (!match.Success)
                    {
                        lblMsg.Text    = "Mật khẩu chứa những ký tự không hợp lệ, xin kiểm tra lại.";
                        lblMsg.Visible = true;
                        return;
                    }

                    item.Password = txtPass.Text.Trim();

                    obj.Insert(item);
                }

                Response.Redirect("admin_manager.aspx", false);
            }
            catch (Exception ex)
            {
                lblMsg.Text = "Tên đăng nhập đã tồn tại. Bạn hãy chọn một tên đăng nhập khác";
            }
        }