private bool DoAdd() { if (context.li_loaner_companies.Any(q => q.name == txtCompanyName.Text.Trim())) { JscriptMsg("企业名称重复!", "", "Error"); return(false); } var model = new li_loaner_companies { name = txtCompanyName.Text.Trim(), setup_time = Convert.ToDateTime(txtSetupTime.Text), business_scope = txtBusinessScope.Text, business_status = txtBusinessStatus.Text, business_lawsuit = txtBusinessLawsuit.Text, registered_capital = txtRegisteredCapital.Text, remark = txtCompanyRemark.Text, manager = txtManager.Text, address = txtAddress.Text, business_belong = txtBusinessBelong.Text, business_license_no = txtBusinessLicenseNo.Text, organization_no = txtOrganizationNo.Text, shareholder = txtShareholder.Text }; context.li_loaner_companies.InsertOnSubmit(model); LoadAlbum(model, Agp2pEnums.AlbumTypeEnum.Pictures); var currentLoanerNames = txtLoaners.Text.Trim().Split(','); currentLoanerNames.ForEach(ln => { var loaner = context.li_loaners.SingleOrDefault(l => l.dt_users.user_name == ln) ?? context.li_loaners.Single(l => l.dt_users.real_name == ln); if (loaner.li_loaner_companies != null) { JscriptMsg(loaner.dt_users.user_name + " 已经绑定企业,不能重复绑定!", "", "Error"); } else { loaner.li_loaner_companies = model; } }); try { context.SubmitChanges(); AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加企业信息:" + txtCompanyName.Text); //记录日志 return(true); } catch (Exception ex) { return(false); } }
private void UpdateLoanerCompanyInfo(li_loaners loaner) { var company = loaner.li_loaner_companies; if (chkBindCompany.Checked) { if (company == null) { company = new li_loaner_companies { name = txtCompanyName.Text, business_lawsuit = txtBusinessLawsuit.Text, business_scope = txtBusinessScope.Text, business_status = txtBusinessStatus.Text, registered_capital = txtRegisteredCapital.Text, setup_time = Convert.ToDateTime(txtSetupTime.Text), remark = txtCompanyRemark.Text, manager = txtManager.Text, business_belong = txtBusinessBelong.Text, address = txtCaddress.Text, business_license_no = txtBusinessLicenseNo.Text, organization_no = txtOrganizationNo.Text }; loaner.li_loaner_companies = company; context.li_loaner_companies.InsertOnSubmit(company); } else { company.name = txtCompanyName.Text; company.business_lawsuit = txtBusinessLawsuit.Text; company.business_scope = txtBusinessScope.Text; company.business_status = txtBusinessStatus.Text; company.registered_capital = txtRegisteredCapital.Text; company.setup_time = Convert.ToDateTime(txtSetupTime.Text); company.remark = txtCompanyRemark.Text; company.manager = txtManager.Text; company.business_belong = txtBusinessBelong.Text; company.address = txtCaddress.Text; company.business_license_no = txtBusinessLicenseNo.Text; company.organization_no = txtOrganizationNo.Text; } } else if (company != null) { /*if (company.li_loaners.Count == 1) * context.li_loaner_companies.DeleteOnSubmit(company);*/ loaner.li_loaner_companies = null; } }
private void LoadAlbum(li_loaner_companies model, Agp2pEnums.AlbumTypeEnum type) { string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); context.li_albums.DeleteAllOnSubmit(context.li_albums.Where(a => a.company == model.id && a.type == (int)type)); if (albumArr != null) { var preAdd = albumArr.Zip(remarkArr, (album, remark) => { var albumSplit = album.Split('|'); return(new li_albums { original_path = albumSplit[1], thumb_path = albumSplit[2], remark = remark, add_time = DateTime.Now, li_loaner_companies = model, type = (byte)type }); }); context.li_albums.InsertAllOnSubmit(preAdd); } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { Init += Project_Init; //加入IInit事件 project_id = DTRequest.GetQueryInt("project_id"); page = Math.Max(1, DTRequest.GetQueryInt("page")); buyClaimId = DTRequest.GetQueryInt("buyClaimId"); if (project_id <= 0) { return; } projectModel = context.li_projects.FirstOrDefault(p => p.id == project_id); if (projectModel == null) { //HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); HttpContext.Current.Response.Redirect(linkurl("404")); return; } li_claims preBuyClaim = null; if (buyClaimId != 0) { preBuyClaim = context.li_claims.SingleOrDefault(c => c.id == buyClaimId); if (preBuyClaim == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } } Investable = new Investable { NeedTransferClaim = preBuyClaim, Project = projectModel }; // 浏览次数 + 1 projectModel.click += 1; context.SubmitChanges(); var pr = GetProjectInvestmentProgress(projectModel); //剩余金额 investmentBalance = pr.GetInvestmentBalance(); //风控信息 risk = projectModel.li_risks; //借款人 loaner = risk.li_loaners; //借款人企业 loaner_company = risk.li_loaners?.li_loaner_companies; //抵押物 mortgages = projectModel.li_risks.li_risk_mortgage.Select(rm => rm.li_mortgages).ToList(); invsetorCount = projectModel.GetInvestedUserCount(); projectSum = projectModel.financing_amount; projectDescription = projectModel.title; //还款计划 repayment_tasks = projectModel.li_repayment_tasks .Where(task => task.only_repay_to == null) .OrderBy(rt => rt.should_repay_time) .ToList(); if (Investable.NeedTransferClaim != null) { var ratio = Investable.NeedTransferClaim.principal / projectModel.financing_amount; repayment_tasks = repayment_tasks.Select(src => new li_repayment_tasks { repay_principal = Math.Round(src.repay_principal * ratio, 2), repay_interest = Investable.NeedTransferClaim.Parent.GetProfitingSectionDays(src, (claimBeforeProfitingDays, claimProfitingDays, claimInvalidDays) => Math.Round(src.repay_interest * ratio * claimInvalidDays / (claimBeforeProfitingDays + claimProfitingDays + claimInvalidDays), 2)), should_repay_time = src.should_repay_time, term = src.term }).ToList(); } }
private void UpdateLoanerInfo(int userId, DateTime lastUpdateTime) { var loanerInfo = context.li_loaners.SingleOrDefault(l => l.user_id == userId); if (chkIsLoaner.Checked) { if (loanerInfo == null) { loanerInfo = new li_loaners { age = Convert.ToInt16(txtAge.Text), user_id = userId, educational_background = txtEducationalBackground.Text, income = txtIncome.Text, job = txtJob.Text, last_update_time = lastUpdateTime, working_at = txtWorkingAt.Text, marital_status = Convert.ToByte(rblMaritalStatus.SelectedValue), native_place = txtCencus.Text, working_company = txtWorkingUnit.Text }; context.li_loaners.InsertOnSubmit(loanerInfo); if (chkBindCompany.Checked) { var loanerCompany = new li_loaner_companies { name = txtCompanyName.Text, business_lawsuit = txtBusinessLawsuit.Text, business_scope = txtBusinessScope.Text, business_status = txtBusinessStatus.Text, registered_capital = txtRegisteredCapital.Text, setup_time = Convert.ToDateTime(txtSetupTime.Text), remark = txtCompanyRemark.Text, manager = txtManager.Text, business_belong = txtBusinessBelong.Text, address = txtCaddress.Text, business_license_no = txtBusinessLicenseNo.Text, organization_no = txtOrganizationNo.Text }; loanerInfo.li_loaner_companies = loanerCompany; context.li_loaner_companies.InsertOnSubmit(loanerCompany); } } else { loanerInfo.age = Convert.ToInt16(txtAge.Text); loanerInfo.user_id = userId; loanerInfo.educational_background = txtEducationalBackground.Text; loanerInfo.income = txtIncome.Text; loanerInfo.job = txtJob.Text; loanerInfo.last_update_time = lastUpdateTime; loanerInfo.working_at = txtWorkingAt.Text; loanerInfo.marital_status = Convert.ToByte(rblMaritalStatus.SelectedValue); loanerInfo.native_place = txtCencus.Text; loanerInfo.working_company = txtWorkingUnit.Text; UpdateLoanerCompanyInfo(loanerInfo); } } else if (loanerInfo != null) { var c = loanerInfo.li_loaner_companies; if (c != null) { context.li_loaner_companies.DeleteOnSubmit(c); } context.li_loaners.DeleteOnSubmit(loanerInfo); } }