/// <summary> /// 得到一个对象实体 /// </summary> public To_ClaimDetail GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" from To_ClaimDetail "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; To_ClaimDetail model = new To_ClaimDetail(); DataTable ds = DBHelper.GetDataSet(strSql.ToString(), parameters); if (ds.Rows.Count > 0) { if (ds.Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Rows[0]["ID"].ToString()); } if (ds.Rows[0]["claimID"].ToString() != "") { model.claimID = int.Parse(ds.Rows[0]["claimID"].ToString()); } model.orderNum = ds.Rows[0]["orderNum"].ToString(); if (ds.Rows[0]["orderCollectId"].ToString() != "") { model.orderCollectId = int.Parse(ds.Rows[0]["orderCollectId"].ToString()); } if (ds.Rows[0]["orderCusId"].ToString() != "") { model.orderCusId = int.Parse(ds.Rows[0]["orderCusId"].ToString()); } if (ds.Rows[0]["receiptAmount"].ToString() != "") { model.receiptAmount = decimal.Parse(ds.Rows[0]["receiptAmount"].ToString()); } if (ds.Rows[0]["realAmount"].ToString() != "") { model.realAmount = decimal.Parse(ds.Rows[0]["realAmount"].ToString()); } if (ds.Rows[0]["receiptStatusCode"].ToString() != "") { model.receiptStatusCode = int.Parse(ds.Rows[0]["receiptStatusCode"].ToString()); } model.mark = ds.Rows[0]["mark"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> public List <To_ClaimDetail> DataTableToList(DataTable dt) { List <To_ClaimDetail> modelList = new List <To_ClaimDetail>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { To_ClaimDetail model; for (int n = 0; n < rowsCount; n++) { model = new To_ClaimDetail(); if (dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } if (dt.Rows[n]["claimID"].ToString() != "") { model.claimID = int.Parse(dt.Rows[n]["claimID"].ToString()); } model.orderNum = dt.Rows[n]["orderNum"].ToString(); if (dt.Rows[n]["orderCollectId"].ToString() != "") { model.orderCollectId = int.Parse(dt.Rows[n]["orderCollectId"].ToString()); } if (dt.Rows[n]["orderCusId"].ToString() != "") { model.orderCusId = int.Parse(dt.Rows[n]["orderCusId"].ToString()); } if (dt.Rows[n]["receiptAmount"].ToString() != "") { model.receiptAmount = decimal.Parse(dt.Rows[n]["receiptAmount"].ToString()); } if (dt.Rows[n]["realAmount"].ToString() != "") { model.realAmount = decimal.Parse(dt.Rows[n]["realAmount"].ToString()); } if (dt.Rows[n]["receiptStatusCode"].ToString() != "") { model.receiptStatusCode = int.Parse(dt.Rows[n]["receiptStatusCode"].ToString()); } model.mark = dt.Rows[n]["mark"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(To_ClaimDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update To_ClaimDetail set "); strSql.Append(" claimID = @claimID , "); strSql.Append(" policyID = @policyID , "); strSql.Append(" receiptAmount = @receiptAmount , "); strSql.Append(" realAmount = @realAmount , "); strSql.Append(" receiptStatusCode = @receiptStatusCode , "); strSql.Append(" mark = @mark "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@claimID", SqlDbType.Int, 4), new SqlParameter("@orderNum", SqlDbType.VarChar, 50), new SqlParameter("@orderCollectId", SqlDbType.Int, 4), new SqlParameter("@orderCusId", SqlDbType.Int, 4), new SqlParameter("@receiptAmount", SqlDbType.Decimal, 18), new SqlParameter("@realAmount", SqlDbType.Decimal, 18), new SqlParameter("@receiptStatusCode", SqlDbType.TinyInt, 1), new SqlParameter("@mark", SqlDbType.VarChar, 500) }; parameters[0].Value = model.ID; parameters[1].Value = model.claimID; parameters[2].Value = model.orderNum; parameters[3].Value = model.orderCollectId; parameters[4].Value = model.orderCusId; parameters[5].Value = model.receiptAmount; parameters[6].Value = model.realAmount; parameters[7].Value = model.receiptStatusCode; parameters[8].Value = model.mark; int rows = DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(To_ClaimDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into To_ClaimDetail("); strSql.Append("claimID,orderNum,orderCollectId,orderCusId,receiptAmount,realAmount,receiptStatusCode,mark"); strSql.Append(") values ("); strSql.Append("@claimID,@orderNum,@orderCollectId,@orderCusId,@receiptAmount,@realAmount,@receiptStatusCode,@mark"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@claimID", SqlDbType.Int, 4), new SqlParameter("@orderNum", SqlDbType.VarChar, 50), new SqlParameter("@orderCollectId", SqlDbType.Int, 4), new SqlParameter("@orderCusId", SqlDbType.Int, 4), new SqlParameter("@receiptAmount", SqlDbType.Decimal, 18), new SqlParameter("@realAmount", SqlDbType.Decimal, 18), new SqlParameter("@receiptStatusCode", SqlDbType.TinyInt, 1), new SqlParameter("@mark", SqlDbType.VarChar, 500) }; parameters[0].Value = model.claimID; parameters[1].Value = model.orderNum; parameters[2].Value = model.orderCollectId; parameters[3].Value = model.orderCusId; parameters[4].Value = model.receiptAmount; parameters[5].Value = model.realAmount; parameters[6].Value = model.receiptStatusCode; parameters[7].Value = model.mark; //DBHelper.ExecuteCommand(strSql.ToString(), parameters); object objResult = DBHelper.GetSingle(strSql.ToString(), parameters); return(objResult == null ? 0 : Convert.ToInt32(objResult)); //using (SqlConnection conn= new SqlConnection(DBHelper.connectionString)) //{ // conn.Open(); // SqlCommand command = new SqlCommand("select @@IDENTITY", conn); // object id = command.ExecuteScalar(); // return id == null ? 0 : Convert.ToInt32(id); //} }
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()); } } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(To_ClaimDetail model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(To_ClaimDetail model) { return(dal.Add(model)); }