示例#1
0
        /// <summary>
        /// 投资合同
        /// </summary>
        /// <returns></returns>
        public ActionResult InvestmentContract(int targetId)
        {
            ContractLogic         _logic = new ContractLogic();
            M_Contract_management model  = _logic.GetContractListForApp(targetId).FirstOrDefault();

            StringBuilder sb = new StringBuilder(model.contract_money);

            sb = sb.Replace("#loan_number#", model.loan_number.ToString());
            //手机号*号处理
            if (!string.IsNullOrEmpty(model.borrower_username) && model.borrower_username.Length == 11)
            {
                model.borrower_username = model.borrower_username.Substring(0, 3) + "****" + model.borrower_username.Substring(7);
            }
            sb = sb.Replace("#borrower_username#", model.borrower_username);
            //姓名  名字*号处理
            if (!string.IsNullOrEmpty(model.borrower_name))
            {
                model.borrower_name = model.borrower_name.Substring(0, 1) + "**";
            }
            sb = sb.Replace("#borrower_name#", model.borrower_name);
            sb = sb.Replace("#borrower_id_card#", model.borrower_id_card);
            sb = sb.Replace("#lender_username#", model.lender_username);
            sb = sb.Replace("#lender_name#", model.lender_name);
            sb = sb.Replace("#lender_id_card#", model.lender_id_card);
            sb = sb.Replace("#surety_company_name#", model.surety_company_name);
            sb = sb.Replace("#guarantor_agent_usernqme#", model.guarantor_agent_usernqme);
            sb = sb.Replace("#contract_amount#", RMB.GetDecimal(model.contract_amount, 2, true).ToString());

            BorrowLogic  _borrowLogic = new BorrowLogic();
            BorrowEntity borrowEntity = _borrowLogic.SelectBorrowDetail(targetId);

            sb = sb.Replace("#annual_interest_rate#", decimal.Parse(borrowEntity.annual_interest_rate.ToString()).ToString("0.00"));
            DateTime date1 = DateTime.Parse(borrowEntity.release_date.ToString());
            DateTime date2 = DateTime.Parse(borrowEntity.repayment_date.ToString());

            sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd"));
            sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd"));
            sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString());
            model.contract_money = sb.ToString();

            //ViewBag.loan_number = model.loan_number;
            //ViewBag.borrower_username = model.borrower_username;
            //ViewBag.borrower_name = model.borrower_name;
            //ViewBag.guarantee_legal_representative = model.guarantee_legal_representative;
            //ViewBag.surety_company_name = model.surety_company_name;
            //ViewBag.StartTime = model.Start_Time;
            //ViewBag.EndTime = model.End_Time;
            //ViewBag.DurationDays = model.DurationTime;
            return(View(model));
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public M_Contract_management GetModel(int contract)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 contract,loan_number,targetid,lender_name,lender_username,lender_registerid,lender_id_card,lenders_account_name,lender_bank_account,lender_bank,lender_address,lenders_telephone,lenders_email,lendres_date_contract,borrower_registerid,borrower_name,borrower_username,borrower_id_card,borrower_account_name,borrower_bank_account,borrower_date_contract,borrower_bank,witness_name,witness_address,witness_telephone,witness_agent,witness_admid,witness_username,witness_id_card,witness_date_contract,surety_company_name,guarantee_business_icense,ensure_address,guarantee_legal_representative,guarantor_agent,guarantor_companyid,guarantor_agent_usernqme,guarantor_agent_id_card,guarantor_agent_idate_contract,contract_money,counselling_service,contract_amount,suretyship_contract,mode_payment,createtime from Contract_management ");
            strSql.Append(" where contract=@contract");
            SqlParameter[] parameters =
            {
                new SqlParameter("@contract", SqlDbType.Int, 4)
            };
            parameters[0].Value = contract;

            M_Contract_management model = new M_Contract_management();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(M_Contract_management model)
 {
     return(dal.Update(model));
 }
示例#4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(M_Contract_management model)
 {
     return(dal.Add(model));
 }
