protected void BtnSubmit_Click(object sender, ImageClickEventArgs e) { To_ClaimManager b_claim = new To_ClaimManager(); To_Claim m_claim = new To_Claim(); Step1 step1 = Context.Handler as Step1; m_claim.collectingID = Convert.ToInt32(Request.QueryString["id"]); m_claim.costType = HidReceiptType.Value; m_claim.payer = HidPayer.Value; m_claim.payerID = int.Parse(HidPayerID.Value); m_claim.payerType = int.Parse(HidPayerType.Value); m_claim.salesman = HidSalesman.Value; m_claim.salesmanID = int.Parse(HidSalesmanID.Value); m_claim.makerID = (Session["login"] as LoginInfo).Id; int claimID = b_claim.Add(m_claim); if (claimID != 0) { To_CollectingManager.ChangeClaim(Convert.ToInt32(Request.QueryString["id"]), chkFinish.Checked ? 2 : 1); if (chkFinish.Checked) { SendMessage(m_claim.collectingID, HidSalesman.Value, 1); } else { SendMessage(m_claim.collectingID, HidSalesman.Value, 0); } if (HidClaimDetail.Value.Trim() != string.Empty) { string[] items = HidClaimDetail.Value.Trim().TrimEnd('@').Split('@'); if (items.Length > 0) { To_ClaimDetailManager b_claimDetail = new To_ClaimDetailManager(); To_ClaimDetail m_claimDetail = new To_ClaimDetail(); foreach (string item in items) { string[] detail = item.Trim().Split('$'); if (detail.Length > 0) { int policyID = int.Parse(detail[0].Trim()); decimal amount = decimal.Parse(detail[1].Trim().TrimStart('¥').TrimStart('¥')); decimal realAmount = decimal.Parse(detail[2].Trim()); m_claimDetail.claimID = claimID; m_claimDetail.mark = ""; m_claimDetail.policyID = policyID; m_claimDetail.realAmount = realAmount; m_claimDetail.receiptAmount = amount; m_claimDetail.receiptStatusCode = 0; b_claimDetail.Add(m_claimDetail); } } } } ClientScript.RegisterClientScriptBlock(this.GetType(), "page", "alert('认领成功');self.location.href='../FundsAllocation.aspx';", true); } }
/// <summary> /// 保存收款认领明细数据的方法 /// </summary> /// <param name="claimId">收款认领单id</param> /// <param name="collectId">收款单id</param> private void SaveClaimDetail(int claimId, int collectId) { IList <string> orderColectIDs = new List <string>(); To_CollectingManager.ChangeClaim(Convert.ToInt32(Request.QueryString["id"]), chkFinish.Checked ? 2 : 1); if (chkFinish.Checked) { SendMessage(collectId, LblMaker.Text, 1); } else { SendMessage(collectId, LblMaker.Text, 0); } if (HidClaimDetail.Value.Trim() != string.Empty) { To_ClaimDetailManager claimDetailManager = new To_ClaimDetailManager(); string[] items = HidClaimDetail.Value.Trim().TrimEnd('@').Split('@'); if (items.Length > 0) { To_ClaimDetail claimDetail = new To_ClaimDetail(); foreach (string item in items) { string[] detail = item.Trim().Split('$'); if (detail.Length > 0) { claimDetail.claimID = claimId; //收款单id claimDetail.orderCollectId = int.Parse(detail[0]); //订单表收款信息明细表id if (!orderColectIDs.Contains(detail[0])) { orderColectIDs.Add(detail[0]); } claimDetail.orderCusId = int.Parse(hidComID.Value); //付款单位id claimDetail.orderNum = detail[1]; //订单编号 claimDetail.receiptAmount = decimal.Parse(detail[2]); //应收金额(在编辑的时候还是要去该订单表收款明细的应收金额,因为这个应收金额可能会变) claimDetail.realAmount = decimal.Parse(detail[3]); //本次收款金额 claimDetail.mark = detail[4]; //备注 claimDetailManager.Add(claimDetail); } } } //更新收款信息明细表的收款状态和实际收款金额 for (int i = 0; i < orderColectIDs.Count; i++) { if (orderColectIDs[i] != "") { double hasAmount = claimDetailManager.GetHasAmount(orderColectIDs[i]); //得到该收款信息明细表关联的所有认领过的金额 double shouldAmount = To_OrderCollectDetialManager.getTo_OrderCollectDetialById(int.Parse(orderColectIDs[i])).Money; //得到应收金额 string getstatus = ""; if (hasAmount == 0) { getstatus = "未收款"; } else if (shouldAmount > hasAmount) { getstatus = "部分收款"; } else { getstatus = "完成收款"; } To_OrderCollectDetialManager.updateDetialStatusAndMoney(orderColectIDs[i], getstatus, hasAmount.ToString()); } } } }