/// <summary> /// 绑定列表 /// </summary> private void BindList() { using (ContractProvider contProvider = new ContractProvider()) { string dFrom = string.IsNullOrWhiteSpace(DateFrom.Text.Trim()) ? string.Empty : LocalGlobal.ConvertDateFormat(DateFrom.Text.Trim()).ToString("yyyyMMdd"); string dTo = string.IsNullOrWhiteSpace(DateTo.Text.Trim()) ? string.Empty : LocalGlobal.ConvertDateFormat(DateTo.Text.Trim()).ToString("yyyyMMdd"); decimal totalAmt = 0; DataTable table = contProvider.GetShipKpDetailList(this.CurrentType, ORDNO.Text.Trim(), CUSTNO.Text.Trim(), CUSTNAME.Text.Trim(), dFrom, dTo); table.Columns.Add("NoKpAmt"); //未开票金额 table.Columns.Add("ShipNoKpQty"); //已交货未开票数量 table.Columns.Add("ShipNoKpAmt"); //已交货未开票金额 table.Columns.Add("KpNoShipQty"); //已开票未交货数量 table.Columns.Add("KpNoShipAmt"); //已开票未交货金额 foreach (DataRow row in table.Rows) { var unitPrice = Util.ToDecimal(row["UNITPRICE"].ToString()); //单价 var amt = Util.ToDecimal(row["amt"].ToString()); //明细 总价 var shipqty = Util.ToDecimal(row["shipqty"].ToString()); //已交货数量 var kpqty = Util.ToDecimal(row["kpqty"].ToString()); //已开票数量 var kpamt = Util.ToDecimal(row["kpamt"].ToString()); //已开票金额 //未开票金额 row["NoKpAmt"] = (amt - kpamt) < 0 ? "" : (amt - kpamt).ToString(); //已交货未开票数量 row["ShipNoKpQty"] = (shipqty - kpqty) < 0 ? "" : (shipqty - kpqty).ToString(); //已交货未开票金额 row["ShipNoKpAmt"] = (unitPrice * shipqty - kpamt) < 0 ? "" : (unitPrice * shipqty - kpamt).ToString(); //已开票未交货数量 row["KpNoShipQty"] = (kpqty - shipqty) < 0 ? "" : (kpqty - shipqty).ToString(); //已开票未交货金额 row["KpNoShipAmt"] = (kpamt - unitPrice * shipqty) < 0 ? "" : (kpamt - unitPrice * shipqty).ToString(); switch (this.CurrentType) { case 0: //全部 case 3: //未开票未交货 case 4: //已开票已交货 totalAmt += amt; break; case 1: //已开票未交货 totalAmt += Util.ToDecimal(row["KpNoShipAmt"].ToString()); break; case 2: //已交货未开票 totalAmt += Util.ToDecimal(row["ShipNoKpAmt"].ToString()); break; } } TotalAmt.Text = totalAmt.ToString(); List.DataSource = table; } List.DataBind(); }