示例#5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(M_Contract_management model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Contract_management(");
            strSql.Append("loan_number,targetid,lender_name,lender_username,lender_registerid,lender_id_card,lenders_account_name,lender_bank_account,lender_bank,lender_address,lenders_telephone,lenders_email,lendres_date_contract,borrower_registerid,borrower_name,borrower_username,borrower_id_card,borrower_account_name,borrower_bank_account,borrower_date_contract,borrower_bank,witness_name,witness_address,witness_telephone,witness_agent,witness_admid,witness_username,witness_id_card,witness_date_contract,surety_company_name,guarantee_business_icense,ensure_address,guarantee_legal_representative,guarantor_agent,guarantor_companyid,guarantor_agent_usernqme,guarantor_agent_id_card,guarantor_agent_idate_contract,contract_money,counselling_service,contract_amount,suretyship_contract,mode_payment,createtime,contract_type,contractpath,bid_records_id)");
            strSql.Append(" values (");
            strSql.Append("@loan_number,@targetid,@lender_name,@lender_username,@lender_registerid,@lender_id_card,@lenders_account_name,@lender_bank_account,@lender_bank,@lender_address,@lenders_telephone,@lenders_email,@lendres_date_contract,@borrower_registerid,@borrower_name,@borrower_username,@borrower_id_card,@borrower_account_name,@borrower_bank_account,@borrower_date_contract,@borrower_bank,@witness_name,@witness_address,@witness_telephone,@witness_agent,@witness_admid,@witness_username,@witness_id_card,@witness_date_contract,@surety_company_name,@guarantee_business_icense,@ensure_address,@guarantee_legal_representative,@guarantor_agent,@guarantor_companyid,@guarantor_agent_usernqme,@guarantor_agent_id_card,@guarantor_agent_idate_contract,@contract_money,@counselling_service,@contract_amount,@suretyship_contract,@mode_payment,@createtime,@contract_type,@contractpath,@bid_records_id)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@loan_number",                    SqlDbType.Decimal,    18),
                new SqlParameter("@targetid",                       SqlDbType.Int,         4),
                new SqlParameter("@lender_name",                    SqlDbType.VarChar,    50),
                new SqlParameter("@lender_username",                SqlDbType.VarChar,    50),
                new SqlParameter("@lender_registerid",              SqlDbType.Int,         4),
                new SqlParameter("@lender_id_card",                 SqlDbType.VarChar,    50),
                new SqlParameter("@lenders_account_name",           SqlDbType.VarChar,    50),
                new SqlParameter("@lender_bank_account",            SqlDbType.VarChar,    50),
                new SqlParameter("@lender_bank",                    SqlDbType.VarChar,    50),
                new SqlParameter("@lender_address",                 SqlDbType.VarChar,   100),
                new SqlParameter("@lenders_telephone",              SqlDbType.VarChar,    50),
                new SqlParameter("@lenders_email",                  SqlDbType.VarChar,    50),
                new SqlParameter("@lendres_date_contract",          SqlDbType.DateTime),
                new SqlParameter("@borrower_registerid",            SqlDbType.Int,         4),
                new SqlParameter("@borrower_name",                  SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_username",              SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_id_card",               SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_account_name",          SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_bank_account",          SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_date_contract",         SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_bank",                  SqlDbType.VarChar,    50),
                new SqlParameter("@witness_name",                   SqlDbType.VarChar,    50),
                new SqlParameter("@witness_address",                SqlDbType.VarChar,    50),
                new SqlParameter("@witness_telephone",              SqlDbType.VarChar,    50),
                new SqlParameter("@witness_agent",                  SqlDbType.VarChar,    50),
                new SqlParameter("@witness_admid",                  SqlDbType.Int,         4),
                new SqlParameter("@witness_username",               SqlDbType.VarChar,    50),
                new SqlParameter("@witness_id_card",                SqlDbType.VarChar,    50),
                new SqlParameter("@witness_date_contract",          SqlDbType.DateTime),
                new SqlParameter("@surety_company_name",            SqlDbType.VarChar,   100),
                new SqlParameter("@guarantee_business_icense",      SqlDbType.VarChar,    50),
                new SqlParameter("@ensure_address",                 SqlDbType.VarChar,    50),
                new SqlParameter("@guarantee_legal_representative", SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_agent",                SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_companyid",            SqlDbType.Int,         4),
                new SqlParameter("@guarantor_agent_usernqme",       SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_agent_id_card",        SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_agent_idate_contract", SqlDbType.DateTime),
                new SqlParameter("@contract_money",                 SqlDbType.VarChar,    -1),
                new SqlParameter("@counselling_service",            SqlDbType.VarChar,    -1),
                new SqlParameter("@contract_amount",                SqlDbType.Decimal,    17),
                new SqlParameter("@suretyship_contract",            SqlDbType.VarChar,    -1),
                new SqlParameter("@mode_payment",                   SqlDbType.VarChar,   255),
                new SqlParameter("@createtime",                     SqlDbType.DateTime),
                new SqlParameter("@contract_type",                  SqlDbType.Int,         4),
                new SqlParameter("@contractpath",                   SqlDbType.VarChar,   255),
                new SqlParameter("@bid_records_id",                 SqlDbType.Int, 4)
            };



            parameters[0].Value  = model.loan_number;
            parameters[1].Value  = model.targetid;
            parameters[2].Value  = model.lender_name;
            parameters[3].Value  = model.lender_username;
            parameters[4].Value  = model.lender_registerid;
            parameters[5].Value  = model.lender_id_card;
            parameters[6].Value  = model.lenders_account_name;
            parameters[7].Value  = model.lender_bank_account;
            parameters[8].Value  = model.lender_bank;
            parameters[9].Value  = model.lender_address;
            parameters[10].Value = model.lenders_telephone;
            parameters[11].Value = model.lenders_email;
            parameters[12].Value = model.lendres_date_contract;
            parameters[13].Value = model.borrower_registerid;
            parameters[14].Value = model.borrower_name;
            parameters[15].Value = model.borrower_username;
            parameters[16].Value = model.borrower_id_card;
            parameters[17].Value = model.borrower_account_name;
            parameters[18].Value = model.borrower_bank_account;
            parameters[19].Value = model.borrower_date_contract;
            parameters[20].Value = model.borrower_bank;
            parameters[21].Value = model.witness_name;
            parameters[22].Value = model.witness_address;
            parameters[23].Value = model.witness_telephone;
            parameters[24].Value = model.witness_agent;
            parameters[25].Value = model.witness_admid;
            parameters[26].Value = model.witness_username;
            parameters[27].Value = model.witness_id_card;
            parameters[28].Value = model.witness_date_contract;
            parameters[29].Value = model.surety_company_name;
            parameters[30].Value = model.guarantee_business_icense;
            parameters[31].Value = model.ensure_address;
            parameters[32].Value = model.guarantee_legal_representative;
            parameters[33].Value = model.guarantor_agent;
            parameters[34].Value = model.guarantor_companyid;
            parameters[35].Value = model.guarantor_agent_usernqme;
            parameters[36].Value = model.guarantor_agent_id_card;
            parameters[37].Value = model.guarantor_agent_idate_contract;
            parameters[38].Value = model.contract_money;
            parameters[39].Value = model.counselling_service;
            parameters[40].Value = model.contract_amount;
            parameters[41].Value = model.suretyship_contract;
            parameters[42].Value = model.mode_payment;
            parameters[43].Value = model.createtime;
            parameters[44].Value = model.contract_type;
            parameters[45].Value = model.contractpath;
            parameters[46].Value = model.bid_records_id;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public M_Contract_management DataRowToModel(DataRow row)
        {
            M_Contract_management model = new M_Contract_management();

            if (row != null)
            {
                if (row["contract"] != null && row["contract"].ToString() != "")
                {
                    model.contract = int.Parse(row["contract"].ToString());
                }
                if (row["loan_number"] != null && row["loan_number"].ToString() != "")
                {
                    model.loan_number = decimal.Parse(row["loan_number"].ToString());
                }
                if (row["targetid"] != null && row["targetid"].ToString() != "")
                {
                    model.targetid = int.Parse(row["targetid"].ToString());
                }
                if (row["lender_name"] != null)
                {
                    model.lender_name = row["lender_name"].ToString();
                }
                if (row["lender_username"] != null)
                {
                    model.lender_username = row["lender_username"].ToString();
                }
                if (row["lender_registerid"] != null && row["lender_registerid"].ToString() != "")
                {
                    model.lender_registerid = int.Parse(row["lender_registerid"].ToString());
                }
                if (row["lender_id_card"] != null)
                {
                    model.lender_id_card = row["lender_id_card"].ToString();
                }
                if (row["lenders_account_name"] != null)
                {
                    model.lenders_account_name = row["lenders_account_name"].ToString();
                }
                if (row["lender_bank_account"] != null)
                {
                    model.lender_bank_account = row["lender_bank_account"].ToString();
                }
                if (row["lender_bank"] != null)
                {
                    model.lender_bank = row["lender_bank"].ToString();
                }
                if (row["lender_address"] != null)
                {
                    model.lender_address = row["lender_address"].ToString();
                }
                if (row["lenders_telephone"] != null)
                {
                    model.lenders_telephone = row["lenders_telephone"].ToString();
                }
                if (row["lenders_email"] != null)
                {
                    model.lenders_email = row["lenders_email"].ToString();
                }
                if (row["lendres_date_contract"] != null && row["lendres_date_contract"].ToString() != "")
                {
                    model.lendres_date_contract = DateTime.Parse(row["lendres_date_contract"].ToString());
                }
                if (row["borrower_registerid"] != null && row["borrower_registerid"].ToString() != "")
                {
                    model.borrower_registerid = int.Parse(row["borrower_registerid"].ToString());
                }
                if (row["borrower_name"] != null)
                {
                    model.borrower_name = row["borrower_name"].ToString();
                }
                if (row["borrower_username"] != null)
                {
                    model.borrower_username = row["borrower_username"].ToString();
                }
                if (row["borrower_id_card"] != null)
                {
                    model.borrower_id_card = row["borrower_id_card"].ToString();
                }
                if (row["borrower_account_name"] != null)
                {
                    model.borrower_account_name = row["borrower_account_name"].ToString();
                }
                if (row["borrower_bank_account"] != null)
                {
                    model.borrower_bank_account = row["borrower_bank_account"].ToString();
                }
                if (row["borrower_date_contract"] != null)
                {
                    model.borrower_date_contract = row["borrower_date_contract"].ToString();
                }
                if (row["borrower_bank"] != null)
                {
                    model.borrower_bank = row["borrower_bank"].ToString();
                }
                if (row["witness_name"] != null)
                {
                    model.witness_name = row["witness_name"].ToString();
                }
                if (row["witness_address"] != null)
                {
                    model.witness_address = row["witness_address"].ToString();
                }
                if (row["witness_telephone"] != null)
                {
                    model.witness_telephone = row["witness_telephone"].ToString();
                }
                if (row["witness_agent"] != null)
                {
                    model.witness_agent = row["witness_agent"].ToString();
                }
                if (row["witness_admid"] != null && row["witness_admid"].ToString() != "")
                {
                    model.witness_admid = int.Parse(row["witness_admid"].ToString());
                }
                if (row["witness_username"] != null)
                {
                    model.witness_username = row["witness_username"].ToString();
                }
                if (row["witness_id_card"] != null)
                {
                    model.witness_id_card = row["witness_id_card"].ToString();
                }
                if (row["witness_date_contract"] != null && row["witness_date_contract"].ToString() != "")
                {
                    model.witness_date_contract = DateTime.Parse(row["witness_date_contract"].ToString());
                }
                if (row["surety_company_name"] != null)
                {
                    model.surety_company_name = row["surety_company_name"].ToString();
                }
                if (row["guarantee_business_icense"] != null)
                {
                    model.guarantee_business_icense = row["guarantee_business_icense"].ToString();
                }
                if (row["ensure_address"] != null)
                {
                    model.ensure_address = row["ensure_address"].ToString();
                }
                if (row["guarantee_legal_representative"] != null)
                {
                    model.guarantee_legal_representative = row["guarantee_legal_representative"].ToString();
                }
                if (row["guarantor_agent"] != null)
                {
                    model.guarantor_agent = row["guarantor_agent"].ToString();
                }
                if (row["guarantor_companyid"] != null && row["guarantor_companyid"].ToString() != "")
                {
                    model.guarantor_companyid = int.Parse(row["guarantor_companyid"].ToString());
                }
                if (row["guarantor_agent_usernqme"] != null)
                {
                    model.guarantor_agent_usernqme = row["guarantor_agent_usernqme"].ToString();
                }
                if (row["guarantor_agent_id_card"] != null)
                {
                    model.guarantor_agent_id_card = row["guarantor_agent_id_card"].ToString();
                }
                if (row["guarantor_agent_idate_contract"] != null && row["guarantor_agent_idate_contract"].ToString() != "")
                {
                    model.guarantor_agent_idate_contract = DateTime.Parse(row["guarantor_agent_idate_contract"].ToString());
                }
                if (row["contract_money"] != null)
                {
                    model.contract_money = row["contract_money"].ToString();
                }
                if (row["counselling_service"] != null)
                {
                    model.counselling_service = row["counselling_service"].ToString();
                }
                if (row["contract_amount"] != null && row["contract_amount"].ToString() != "")
                {
                    model.contract_amount = decimal.Parse(row["contract_amount"].ToString());
                }
                if (row["suretyship_contract"] != null)
                {
                    model.suretyship_contract = row["suretyship_contract"].ToString();
                }
                if (row["mode_payment"] != null)
                {
                    model.mode_payment = row["mode_payment"].ToString();
                }
                if (row["createtime"] != null && row["createtime"].ToString() != "")
                {
                    model.createtime = DateTime.Parse(row["createtime"].ToString());
                }
            }
            return(model);
        }
