protected void btn_Submit_Click(object sender, EventArgs e)
 {
     if (Request.Headers["Accept"] != "*/*")
     {
         string oldpwd = Library.StringLbl.EncryptMD5(this.txt_oldPassword.Text);
         int userid = logic.customer.userId;
         string sqlpwd = logic.customer.getById(userid).Password;
         if (oldpwd == sqlpwd)
         {
             CustomerEntity _cus = new CustomerEntity();
             _cus.CustomerId = userid;
             _cus.Password = Library.StringLbl.EncryptMD5(txt_password.Text);
             _cus.Oldpassword = oldpwd;
             _cus.IP = GetClientIP();
             logic.customer.updatePwd(_cus);
             Library.Script.ClientMsg("修改成功!");
         }
         else
         {
             //旧密码不正确
             Library.Script.ClientMsg("旧密码不正确!");
             return;
         }
     }
 }
Example #2
0
 public static CustomerEntity getById(int customerId)
 {
     DataRow dr = DbHelper.ExecuteDataRow("p_Customer_getById", customerId);
     CustomerEntity customer = new CustomerEntity();
     if (dr != null)
     {
         customer.CustomerId = customerId;
         customer.Username = dr["username"].ToString();
         customer.Email = dr["email"].ToString();
         customer.Password = dr["password"].ToString();
         customer.Realname = dr["realname"].ToString();
         customer.Phone = dr["phone"].ToString();
         customer.RegisterDt = Convert.ToDateTime(dr["registerDt"]);
         customer.CompanyId = Convert.ToInt32(dr["companyId"]);
         customer.Permissions = dr["permissions"].ToString();
         customer.IsAdmin = Convert.ToBoolean(dr["isAdmin"]);
         customer.IsRefuse = Convert.ToBoolean(dr["isRefuse"]);
         if (dr["lastLoginDate"] != DBNull.Value)
             customer.LastLoginDate = Convert.ToDateTime(dr["lastLoginDate"]);
         if (dr["currentLoginDate"] != DBNull.Value)
             customer.CurrentLoginDate = Convert.ToDateTime(dr["currentLoginDate"]);
         if (dr["expireDt"] != DBNull.Value)
             customer.expireDt = Convert.ToDateTime(dr["expireDt"]);
         customer.Position = dr["Position"].ToString();
     }
     return customer;
 }
Example #3
0
        public void AddCustomer(CustomerEntity entity)
        {
            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(entity);

            // Execute the insert operation.
            table.Execute(insertOperation);
        }
        protected void lbtn_Save_Click(object sender, EventArgs e)
        {
            if (customerId == 0)
            {
                if (logic.customer.isExistUser(txt_Username.Text))
                {
                    Library.Script.ClientMsg("此用户名已经存在,请重新输入!");
                    return;
                }
            }
            CustomerEntity cus = new CustomerEntity();

            cus.Username = txt_Username.Text;
            cus.Email = txt_Email.Text;
            cus.Phone = txt_Phone.Text;
            cus.Realname = txt_Realname.Text;
            cus.IsRefuse = chx_isRefuse.Checked;
            int companyId = 0;
            if (hid_complanyid.Value == "")
            {
                companyId = logic.customer.getById(logic.customer.userId).CompanyId;
            }
            else
            {
                companyId = Convert.ToInt32(hid_complanyid.Value);
            }

            if (logic.company.getById(companyId).buyerType == "2")
            {
                hid_expireDt.Value = DateTime.Now.AddDays(7).ToString();
            }
            else
            {
                hid_expireDt.Value = DateTime.Now.ToString();
            }
            cus.CompanyId = companyId;
            cus.expireDt = Convert.ToDateTime(hid_expireDt.Value);
            cus.IsAdmin = chx_isAdmin.Checked;
            cus.Position = txt_position.Text.Trim();
            if (customerId != 0)
            {
                cus.CustomerId = customerId;
                cus.Password = hid_Pwd.Value;
                //cus.IsAdmin = Convert.ToBoolean(hid_isAdmin.Value);
                logic.customer.update(cus);
            }
            else
            {
                //cus.IsAdmin = false;
                cus.Password = Library.StringLbl.EncryptMD5(txt_Pwd.Text);
                logic.customer.insert(cus);
            }
            Library.Script.ClientMsgUrl("保存成功!", "buyer_customerList.aspx");
        }
