Beispiel #1
0
        //添加新用户、也就是注册
        public ActionResult InsertYongHu(B_AccountTable Account)
        {
            string str = "";

            try
            {
                int user = (from tbuser in myModels.B_AccountTable
                            where tbuser.User == Account.User
                            select tbuser).Count();
                if (user > 0)
                {
                    str = "Exist";
                }
                else
                {
                    string pw = AESEncryptHelper.AESEncrypt(Account.Password);
                    Account.Password = pw;
                    Account.Cancel   = false;
                    myModels.B_AccountTable.Add(Account);
                    myModels.SaveChanges();
                    str = "success";
                }
            }
            catch (Exception e)
            {
            }

            return(Json(str, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult insertUserPwP(B_AccountTable Account, B_UserTable User)
        {
            string strMed      = "fail";
            string password    = AESEncryptHelper.AESEncrypt(Account.Password);
            string Paypassword = AESEncryptHelper.AESEncrypt(User.PayPassword);
            int    intaccon    = (from tbaccounnt in myDYXTEntities.B_AccountTable
                                  where tbaccounnt.User == User.UserName
                                  select tbaccounnt).Count();

            if (intaccon == 0)
            {
                Account.User     = User.UserName;
                Account.Password = password;
                Account.Cancel   = false;
                myDYXTEntities.B_AccountTable.Add(Account);
                myDYXTEntities.SaveChanges();

                int varuser = (from tbUSer in myDYXTEntities.B_UserTable
                               where tbUSer.UserName == User.UserName
                               select tbUSer).Count();
                if (varuser == 0)
                {
                    var varaccon = (from tbaccounnt in myDYXTEntities.B_AccountTable
                                    where tbaccounnt.User == User.UserName
                                    select tbaccounnt).Single();

                    User.AccountID         = varaccon.AccountID;
                    User.PayPassword       = Paypassword;
                    User.UserTypeID        = 2;
                    User.Time              = DateTime.Now;
                    User.PropertyAmounts   = 0;
                    User.UsableMoney       = 0;
                    User.FreezeMoney       = 0;
                    User.WaitMoney         = 0;
                    User.CompensatoryMoney = 0;
                    myDYXTEntities.B_UserTable.Add(User);
                    myDYXTEntities.SaveChanges();
                    strMed = "success";
                }
                else
                {
                    strMed = "UserNamefail";//用户名已存在
                }
            }
            else
            {
                strMed = "AccountUserfail";//账号名已存在
            }

            return(Json(strMed, JsonRequestBehavior.AllowGet));
        }
        public ActionResult updataPasswords(string YPassword, string QPassword)
        {
            string strMsg = "fali";

            try
            {
                int yAccountID = Convert.ToInt32(Session["AccountID"]);
                int dbUser     = (from tbUser in myDYXTEntities.B_AccountTable
                                  where tbUser.AccountID == yAccountID
                                  select tbUser).Count();
                if (dbUser > 0)
                {
                    var varuser = (from tbUser in myDYXTEntities.B_AccountTable
                                   where tbUser.AccountID == yAccountID
                                   select new
                    {
                        tbUser.AccountID,
                        tbUser.User,
                        tbUser.Password
                    }).Single();
                    //将用户输入的密码进行AES265后与数据库中的密码对比
                    string password = AESEncryptHelper.AESEncrypt(YPassword);
                    if (varuser.Password.Trim().Equals(password))
                    {
                        var struser = (from tbUser in myDYXTEntities.B_AccountTable
                                       where tbUser.AccountID == yAccountID
                                       select tbUser).Single();
                        string qPassword = AESEncryptHelper.AESEncrypt(QPassword);
                        struser.Password = qPassword;
                        myDYXTEntities.Entry(struser).State = System.Data.Entity.EntityState.Modified;
                        myDYXTEntities.SaveChanges();
                        strMsg = "success";
                    }
                    else
                    {
                        strMsg = "strpassword";//密码错误
                    }
                }
                else
                {
                    strMsg = "nonexistent";
                }
            }
            catch (Exception e)
            {
            }
            return(Json(strMsg, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult UserLogin(B_AccountTable Account)
        {
            string str          = "";                   //
            string strUser      = Request["username"];  //用户名
            string strPassword  = Request["password"];  //密码
            string strvalidCode = Request["validCode"]; //验证码
            string strSession   = "";

            if (Session["vildeCode"] != null)
            {
                strSession = Session["vildeCode"].ToString();
                if (strSession.Equals(strvalidCode, StringComparison.CurrentCultureIgnoreCase))
                {
                    try
                    {
                        var list = (from tbUser in myModels.B_AccountTable
                                    where tbUser.User == strUser.Trim()
                                    select new
                        {
                            tbUser.User,
                            tbUser.Password,
                            tbUser.AccountID
                        }).Single();
                        string strpassword = AESEncryptHelper.AESEncrypt(strPassword);
                        if (strpassword == list.Password.Trim())
                        {
                            Session["AccountID"] = list.AccountID; // 传递 UserID
                            Session["Password"]  = list.Password;


                            var BLoginDetai = (from tblo in myModels.B_UserLoginDetailTable
                                               select new
                            {
                                tblo.AccountID,
                            }).ToList();
                            for (int i = 0; i < BLoginDetai.Count; i++)
                            {
                                if (BLoginDetai[i].AccountID == list.AccountID)
                                {
                                    B_UserLoginDetailTable BLoginss = (from tblogin in myModels.B_UserLoginDetailTable
                                                                       where tblogin.AccountID == list.AccountID
                                                                       select tblogin).Single();
                                    if (BLoginss.lastLoginTime == null || BLoginss.LoginFrequency == null)
                                    {
                                        BLoginss.RegisterTime          = DateTime.Now;
                                        BLoginss.lastLoginTime         = DateTime.Now;
                                        BLoginss.LoginFrequency        = 1;
                                        BLoginss.EndLoginTime          = DateTime.Now;
                                        myModels.Entry(BLoginss).State = System.Data.Entity.EntityState.Modified;
                                        myModels.SaveChanges();
                                    }
                                    else
                                    {
                                        BLoginss.lastLoginTime         = BLoginss.EndLoginTime;
                                        BLoginss.LoginFrequency        = BLoginss.LoginFrequency + 1;
                                        BLoginss.EndLoginTime          = DateTime.Now;
                                        myModels.Entry(BLoginss).State = System.Data.Entity.EntityState.Modified;
                                        myModels.SaveChanges();
                                    }
                                    break;
                                }
                            }

                            str = "success";
                        }
                        else
                        {
                            str = "fail";
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    str = "validCodeFail";
                }
            }
            else
            {
                str = "writevalidCode";
            }
            return(Json(str, JsonRequestBehavior.AllowGet));
        }
        public ActionResult UserLogin(B_AccountTable B_Account)
        {
            string strMed              = "fail";
            string struser             = Request["User"];;     //用户
            string strPassword         = Request["password"];
            string strvalidCode        = Request["validCode"]; //验证码
            string strSessionValidCode = "";                   //获取 session中的验证码

            try
            {
                strSessionValidCode = Session["ValidCode"].ToString();
            }
            catch (Exception)
            {
                return(Json("loginerror", JsonRequestBehavior.AllowGet));
            }
            //判断验证码
            if (strSessionValidCode.Equals(strvalidCode.Trim(), StringComparison.InvariantCultureIgnoreCase))
            {
                try
                {
                    //根据 UserNuber 查询用户
                    var dbUser = (from tbUser in myDYXTEntities.B_AccountTable
                                  where tbUser.User == struser.Trim()
                                  select new
                    {
                        tbUser.AccountID,
                        tbUser.User,
                        tbUser.Password
                    }).Single();
                    //将用户输入的密码进行AES265后与数据库中的密码对比
                    string password = AESEncryptHelper.AESEncrypt(strPassword);
                    if (dbUser.Password.Trim().Equals(password))
                    {
                        B_UserTable dbuser = (from tbuser in myDYXTEntities.B_UserTable
                                              where tbuser.AccountID == dbUser.AccountID
                                              select tbuser).Single();
                        if (dbuser.UserTypeID == 1 || dbuser.UserTypeID == 4 || dbuser.UserTypeID == 12)
                        {
                            Session["AccountID"] = dbUser.AccountID;

                            B_UserTable varFundCost = (from tbuser in myDYXTEntities.B_UserTable
                                                       where tbuser.AccountID == dbUser.AccountID
                                                       select tbuser).Single();
                            B_ManagerRecord ManagerRecord = new B_ManagerRecord();
                            ManagerRecord.UserID    = varFundCost.UserID;
                            ManagerRecord.BearFruit = "成功".Trim();
                            ManagerRecord.Content   = "用户" + varFundCost.UserName.Trim() + "在“" + DateTime.Now + "”登录后台";
                            ManagerRecord.LoginTime = DateTime.Now;
                            string IP = "";
                            try
                            {
                                string pHostName = Dns.GetHostName();//Dns类


                                IPHostEntry myAddress = Dns.GetHostEntry(pHostName);
                                //myAddress.Aliases
                                IPAddress[] myIPAddress = myAddress.AddressList;

                                foreach (IPAddress add in myIPAddress)
                                {
                                    if (add.AddressFamily == AddressFamily.InterNetwork)
                                    {
                                        IP = add.ToString();
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                            }
                            ManagerRecord.LoginIP = IP;
                            myDYXTEntities.B_ManagerRecord.Add(ManagerRecord);
                            myDYXTEntities.SaveChanges();

                            strMed = "strsuccess";//登录成功
                        }
                        else
                        {
                            strMed = "strfail";//登录成功
                        }
                    }
                    else
                    {
                        strMed = "strpassword";//密码错误
                    }
                }
                catch (Exception e)
                {
                    strMed = "usernoexsit";//没有此用户
                }
            }
            else
            {
                strMed = "ValidCodeErro";//验证码错误
            }
            return(Json(strMed, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 确定认购
        /// </summary>
        /// <param name="bInvest"></param>
        /// <param name="Loantitle"></param>
        /// <param name="fenshu"></param>
        /// <param name="LowestTenderMoney"></param>
        /// <param name="Rate"></param>
        /// <param name="PayPassword"></param>
        /// <returns></returns>
        public ActionResult InsertLoan(B_InvestTable bInvest, string Loantitle, int fenshu, string LowestTenderMoney, string Rate, string PayPassword)
        {
            string      str            = "";
            int         loanid         = Convert.ToInt32(bInvest.LoanID);
            B_LoanTable varB_LoanTable = (from tbtbB_Loan in myModels.B_LoanTable
                                          where tbtbB_Loan.LoanID == loanid
                                          select tbtbB_Loan).Single();
            int         userid  = Convert.ToInt32(varB_LoanTable.UserID);
            B_UserTable varuser = (from tbuser in myModels.B_UserTable
                                   where tbuser.UserID == userid
                                   select tbuser).Single();
            string password = AESEncryptHelper.AESEncrypt(PayPassword);

            if (varuser.PayPassword.Trim().Equals(password))
            {
                int accountID = Convert.ToInt32(Session["AccountID"].ToString());
                var list      = (from tbuser in myModels.B_UserTable
                                 where tbuser.AccountID == accountID
                                 select tbuser).Single();
                bInvest.LoanTreetop = Loantitle;
                decimal intLowestTenderMoney = Convert.ToDecimal(LowestTenderMoney);
                bInvest.InvestMoney = fenshu * intLowestTenderMoney;                            //份数*最低投标金额

                decimal rate = Convert.ToDecimal(Rate.ToString().Trim());                       //年利率
                bInvest.ReceivableInterest = (bInvest.InvestMoney * rate) / 100;                //应收利息

                bInvest.ReceivablePrincipal = bInvest.InvestMoney + bInvest.ReceivableInterest; //应收本息

                bInvest.CountermandPrincipal = Convert.ToDecimal(0.00);                         //已收本息
                bInvest.NotRetrievePrincipal = bInvest.ReceivablePrincipal;                     //未收本息
                if (list.PropertyAmounts > bInvest.InvestMoney)
                {
                    if (bInvest.LoanID != null)
                    {
                        bInvest.InvestTime    = DateTime.Now;
                        bInvest.UserID        = list.UserID;
                        bInvest.StatusID      = 16;
                        bInvest.WhetherAttorn = false;
                        myModels.B_InvestTable.Add(bInvest);
                        myModels.SaveChanges();

                        //修改借款标表
                        B_LoanTable B_Loan = (from tbloan in myModels.B_LoanTable
                                              where tbloan.LoanID == bInvest.LoanID
                                              select tbloan).Single();
                        //B_Loan.LoanMoney = B_Loan.LoanMoney - bInvest.InvestMoney;//借款金额

                        int investTime;
                        investTime        = Convert.ToInt32(B_Loan.InvestTime.ToString());//投资次数
                        investTime        = investTime + 1;
                        B_Loan.InvestTime = Convert.ToInt32(investTime).ToString();



                        int grossscore;
                        grossscore = Convert.ToInt32(B_Loan.Grossscore); //总份数;
                        double scheduleinvestment;                       //进度
                        scheduleinvestment        = Convert.ToDouble(B_Loan.Scheduleinvestment);
                        scheduleinvestment        = Convert.ToDouble(Convert.ToDouble(fenshu) / Convert.ToDouble(grossscore)) * 100;
                        B_Loan.Scheduleinvestment = Convert.ToDecimal(scheduleinvestment + Convert.ToDouble(B_Loan.Scheduleinvestment));

                        int surplusLoan;//剩余份数
                        surplusLoan        = Convert.ToInt32(B_Loan.SurplusLoan);
                        surplusLoan        = (surplusLoan - fenshu);
                        B_Loan.SurplusLoan = Convert.ToDecimal(surplusLoan);

                        int alreadyLoan;//已被购买份数
                        alreadyLoan        = Convert.ToInt32(B_Loan.AlreadyLoan);
                        B_Loan.AlreadyLoan = Convert.ToInt32(alreadyLoan + fenshu);

                        myModels.Entry(B_Loan).State = System.Data.Entity.EntityState.Modified;
                        myModels.SaveChanges();
                        if (B_Loan.SurplusLoan == 0)
                        {
                            B_LoanTable bloan = (from tbloa in myModels.B_LoanTable
                                                 where tbloa.LoanID == bInvest.LoanID
                                                 select tbloa).Single();
                            bloan.StatusID = 28;
                            myModels.Entry(bloan).State = System.Data.Entity.EntityState.Modified;
                            myModels.SaveChanges();
                        }

                        //修改用户表的金额
                        B_UserTable listS = (from tbuser in myModels.B_UserTable
                                             where tbuser.AccountID == accountID
                                             select tbuser).Single();
                        //listS.PropertyAmounts = listS.PropertyAmounts - bInvest.InvestMoney;
                        listS.UsableMoney           = listS.UsableMoney - bInvest.InvestMoney;
                        listS.FreezeMoney           = listS.FreezeMoney + bInvest.InvestMoney;
                        myModels.Entry(listS).State = System.Data.Entity.EntityState.Modified;
                        myModels.SaveChanges();


                        B_CapitalrecordTable Capitalrecord = new B_CapitalrecordTable();
                        Capitalrecord.UserID          = list.UserID;
                        Capitalrecord.OperateTypeID   = 4;
                        Capitalrecord.OpFare          = Convert.ToDecimal(bInvest.InvestMoney);
                        Capitalrecord.Income          = Convert.ToDecimal(0);
                        Capitalrecord.Expend          = Convert.ToDecimal(bInvest.InvestMoney);
                        Capitalrecord.PropertyAmounts = list.PropertyAmounts;
                        Capitalrecord.Remarks         = "用户" + "[" + list.UserName.Trim() + "]" + ",投资成功,可用余额减少" + bInvest.InvestMoney + "元";
                        Capitalrecord.operatetime     = DateTime.Now;
                        myModels.B_CapitalrecordTable.Add(Capitalrecord);
                        myModels.SaveChanges();
                        str = "success";
                    }
                    else
                    {
                        str = "fail";
                    }
                }
            }
            else
            {
                str = "failPayPassword";
            }

            return(Json(str, JsonRequestBehavior.AllowGet));
        }