示例#7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(M_Contract_management model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Contract_management set ");
            strSql.Append("loan_number=@loan_number,");
            strSql.Append("targetid=@targetid,");
            strSql.Append("lender_name=@lender_name,");
            strSql.Append("lender_username=@lender_username,");
            strSql.Append("lender_registerid=@lender_registerid,");
            strSql.Append("lender_id_card=@lender_id_card,");
            strSql.Append("lenders_account_name=@lenders_account_name,");
            strSql.Append("lender_bank_account=@lender_bank_account,");
            strSql.Append("lender_bank=@lender_bank,");
            strSql.Append("lender_address=@lender_address,");
            strSql.Append("lenders_telephone=@lenders_telephone,");
            strSql.Append("lenders_email=@lenders_email,");
            strSql.Append("lendres_date_contract=@lendres_date_contract,");
            strSql.Append("borrower_registerid=@borrower_registerid,");
            strSql.Append("borrower_name=@borrower_name,");
            strSql.Append("borrower_username=@borrower_username,");
            strSql.Append("borrower_id_card=@borrower_id_card,");
            strSql.Append("borrower_account_name=@borrower_account_name,");
            strSql.Append("borrower_bank_account=@borrower_bank_account,");
            strSql.Append("borrower_date_contract=@borrower_date_contract,");
            strSql.Append("borrower_bank=@borrower_bank,");
            strSql.Append("witness_name=@witness_name,");
            strSql.Append("witness_address=@witness_address,");
            strSql.Append("witness_telephone=@witness_telephone,");
            strSql.Append("witness_agent=@witness_agent,");
            strSql.Append("witness_admid=@witness_admid,");
            strSql.Append("witness_username=@witness_username,");
            strSql.Append("witness_id_card=@witness_id_card,");
            strSql.Append("witness_date_contract=@witness_date_contract,");
            strSql.Append("surety_company_name=@surety_company_name,");
            strSql.Append("guarantee_business_icense=@guarantee_business_icense,");
            strSql.Append("ensure_address=@ensure_address,");
            strSql.Append("guarantee_legal_representative=@guarantee_legal_representative,");
            strSql.Append("guarantor_agent=@guarantor_agent,");
            strSql.Append("guarantor_companyid=@guarantor_companyid,");
            strSql.Append("guarantor_agent_usernqme=@guarantor_agent_usernqme,");
            strSql.Append("guarantor_agent_id_card=@guarantor_agent_id_card,");
            strSql.Append("guarantor_agent_idate_contract=@guarantor_agent_idate_contract,");
            strSql.Append("contract_money=@contract_money,");
            strSql.Append("counselling_service=@counselling_service,");
            strSql.Append("contract_amount=@contract_amount,");
            strSql.Append("suretyship_contract=@suretyship_contract,");
            strSql.Append("mode_payment=@mode_payment,");
            strSql.Append("createtime=@createtime");
            strSql.Append(" where contract=@contract");
            SqlParameter[] parameters =
            {
                new SqlParameter("@loan_number",                    SqlDbType.Decimal,    18),
                new SqlParameter("@targetid",                       SqlDbType.Int,         4),
                new SqlParameter("@lender_name",                    SqlDbType.VarChar,    50),
                new SqlParameter("@lender_username",                SqlDbType.VarChar,    50),
                new SqlParameter("@lender_registerid",              SqlDbType.Int,         4),
                new SqlParameter("@lender_id_card",                 SqlDbType.VarChar,    50),
                new SqlParameter("@lenders_account_name",           SqlDbType.VarChar,    50),
                new SqlParameter("@lender_bank_account",            SqlDbType.VarChar,    50),
                new SqlParameter("@lender_bank",                    SqlDbType.VarChar,    50),
                new SqlParameter("@lender_address",                 SqlDbType.VarChar,   100),
                new SqlParameter("@lenders_telephone",              SqlDbType.VarChar,    50),
                new SqlParameter("@lenders_email",                  SqlDbType.VarChar,    50),
                new SqlParameter("@lendres_date_contract",          SqlDbType.DateTime),
                new SqlParameter("@borrower_registerid",            SqlDbType.Int,         4),
                new SqlParameter("@borrower_name",                  SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_username",              SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_id_card",               SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_account_name",          SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_bank_account",          SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_date_contract",         SqlDbType.VarChar,    50),
                new SqlParameter("@borrower_bank",                  SqlDbType.VarChar,    50),
                new SqlParameter("@witness_name",                   SqlDbType.VarChar,    50),
                new SqlParameter("@witness_address",                SqlDbType.VarChar,    50),
                new SqlParameter("@witness_telephone",              SqlDbType.VarChar,    50),
                new SqlParameter("@witness_agent",                  SqlDbType.VarChar,    50),
                new SqlParameter("@witness_admid",                  SqlDbType.Int,         4),
                new SqlParameter("@witness_username",               SqlDbType.VarChar,    50),
                new SqlParameter("@witness_id_card",                SqlDbType.VarChar,    50),
                new SqlParameter("@witness_date_contract",          SqlDbType.DateTime),
                new SqlParameter("@surety_company_name",            SqlDbType.VarChar,   100),
                new SqlParameter("@guarantee_business_icense",      SqlDbType.VarChar,    50),
                new SqlParameter("@ensure_address",                 SqlDbType.VarChar,    50),
                new SqlParameter("@guarantee_legal_representative", SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_agent",                SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_companyid",            SqlDbType.Int,         4),
                new SqlParameter("@guarantor_agent_usernqme",       SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_agent_id_card",        SqlDbType.VarChar,    50),
                new SqlParameter("@guarantor_agent_idate_contract", SqlDbType.DateTime),
                new SqlParameter("@contract_money",                 SqlDbType.VarChar,    -1),
                new SqlParameter("@counselling_service",            SqlDbType.VarChar,    -1),
                new SqlParameter("@contract_amount",                SqlDbType.Decimal,    17),
                new SqlParameter("@suretyship_contract",            SqlDbType.VarChar,    -1),
                new SqlParameter("@mode_payment",                   SqlDbType.VarChar,   255),
                new SqlParameter("@createtime",                     SqlDbType.DateTime),
                new SqlParameter("@contract",                       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.loan_number;
            parameters[1].Value  = model.targetid;
            parameters[2].Value  = model.lender_name;
            parameters[3].Value  = model.lender_username;
            parameters[4].Value  = model.lender_registerid;
            parameters[5].Value  = model.lender_id_card;
            parameters[6].Value  = model.lenders_account_name;
            parameters[7].Value  = model.lender_bank_account;
            parameters[8].Value  = model.lender_bank;
            parameters[9].Value  = model.lender_address;
            parameters[10].Value = model.lenders_telephone;
            parameters[11].Value = model.lenders_email;
            parameters[12].Value = model.lendres_date_contract;
            parameters[13].Value = model.borrower_registerid;
            parameters[14].Value = model.borrower_name;
            parameters[15].Value = model.borrower_username;
            parameters[16].Value = model.borrower_id_card;
            parameters[17].Value = model.borrower_account_name;
            parameters[18].Value = model.borrower_bank_account;
            parameters[19].Value = model.borrower_date_contract;
            parameters[20].Value = model.borrower_bank;
            parameters[21].Value = model.witness_name;
            parameters[22].Value = model.witness_address;
            parameters[23].Value = model.witness_telephone;
            parameters[24].Value = model.witness_agent;
            parameters[25].Value = model.witness_admid;
            parameters[26].Value = model.witness_username;
            parameters[27].Value = model.witness_id_card;
            parameters[28].Value = model.witness_date_contract;
            parameters[29].Value = model.surety_company_name;
            parameters[30].Value = model.guarantee_business_icense;
            parameters[31].Value = model.ensure_address;
            parameters[32].Value = model.guarantee_legal_representative;
            parameters[33].Value = model.guarantor_agent;
            parameters[34].Value = model.guarantor_companyid;
            parameters[35].Value = model.guarantor_agent_usernqme;
            parameters[36].Value = model.guarantor_agent_id_card;
            parameters[37].Value = model.guarantor_agent_idate_contract;
            parameters[38].Value = model.contract_money;
            parameters[39].Value = model.counselling_service;
            parameters[40].Value = model.contract_amount;
            parameters[41].Value = model.suretyship_contract;
            parameters[42].Value = model.mode_payment;
            parameters[43].Value = model.createtime;
            parameters[44].Value = model.contract;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#8
0
        protected M_Contract_management GetEntity(DataRow row)
        {
            if (row == null)
            {
                return(null);
            }
            M_Contract_management result = new M_Contract_management();

            result.contract                       = row["contract"] == null ? -1 : (int)row["contract"];
            result.loan_number                    = row["loan_number"] == null ? -1 : (decimal)row["loan_number"];
            result.targetid                       = row["targetid"] == null ? -1 : (int)row["targetid"];
            result.lender_name                    = row["lender_name"] == null ? string.Empty : row["lender_name"].ToString();
            result.lender_username                = row["lender_username"] == null ? string.Empty : row["lender_username"].ToString();
            result.lender_registerid              = row["lender_registerid"] == null ? -1 : (int)row["lender_registerid"];
            result.lender_id_card                 = row["lender_id_card"] == null ? string.Empty : row["lender_id_card"].ToString();
            result.lenders_account_name           = row["lenders_account_name"] == null ? string.Empty : row["lenders_account_name"].ToString();
            result.lender_bank_account            = row["lender_bank_account"] == null ? string.Empty : row["lender_bank_account"].ToString();
            result.lender_bank                    = row["lender_bank"] == null ? string.Empty : row["lender_bank"].ToString();
            result.lender_address                 = row["lender_address"] == null ? string.Empty : row["lender_address"].ToString();
            result.lenders_telephone              = row["lenders_telephone"] == null ? string.Empty : row["lenders_telephone"].ToString();
            result.lenders_email                  = row["lenders_email"] == null ? string.Empty : row["lenders_email"].ToString();
            result.lendres_date_contract          = row["lendres_date_contract"] == null ? DateTime.MinValue : Convert.ToDateTime(row["lendres_date_contract"]);
            result.borrower_registerid            = row["borrower_registerid"] == null ? -1 : (int)row["borrower_registerid"];
            result.borrower_name                  = row["borrower_name"] == null ? string.Empty : row["borrower_name"].ToString();
            result.borrower_username              = row["borrower_username"] == null ? string.Empty : row["borrower_username"].ToString();
            result.borrower_id_card               = row["borrower_id_card"] == null ? string.Empty : row["borrower_id_card"].ToString();
            result.borrower_account_name          = row["borrower_account_name"] == null ? string.Empty : row["borrower_account_name"].ToString();
            result.borrower_bank_account          = row["borrower_bank_account"] == null ? string.Empty : row["borrower_bank_account"].ToString();
            result.borrower_date_contract         = row["borrower_date_contract"] == null ? string.Empty : row["borrower_date_contract"].ToString();
            result.borrower_bank                  = row["borrower_bank"] == null ? string.Empty : row["borrower_bank"].ToString();
            result.witness_name                   = row["witness_name"] == null ? string.Empty : row["witness_name"].ToString();
            result.witness_address                = row["witness_address"] == null ? string.Empty : row["witness_address"].ToString();
            result.witness_telephone              = row["witness_telephone"] == null ? string.Empty : row["witness_telephone"].ToString();
            result.witness_agent                  = row["witness_agent"] == null ? string.Empty : row["witness_agent"].ToString();
            result.witness_admid                  = row["witness_admid"] == null ? -1 : (int)row["witness_admid"];
            result.witness_username               = row["witness_username"] == null ? string.Empty : row["witness_username"].ToString();
            result.witness_id_card                = row["witness_id_card"] == null ? string.Empty : row["witness_id_card"].ToString();
            result.witness_date_contract          = row["witness_date_contract"] == null ? DateTime.MinValue : Convert.ToDateTime(row["witness_date_contract"]);
            result.surety_company_name            = row["surety_company_name"] == null ? string.Empty : row["surety_company_name"].ToString();
            result.guarantee_business_icense      = row["guarantee_business_icense"] == null ? string.Empty : row["guarantee_business_icense"].ToString();
            result.ensure_address                 = row["ensure_address"] == null ? string.Empty : row["ensure_address"].ToString();
            result.guarantee_legal_representative = row["guarantee_legal_representative"] == null ? string.Empty : row["guarantee_legal_representative"].ToString();
            result.guarantor_agent                = row["guarantor_agent"] == null ? string.Empty : row["guarantor_agent"].ToString();
            result.guarantor_companyid            = row["guarantor_companyid"] == null ? -1 : (int)row["guarantor_companyid"];
            result.guarantor_agent_usernqme       = row["guarantor_agent_usernqme"] == null ? string.Empty : row["guarantor_agent_usernqme"].ToString();
            result.guarantor_agent_id_card        = row["guarantor_agent_id_card"] == null ? string.Empty : row["guarantor_agent_id_card"].ToString();
            result.guarantor_agent_idate_contract = row["guarantor_agent_idate_contract"] == null ? DateTime.MinValue : Convert.ToDateTime(row["guarantor_agent_idate_contract"]);
            result.contract_money                 = row["contract_money"] == null ? string.Empty : row["contract_money"].ToString();
            result.counselling_service            = row["counselling_service"] == null ? string.Empty : row["counselling_service"].ToString();
            result.contract_amount                = row["contract_amount"] == null ? 0.00M : Convert.ToDecimal(row["contract_amount"]);
            result.suretyship_contract            = row["suretyship_contract"] == null ? string.Empty : row["suretyship_contract"].ToString();
            result.mode_payment                   = row["mode_payment"] == null ? string.Empty : row["mode_payment"].ToString();
            result.createtime                     = row["createtime"] == null ? DateTime.MinValue : Convert.ToDateTime(row["createtime"]);
            result.contract_type                  = row["contract_type"] == null ? -1 : (int)row["contract_type"];
            result.contractpath                   = row["contractpath"] == null ? string.Empty : row["contractpath"].ToString();
            result.bid_records_id                 = row["bid_records_id"] == null ? -1 : (int)row["bid_records_id"];
            result.Start_Time                     = row["start_time"] == null ? string.Empty : ((DateTime)row["start_time"]).ToString("yyyy-MM-dd HH:mm:ss");
            result.End_Time                       = row["End_Time"] == null ? string.Empty : ((DateTime)row["End_Time"]).ToString("yyyy-MM-dd HH:mm:ss");
            if (!string.IsNullOrWhiteSpace(result.Start_Time) && !string.IsNullOrWhiteSpace(result.End_Time))
            {
                result.DurationTime = Utils.GetTargetDurationDays(result.Start_Time, result.End_Time).ToString();
                result.Start_Time   = result.Start_Time.Split(' ')[0].Replace("/", "-");
                result.End_Time     = result.End_Time.Split(' ')[0].Replace("/", "-");
            }
            return(result);
        }
示例#9
0
        //用户查看pdf(我的投资列表---合同 ---查看) 增加权限判断
        //waitfor 将多处生成合同代码整合复用
        public JsonResult MakePdf(int id)
        {
            string contractpath = "";

            hx_Bid_records hbr = ef.hx_Bid_records.Where(p => p.bid_records_id == id).FirstOrDefault();
            int            uid = Utils.checkloginsessiontop();

            if (hbr != null && hbr.investor_registerid == uid)
            {
                contractpath = hbr.contractpath;
            }
            else
            {
                return(Json(new PdfDetail {
                    Path = ""
                }, JsonRequestBehavior.AllowGet));
            }
            try
            {
                if (string.IsNullOrEmpty(contractpath) || !System.IO.File.Exists(Server.MapPath(contractpath)))
                {
                    #region 生成合同
                    //生成用户合同
                    LogInfo.WriteLog("生成用户合同响应");
                    var sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,usertypes,CopName  from V_borrowing_target_bonding where targetid=" + hbr.targetid;

                    DataTable dt = DbHelperSQL.GET_DataTable_List(sql);
                    if (dt.Rows.Count > 0)
                    {
                        var            str = UserContactText(Convert.ToInt32(hbr.targetid));
                        B_member_table ub  = new B_member_table();
                        M_member_table up  = new M_member_table();
                        // int uid = Utils.checkloginsessiontop();
                        // int uid = Convert.ToInt32(hbr.investor_registerid);
                        string OrdId = hbr.OrdId.ToString();
                        LogInfo.WriteLog("是否有接收到信息: OrdId=" + OrdId + " uc:" + uid);
                        //if (uid <= 0)
                        //{
                        //    Response.End();
                        //}
                        up = ub.GetModel(uid);
                        string fileName = "U_" + up.registerid.ToString() + "_" + dt.Rows[0]["targetid"].ToString() + "_" + dt.Rows[0]["loan_number"].ToString() + "_" + Utils.RndNum(3);
                        string path     = "/PDF/" + fileName + ".pdf";

                        M_Contract_management p = new M_Contract_management();
                        B_Contract_management o = new B_Contract_management();

                        sql = "select top 1 bid_records_id,investment_amount,value_date,investment_maturity from hx_Bid_records where targetid=" + hbr.targetid.ToString() + " and  investor_registerid=" + uid.ToString() + " and  OrdId ='" + OrdId + "' order by bid_records_id desc";

                        DataTable dtbid = DbHelperSQL.GET_DataTable_List(sql);
                        DateTime  dte   = DateTime.Now;
                        p.loan_number           = decimal.Parse(dt.Rows[0]["loan_number"].ToString());
                        p.targetid              = id;
                        p.bid_records_id        = int.Parse(dtbid.Rows[0]["bid_records_id"].ToString());
                        p.lender_username       = up.username;
                        p.lender_name           = up.realname;
                        p.lender_registerid     = uid;
                        p.lender_id_card        = up.iD_number;
                        p.lenders_account_name  = "";
                        p.lender_bank_account   = "";
                        p.lender_bank           = "";
                        p.lenders_telephone     = up.mobile;
                        p.lenders_email         = up.email;
                        p.lendres_date_contract = dte;
                        p.borrower_registerid   = int.Parse(dt.Rows[0]["borrower_registerid"].ToString());
                        p.borrower_name         = dt.Rows[0]["realname"].ToString();
                        if (dt.Rows[0]["usertypes"].ToString() == "2")
                        {
                            p.borrower_username = dt.Rows[0]["CopName"].ToString();
                        }
                        else
                        {
                            p.borrower_username = dt.Rows[0]["username"].ToString();
                        }
                        p.borrower_id_card               = dt.Rows[0]["iD_number"].ToString();
                        p.borrower_account_name          = dt.Rows[0]["realname"].ToString();
                        p.borrower_bank_account          = "";
                        p.borrower_date_contract         = dte.ToString();
                        p.borrower_bank                  = "";
                        p.surety_company_name            = dt.Rows[0]["company_name"].ToString();
                        p.guarantor_agent                = dt.Rows[0]["agent_name"].ToString();
                        p.guarantor_agent_usernqme       = dt.Rows[0]["agent_name"].ToString();
                        p.guarantor_companyid            = int.Parse(dt.Rows[0]["companyid"].ToString());
                        p.guarantor_agent_idate_contract = dte;
                        p.witness_date_contract          = dte;
                        p.contract_money                 = str;
                        p.contract_amount                = decimal.Parse(dtbid.Rows[0]["investment_amount"].ToString());
                        p.createtime    = dte;
                        p.mode_payment  = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString()));
                        p.contract_type = 1;

                        StringBuilder sb = new StringBuilder(str);
                        sb = sb.Replace("#loan_number#", p.loan_number.ToString());
                        sb = sb.Replace("#borrower_username#", p.borrower_username);
                        sb = sb.Replace("#borrower_name#", p.borrower_name);
                        sb = sb.Replace("#borrower_id_card#", p.borrower_id_card);
                        sb = sb.Replace("#lender_username#", p.lender_username);
                        sb = sb.Replace("#lender_name#", p.lender_name);
                        sb = sb.Replace("#lender_id_card#", p.lender_id_card);
                        sb = sb.Replace("#surety_company_name#", p.surety_company_name);
                        sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme);
                        sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString());
                        sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00"));

                        DateTime date1 = DateTime.Parse(dtbid.Rows[0]["value_date"].ToString());
                        DateTime date2 = DateTime.Parse(dtbid.Rows[0]["investment_maturity"].ToString());
                        sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd"));
                        sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd"));
                        sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString());

                        p.contract_money = sb.ToString();
                        p.contractpath   = path;
                        int cid = o.Add(p);
                        if (cid > 0)
                        {
                            sql = "update hx_Bid_records set contractid=" + cid + ",contractpath= '" + p.contractpath + "' where bid_records_id=" + p.bid_records_id;
                            DbHelperSQL.ExecuteSql(sql);
                            if (HTMLToPDF(sb.ToString(), fileName))
                            {
                                return(Json(new PdfDetail {
                                    Path = p.contractpath
                                }, JsonRequestBehavior.AllowGet));
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    return(Json(new PdfDetail {
                        Path = contractpath
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new PdfDetail {
                    Path = ""
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new PdfDetail {
                Path = contractpath
            }, JsonRequestBehavior.AllowGet));
        }
示例#10
0
        // GET: pdf
        public ActionResult Index()
        {
            string str    = "pdf";
            string sql    = "";
            int    id     = DNTRequest.GetInt("data", 0);
            string action = Utils.CheckSQLHtml(DNTRequest.GetString("action"));

            if (action == "PDF" && id > 0)
            {//生成某项目借款合同范本
                sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,legal_representative,usertypes,CopName  from V_borrowing_target_bonding where targetid=" + id;

                DataTable dt = DbHelperSQL.GET_DataTable_List(sql);
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["companyid"].ToString() == "6")
                    {
                        str = ContractText(6);
                    }
                    else
                    {
                        str = ContractText(1);
                    }

                    string fileName         = "template" + dt.Rows[0]["targetid"].ToString() + dt.Rows[0]["loan_number"].ToString();
                    string path             = "/PDF/" + fileName + ".pdf";
                    M_Contract_management p = new M_Contract_management();
                    B_Contract_management o = new B_Contract_management();
                    DateTime dte            = DateTime.Parse(dt.Rows[0]["release_date"].ToString());
                    p.loan_number           = decimal.Parse(dt.Rows[0]["loan_number"].ToString());
                    p.targetid              = id;
                    p.lender_username       = "";
                    p.lender_registerid     = 0;
                    p.lender_id_card        = "";
                    p.lenders_account_name  = "";
                    p.lender_bank_account   = "";
                    p.lender_bank           = "";
                    p.lenders_telephone     = "";
                    p.lenders_email         = "";
                    p.lendres_date_contract = dte;
                    p.borrower_registerid   = int.Parse(dt.Rows[0]["borrower_registerid"].ToString());

                    p.borrower_name = dt.Rows[0]["realname"].ToString();
                    if (dt.Rows[0]["usertypes"].ToString() == "2")
                    {
                        p.borrower_username = dt.Rows[0]["CopName"].ToString();
                    }
                    else
                    {
                        p.borrower_username = dt.Rows[0]["username"].ToString();
                    }

                    p.borrower_id_card               = dt.Rows[0]["iD_number"].ToString();
                    p.borrower_account_name          = dt.Rows[0]["realname"].ToString();
                    p.borrower_bank_account          = "";
                    p.borrower_date_contract         = dte.ToString();
                    p.borrower_bank                  = "";
                    p.surety_company_name            = dt.Rows[0]["company_name"].ToString();
                    p.guarantor_agent                = dt.Rows[0]["agent_name"].ToString();
                    p.guarantor_companyid            = int.Parse(dt.Rows[0]["companyid"].ToString());
                    p.guarantor_agent_idate_contract = dte;
                    p.guarantor_agent_usernqme       = dt.Rows[0]["legal_representative"].ToString();
                    p.witness_date_contract          = dte;
                    p.contract_money                 = str;
                    p.contract_amount                = decimal.Parse(dt.Rows[0]["borrowing_balance"].ToString());
                    p.createtime    = dte;
                    p.mode_payment  = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString()));
                    p.contract_type = 0;
                    sql             = "select contract,targetid from Contract_management where contract_type=0  and  targetid=" + id;

                    DataTable dt1 = DbHelperSQL.GET_DataTable_List(sql);
                    if (dt1.Rows.Count > 0)
                    {
                        p.contract = int.Parse(dt1.Rows[0]["contract"].ToString());
                        o.Update(p);
                    }
                    else
                    {
                        o.Add(p);
                    }

                    StringBuilder sb = new StringBuilder(str);
                    sb = sb.Replace("#loan_number#", p.loan_number.ToString());
                    sb = sb.Replace("#borrower_username#", p.borrower_username);
                    sb = sb.Replace("#borrower_name#", p.borrower_name);

                    sb = sb.Replace("#borrower_id_card#", p.borrower_id_card);
                    sb = sb.Replace("#lender_username#", p.lender_username);
                    sb = sb.Replace("#lender_name#", p.lender_name);
                    sb = sb.Replace("#lender_id_card#", p.lender_id_card);
                    sb = sb.Replace("#surety_company_name#", p.surety_company_name);
                    sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme);


                    sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString());
                    sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00"));
                    DateTime date1 = DateTime.Parse(dt.Rows[0]["release_date"].ToString());
                    DateTime date2 = DateTime.Parse(dt.Rows[0]["repayment_date"].ToString());

                    sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd"));
                    sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd"));
                    sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString());

                    /*
                     *
                     * string expr = @"#+([a-zA-Z0-9_\u4e00-\u9fa5]*)+#";
                     * MatchCollection mc = Regex.Matches(sb.ToString(), expr);
                     *
                     * string[] array = new string[mc.Count];
                     * array.SetValue(p.loan_number.ToString(), 0);
                     * array.SetValue(p.borrower_username, 1);
                     * array.SetValue(p.borrower_name, 2);
                     * array.SetValue(p.borrower_id_card, 3);
                     * array.SetValue(p.lender_username, 4);
                     * array.SetValue(p.lender_name, 5);
                     * array.SetValue(p.lender_id_card, 6);
                     * array.SetValue(p.surety_company_name, 7);
                     * array.SetValue(p.guarantor_agent_usernqme, 8);
                     * array.SetValue("", 9);
                     * array.SetValue(dt.Rows[0]["annual_interest_rate"].ToString(), 10);
                     * DateTime date1 = DateTime.Parse(dt.Rows[0]["release_date"].ToString());
                     * DateTime date2 = DateTime.Parse(dt.Rows[0]["repayment_date"].ToString());
                     * array.SetValue(date1.ToString("yyyy-MM-dd"), 11);
                     * array.SetValue(date2.ToString("yyyy-MM-dd"), 12);
                     * array.SetValue(Utils.DateDiff("Day",date1,date2).ToString(), 13);
                     *
                     * array.SetValue(p.borrower_name, 14);
                     * array.SetValue(p.borrower_id_card, 15);
                     * array.SetValue("", 16);
                     * array.SetValue("", 17);
                     * array.SetValue(p.surety_company_name, 18);
                     * array.SetValue(p.guarantor_agent_usernqme, 19);
                     *
                     * for (int i = 0; i < mc.Count; i++)
                     * {
                     *  sb = sb.Replace(mc[i].ToString(), array[i].ToString());
                     * }
                     */

                    if (HTMLToPDF(sb.ToString(), fileName))
                    {
                        json = @" {""rs""    : ""y"", ""datainfo"" :  ""add""}";
                        json = json.Replace("add", path);
                        Response.Write(json);
                        Response.End();
                    }
                    else
                    {
                        json = @" {""rs""    : ""n"", ""datainfo"" :  ""PDF合同生成失败""}";
                        Response.Write(json);
                        Response.End();
                    }
                }
                return(Content(str));
                //return View();
            }
            else if (action == "UserPDF" && id > 0)
            {
                //生成用户合同
                sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,usertypes,CopName  from V_borrowing_target_bonding where targetid=" + id;

                DataTable dt = DbHelperSQL.GET_DataTable_List(sql);
                if (dt.Rows.Count > 0)
                {
                    str = UserContactText(id);
                    B_member_table ub  = new B_member_table();
                    M_member_table up  = new M_member_table();
                    int            uid = Utils.checkloginsessiontop();
                    //int uid = 9;
                    if (uid <= 0)
                    {
                        Response.Redirect("/login.html");
                        Response.End();
                    }

                    up = ub.GetModel(uid);
                    string fileName = "U_" + up.registerid.ToString() + "_" + dt.Rows[0]["targetid"].ToString() + "_" + dt.Rows[0]["loan_number"].ToString() + "_" + Utils.RndNum(3);

                    string path             = "/PDF/" + fileName + ".pdf";
                    M_Contract_management p = new M_Contract_management();
                    B_Contract_management o = new B_Contract_management();
                    sql = "select top 1 bid_records_id,investment_amount,value_date,investment_maturity from hx_Bid_records where targetid=" + id.ToString() + " and  investor_registerid=" + uid.ToString() + " order by bid_records_id desc";

                    DataTable dtbid = DbHelperSQL.GET_DataTable_List(sql);
                    DateTime  dte   = DateTime.Now;
                    p.loan_number          = decimal.Parse(dt.Rows[0]["loan_number"].ToString());
                    p.targetid             = id;
                    p.bid_records_id       = int.Parse(dtbid.Rows[0]["bid_records_id"].ToString());
                    p.lender_username      = up.username;
                    p.lender_name          = up.realname;
                    p.lender_registerid    = uid;
                    p.lender_id_card       = up.iD_number;
                    p.lenders_account_name = "";
                    p.lender_bank_account  = "";
                    p.lender_bank          = "";

                    p.lenders_telephone     = up.mobile;
                    p.lenders_email         = up.email;
                    p.lendres_date_contract = dte;
                    p.borrower_registerid   = int.Parse(dt.Rows[0]["borrower_registerid"].ToString());
                    p.borrower_name         = dt.Rows[0]["realname"].ToString();

                    if (dt.Rows[0]["usertypes"].ToString() == "2")
                    {
                        p.borrower_username = dt.Rows[0]["CopName"].ToString();
                    }
                    else
                    {
                        p.borrower_username = dt.Rows[0]["username"].ToString();
                    }
                    p.borrower_id_card               = dt.Rows[0]["iD_number"].ToString();
                    p.borrower_account_name          = dt.Rows[0]["realname"].ToString();
                    p.borrower_bank_account          = "";
                    p.borrower_date_contract         = dte.ToString();
                    p.borrower_bank                  = "";
                    p.surety_company_name            = dt.Rows[0]["company_name"].ToString();
                    p.guarantor_agent                = dt.Rows[0]["agent_name"].ToString();
                    p.guarantor_agent_usernqme       = dt.Rows[0]["agent_name"].ToString();
                    p.guarantor_companyid            = int.Parse(dt.Rows[0]["companyid"].ToString());
                    p.guarantor_agent_idate_contract = dte;

                    p.witness_date_contract = dte;
                    p.contract_money        = str;
                    p.contract_amount       = decimal.Parse(dtbid.Rows[0]["investment_amount"].ToString());
                    p.createtime            = dte;
                    p.mode_payment          = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString()));
                    p.contract_type         = 1;

                    StringBuilder sb = new StringBuilder(str);
                    sb = sb.Replace("#loan_number#", p.loan_number.ToString());
                    sb = sb.Replace("#borrower_username#", p.borrower_username);
                    sb = sb.Replace("#borrower_name#", p.borrower_name);
                    sb = sb.Replace("#borrower_id_card#", p.borrower_id_card);
                    sb = sb.Replace("#lender_username#", p.lender_username);
                    sb = sb.Replace("#lender_name#", p.lender_name);
                    sb = sb.Replace("#lender_id_card#", p.lender_id_card);
                    sb = sb.Replace("#surety_company_name#", p.surety_company_name);
                    sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme);

                    sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString());
                    sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00"));
                    DateTime date1 = DateTime.Parse(dtbid.Rows[0]["value_date"].ToString());
                    DateTime date2 = DateTime.Parse(dtbid.Rows[0]["investment_maturity"].ToString());
                    sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd"));
                    sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd"));
                    sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString());
                    p.contract_money = sb.ToString();
                    p.contractpath   = path;
                    int cid = o.Add(p);
                    if (cid > 0)
                    {
                        sql = "update hx_Bid_records set contractid=" + cid + ",contractpath= '" + p.contractpath + "' where bid_records_id=" + p.bid_records_id;
                        DbHelperSQL.ExecuteSql(sql);
                        if (HTMLToPDF(sb.ToString(), fileName))
                        {
                            json = @" {""rs""    : ""y"", ""datainfo"" :  ""/usercenter/myinvest.html""}";
                            Response.Write(json);
                            Response.End();
                        }
                        else
                        {
                            json = @" {""rs""    : ""n"", ""datainfo"" :  ""PDF合同生成失败""}";
                            Response.Write(json);
                            Response.End();
                        }
                    }
                }
            }
            else if (action == "MUserPDF" && id > 0)
            { //生成用户合同
                LogInfo.WriteLog("生成用户合同响应");
                sql = " SELECT targetid,loan_number, borrower_registerid,borrowing_title,annual_interest_rate,payment_options,borrowing_balance,life_of_loan,unit_day,release_date,month_payment_date,repayment_date,end_time,companyid,company_name,agent_name,agent_id_card,username,realname,iD_number,usertypes,CopName  from V_borrowing_target_bonding where targetid=" + id;

                DataTable dt = DbHelperSQL.GET_DataTable_List(sql);
                if (dt.Rows.Count > 0)
                {
                    str = UserContactText(id);
                    B_member_table ub = new B_member_table();
                    M_member_table up = new M_member_table();
                    // int uid = Utils.checkloginsessiontop();
                    int    uid   = DNTRequest.GetInt("uc", 0);
                    string OrdId = DNTRequest.GetString("OrdId");
                    LogInfo.WriteLog("是否有接收到信息: OrdId=" + OrdId + " uc:" + uid);

                    //int uid = 9;
                    if (uid <= 0)
                    {
                        Response.End();
                    }

                    up = ub.GetModel(uid);
                    string fileName = "U_" + up.registerid.ToString() + "_" + dt.Rows[0]["targetid"].ToString() + "_" + dt.Rows[0]["loan_number"].ToString() + "_" + Utils.RndNum(3);
                    string path     = "/PDF/" + fileName + ".pdf";

                    M_Contract_management p = new M_Contract_management();
                    B_Contract_management o = new B_Contract_management();
                    sql = "select top 1 bid_records_id,investment_amount,value_date,investment_maturity from hx_Bid_records where targetid=" + id.ToString() + " and  investor_registerid=" + uid.ToString() + " and  OrdId ='" + OrdId + "' order by bid_records_id desc";
                    DataTable dtbid = DbHelperSQL.GET_DataTable_List(sql);
                    DateTime  dte   = DateTime.Now;
                    p.loan_number           = decimal.Parse(dt.Rows[0]["loan_number"].ToString());
                    p.targetid              = id;
                    p.bid_records_id        = int.Parse(dtbid.Rows[0]["bid_records_id"].ToString());
                    p.lender_username       = up.username;
                    p.lender_name           = up.realname;
                    p.lender_registerid     = uid;
                    p.lender_id_card        = up.iD_number;
                    p.lenders_account_name  = "";
                    p.lender_bank_account   = "";
                    p.lender_bank           = "";
                    p.lenders_telephone     = up.mobile;
                    p.lenders_email         = up.email;
                    p.lendres_date_contract = dte;
                    p.borrower_registerid   = int.Parse(dt.Rows[0]["borrower_registerid"].ToString());
                    p.borrower_name         = dt.Rows[0]["realname"].ToString();
                    if (dt.Rows[0]["usertypes"].ToString() == "2")
                    {
                        p.borrower_username = dt.Rows[0]["CopName"].ToString();
                    }
                    else
                    {
                        p.borrower_username = dt.Rows[0]["username"].ToString();
                    }
                    p.borrower_id_card               = dt.Rows[0]["iD_number"].ToString();
                    p.borrower_account_name          = dt.Rows[0]["realname"].ToString();
                    p.borrower_bank_account          = "";
                    p.borrower_date_contract         = dte.ToString();
                    p.borrower_bank                  = "";
                    p.surety_company_name            = dt.Rows[0]["company_name"].ToString();
                    p.guarantor_agent                = dt.Rows[0]["agent_name"].ToString();
                    p.guarantor_agent_usernqme       = dt.Rows[0]["agent_name"].ToString();
                    p.guarantor_companyid            = int.Parse(dt.Rows[0]["companyid"].ToString());
                    p.guarantor_agent_idate_contract = dte;
                    p.witness_date_contract          = dte;
                    p.contract_money                 = str;
                    p.contract_amount                = decimal.Parse(dtbid.Rows[0]["investment_amount"].ToString());
                    p.createtime    = dte;
                    p.mode_payment  = Utils.Getpayment_options(int.Parse(dt.Rows[0]["payment_options"].ToString()));
                    p.contract_type = 1;
                    StringBuilder sb = new StringBuilder(str);
                    sb = sb.Replace("#loan_number#", p.loan_number.ToString());
                    sb = sb.Replace("#borrower_username#", p.borrower_username);
                    sb = sb.Replace("#borrower_name#", p.borrower_name);
                    sb = sb.Replace("#borrower_id_card#", p.borrower_id_card);
                    sb = sb.Replace("#lender_username#", p.lender_username);
                    sb = sb.Replace("#lender_name#", p.lender_name);
                    sb = sb.Replace("#lender_id_card#", p.lender_id_card);
                    sb = sb.Replace("#surety_company_name#", p.surety_company_name);
                    sb = sb.Replace("#guarantor_agent_usernqme#", p.guarantor_agent_usernqme);
                    sb = sb.Replace("#contract_amount#", RMB.GetDecimal(p.contract_amount, 2, true).ToString());
                    sb = sb.Replace("#annual_interest_rate#", decimal.Parse(dt.Rows[0]["annual_interest_rate"].ToString()).ToString("0.00"));
                    DateTime date1 = DateTime.Parse(dtbid.Rows[0]["value_date"].ToString());
                    DateTime date2 = DateTime.Parse(dtbid.Rows[0]["investment_maturity"].ToString());
                    sb = sb.Replace("#release_date#", date1.ToString("yyyy-MM-dd"));
                    sb = sb.Replace("#repayment_date#", date2.ToString("yyyy-MM-dd"));
                    sb = sb.Replace("#days#", Utils.DateDiff("Day", date1, date2).ToString());

                    p.contract_money = sb.ToString();
                    p.contractpath   = path;
                    int cid = o.Add(p);
                    if (cid > 0)
                    {
                        sql = "update hx_Bid_records set contractid=" + cid + ",contractpath= '" + p.contractpath + "' where bid_records_id=" + p.bid_records_id;
                        DbHelperSQL.ExecuteSql(sql);

                        if (HTMLToPDF(sb.ToString(), fileName))
                        {
                            json = @" {""rs""    : ""y"", ""datainfo"" :  ""/usercenter/myinvest.html""}";
                            Response.Write(json);
                            Response.End();
                        }
                        else
                        {
                            json = @" {""rs""    : ""n"", ""datainfo"" :  ""PDF合同生成失败""}";
                            Response.Write(json);
                            Response.End();
                        }
                    }
                }
            }
            return(Content(str));//权限?
            //return View();
        }