/// <summary> /// /// </summary> public static IList <To_PaymentDetail> getTo_PaymentDetailsBySql(string strWhere) { IList <To_PaymentDetail> list = new List <To_PaymentDetail>(); string sql = " select * from To_PaymentDetail "; if (strWhere != "") { sql += " where " + strWhere; } DataTable dt = DBHelper.GetDataSet(sql); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { To_PaymentDetail to_paymentdetail = new To_PaymentDetail(); to_paymentdetail.Id = Convert.ToInt32(dr["id"]); to_paymentdetail.PaymentID = Convert.ToString(dr["paymentID"]); to_paymentdetail.OrderNum = Convert.ToString(dr["orderNum"]); to_paymentdetail.OrderPayId = Convert.ToInt32(dr["orderPayId"]); to_paymentdetail.ShouldPay = Convert.ToDouble(dr["shouldPay"]); to_paymentdetail.PayAmount = Convert.ToDouble(dr["payAmount"]); list.Add(to_paymentdetail); } } return(list); }
/// <summary> ///[To_PaymentDetail] /// </summary> public static To_PaymentDetail GetModel(int id) { To_PaymentDetail to_paymentdetail = null; string sql = "select * from To_PaymentDetail where id=@id"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@id", id) }; DataTable dt = DBHelper.GetDataSet(sql, sp); if (dt.Rows.Count > 0) { to_paymentdetail = new To_PaymentDetail(); foreach (DataRow dr in dt.Rows) { to_paymentdetail.Id = Convert.ToInt32(dr["id"]); to_paymentdetail.PaymentID = Convert.ToString(dr["paymentID"]); to_paymentdetail.OrderNum = Convert.ToString(dr["orderNum"]); to_paymentdetail.OrderPayId = Convert.ToInt32(dr["orderPayId"]); to_paymentdetail.ShouldPay = Convert.ToDouble(dr["shouldPay"]); to_paymentdetail.PayAmount = Convert.ToDouble(dr["payAmount"]); } } return(to_paymentdetail); }
/// <summary> /// 添加付款详细信息 /// </summary> /// <param name="paymentID"></param> private void SavePaymentDetail(string paymentID) { To_PaymentDetailManager bPaymentDetail = new To_PaymentDetailManager(); To_PaymentDetail mPaymentDetail = new To_PaymentDetail(); IList <string> payids = new List <string>(); mPaymentDetail.PaymentID = paymentID; if (hidPayDetail.Value.Trim().TrimEnd('@') != string.Empty) { IEnumerable <string> detailList = hidPayDetail.Value.Trim().TrimEnd('@').Split('@').Where(x => x.Trim() != string.Empty); if (detailList.Count() > 0) { foreach (string detail in detailList) { string[] detailItem = detail.Split('$'); mPaymentDetail.OrderPayId = int.Parse(detailItem[0].Trim()); //订单付款信息明细表id if (!payids.Contains(detailItem[0].Trim())) { payids.Add(detailItem[0].Trim()); } mPaymentDetail.OrderNum = detailItem[1].Trim(); //订单编号 mPaymentDetail.ShouldPay = double.Parse(detailItem[2].Trim()); //应付金额 mPaymentDetail.PayAmount = double.Parse(detailItem[3].Trim()); //本次支付金额 bPaymentDetail.Add(mPaymentDetail); } } //更新付款信息明细表的付款状态和实际付款金额 for (int i = 0; i < payids.Count; i++) { if (payids[i] != "") { double hasAmount = bPaymentDetail.GetHasAmount(payids[i].Trim()); //得到付过款的金额 double shouldAmount = To_OrderPayDetialManager.getTo_OrderPayDetialById(int.Parse(payids[i])).Money; //得到应付金额 string getstatus = ""; if (hasAmount == 0) { getstatus = "未付款"; } else if (shouldAmount > hasAmount) { getstatus = "部分付款"; } else { getstatus = "完成付款"; } To_OrderPayDetialManager.updateDetialStatusAndMoney(payids[i], getstatus, hasAmount.ToString()); } } } }
/// <summary> ///[To_PaymentDetail] /// </summary> public static int Add(To_PaymentDetail to_paymentdetail) { string sql = "insert into To_PaymentDetail([paymentID],[orderNum],[orderPayId],[shouldPay],[payAmount]) values (@paymentID,@orderNum,@orderPayId,@shouldPay,@payAmount)"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@paymentID", to_paymentdetail.PaymentID), new SqlParameter("@orderNum", to_paymentdetail.OrderNum), new SqlParameter("@orderPayId", to_paymentdetail.OrderPayId), new SqlParameter("@shouldPay", to_paymentdetail.ShouldPay), new SqlParameter("@payAmount", to_paymentdetail.PayAmount) }; return(DBHelper.ExecuteCommand(sql, sp)); }
/// <summary> /// /// </summary> public static To_PaymentDetail getTo_PaymentDetailBySql(string sql) { To_PaymentDetail to_paymentdetail = null; DataTable dt = DBHelper.GetDataSet(sql); if (dt.Rows.Count > 0) { to_paymentdetail = new To_PaymentDetail(); foreach (DataRow dr in dt.Rows) { to_paymentdetail.Id = Convert.ToInt32(dr["id"]); to_paymentdetail.PaymentID = Convert.ToString(dr["paymentID"]); to_paymentdetail.OrderNum = Convert.ToString(dr["orderNum"]); to_paymentdetail.OrderPayId = Convert.ToInt32(dr["orderPayId"]); to_paymentdetail.ShouldPay = Convert.ToDouble(dr["shouldPay"]); to_paymentdetail.PayAmount = Convert.ToDouble(dr["payAmount"]); } } return(to_paymentdetail); }
/// <summary> ///[To_PaymentDetail] /// </summary> public static bool Update(To_PaymentDetail to_paymentdetail) { string sql = "update To_PaymentDetail set paymentID=@paymentID,orderNum=@orderNum,orderPayId=@orderPayId,shouldPay=@shouldPay,payAmount=@payAmount where id=@id"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@id", to_paymentdetail.Id), new SqlParameter("@paymentID", to_paymentdetail.PaymentID), new SqlParameter("@orderNum", to_paymentdetail.OrderNum), new SqlParameter("@orderPayId", to_paymentdetail.OrderPayId), new SqlParameter("@shouldPay", to_paymentdetail.ShouldPay), new SqlParameter("@payAmount", to_paymentdetail.PayAmount) }; int rows = DBHelper.ExecuteCommand(sql, sp); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(To_PaymentDetail model) { return(To_PaymentDetailService.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(To_PaymentDetail model) { return(To_PaymentDetailService.Add(model)); }