Esempio n. 1
0
        public BaseResultDto <string> ApplyBorrower(SystemBorrowerApply model)
        {
            BaseResultDto <string> result = new BaseResultDto <string>();

            try
            {
                if (helper.Add <SystemBorrowerApply>(model) > 0)
                {
                    result.ErrorMsg  = "成功";
                    result.ErrorCode = 1;
                    result.IsSeccess = true;
                }
                else
                {
                    result.ErrorMsg  = "失败";
                    result.ErrorCode = 0;
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg  = ex.Message;
                result.ErrorCode = -1;
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SystemBorrowerApply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SystemBorrowerApply(");
            strSql.Append("BorrowerID,BorrowerName,LoanAmount,BorrowerReason,CollateralDesc,BorrowerTime,BorrowerType");
            strSql.Append(") values (");
            strSql.Append("@BorrowerID,@BorrowerName,@LoanAmount,@BorrowerReason,@CollateralDesc,@BorrowerTime,@BorrowerType");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BorrowerID",     SqlDbType.Int,      4),
                new SqlParameter("@BorrowerName",   SqlDbType.VarChar, 50),
                new SqlParameter("@LoanAmount",     SqlDbType.Decimal,  9),
                new SqlParameter("@BorrowerReason", SqlDbType.VarChar, -1),
                new SqlParameter("@CollateralDesc", SqlDbType.VarChar, -1),
                new SqlParameter("@BorrowerTime",   SqlDbType.VarChar, 20),
                new SqlParameter("@BorrowerType",   SqlDbType.Int, 4)
            };

            parameters[0].Value = model.BorrowerID;
            parameters[1].Value = model.BorrowerName;
            parameters[2].Value = model.LoanAmount;
            parameters[3].Value = model.BorrowerReason;
            parameters[4].Value = model.CollateralDesc;
            parameters[5].Value = model.BorrowerTime;
            parameters[6].Value = model.BorrowerType; return(sqlhelper.ExecNon(strSql.ToString(), parameters));
        }
Esempio n. 3
0
        public bool Update(SystemBorrowerApply model, List <string> fileds, string sqlWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.AppendFormat("update {0} set ", model.GetType().Name);
            List <string>       filedsList   = new List <string>();
            List <SqlParameter> sqlParameter = new List <SqlParameter>();
            SqlParameter        Param        = new SqlParameter("@Id", SqlDbType.Int, 4);

            if (string.IsNullOrEmpty(sqlWhere))
            {
                Param.Value = model.Id;
                sqlParameter.Add(Param);
            }
            foreach (string filed in fileds)
            {
                filedsList.Add(string.Format("{0}=@{0}", filed));
                Param = new SqlParameter(string.Format("@{0}", filed), model.GetType().GetProperty(filed).GetValue(model, null));
                sqlParameter.Add(Param);
            }
            strSql.AppendFormat("{0}", string.Join(",", filedsList.ToArray()));
            if (string.IsNullOrEmpty(sqlWhere))
            {
                strSql.Append(" where Id=@Id ");
            }
            else
            {
                strSql.AppendFormat(" where 1=1 and {0} ", sqlWhere);
            }
            SqlParameter[] parameters = sqlParameter.ToArray();
            return(sqlhelper.ExecNon(strSql.ToString(), parameters) > 0 ? true : false);
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SystemBorrowerApply GetModel(string where)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, BorrowerID, BorrowerName, LoanAmount, BorrowerReason, CollateralDesc, BorrowerTime, BorrowerType  ");
            strSql.Append("  from SystemBorrowerApply ");
            strSql.Append(" where ");
            strSql.Append(where);


            var dt = sqlhelper.GetTable(strSql.ToString());
            SystemBorrowerApply model = null;

            if (dt.Rows.Count > 0)
            {
                model = Mapper.DynamicMap <IDataReader, List <SystemBorrowerApply> >(dt.CreateDataReader()).FirstOrDefault();
            }
            return(model);
        }
Esempio n. 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SystemBorrowerApply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SystemBorrowerApply set ");

            strSql.Append(" BorrowerID = @BorrowerID , ");
            strSql.Append(" BorrowerName = @BorrowerName , ");
            strSql.Append(" LoanAmount = @LoanAmount , ");
            strSql.Append(" BorrowerReason = @BorrowerReason , ");
            strSql.Append(" CollateralDesc = @CollateralDesc , ");
            strSql.Append(" BorrowerTime = @BorrowerTime , ");
            strSql.Append(" BorrowerType = @BorrowerType  ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",             SqlDbType.Int,      4),
                new SqlParameter("@BorrowerID",     SqlDbType.Int,      4),
                new SqlParameter("@BorrowerName",   SqlDbType.VarChar, 50),
                new SqlParameter("@LoanAmount",     SqlDbType.Decimal,  9),
                new SqlParameter("@BorrowerReason", SqlDbType.VarChar, -1),
                new SqlParameter("@CollateralDesc", SqlDbType.VarChar, -1),
                new SqlParameter("@BorrowerTime",   SqlDbType.VarChar, 20),
                new SqlParameter("@BorrowerType",   SqlDbType.Int, 4)
            };

            parameters[0].Value = model.Id;
            parameters[1].Value = model.BorrowerID;
            parameters[2].Value = model.BorrowerName;
            parameters[3].Value = model.LoanAmount;
            parameters[4].Value = model.BorrowerReason;
            parameters[5].Value = model.CollateralDesc;
            parameters[6].Value = model.BorrowerTime;
            parameters[7].Value = model.BorrowerType;
            return(sqlhelper.ExecNon(strSql.ToString(), parameters) > 0 ? true : false);
        }
