示例#1
0
        public override SubmitResult RequestPasswordReset(ResetPasswordDTO dto)
        {
            if (SecurityUnit.UserRepository.EmailExists(dto.Email))
            {
                User u     = AuthUnit.AuthUserRepository.FindSingle(d => d.Email == dto.Email);
                var  mails = SecurityUnit.ServiceProvider.GetService <IAuthenticationMailService>();

                dto.NewPassword  = Utils.RandomAlphaNumeric(8, CharType.Small);
                dto.ServerUrl    = Shell.GetConfigAs <string>("ServerUrl", false);
                dto.LogonName    = u.LogonName;
                dto.UserFullName = u.Name;

                var res = mails.SendResetEmail(dto);
                if (res.IsSuccess)
                {
                    u.Password = dto.NewPassword.ToMD5();
                    AuthUnit.AuthUserRepository.Update(u);
                    var sRes = AuthUnit.SaveChanges();
                    sRes.Data["EmailRes"] = res;
                    return(sRes);
                }
                else
                {
                    var sRes = res.MapToResult <SubmitResult>();
                    sRes.Message = SecurityUnit.TranslateIfMobile("mail_sending_failed");
                    return(sRes);
                }
            }
            else
            {
                return(new SubmitResult(1, SecurityUnit.TranslateIfMobile("no_such_email")));
            }
        }
示例#2
0
 private void LoginBtn_Click(object sender, EventArgs e)
 {
     if (AdminName_TextBox.Text.Trim().Equals("") || AdminPwd_TextBox.Text.Trim().Equals(""))
     {
         MessageBox.Show("用户名密码均不为空!");
     }
     else
     {
         String name;
         String pwd_sha1;
         name     = AdminName_TextBox.Text.Trim();
         pwd_sha1 = SecurityUnit.EncryptToSHA1(AdminPwd_TextBox.Text.Trim());
         if (Object.Equals(pwd_sha1, Connector.Get_Pwd(name)))
         {
             MessageBox.Show("登陆成功");
             LoginInfo.LoginName = name;
             LoginInfo.Power     = Connector.GetPower(name);
             this.DialogResult   = DialogResult.OK;
             this.Dispose();
             this.Close();
         }
         else
         {
             MessageBox.Show("密码错误");
         }
     }
 }
 private void submit_button_Click(object sender, EventArgs e)
 {
     if (!CheckString.ChechPower(power_textBox.Text.Trim()))
     {
         MessageBox.Show("权限仅限 管理员/进货员/销售员", "权限输入错误");
     }
     else if (name_textBox.Text.Trim().Equals(""))
     {
         MessageBox.Show("用户名不能为空", "用户名输入错误");
     }
     else
     {
         Connector.AddNewSysUser(name_textBox.Text.Trim(), SecurityUnit.EncryptToSHA1(pwd_textBox.Text.Trim()), power_textBox.Text.Trim());
     }
 }
        private void submit_Click(object sender, EventArgs e)
        {
            String pwd_sha1 = SecurityUnit.EncryptToSHA1(pwd_textbox.Text.Trim());

            if (mode == 1)
            {
                Connector.AddNewVip(num_textbox.Text.Trim(), name_textbox.Text.Trim(), pwd_sha1, phone_textbox.Text.Trim(), mail_textbox.Text.Trim());
                num_textbox.Text = Connector.GetNewVipNum();
                this.dataGridView1.DataSource = Connector.SelectVipTTable().Tables[0].DefaultView;
                name_textbox.Text             = "";
                pwd_textbox.Text   = "";
                phone_textbox.Text = "";
                mail_textbox.Text  = "";
            }
            else if (mode == 2)
            {
                if (!CheckString.CheckUInt(num_textbox.Text.Trim()))
                {
                    MessageBox.Show("编号填写错误", "编号错误");
                }
                else
                {
                    Connector.UpgradeVipLevel(num_textbox.Text.Trim());
                    this.dataGridView1.DataSource = Connector.SelectVipTTable().Tables[0].DefaultView;
                    for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++)
                    {
                        if (dt.Rows[i].ItemArray[0].ToString().Equals(num_textbox.Text.Trim()))
                        {
                            name_textbox.Text  = dt.Rows[i].ItemArray[1].ToString();
                            pwd_textbox.Text   = dt.Rows[i].ItemArray[2].ToString();
                            phone_textbox.Text = dt.Rows[i].ItemArray[3].ToString();
                            mail_textbox.Text  = dt.Rows[i].ItemArray[4].ToString();
                            level_textbox.Text = dt.Rows[i].ItemArray[5].ToString();
                            break;
                        }
                    }
                    num_textbox.Enabled = false;
                }
            }
            else if (mode == 3)
            {
                Connector.ChangeVipInfo(num_textbox.Text.Trim(), name_textbox.Text.Trim(), pwd_sha1, phone_textbox.Text.Trim(), mail_textbox.Text.Trim());
                this.dataGridView1.DataSource = Connector.SelectVipTTable().Tables[0].DefaultView;
            }
        }
