/// <summary> /// 删除订单 /// </summary> /// <param name="id">订单的id值</param> private void Del(int id) { To_OrderInfo orderinfo = To_OrderInfoManager.getTo_OrderInfoById(id); if (orderinfo != null) { int jobflowid = orderinfo.JobflowID; JobFlow model = JobFlowManager.GetModel(jobflowid); if (model == null || model.auditstatus != "01") { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "del", "<script>alert('订单已删除或审核员已审核')</script>"); } else if (!To_OrderInfoManager.CanDelete(id)) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "del", "<script>alert('该订单关联过收款或付款或退款或报销,无法删除')</script>"); } else { string strdel = " jobflowid=" + jobflowid; AuditJobFlowManager.Delete(strdel); JobFlowManager.Delete(jobflowid); To_OrderInfoManager.deleteTo_OrderInfo(Convert.ToInt32(id)); To_OrderCollectDetialManager.deleteTo_OrderCollectDetialByOrderID(Convert.ToInt32(id)); To_OrderPayDetialManager.deleteTo_OrderPayDetialByOrderID(Convert.ToInt32(id)); To_OrderRefunDetialManager.deleteTo_OrderRefunDetialByOrderID(Convert.ToInt32(id)); } } }
/// <summary> /// 更新订单退款的实际信息 /// </summary> /// <param name="jobflowid"></param> public void updateOrderRetDetail(int jobflowid) { DataTable dt = To_PaymentReturnManager.GetOrderReturnDetail(" jobFlowID =" + jobflowid); for (int i = 0; i < dt.Rows.Count; i++) { string orderRetID = dt.Rows[i]["orderRetID"].ToString(); //得到退款明细所引用的订单退款明细数据的id double hasAmount = To_PaymentReturnManager.GetRealityHasAmount(orderRetID); double shouldAmount = Convert.IsDBNull(dt.Rows[i]["money"]) ? Convert.ToDouble(dt.Rows[i]["money"]) : 0; string getStatus = ""; if (hasAmount == 0) { getStatus = "未退款"; } else if (shouldAmount > hasAmount) { getStatus = "部分退款"; } else { getStatus = "完成退款"; } To_OrderRefunDetialManager.updateDetialStatusAndMoney(orderRetID, getStatus, hasAmount.ToString()); } }
/// <summary> /// 退款 /// </summary> /// <param name="id"></param> private decimal LoadRet(int id) { decimal moneyAmount = 0; decimal outmoney = 0; decimal hasAmount = 0; DataTable dt = To_OrderRefunDetialManager.getList(id); if (dt.Rows.Count > 0) { HtmlTableRow row = null; HtmlTableCell cell = null; for (int i = 0; i < dt.Rows.Count; i++) { //string[] result = GetReturnStatusAndMoney(dt.Rows[i]["orderid"].ToString(), dt.Rows[i]["cusid"].ToString(), dt.Rows[i]["money"].ToString()); row = new HtmlTableRow(); cell = new HtmlTableCell(); //退款单位 cell.Attributes.CssStyle.Add("height", "20px"); cell.InnerHtml = dt.Rows[i]["cusName"].ToString(); row.Controls.Add(cell); cell = new HtmlTableCell(); //应退金额 cell.InnerHtml = dt.Rows[i]["money"].ToString(); row.Controls.Add(cell); cell = new HtmlTableCell(); //退款状态 cell.InnerHtml = dt.Rows[i]["refundStatus"].ToString(); row.Controls.Add(cell); cell = new HtmlTableCell(); //实际退款金额 cell.InnerHtml = dt.Rows[i]["refundAmount"].ToString(); row.Controls.Add(cell); cell = new HtmlTableCell(); //备注 cell.InnerHtml = dt.Rows[i]["remark"].ToString(); row.Controls.Add(cell); this.tableback.Controls.Add(row); //应退金额合计 outmoney = 0; decimal.TryParse(dt.Rows[i]["money"].ToString(), out outmoney); moneyAmount += outmoney; //实际退款金额合计 outmoney = 0; decimal.TryParse(dt.Rows[i]["refundAmount"].ToString(), out outmoney); hasAmount += outmoney; } this.lblBackAmount.InnerText = moneyAmount.ToString("F2"); this.lblBackHasAmount.InnerText = hasAmount.ToString("F2"); } return(hasAmount); }
/// <summary> /// 保存退款信息 /// </summary> /// <param name="paymentId"></param> private void SavePaymentReturn(string paymentId) { IList <string> returnIDs = new List <string>(); To_PaymentReturn paymentReturn = new To_PaymentReturn(); paymentReturn.PaymentID = paymentId; if (hidPayReturn.Value.Trim().TrimEnd('@') != string.Empty) { IEnumerable <string> returnList = hidPayReturn.Value.Trim().TrimEnd('@').Split('@').Where(x => x.Trim() != string.Empty); if (returnList.Count() > 0) { foreach (string list in returnList) { string[] item = list.Split('$'); paymentReturn.orderRetID = int.Parse(item[0].Trim()); //订单退款信息明细表id if (!returnIDs.Contains(item[0].Trim())) { returnIDs.Add(item[0].Trim()); } paymentReturn.OrderNum = item[1].Trim(); //订单编号 paymentReturn.ShouldReturn = double.Parse(item[2].Trim()); //应退金额 paymentReturn.ReturnAmount = double.Parse(item[3].Trim()); //本次退付金额 To_PaymentReturnManager.addTo_PaymentReturn(paymentReturn); } } for (int i = 0; i < returnIDs.Count; i++) { if (returnIDs[i] != "") { double hasAmount = To_PaymentReturnManager.GetHasAmount(returnIDs[i]); //得到该退款信息明细表关联的所有退过款的金额 double shouldAmount = To_OrderRefunDetialManager.getTo_OrderRefunDetialById(int.Parse(returnIDs[i])).Money; //得到应退金额 string getstatus = ""; if (hasAmount == 0) { getstatus = "未退款"; } else if (shouldAmount > hasAmount) { getstatus = "部分退款"; } else { getstatus = "完成退款"; } To_OrderRefunDetialManager.updateDetialStatusAndMoney(returnIDs[i], getstatus, hasAmount.ToString()); } } } }
/// <summary> /// 得到订单id /// </summary> /// <param name="orderRetid">退款信息明细表id</param> /// <returns></returns> public string getOrderidRet(string orderRetid) { int id = 0; int.TryParse(orderRetid, out id); To_OrderRefunDetial model = To_OrderRefunDetialManager.getTo_OrderRefunDetialById(id); if (model != null) { return(model.Orderid.ToString()); } else { return(""); } }
/// <summary> /// 添加退款单位 /// </summary> private void addback(int orderID) { string banklist = this.hidback.Value; if (banklist != "") { string[] row = null; string[] cell = null; EtNet_Models.To_OrderRefunDetial factbank = null; if (banklist.IndexOf(',') >= 0) { row = banklist.Split(','); } else { row = new string[1] { banklist }; } if (row.Count() > 0) { for (int i = 0; i < row.Length; i++) { cell = row[i].Split('|'); if (cell[0] != "") { factbank = new EtNet_Models.To_OrderRefunDetial(); factbank.Cusid = Convert.ToInt32(cell[0]); //退款单位id factbank.CusName = cell[1]; //退款单位名称 if (cell[2] == "") //退款金额 { factbank.Money = 0; } else { factbank.Money = Convert.ToDouble(cell[2]); } factbank.RefundStatus = factbank.Money == 0 ? "完成退款" : cell[3]; //退款状态 factbank.Remark = cell[4]; //备注 factbank.Orderid = orderID; To_OrderRefunDetialManager.addTo_OrderRefunDetial(factbank); } } } } }
/// <summary> /// 删除订单 /// </summary> /// <param name="id">订单的id值</param> private void Del(int id) { To_OrderInfo orderinfo = To_OrderInfoManager.getTo_OrderInfoById(id); if (orderinfo != null) { int jobflowid = orderinfo.JobflowID; JobFlow model = JobFlowManager.GetModel(jobflowid); string strdel = " jobflowid=" + jobflowid; AuditJobFlowManager.Delete(strdel); JobFlowManager.Delete(jobflowid); To_OrderInfoManager.deleteTo_OrderInfo(Convert.ToInt32(id)); To_OrderCollectDetialManager.deleteTo_OrderCollectDetialByOrderID(Convert.ToInt32(id)); To_OrderPayDetialManager.deleteTo_OrderPayDetialByOrderID(Convert.ToInt32(id)); To_OrderRefunDetialManager.deleteTo_OrderRefunDetialByOrderID(Convert.ToInt32(id)); } }
protected void ibtnDeleteAll_Click(object sender, ImageClickEventArgs e) { string delId = ""; //先遍历取得选中项 for (int i = 0; i < this.rpPoliy.Items.Count; i++) { CheckBox cbx = (CheckBox)(rpPoliy.Items[i].FindControl("cbx")); Label lbl = (Label)rpPoliy.Items[i].FindControl("lbl"); if (cbx != null || cbx.Text != "") { if (cbx.Checked) { delId += lbl.Text + ","; } } } //去掉最后一个, delId = (delId + ")").Replace(",)", ""); IList check = delId.Split(','); for (int i = 0; i < check.Count; i++) { To_OrderInfo orderinfo = To_OrderInfoManager.getTo_OrderInfoById(Convert.ToInt32(check[i])); if (orderinfo != null) { int jobflowid = orderinfo.JobflowID; JobFlow model = JobFlowManager.GetModel(jobflowid); string strdel = " jobflowid=" + jobflowid; AuditJobFlowManager.Delete(strdel); JobFlowManager.Delete(jobflowid); To_OrderInfoManager.deleteTo_OrderInfo(Convert.ToInt32(check[i])); To_OrderCollectDetialManager.deleteTo_OrderCollectDetialByOrderID(Convert.ToInt32(check[i])); To_OrderPayDetialManager.deleteTo_OrderPayDetialByOrderID(Convert.ToInt32(check[i])); To_OrderRefunDetialManager.deleteTo_OrderRefunDetialByOrderID(Convert.ToInt32(check[i])); } } BindData(); }
/// <summary> /// 得到退款明细 /// </summary> /// <param name="orderid"></param> /// <returns></returns> public string getRefDetail(object orderid) { StringBuilder str = new StringBuilder(); str.Append("<table border='1' >"); str.Append("<tr><th width='200px'>退款单位</th><th width='80px'>应退金额</th><th width='80px'>已退金额</th><th width='80px'>未退金额</th></tr>"); DataTable dt = To_OrderRefunDetialManager.getList(int.Parse(orderid.ToString())); for (int i = 0; i < dt.Rows.Count; i++) { double money = Convert.IsDBNull(dt.Rows[i]["money"]) ? 0.0 : Convert.ToDouble(dt.Rows[i]["money"]); double refAmount = Convert.IsDBNull(dt.Rows[i]["refundAmount"]) ? 0.0 : Convert.ToDouble(dt.Rows[i]["refundAmount"]); str.Append("<tr><td>" + dt.Rows[i]["cusName"].ToString() + "</td>"); //退款单位 str.Append("<td>" + money.ToString() + "</td>"); //应退金额 str.Append("<td>" + refAmount.ToString() + "</td>"); //已退金额 str.Append("<td>" + (money - refAmount).ToString() + "</td>"); //未退金额 } str.Append("</table>"); return(str.ToString()); }