Esempio n. 6
0
        public ActionResult ApplyBorrower(SystemBorrowerApply model)
        {
            JsonResult result = null;

            try
            {
                BaseResultDto <string> resultDto = new BaseResultDto <string>();
                if (model.LoanAmount > 0)
                {
                    SystemUsers currUser = Session["UserInfo"] as SystemUsers;
                    if (currUser != null)
                    {
                        model.BorrowerID   = currUser.ID;
                        model.BorrowerTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        model.BorrowerType = 1;
                        resultDto          = http.DoPostObject <BaseResultDto <string> >(ApplicationPropertys.WEBAPI_URL + "/ClaimsApplay/ApplyBorrower/", model);
                    }
                    else
                    {
                        resultDto.ErrorCode = -1;
                        resultDto.ErrorMsg  = "请重新登录,账户已过期";
                    }
                }
                else
                {
                    resultDto.ErrorCode = -1;
                    resultDto.ErrorMsg  = "申请金额不能小于零";
                }
                result = Json(new { status = resultDto.ErrorCode, message = resultDto.ErrorMsg }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                result = Json(new { status = -1, message = ex.Message }, JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
Esempio n. 7
0
        public ApplayClaimsDto GetApplayClaims(int ApplyId)
        {
            SystemBorrowerApply systemBorrowerApply = helper.GetModelById <SystemBorrowerApply>(ApplyId);
            //借款人账号和申请的债权 唯一对应一条债权
            string       sqlwhere     = string.Format(" BorrowerID={0} and ClaimsApplayID={1}", systemBorrowerApply.BorrowerID, systemBorrowerApply.Id);
            SystemClaims systemClaims = helper.GetList <SystemClaims>(sqlwhere).FirstOrDefault();

            if (systemClaims == null)
            {
                systemClaims = new SystemClaims();
                systemClaims.EarningsStartTime = System.DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd");
                systemClaims.InvestmentEndTime = System.DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd");
            }
            systemClaims.BorrowerID     = systemBorrowerApply.BorrowerID;
            systemClaims.ClaimsApplayID = systemBorrowerApply.Id;
            systemClaims.Borrower       = systemBorrowerApply.BorrowerName;
            systemClaims.LoanAmount     = systemBorrowerApply.LoanAmount;
            //从字典表获取所有设置的小图标
            sqlwhere = string.Format(" DicKey ='{0}' ", EnumDictionary.SmallIcon);
            List <SystemDictionary> dics              = helper.GetList <SystemDictionary>(sqlwhere);
            List <IconProperty>     ShowIcons         = new List <IconProperty>();
            List <IconProperty>     ShowIconsAttrCode = new List <IconProperty>();
            List <IconModel>        icoList           = new List <IconModel>();

            if (systemClaims.Icons != "")
            {
                icoList = systemClaims.Icons.ToModel <List <IconModel> >();
            }
            bool IsOpen = false;

            dics.ForEach(p =>
            {
                //类型^标题^弹出提示^背景样式字符串^日息
                string[] strArr = p.DicValue.Split('^');
                if (strArr.Length >= 4)
                {
                    string AtrrCode = strArr.Length >= 5 ? strArr[4] : "";
                    if (AtrrCode != "")
                    {
                        IsOpen = icoList.Exists(p1 => p1.IconType.Trim() == strArr[0].Trim() && p1.AtrrCode == AtrrCode);
                        ShowIconsAttrCode.Add(new IconProperty()
                        {
                            IsOpen          = IsOpen,
                            AddShow         = p.DicType, //显示
                            IconType        = strArr[0], //类型
                            Title           = strArr[1], //标题
                            TipMessage      = strArr[2], //弹出提示
                            BackgroundClass = strArr[3], //背景样式字符串
                            AtrrCode        = AtrrCode   //还款方式
                        });
                    }
                    else
                    {
                        IsOpen = icoList.Exists(p1 => p1.IconType.Trim() == strArr[0].Trim());
                        ShowIcons.Add(new IconProperty()
                        {
                            IsOpen          = IsOpen,
                            AddShow         = p.DicType, //显示
                            IconType        = strArr[0], //类型
                            Title           = strArr[1], //标题
                            TipMessage      = strArr[2], //弹出提示
                            BackgroundClass = strArr[3], //背景样式字符串
                            AtrrCode        = AtrrCode   //还款方式
                        });
                    }
                }
            });
            var model = new ApplayClaimsDto()
            {
                Applay       = systemBorrowerApply,
                Claims       = systemClaims,
                ShowIcons    = ShowIcons,
                ShowAttrCode = ShowIconsAttrCode
            };

            return(model);
        }