private void BindRepayRd(string strID) { string strSql = string.Format(string.Copy(strRepaySearch), strID); RepayApplyMasterDAL dalRepay = new RepayApplyMasterDAL(); DataTable dtRepay = dalRepay.GetRepayRdList(strSql); if (dtRepay == null) { return; } gvRepayList.DataSource = dtRepay; gvRepayList.DataBind(); }
protected void btnUpdateUnRepayRd_Click(object sender, EventArgs e) { BorrowApplyMasterDAL dalBorrow = new BorrowApplyMasterDAL(); RepayApplyMasterDAL dalRepay = new RepayApplyMasterDAL(); ChargeApplyMasterDAL dalCharge = new ChargeApplyMasterDAL(); foreach (GridViewRow row in gvUnRepayList.Rows) { string strId = Server.HtmlDecode(row.Cells[1].Text).ToString(); string strBorrow = Server.HtmlDecode(row.Cells[6].Text).ToString(); string strUnRepay = Server.HtmlDecode(row.Cells[7].Text).ToString(); if (string.IsNullOrWhiteSpace(strId) || string.IsNullOrWhiteSpace(strBorrow) || string.IsNullOrWhiteSpace(strUnRepay)) { continue; } string strSql_Repay = string.Format(string.Copy(strRepaySearch), strId); DataTable dtRepay = dalRepay.GetRepayRdList(strSql_Repay); if (dtRepay == null) { continue; } decimal dRepayMoney = 0; decimal dUpdateMoney = 0; decimal dBorrow = 0; decimal dUnRepay = 0; decimal.TryParse(strBorrow, out dBorrow); decimal.TryParse(strUnRepay, out dUnRepay); foreach (DataRow item in dtRepay.Rows) { decimal dRepayTemp = 0, dChage = 0; string strRepayId = string.Empty, strOrderType = string.Empty; if (item["ORDERTYPE"] == null || item["REPAYMONEY"] == null || item["CHARGEMONEY"] == null) { continue; } strRepayId = item["REPAYAPPLYDETAILID"].ToString(); strOrderType = item["ORDERTYPE"].ToString(); if (strOrderType == "Repay") { decimal.TryParse(item["REPAYMONEY"].ToString(), out dRepayTemp); } else if (strOrderType == "Charge") { decimal.TryParse(item["REPAYMONEY"].ToString(), out dRepayTemp); decimal.TryParse(item["CHARGEMONEY"].ToString(), out dChage); decimal dTemp = dBorrow - dRepayMoney; bool bUpdate = false; if (dTemp >= dChage) { if (dRepayTemp < dChage) { dRepayTemp = dChage; bUpdate = true; } } else { if (dRepayTemp != dTemp) { dRepayTemp = dTemp; bUpdate = true; } } if (bUpdate) { string strUpdateChage = string.Format(string.Copy(strChageUpdate), dRepayTemp, strRepayId); dalCharge.UpdateBySql(strUpdateChage); Literal5.Text += "已更新的冲借款" + strRepayId + ";"; } } dRepayMoney += dRepayTemp; } if (dRepayMoney == 0) { Literal4.Text += "该借款" + strId + "不存在还款;"; } if (dRepayMoney > dBorrow) { dRepayMoney = dBorrow; Literal4.Text += "还款超出借款" + strId + ";"; } dUpdateMoney = dBorrow - dRepayMoney; if (dUpdateMoney == dUnRepay) { continue; } string strUpdateBorrow = string.Format(string.Copy(strBorrowUpdate), dUpdateMoney, strId); dalBorrow.UpdateBySql(strUpdateBorrow); Literal3.Text += "已更新的借款" + strId + ";"; } }