コード例 #1
0
ファイル: IndexController.cs プロジェクト: mkbiltek2019/CLT
        /// <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
ファイル: pdfController.cs プロジェクト: DarkMoon4CN/CLT
        //用户查看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));
        }
コード例 #3
0
ファイル: pdfController.cs プロジェクト: DarkMoon4CN/CLT
        // 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();
        }