示例#5
0
 private void submit_btn_Click(object sender, EventArgs e)
 {
     if (!Object.Equals(newpwd_textbox.Text.Trim(), confimnewpwd_textbox.Text.Trim()))
     {
         MessageBox.Show("原密码与新密码不符", "修改密码失败");
     }
     else
     {
         MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
         DialogResult      dr         = MessageBox.Show("确定?", "确认", messButton);
         if (dr == DialogResult.OK)//如果点击“确定”按钮
         {
             String oldpwd_sha1 = SecurityUnit.EncryptToSHA1(oldpwd_textbox.Text.Trim());
             String newpwd_sha1 = SecurityUnit.EncryptToSHA1(newpwd_textbox.Text.Trim());
             Connector.ChangeAdminPwd(oldpwd_sha1, newpwd_sha1);
             this.Dispose();
             this.Close();
         }
         else//如果点击“取消”按钮
         {
             this.newpwd_textbox.Text = this.oldpwd_textbox.Text = this.confimnewpwd_textbox.Text = "";
         }
     }
 }
        private void SubmitSell(object sender, EventArgs e)
        {
            if (!CheckString.CheckISBN(isbn_textbox.Text.Trim()))
            {
                MessageBox.Show("请检查ISBN填写是否正确", "ISBN格式错误");
            }
            else if (!CheckString.CheckUInt(num_textbox.Text.Trim()) || int.Parse(num_textbox.Text.Trim()) == 0)
            {
                MessageBox.Show("请检查数量填写是否正确", "数量错误");
            }
            else
            {
                money_textbox.Text = (double.Parse(Connector.GetPrice(isbn_textbox.Text.Trim())) * int.Parse(num_textbox.Text.Trim())).ToString();

                String ISBN     = isbn_textbox.Text.Trim();
                int    num      = int.Parse(num_textbox.Text.Trim());
                String TranMode = mode_textbox.Text.Trim();
                String Remarks  = remarks_textbox.Text.Trim();



                Int64  VipNum;
                String time;
                double money = Double.Parse(money_textbox.Text.Trim());
                bool   flag  = true;

                if (Object.Equals(vipnum_textbox.Text.Trim(), ""))
                {
                    vipnum_textbox.Text = "0";
                    VipNum = 0;
                }
                else
                {
                    if (!CheckString.CheckUInt(vipnum_textbox.Text.Trim()))
                    {
                        MessageBox.Show("会员编号填写错误", "会员编号错误");
                        VipNum = 0;
                        flag   = false;
                    }
                    else
                    {
                        VipNum = Int64.Parse(vipnum_textbox.Text.Trim());
                    }
                }

                if (Object.Equals(time_textbox.Text.Trim(), ""))
                {
                    time_textbox.Text = string.Format("{0:G}", DateTime.Now);
                    time = string.Format("{0:G}", System.DateTime.Now);
                }
                else
                {
                    if (!CheckString.CheckDate(time_textbox.Text.Trim()))
                    {
                        MessageBox.Show("交易时间填写错误", "时间格式错误");
                        flag = false;
                        time = string.Format("{0:G}", System.DateTime.Now);
                    }
                    else
                    {
                        time = time_textbox.Text.Trim();
                    }
                }

                if (flag)
                {
                    trannum_textbox.Text = SecurityUnit.EncryptToMD5(VipNum + ISBN + time + TranMode);
                    String TranNum = trannum_textbox.Text.Trim();

                    MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                    DialogResult      dr         = MessageBox.Show("确定?", "确认订单", messButton);
                    if (dr == DialogResult.OK)//如果点击“确定”按钮
                    {
                        if (Connector.InquireBookNumbers(ISBN) >= num)
                        {
                            Connector.AddToSellList(VipNum, ISBN, time, num, money, TranMode, TranNum, Remarks);
                            Connector.Replenishment(2, ISBN, -1 * num);

                            money_textbox.Text   = "";
                            isbn_textbox.Text    = "";
                            num_textbox.Text     = "";
                            mode_textbox.Text    = "";
                            remarks_textbox.Text = "";
                            trannum_textbox.Text = "";
                            time_textbox.Text    = "";
                            vipnum_textbox.Text  = "";

                            if (money > 50 && VipNum == 0)
                            {
                                MessageBoxButtons messButton2 = MessageBoxButtons.OKCancel;
                                DialogResult      dr2         = MessageBox.Show("添加会员吗?", "添加会员", messButton2);
                                if (dr2 == DialogResult.OK)//如果点击“确定”按钮
                                {
                                    VipManage newpage = new VipManage();
                                    newpage.Show();
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("存货不足!");
                        }
                    }
                    else//如果点击“取消”按钮
                    {
                        vipnum_textbox.Text
                                        = isbn_textbox.Text
                                        = time_textbox.Text
                                        = num_textbox.Text
                                        = money_textbox.Text
                                        = mode_textbox.Text
                                        = remarks_textbox.Text
                                        = trannum_textbox.Text = "";
                    }
                }
            }
        }
 public SetIntersightSecurityUnit()
 {
     ApiInstance = new SecurityApi(Config);
     ModelObject = new SecurityUnit();
     MethodName  = "UpdateSecurityUnitWithHttpInfo";
 }