/// <summary>
 /// 创建一个会员
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个会员</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, DAL.Account entity)
 {
     try
     {
         AccountArg arg = new AccountArg();
         arg.Name        = entity.Name;
         arg.PhoneNumber = entity.PhoneNumber;
         string      err   = string.Empty;
         DAL.Account model = null;
         if (!IsExist(arg, ref err, ref model))
         {
             entity.State      = StateEnums.QY;
             entity.CreateTime = DateTime.Now;
             entity.UpdateTime = entity.CreateTime;
             repository.Create(entity);
             return(true);
         }
         else
         {
             validationErrors.Add(err);
             return(false);
         }
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
示例#2
0
        public override void Save()
        {
            if (!IsDataValidated())
            {
                return;
            }

            var db = new DAL.dbDataContext();

            DAL.Account account;

            if (cusVendor.ID == 0)
            {
                db.CustomersAndVendors.InsertOnSubmit(cusVendor);
                account = new DAL.Account();
                db.Accounts.InsertOnSubmit(account);
            }
            else
            {
                db.CustomersAndVendors.Attach(cusVendor);
                account = db.Accounts.Single(s => s.ID == cusVendor.AccountID);
            }

            SetData();
            account.Name = cusVendor.Name;
            db.SubmitChanges();
            cusVendor.AccountID = account.ID;
            db.SubmitChanges();

            base.Save();
        }
示例#3
0
        public override void Save()
        {
            if (txt_Name.Text.Trim() == String.Empty)
            {
                txt_Name.ErrorText = "برجاء ادخال اسم الخزنة";
                return;
            }

            var db = new DAL.dbDataContext();

            DAL.Account account;
            if (drawer.ID == 0)
            {
                account = new DAL.Account();
                db.Drawers.InsertOnSubmit(drawer);
                db.Accounts.InsertOnSubmit(account);
            }
            else
            {
                db.Drawers.Attach(drawer);
                account = db.Accounts.Single(s => s.ID == drawer.AccountID);
            }

            SetData();
            account.Name = drawer.Name;
            db.SubmitChanges();
            drawer.AccountID = account.ID;
            db.SubmitChanges();

            base.Save();
        }
        public Common.ClientResult.Result Logon([FromBody] Langben.App.Models.LogonModel logonModel)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();

            if (ModelState.IsValid)
            {
                DAL.Account model = m_BLL.ValidateUser(logonModel.PersonName, logonModel.Password);
                if (model != null)
                {//登录成功
                    IBLL.IResumeBLL rBll    = new ResumeBLL();
                    var             data    = rBll.GetByAccountID(model.Id).FirstOrDefault();
                    Common.Account  account = new Common.Account();
                    account.Name     = model.Name;
                    account.Id       = model.Id;
                    account.ResumeId = data.Id;
                    Utils.WriteCookie("account", account, 7);
                    result.Code = Common.ClientCode.Succeed;
                }
                else
                {
                    result.Code = Common.ClientCode.FindNull;
                }
            }
            else
            {
                result.Code = Common.ClientCode.Fail;
            }
            return(result);
        }
示例#5
0
        public Account CreateAccount(Account record)
        {
            var dbAccount = new DAL.Account
            {
                FirstName = record.FirstName,
                LastName  = record.LastName,
                Email     = record.Email,
                Phone     = record.Phone,
                Address   = record.Address,
                Country   = record.Country,
                State     = record.State,
                Amount    = record.Amount
            };
            var result = accountRepository.CreateAccount(dbAccount);

            if (result > 0)
            {
                record.Id = result;
                return(record);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
        public double takeMoney(int accountId, double amount)
        {
            DAL.Account givingMoney = db.Account.Find(accountId);
            if (amount > givingMoney.Balance)
            {
                return(0);
            }

            givingMoney.Balance -= amount;
            db.Account.Update(givingMoney);
            db.SaveChanges();
            return(amount);
        }
示例#7
0
        public override void Save()
        {
            if (textEdit1.Text.Trim() == string.Empty)
            {
                textEdit1.ErrorText = "برجاء ادخال اسم الفرع";
                return;
            }
            DAL.Account SalesAccount          = new DAL.Account();
            DAL.Account SalesReturnAccount    = new DAL.Account();
            DAL.Account InventoryAccount      = new DAL.Account();
            DAL.Account CostOfSoldGoodsAccont = new DAL.Account();

            var db = new DAL.dbDataContext();

            if (store.ID == 0)
            {
                db.Stores.InsertOnSubmit(store);

                db.Accounts.InsertOnSubmit(SalesAccount);
                db.Accounts.InsertOnSubmit(SalesReturnAccount);
                db.Accounts.InsertOnSubmit(InventoryAccount);
                db.Accounts.InsertOnSubmit(CostOfSoldGoodsAccont);

                store.DiscountAllowedAccountID = Session.Defaults.DiscountAllowedAccount;
                store.DiscountReveiedAccountID = Session.Defaults.DiscountReceivedAccount;
            }
            else
            {
                db.Stores.Attach(store);

                SalesAccount          = db.Accounts.Single(x => x.ID == store.SalesAccountID);
                SalesReturnAccount    = db.Accounts.Single(x => x.ID == store.SalesReturnAccountID);
                InventoryAccount      = db.Accounts.Single(x => x.ID == store.InventoryAccountID);
                CostOfSoldGoodsAccont = db.Accounts.Single(x => x.ID == store.CostOfSoldGoodsAccountID);
            }

            SetData();
            SalesAccount.Name          = store.Name + "- مبيعات";
            SalesReturnAccount.Name    = store.Name + "- مردود مبيعات";
            InventoryAccount.Name      = store.Name + "- المخزون";
            CostOfSoldGoodsAccont.Name = store.Name + "- تكلفه البضاعه المباعه";
            db.SubmitChanges();

            store.SalesAccountID           = SalesAccount.ID;
            store.SalesReturnAccountID     = SalesReturnAccount.ID;
            store.InventoryAccountID       = InventoryAccount.ID;
            store.CostOfSoldGoodsAccountID = CostOfSoldGoodsAccont.ID;

            db.SubmitChanges();
            base.Save();
        }
 /// <summary>
 /// 获取账户信息
 /// </summary>
 /// <param name="arg">查询条件</param>
 /// <returns></returns>
 public DAL.Account GetByParam(DAL.AccountArg arg)
 {
     DAL.Account result = new DAL.Account();
     if (arg != null)
     {
         StringBuilder sb = new StringBuilder();
         if (!string.IsNullOrEmpty(arg.Id) && arg.Id.Trim() != "")
         {
             sb.AppendFormat("Id{0}&{1}^", ArgEnums.DDL_String, arg.Id);
         }
         if (!string.IsNullOrEmpty(arg.Name) && arg.Name.Trim() != "")
         {
             sb.AppendFormat("Name{0}&{1}^", ArgEnums.DDL_String, arg.Name.ToLower());
         }
         if (!string.IsNullOrEmpty(arg.Email) && arg.Email.Trim() != "")
         {
             sb.AppendFormat("Email{0}&{1}^", ArgEnums.DDL_String, arg.Email.ToLower());
         }
         if (!string.IsNullOrEmpty(arg.MyName) && arg.MyName.Trim() != "")
         {
             sb.AppendFormat("MyName{0}&{1}^", ArgEnums.DDL_String, arg.MyName.ToLower());
         }
         if (!string.IsNullOrEmpty(arg.PhoneNumber) && arg.PhoneNumber.Trim() != "")
         {
             sb.AppendFormat("PhoneNumber{0}&{1}^", ArgEnums.DDL_String, arg.PhoneNumber.ToLower());
         }
         if (sb.ToString().Trim() != "")
         {
             sb = sb.Remove(sb.ToString().Length - 1, 1);
             List <DAL.Account> list = repository.GetData(db, "desc", "CreateTime", sb.ToString()).ToList();
             if (list == null || list.Count == 0)
             {
                 result = null;
             }
             else
             {
                 result = list[0];
             }
         }
         else
         {
             result = null;
         }
     }
     else
     {
         result = null;
     }
     return(result);
 }
 /// <summary>
 /// 编辑一个会员
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="entity">一个会员</param>
 /// <returns></returns>
 public bool Edit(ref ValidationErrors validationErrors, DAL.Account entity)
 {
     try
     {
         repository.Edit(db, entity);
         repository.Save(db);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
示例#10
0
 // Transaction api
 public void addMoney(int accountId, double amount)
 {
     Debug.WriteLine(accountId + " is account");
     Debug.WriteLine(amount + " is amount");
     try
     {
         DAL.Account receiveingMoney = db.Account.Find(accountId);
         receiveingMoney.Balance += amount;
         db.Account.Update(receiveingMoney);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
     }
 }
 /// <summary>
 /// 验证数据是否存在
 /// </summary>
 /// <param name="arg">查询条件</param>
 /// <param name="err">返回提示信息</param>
 /// <param name="result">存在返回对象</param>
 /// <returns></returns>
 public bool IsExist(DAL.AccountArg arg, ref string err, ref DAL.Account result)
 {
     //DAL.Account result = new DAL.Account();
     if (arg != null)
     {
         StringBuilder sb = new StringBuilder();
         if (!string.IsNullOrEmpty(arg.Id) && arg.Id.Trim() != "")
         {
             sb.AppendFormat("Id{0}&{1}^", ArgEnums.DDL_String, arg.Id);
         }
         if (!string.IsNullOrEmpty(arg.Name) && arg.Name.Trim() != "")
         {
             sb.AppendFormat("Name{0}&{1}^", ArgEnums.DDL_String, arg.Name.ToLower());
         }
         if (!string.IsNullOrEmpty(arg.Email) && arg.Email.Trim() != "")
         {
             sb.AppendFormat("Email{0}&{1}^", ArgEnums.DDL_String, arg.Email.ToLower());
         }
         if (!string.IsNullOrEmpty(arg.MyName) && arg.MyName.Trim() != "")
         {
             sb.AppendFormat("MyName{0}&{1}^", ArgEnums.DDL_String, arg.MyName.ToLower());
         }
         if (!string.IsNullOrEmpty(arg.PhoneNumber) && arg.PhoneNumber.Trim() != "")
         {
             sb.AppendFormat("PhoneNumber{0}&{1}^", ArgEnums.DDL_String, arg.PhoneNumber.ToLower());
         }
         if (sb.ToString().Trim() != "")
         {
             sb = sb.Remove(sb.ToString().Length - 1, 1);
             List <DAL.Account> list = repository.GetData(db, "desc", "CreateTime", sb.ToString(), "or").ToList();
             if (list == null || list.Count == 0)
             {
                 result = null;
             }
             else
             {
                 result = list[0];
             }
         }
         else
         {
             result = null;
         }
     }
     else
     {
         result = null;
     }
     if (result == null)
     {
         return(false);
     }
     else
     {
         if (result.Name == arg.Name)
         {
             err = "绰号已存在!";
         }
         else if (result.PhoneNumber == arg.PhoneNumber)
         {
             err = "手机已存在!";
         }
         return(true);
     }
 }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Common.ClientResult.Result Edit([FromBody] DAL.Account entity)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (entity != null)
            {
                if (string.IsNullOrWhiteSpace(entity.MyName))
                {
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "姓名不能为空";
                    return(result); //提示失败
                }
                if (string.IsNullOrWhiteSpace(entity.Sex))
                {
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "性别不能为空";
                    return(result); //提示失败
                }
                if (string.IsNullOrWhiteSpace(entity.AnmeldenCity))
                {
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "户口所在地不能为空";
                    return(result); //提示失败
                }
                if (string.IsNullOrWhiteSpace(entity.LiveCity))
                {
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "现在居住地不能为空";
                    return(result); //提示失败
                }

                if (string.IsNullOrWhiteSpace(entity.PersonalAssessment))
                {
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "个人评价不能为空";
                    return(result); //提示失败
                }
                if (string.IsNullOrWhiteSpace(entity.Email) || !Validator.IsEmail(entity.Email))
                {
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "电子邮箱不能为空或者格式不对";
                    return(result); //提示失败
                }
                if (CurrentPersonId != entity.Id)
                {
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "请登录";
                    return(result); //提示失败
                }
                DAL.Account model = m_BLL.GetById(CurrentPersonId);
                model.AnmeldenCity       = entity.AnmeldenCity;
                model.AnmeldenProvince   = entity.AnmeldenProvince;
                model.Email              = entity.Email;
                model.LiveCity           = entity.LiveCity;
                model.LiveProvince       = entity.LiveProvince;
                model.MyName             = entity.MyName;
                model.PersonalAssessment = entity.PersonalAssessment;
                model.Sex          = entity.Sex;
                model.UpdatePerson = CurrentPerson;
                model.UpdateTime   = DateTime.Now;
                string returnValue = string.Empty;
                if (m_BLL.Edit(ref validationErrors, model))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",会员的信息的Id为" + model.Id, "会员"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = "提交成功";

                    return(result); //提交成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",会员的信息," + returnValue, "会员"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.UpdateFail + returnValue;
                    return(result); //提示插入失败
                }
            }

            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.UpdateFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            return(result);
        }
 public ActionResult Index()
 {
     DAL.Account model = m_BLL.GetById(CurrentPersonId);
     return(View(model));
 }
示例#14
0
        /// <summary>
        /// 注册
        /// </summary>
        public Common.Account Register(string name, string phoneNumber, string password, string inviteCode, ref string message)
        {
            //获取用户信息,请确定web.config中的连接字符串正确
            using (SysEntities db = new SysEntities())
            {
                bool invites = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["InviteCodeEnabled"]);

                if (!invites)
                {
                    password = EncryptAndDecrypte.EncryptString(password);
                    var dataAccount = (from p in db.Account
                                       where p.PhoneNumber == phoneNumber ||
                                       p.Name == name
                                       select p).FirstOrDefault();
                    if (dataAccount == null)
                    {
                        Invite invite = new Invite()
                        {
                            Id    = Common.Result.GetNewId(),
                            Code  = GetByRndNum(5),
                            State = StateEnums.QY
                            ,
                            CreateTime   = DateTime.Now,
                            CreatePerson = name
                        };
                        db.Invite.Add(invite);
                        Invite invite2 = new Invite()
                        {
                            Id    = Common.Result.GetNewId(),
                            Code  = GetByRndNum(5),
                            State = StateEnums.QY
                            ,
                            CreateTime   = DateTime.Now,
                            CreatePerson = name
                        };
                        db.Invite.Add(invite2);
                        var account = new DAL.Account()
                        {
                            Id          = Common.Result.GetNewId(),
                            State       = StateEnums.QY,
                            PhoneNumber = phoneNumber,
                            Name        = name,
                            Password    = password

                            ,
                            CreateTime   = DateTime.Now,
                            CreatePerson = phoneNumber
                        };
                        db.Account.Add(account);
                        Resume resume = new Resume()
                        {
                            Id                   = Common.Result.GetNewId(),
                            AccountId            = account.Id,
                            CreateTime           = DateTime.Now,
                            CreatePerson         = name,
                            Name                 = "默认",
                            Remark               = "注册账号自动创建",
                            Sort                 = 0,
                            State                = StateEnums.QY,
                            CompletionPercentage = 0
                        };
                        db.Resume.Add(resume);

                        SysNotice notice = new SysNotice();
                        notice.Id           = Result.GetNewId();
                        notice.CreatePerson = name;
                        notice.CreateTime   = DateTime.Now;
                        notice.AccountId    = account.Id;
                        notice.Message      = "您的邀请码为:" + invite.Code + ",另一个为:" + invite2.Code;
                        db.SysNotice.Add(notice);

                        db.SaveChanges();

                        Common.Account accountCommon = new Common.Account();
                        accountCommon.ResumeId = resume.Id;
                        accountCommon.Name     = name;
                        accountCommon.Id       = account.Id;
                        return(accountCommon);
                    }
                    else
                    {
                        if (phoneNumber == dataAccount.PhoneNumber)
                        {
                            message = "手机号码已经存在";
                        }
                        else if (name == dataAccount.Name)
                        {
                            message = "绰号已经存在";
                        }
                    }
                }
                else
                {
                    var data = (from p in db.Invite
                                where p.Code == inviteCode &&
                                p.State == StateEnums.QY
                                select p).FirstOrDefault();
                    if (data != null)
                    {
                        password = EncryptAndDecrypte.EncryptString(password);
                        var dataAccount = (from p in db.Account
                                           where p.PhoneNumber == phoneNumber ||
                                           p.Name == name
                                           select p).FirstOrDefault();
                        if (dataAccount == null)
                        {
                            data.State        = StateEnums.JY;
                            data.UpdatePerson = name;
                            data.UpdateTime   = DateTime.Now;
                            Invite invite = new Invite()
                            {
                                Id    = Common.Result.GetNewId(),
                                Code  = GetByRndNum(5),
                                State = StateEnums.QY
                                ,
                                CreateTime   = DateTime.Now,
                                CreatePerson = name
                            };
                            db.Invite.Add(invite);
                            Invite invite2 = new Invite()
                            {
                                Id    = Common.Result.GetNewId(),
                                Code  = GetByRndNum(5),
                                State = StateEnums.QY
                                ,
                                CreateTime   = DateTime.Now,
                                CreatePerson = name
                            };
                            db.Invite.Add(invite2);
                            var account = new DAL.Account()
                            {
                                Id          = Common.Result.GetNewId(),
                                State       = StateEnums.QY,
                                PhoneNumber = phoneNumber,
                                Name        = name,
                                Password    = password

                                ,
                                CreateTime   = DateTime.Now,
                                CreatePerson = phoneNumber
                            };
                            db.Account.Add(account);
                            Resume resume = new Resume()
                            {
                                Id                   = Common.Result.GetNewId(),
                                AccountId            = account.Id,
                                CreateTime           = DateTime.Now,
                                CreatePerson         = name,
                                Name                 = "默认",
                                Remark               = "注册账号自动创建",
                                Sort                 = 0,
                                State                = StateEnums.QY,
                                CompletionPercentage = 0
                            };
                            db.Resume.Add(resume);

                            SysNotice notice = new SysNotice();
                            notice.Id           = Result.GetNewId();
                            notice.CreatePerson = name;
                            notice.CreateTime   = DateTime.Now;
                            notice.AccountId    = account.Id;
                            notice.Message      = "您的邀请码为:" + invite.Code + ",另一个为:" + invite2.Code;
                            db.SysNotice.Add(notice);

                            db.SaveChanges();

                            Common.Account accountCommon = new Common.Account();
                            accountCommon.ResumeId = resume.Id;
                            accountCommon.Name     = name;
                            accountCommon.Id       = account.Id;
                            return(accountCommon);
                        }
                        else
                        {
                            if (phoneNumber == dataAccount.PhoneNumber)
                            {
                                message = "手机号码已经存在";
                            }
                            else if (name == dataAccount.Name)
                            {
                                message = "绰号已经存在";
                            }
                        }
                    }
                    else
                    {
                        message = "邀请码不正确";
                    }
                }
            }
            return(null);
        }