Пример #1
0
        private void guna2GradientButton1_Click_1(object sender, EventArgs e)
        {
            string userName, pass, manv, role;

            if (tbMa.Text.StartsWith(" ") || tbPass.Text.StartsWith(" ") || tbTen.Text.StartsWith(" ") || tbRole.Text.StartsWith(" "))
            {
                MessageBox.Show("Bạn Chưa Điền đủ thông tin");
            }
            else
            {
                userName = tbTen.Text;
                pass     = tbPass.Text;
                manv     = tbMa.Text;
                role     = tbRole.Text;
                DTO.Account acc = new DTO.Account(userName, pass, role, manv);
                if (_accBll.AddUser(acc))
                {
                    MessageBox.Show("Thêm  Success");
                    LoadingAcc();
                }
                else
                {
                    MessageBox.Show("Thêm Fail!");
                }
            }
        }
Пример #2
0
        public ReturnJasonConstruct <DTO.Account> Get(string telNo)
        {
            DTO.Account ac = new DTO.Account();
            ReturnJasonConstruct <DTO.Account> obj = new ReturnJasonConstruct <DTO.Account>();

            switch (Services.Account.CanSendCheckCode(telNo))
            {
            case 0:
            {
                bool result;
                int  code = SMS.SendMessage(telNo, out result);
                if (result == false)
                {
                    obj.status      = (int)executeStatus.warning;
                    obj.information = "请勿频繁发送短信,请稍后再次尝试.";
                    return(obj);
                }
                Console.WriteLine("******Code is:" + code.ToString());
                if (!Services.Account.Exist(telNo))
                {
                    return(Services.Account.Create(telNo, code));
                }
                else
                {
                    return(Services.Account.Update(telNo, code));
                }
            }

            case 1:
            {
                //account exist cannot send check code,please change to another telephone number.
                obj.status      = (int)executeStatus.warning;
                obj.information = "账户已经存在,请确认手机号填写是否正确.";
                return(obj);
            }

            case 2:
            {
                obj.status      = (int)executeStatus.warning;
                obj.information = "验证码每一分钟只能发送一次,请稍后再试.";
                return(obj);
            }

            default:
            {
                obj.status      = (int)executeStatus.warning;
                obj.information = "获取验证码出现未知错误,请联系客服.";
                return(obj);
            }
            }
        }
Пример #3
0
        public ReturnJasonConstruct <DTO.Account> Put([FromBody] DTO.Account dto)
        {
            ReturnJasonConstruct <DTO.Account> obj = new ReturnJasonConstruct <DTO.Account>();

            if (!Services.Account.Exist(dto.customer.telNo))
            {
                obj.SetWarningInformation("新建用户失败.");
                return(obj);
            }
            else
            {
                return(Services.Account.Update(dto));
            }
        }
Пример #4
0
        public void FillAccount()
        {
            string userName, pass, manv, role;

            if (tbMaNV.Text.StartsWith(" ") || tbPassWord.Text.StartsWith(" ") || tbUsser.Text.StartsWith(" "))
            {
                MessageBox.Show("Bạn Chưa Điền đủ thông tin");
            }
            else
            {
                userName = tbUsser.Text;
                pass     = tbPassWord.Text;
                manv     = tbMaNV.Text;
                role     = "User";
                DTO.Account acc = new DTO.Account(userName, pass, role, manv);
                _accBll.AddUser(acc);
            }
        }
Пример #5
0
        public static ReturnJasonConstruct <DTO.Account> Update(DTO.Account account)
        {
            ReturnJasonConstruct <DTO.Account> obj = new ReturnJasonConstruct <DTO.Account>();

            try
            {
                Models.Account    acc = account.ToModel();
                MissFreshEntities db  = new MissFreshEntities();
                var model             = db.Accounts.SingleOrDefault(p => p.Customer.telNo == acc.Customer.telNo && p.Customer.password == null);
                if (model == null)
                {
                    obj.SetWarningInformation("用于已存在!请检查手机号输入是否正确.");
                    return(obj);
                }
                else
                {
                    if (model.code == acc.code)
                    {
                        model.code = SMS.GetRandomCode().ToString();
                        model.Customer.firstName = acc.Customer.firstName;
                        model.Customer.lastName  = acc.Customer.lastName;
                        model.Customer.email     = acc.Customer.email;
                        model.Customer.password  = acc.Customer.password;
                        db.SaveChanges();
                        obj.SetDTOObject(model.ToDTO());
                    }
                    else
                    {
                        obj.SetWarningInformation("验证码输入错误,请重新输入.");
                    }
                    return(obj);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
 public bool AddUser(DTO.Account acc)
 {
     return(AccountDAL.Instance.AddUser(acc));
 }