Example #5
0
 public static void insert(CustomerEntity customer)
 {
     DbHelper.ExecuteNonQuery("p_Customer_insert",
       customer.Username,
       customer.Email,
       customer.Password,
       customer.Realname,
       customer.Phone,
       customer.CompanyId,
       customer.IsAdmin,
       customer.IsRefuse,
       customer.expireDt,
       customer.Position
        );
 }
 protected void btn_Save_Click(object sender, EventArgs e)
 {
     if (Request.Headers["Accept"] != "*/*")
     {
         CustomerEntity _cus = new CustomerEntity();
         _cus.CustomerId = logic.customer.userId;
         _cus.Username = txt_username.Value.Trim();
         _cus.Password = hid_Pwd.Value.Trim();
         _cus.Email = txt_email.Value.Trim();
         _cus.Realname = txt_realname.Value.Trim();
         _cus.Phone = txt_phone.Value.Trim();
         _cus.CompanyId = Convert.ToInt32(hid_companyid.Value);
         _cus.IsAdmin = Convert.ToBoolean(hid_isAdmin.Value);
         _cus.IsRefuse = Convert.ToBoolean(hid_isRefuse.Value);
         _cus.expireDt = Convert.ToDateTime(hid_expireDt.Value);
         logic.customer.update(_cus);
         Library.Script.ClientMsg("修改成功!");
     }
 }
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            if (customerId==0)
            {
                if (logic.customer.isExistUser(txt_Username.Text.Trim()))
                {
                    Library.Script.ClientMsg("此用户名已存在,请重新输入!");
                    return;
                }
            }

            CustomerEntity cus = new CustomerEntity();

            cus.Username = txt_Username.Text;
            cus.Email = txt_Email.Text;
            cus.Phone = txt_Phone.Text;
            cus.Realname = txt_Realname.Text;
            cus.CompanyId = companyId;
            cus.IsRefuse = chx_isRefuse.Checked;
            cus.IsAdmin = chx_isAdmin.Checked;
            //cus.expireDt = Convert.ToDateTime(ext_expireDt.Value).AddHours(Convert.ToInt32(DateTime.Now.Hour));
            cus.expireDt = Convert.ToDateTime(ext_expireDt.Value).AddHours(Convert.ToInt32(DateTime.Now.Hour)).AddMinutes(Convert.ToInt32(DateTime.Now.Minute)).AddSeconds(Convert.ToInt32(DateTime.Now.Second));
            if (customerId != 0)
            {

                cus.CustomerId = customerId;
                cus.Password = hid_Pwd.Value;
                logic.customer.update(cus);

            }
            else
            {

                cus.Password = Library.StringLbl.EncryptMD5(hid_Pwd.Value);
                logic.customer.insert(cus);
            }
            Library.Script.ClientMsgUrl("保存成功!", "customerList.aspx?company=" + companyId);
        }
Example #8
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>StatusCode描述:8-用户名不存在;9-密码不正确;10-账号已过期;11-账号已禁用;12-验证通过</returns>
        public static CustomerEntity login(string username, string password)
        {
            CustomerEntity customer = new CustomerEntity();
            DataRow dr = DbHelper.ExecuteDataRow("[dbo].[p_Customer_login]", username, password);
            if (dr != null)
            {
                if(dr["customerId"]!=DBNull.Value)
                    customer.CustomerId = Convert.ToInt32(dr["customerId"]);
                if(dr["companyId"]!=DBNull.Value)
                    customer.CompanyId = Convert.ToInt32(dr["companyId"]);
                if (dr["companyType"] != DBNull.Value)
                    customer.CompanyType = dr["companyType"].ToString();
                if(dr["StatusCode"]!=DBNull.Value)
                    customer.StatusCode = Convert.ToInt32(dr["StatusCode"]);
            }

            return customer;
        }
Example #9
0
 public static void updatePwd(CustomerEntity cus)
 {
     DbHelper.ExecuteNonQuery("p_Customer_updatePwd", cus.CustomerId, cus.Password, cus.IP, cus.Oldpassword);
 }
 /// <summary>
 /// 修改随机生成的密码
 /// </summary>
 /// <param name="username"></param>
 /// <param name="ranpwd"></param>
 void updatePwd(string username, string ranpwd)
 {
     DataRow dr = logic.customer.getByUsername(username);
     if (dr != null)
     {
         int userid = Convert.ToInt32(dr["customerId"]);
         CustomerEntity _cus = new CustomerEntity();
         _cus.CustomerId = userid;
         _cus.Password = Library.StringLbl.EncryptMD5(ranpwd);
         logic.customer.updatePwd(_cus);
     }
 }
Example #11
0
 public static void updatePwd(CustomerEntity cus)
 {
     Customer.updatePwd(cus);
 }
Example #12
0
 public static void insert(CustomerEntity cus)
 {
     Customer.insert(cus);
 }