/// <summary> /// 删除保单 /// </summary> /// <param name="id">保单的id值</param> private void Del(int id) { To_Policy policy = To_PolicyManager.getTo_PolicyById(id); if (policy != null) { int jobflowid = policy.IsVerify; JobFlow model = JobFlowManager.GetModel(jobflowid); if (model == null || model.auditstatus != "01") { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "del", "<script>alert('保单已删除或审核员已审核')</script>"); } else { string strdel = " jobflowid=" + jobflowid; AuditJobFlowManager.Delete(strdel); JobFlowManager.Delete(jobflowid); To_PolicyManager.deleteTo_Policy(id); To_PolicyDetailManager.DeleteByPolicy(id); } } }
/// <summary> /// 保存保单(编辑或添加) /// </summary> /// <returns>返回业务编号</returns> private string SavePolicy(int jobflowid) { To_Policy policyModel = new To_Policy(); string cuscode = ""; //公司代码全称 string codeformat = ""; //公司代码,不包含流水号 string ordernum = ""; //流水号 if (StrNumbers(TxtSerialNum.Text.Trim(), out cuscode, out codeformat, out ordernum)) { policyModel.Assured = TxtAssured.Text; //被保险人 policyModel.Company = int.Parse(HidComId.Value); //保险公司 policyModel.Customer = int.Parse(HidCusId.Value); //投保客户 policyModel.IsVerify = jobflowid; //工作流管理id policyModel.Policy_date = Convert.ToDateTime(TxtPolicyDate.Text); //表单日期 policyModel.Policy_enddate = Convert.ToDateTime(txtEndTime.Text).ToString("yyyy-MM-dd"); //Convert.ToDateTime(TxtTimeStart.Text).AddYears(int.Parse(TxtYears.Text.Trim())).ToString("yyyy-MM-dd");//投保到期日期 policyModel.Policy_startdate = Convert.ToDateTime(TxtTimeStart.Text).ToString("yyyy-MM-dd"); //投保开始日期 policyModel.Policy_maker = TxtPolicyMaker.Text; //制单人 policyModel.Policy_num = TxtPolicyNum.Text; //表单编号 policyModel.Policy_state = Convert.ToInt32(DdlPolicyState.SelectedValue); //保单状态(0:无效;1:有效) policyModel.Protype = HidTypeId.Value; //险种 //policyModel.Salesman = int.Parse(HidSalesman.Value);// int.Parse(TxtSalesman.Text);//所属业务员 policyModel.Salesman = 0; //去掉主表中的业务员信息,将其设置为默认0; //policyModel.Serialnum = TxtSerialNum.Text;//内部流水号 policyModel.Verifydate = DateTime.Now; // Convert.ToDateTime(TxtVerifyDate.Text);//审核日期 policyModel.VerifyUser = ""; // TxtVerifyUser.Text;//审核人 policyModel.IsRenewal = Convert.ToInt32(DdlIsRenewal.SelectedValue); //是否续保 policyModel.UserCompany = ddlUnit.SelectedItem.Text; //经营单位 policyModel.TotalEcoRate = Convert.ToDouble(zjjfrate.Text); //总经济费比率 policyModel.TotalEconomic = Convert.ToDouble(this.zjjf.Text); //总经济费 policyModel.TotalRich = Convert.ToDouble(ztf.Text); //总贴费 policyModel.ShipName = cm.Text; //船名 policyModel.TotalPremium = Convert.ToDouble(zbf.Text); //总保费 policyModel.TotalBrokerage = Convert.ToDouble(zbe.Text); //总保额 policyModel.Txt = ""; //审核意见 policyModel.IsDaidian = int.Parse(DdlIsDaidian.SelectedValue.Trim()); //是否代垫保费,0:否,1:是 policyModel.OrderNum = ordernum; policyModel.CodeFormart = codeformat; policyModel.Serialnum = cuscode; object action = Request.QueryString["action"]; //表示编辑保单 if (action != null && action.ToString() == "edit") { List <string> p = new List <string>(); //存储业务员的汇总 object id = Request.QueryString["id"]; int rid = 0; if (id != null && int.TryParse(id.ToString(), out rid)) { policyModel.Id = rid; if (To_PolicyManager.updateTo_Policy(policyModel) > 0) { To_PolicyDetailManager.DeleteByPolicy(policyModel.Id); if (HidPros.Value != "") { string[] items = HidPros.Value.Split(','); string[] txt = null; To_PolicyDetail pdModel = null; foreach (string item in items) { pdModel = new To_PolicyDetail(); txt = item.Split('|'); pdModel.PolicyId = policyModel.Id; //保单id pdModel.Salesman = txt[0]; //业务员 if (!p.Contains(txt[0])) { p.Add(txt[0]); } pdModel.DepartName = txt[1]; //部门 pdModel.NumRate = decimal.Parse(txt[2]); //比率 pdModel.Fmone = decimal.Parse(txt[3]); //经济费 pdModel.Rich = decimal.Parse(txt[4]); //贴费 pdModel.Mark = txt[5]; //备注 To_PolicyDetailManager.addTo_PolicyDetail(pdModel); } StringBuilder persons = new StringBuilder(); foreach (string s in p) { persons.Append(s + ";"); } To_PolicyManager.updateTo_PolicySalesman(persons.ToString(), rid); } To_PolicyTargetManager.DeleteByPolicy(rid); if (HidTarget.Value != "") { string hidValues = HidTarget.Value.TrimEnd('@').Replace("\r\n", ""); string[] values = hidValues.Split('@'); To_PolicyTarget To_PolicyTarget = new To_PolicyTarget(); To_PolicyTarget.PolicyID = rid; foreach (string value in values) { string[] propertyArr = value.Split('$'); To_PolicyTarget.Datatype = propertyArr[4].Trim() == "" ? 0 : int.Parse(propertyArr[4].Trim()); To_PolicyTarget.PropertyName = propertyArr[0].Trim(); To_PolicyTarget.PropertyTypeID = propertyArr[2].Trim() == "" ? 0 : int.Parse(propertyArr[2].Trim()); To_PolicyTarget.PropertyValue = propertyArr[1].Trim(); To_PolicyTarget.PropertyID = propertyArr[3].Trim() == "" ? 0 : int.Parse(propertyArr[3].Trim()); To_PolicyTargetManager.addTo_PolicyTarget(To_PolicyTarget); } } if (HidFiles.Value != "") { string oldFiles = HidFiles.Value.Trim().TrimEnd(','); if (oldFiles != "") { To_PolicyFileManager policyFileBLL = new To_PolicyFileManager(); policyFileBLL.DeleteList(oldFiles); } } //上传附件并返回文件名集合 string[] str = FileUp(Request.Files); if (str[0] == "" && str[6] == "1") { SaveFilePath(str, rid); } } UCBudgetEdit1.SaveData(rid); } } //新增保单 else if (action != null && action.ToString() == "new") { policyModel.Policy_makerId = (Session["login"] as LoginInfo).Id; Add(policyModel); } } return(cuscode); }