コード例 #1
0
        private void FillData(AdminInfo entity)
        {
            entity.UserName     = txtUserName.Value;
            entity.Password     = EncryptString.MD5(txtPassword.Value);
            entity.PasswordText = txtPassword.Value;
            entity.Realname     = txtRealname.Value;
            entity.Mobile       = txtMobile.Value;
            entity.QQ           = txtQQ.Value;
            entity.Sex          = DataConvert.SafeInt(rblSex.SelectedValue);
            entity.LastLoginIP  = string.Empty;
            entity.State        = rblState.SelectedValue;
            if (entity.UserRole == UserRoleType.普通用户)
            {
                entity.PowerGroupID = DataConvert.SafeInt(hdnPowerGroup.Value);
            }

            if (Admin.Administrator)
            {
                entity.CorporationID = DataConvert.SafeInt(ddlCorporation.SelectedValue);
                entity.Corporation   = ddlCorporation.SelectedItem.Text;
            }
            else
            {
                entity.CorporationID = Admin.CorporationID;
                entity.Corporation   = Admin.Corporation;
            }
        }
コード例 #2
0
ファイル: login.aspx.cs プロジェクト: shaohaiou/comopp
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string userName = StrHelper.Trim(txtUserName.Value);
                string password = StrHelper.Trim(txtUserPwd.Value);

                ///用户名,密码,验证码不允许为空
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
                {
                    int id = Admins.Instance.ValiUser(userName, EncryptString.MD5(password));//验证用户

                    if (id > 0)
                    {
                        AdminInfo admin = Admins.Instance.GetAdmin(id);
                        if (admin.State == "1")
                        {
                            admin.LastLoginIP   = WebHelper.GetClientsIP();
                            admin.LastLoginTime = DateTime.Now;
                            admin.LoginTimes++;
                            Admins.Instance.UpdateAdmin(admin);
                            LoginRecordInfo lr = new LoginRecordInfo()
                            {
                                AdminID     = admin.ID,
                                LastLoginIP = admin.LastLoginIP,
                                LoginTime   = DateTime.Now,
                                UserName    = admin.UserName
                            };
                            Admins.Instance.AddLoginRecord(lr);
                            Session[GlobalKey.SESSION_ADMIN] = admin;
                            ManageCookies.CreateCookie(GlobalKey.SESSION_ADMIN, id.ToString(), true, DateTime.Today.AddDays(1), HXContext.Current.CookieDomain);
                            Response.Redirect("index.aspx");
                        }
                        else
                        {
                            lblMsg.Text = "用户状态异常,请联系管理员";
                        }
                    }
                    else
                    {
                        lblMsg.Text = "用户名或密码错误";
                    }
                    Session[GlobalKey.SESSION_ADMIN] = null;
                }
            }
        }
コード例 #3
0
ファイル: adminedit.aspx.cs プロジェクト: shaohaiou/comopp
 private void FillData(AdminInfo entity)
 {
     entity.UserName     = txtUserName.Value;
     entity.UserRole     = UserRoleType.系统管理员;
     entity.Password     = EncryptString.MD5(txtPassword.Value);
     entity.PasswordText = txtPassword.Value;
     entity.Realname     = txtRealname.Value;
     entity.Mobile       = txtMobile.Value;
     entity.QQ           = txtQQ.Value;
     entity.Sex          = DataConvert.SafeInt(rblSex.SelectedValue);
     entity.LastLoginIP  = string.Empty;
     if (!entity.Administrator)
     {
         entity.CorporationID = DataConvert.SafeInt(ddlCorp.SelectedValue);
         entity.Corporation   = ddlCorp.SelectedItem.Text;
     }
     entity.State = rblState.SelectedValue;
 }
コード例 #4
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         bool result = Admins.Instance.ChangePassword(HXContext.Current.AdminUserID, EncryptString.MD5(txtOldpassword.Value), EncryptString.MD5(txtPassword.Value));
         if (!result)
         {
             WriteMessage("/message.aspx", "系统提示", "原密码错误!", "", "/center/safe.aspx");
         }
         else
         {
             AdminInfo admin = Admins.Instance.GetAdmin(AdminID);
             admin.PasswordText = txtPassword.Value;
             Admins.Instance.UpdateAdmin(admin);
             WriteMessage("/message.aspx", "系统提示", "密码修改成功,请使用新密码登录!", "", "/logout.aspx");
         }
     }
 }
コード例 #5
0
        private void MoveData()
        {
            string method   = GetString("method");
            int    owneruid = GetInt("owneruid");
            string password = GetString("password");
            int    page     = GetInt("page");
            int    maxpage  = 0;

            if (owneruid == 0 || string.IsNullOrEmpty(password))
            {
                return;
            }
            if (Admin.Password != EncryptString.MD5(password))
            {
                Response.Write("success,error.pwd,");
                Response.End();
            }

            if (method == "ids")
            {
                int result = 0;
                try
                {
                    string[] ids = GetString("ids").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    maxpage = ids.Length;
                    AdminInfo    admin    = Admins.Instance.GetAdmin(owneruid);
                    CustomerInfo customer = Customers.Instance.GetCustomerByID(DataConvert.SafeInt(ids[page - 1]));
                    customer.OwnerID           = owneruid;
                    customer.Owner             = admin.Realname;
                    customer.OwnerPowerGroupID = admin.PowerGroupID;
                    customer.LastUpdateUserID  = AdminID;
                    customer.LastUpdateUser    = Admin.Realname;
                    customer.LastUpdateTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    result = Customers.Instance.Move(customer);
                }
                catch
                {
                    Response.Clear();
                    Response.Write("failed");
                    Response.End();
                }
                Response.Clear();
                if (result > 0)
                {
                    Response.Write("success,0," + maxpage + "," + page);
                }
                else
                {
                    Response.Write("failed");
                }
                Response.End();
            }
            else if (method == "member")
            {
                int result = 0;
                try
                {
                    int    source = GetInt("source");
                    string idsstr = Session["menbercustomerlistids"] as string;
                    if (string.IsNullOrEmpty(idsstr))
                    {
                        AdminInfo adminsource = Admins.Instance.GetAdmin(source);

                        List <CustomerInfo> list = Customers.Instance.GetCustomerListByCorporation(adminsource.CorporationID, true);
                        list   = list.FindAll(l => l.OwnerID == adminsource.ID);
                        idsstr = string.Join(",", list.Select(l => l.ID));
                        Session["menbercustomerlistids"] = idsstr;
                    }
                    string[] ids = idsstr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    maxpage = ids.Length;

                    AdminInfo    admin    = Admins.Instance.GetAdmin(owneruid);
                    CustomerInfo customer = Customers.Instance.GetCustomerByID(DataConvert.SafeInt(ids[page - 1]));
                    customer.OwnerID           = owneruid;
                    customer.Owner             = admin.Realname;
                    customer.OwnerPowerGroupID = admin.PowerGroupID;
                    customer.LastUpdateUserID  = AdminID;
                    customer.LastUpdateUser    = Admin.Realname;
                    customer.LastUpdateTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    result = Customers.Instance.Move(customer);
                    if (page == maxpage)
                    {
                        Session["menbercustomerlistids"] = null;
                    }
                }
                catch
                {
                    Session["menbercustomerlistids"] = null;
                    Response.Clear();
                    Response.Write("failed");
                    Response.End();
                }
                Response.Clear();
                if (result > 0)
                {
                    Response.Write("success,0," + maxpage + "," + page);
                }
                else
                {
                    Response.Write("failed");
                }
                Response.End();
            }
        }