private void BindGrid() { DateTime dtbegin, dtend; int salesman, deliveryman; DateTime.TryParse(tbx_begin.Text, out dtbegin); DateTime.TryParse(tbx_end.Text, out dtend); int.TryParse(ddl_SalesMan.SelectedValue, out salesman); int.TryParse(ddl_DeliveryMan.SelectedValue, out deliveryman); if (gv_List_Product.Visible) { DataTable dt = PBM_DeliveryBLL.GetDeliverySummary_ByProduct((int)Session["OwnerClient"], salesman, deliveryman, 0, dtbegin, dtend); int _quantity_t = 0, _quantity_p = 0; decimal _amount = 0; foreach (DataRow dr in dt.Rows) { _quantity_t += (int)dr["Quantity_T"]; _quantity_p += (int)dr["Quantity_P"]; _amount += (decimal)dr["TotalAmount"]; } DataRow row = dt.NewRow(); row["ProductName"] = "合计"; row["Quantity_T"] = _quantity_t; row["Quantity_P"] = _quantity_p; row["TotalAmount"] = _amount; dt.Rows.Add(row); gv_List_Product.DataSource = dt; gv_List_Product.DataBind(); } else if (gv_List_Client.Visible) { DataTable dt = PBM_DeliveryBLL.GetDeliverySummary_ByClient((int)Session["OwnerClient"], salesman, deliveryman, 0, dtbegin, dtend); gv_List_Client.DataSource = dt; gv_List_Client.DataBind(); } else if (gv_PayInfoSummary.Visible) { DataTable dt = PBM_DeliveryBLL.GetPayInfoSummary((int)Session["OwnerClient"], salesman, deliveryman, dtbegin, dtend); gv_PayInfoSummary.DataSource = dt; gv_PayInfoSummary.DataBind(); gv_PayInfoSummary.Visible = true; } else if (gv_PayInfoDetail.Visible) { DataTable dt = PBM_DeliveryBLL.GetPayInfoDetail((int)Session["OwnerClient"], salesman, deliveryman, dtbegin, dtend); dt = MatrixTable.Matrix(dt, new string[] { "SheetCode", "ClientName", "DeliveryManName" }, "PayModeName", "Amount"); dt.Columns["SheetCode"].ColumnName = "单号"; dt.Columns["ClientName"].ColumnName = "客户"; dt.Columns["DeliveryManName"].ColumnName = "送货人"; gv_PayInfoDetail.DataSource = dt; gv_PayInfoDetail.DataBind(); } }
protected void bt_OK_Click(object sender, EventArgs e) { int suppler = 0, warehouse = 0, salesman = 0; int.TryParse(ddl_Supplier.SelectedValue, out suppler); int.TryParse(ddl_ClientWareHouse.SelectedValue, out warehouse); int.TryParse(ddl_Salesman.SelectedValue, out salesman); if (suppler == 0) { MessageBox.Show(this, "请正确选择供货商!"); return; } if (warehouse == 0) { MessageBox.Show(this, "请正确选择采购到货仓库!"); return; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); bll.Model.Supplier = suppler; bll.Model.Client = (int)Session["OwnerClient"]; bll.Model.ClientWareHouse = warehouse; bll.Model.SalesMan = salesman; bll.Model.Classify = (int)ViewState["Classify"] == 0 ? 11 : (int)ViewState["Classify"]; bll.Model.PrepareMode = 1; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model.State = 1; bll.Model.ApproveFlag = 2; int id = bll.Add(); Response.Redirect("PurchaseDetail.aspx?ID=" + id.ToString()); //Response.Redirect("PurchaseDeail.aspx?Supplier=" + ddl_Supplier.SelectedValue + // "&WareHouse=" + ddl_ClientWareHouse.SelectedValue + "&Salesman=" + ddl_Salesman.SelectedValue); }
/// <summary> /// 保存付款信息 /// </summary> private void SavePayInfo() { if ((int)ViewState["ID"] != 0) { PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); _bll.ClearPayInfo(); decimal amount = 0; if (decimal.TryParse(tbx_PayAmount1.Text, out amount) && amount != 0) { PBM_DeliveryPayInfoBLL paybll = new PBM_DeliveryPayInfoBLL(); paybll.Model.DeliveryID = _bll.Model.ID; paybll.Model.PayMode = int.Parse(ddl_PayMode1.SelectedValue); paybll.Model.Amount = amount; paybll.Model.ApproveFlag = 2; paybll.Model.InsertStaff = (int)Session["UserID"]; paybll.Add(); } if (decimal.TryParse(tbx_PayAmount2.Text, out amount) && amount != 0) { PBM_DeliveryPayInfoBLL paybll = new PBM_DeliveryPayInfoBLL(); paybll.Model.DeliveryID = _bll.Model.ID; paybll.Model.PayMode = int.Parse(ddl_PayMode2.SelectedValue); paybll.Model.Amount = amount; paybll.Model.ApproveFlag = 2; paybll.Model.InsertStaff = (int)Session["UserID"]; paybll.Add(); } } }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if ((int)ViewState["ID"] == 0 || bll.Model == null) { Response.Redirect("SaleOutList.aspx"); } if (Session["OwnerType"] != null && (int)Session["OwnerType"] == 3 && bll.Model.Supplier != (int)Session["OwnerClient"]) { Response.Redirect("SaleOutList.aspx"); } ListTable <PBM_DeliveryDetail> listDelivery = new ListTable <PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["Details"] = listDelivery; //获取分页数量 int totlaItem = ((ListTable <PBM_DeliveryDetail>)ViewState["Details"]).GetListItem().Count; int pageNum = (totlaItem / PRINTPAGESIZE) + (totlaItem % PRINTPAGESIZE == 0 ? 0 : 1); ViewState["TotalPageCount"] = pageNum; //int[] intTemp = new int[pageNum]; //for (int i = 0; i < pageNum; i++) intTemp[i] = i; //Repeater1.DataSource = intTemp; //Repeater1.DataBind(); }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model != null) { pl_detail.BindData(bll.Model); ViewState["Details"] = new ListTable <PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["WareHouse"] = bll.Model.ClientWareHouse; ViewState["State"] = bll.Model.State; ViewState["Classify"] = bll.Model.Classify; BindGrid(); #region 界面控件可视状态 if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2) { bt_OK.Visible = false; bt_Delete.Visible = false; pl_detail.SetControlsEnable(false); gv_List.SetControlsEnable(false); } if (!((bll.Model.State == 1 && bll.Model.PrepareMode == 1) || (bll.Model.State == 3 && bll.Model.PrepareMode == 3))) { bt_Confirm.Visible = false; } #endregion } }
protected void bt_OK_Click(object sender, EventArgs e) { int client = 0, warehouse = 0, salesman = 0; int.TryParse(select_Client.SelectValue, out client); int.TryParse(ddl_SupplierWareHouse.SelectedValue, out warehouse); int.TryParse(ddl_Salesman.SelectedValue, out salesman); if (client == 0) { MessageBox.Show(this, "请正确选择零售店!"); return; } if (warehouse == 0) { MessageBox.Show(this, "请正确选择供货出库仓库!"); return; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); bll.Model.Supplier = (int)Session["OwnerClient"]; bll.Model.SupplierWareHouse = warehouse; bll.Model.Client = client; bll.Model.SalesMan = salesman; bll.Model.Classify = (int)ViewState["Classify"] == 0 ? 1 : (int)ViewState["Classify"]; bll.Model.PrepareMode = 1; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model.State = 1; bll.Model.ApproveFlag = 2; int id = bll.Add(); Response.Redirect("SaleOutDetail.aspx?ID=" + id.ToString()); }
protected void bt_Confirm_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { if (!Save()) return; PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); int ret = _bll.Confirm((int)Session["UserID"]); switch (ret) { case 0: Response.Redirect("InventoryAdjustList.aspx"); return; case -1: MessageBox.Show(this, "对不起,单据确认失败! 单据状态不可操作"); return; case -2: MessageBox.Show(this, "对不起,单据确认失败! 未指定正确的仓库"); return; case -10: MessageBox.Show(this, "对不起,单据确认失败! 库存数量不够盘亏"); return; default: MessageBox.Show(this, "对不起,单据确认失败! Ret=" + ret.ToString()); break; } Response.Redirect("InventoryAdjustList.aspx"); } }
protected void bt_BatConfirm_Click(object sender, EventArgs e) { int success = 0; foreach (GridViewRow row in gv_List.Rows) { int id = (int)gv_List.DataKeys[row.RowIndex]["PBM_Delivery_ID"]; CheckBox cbx = (CheckBox)row.FindControl("cbx"); { if (cbx != null && cbx.Checked) { PBM_DeliveryBLL _bll = new PBM_DeliveryBLL(id); if (_bll.Model == null) { continue; } if (_bll.Model.State >= 4) { continue; } IList <PBM_DeliveryPayInfo> payinfos = _bll.GetPayInfoList(); if (payinfos.Count == 0 && _bll.Model.ActAmount != 0) { #region 默认现金收款 PBM_DeliveryPayInfoBLL paybll = new PBM_DeliveryPayInfoBLL(); paybll.Model.DeliveryID = _bll.Model.ID; paybll.Model.PayMode = 1; paybll.Model.Amount = _bll.Model.ActAmount; paybll.Model.ApproveFlag = 2; paybll.Model.InsertStaff = (int)Session["UserID"]; paybll.Add(); #endregion } else if (payinfos.Sum(p => p.Amount) != _bll.Model.ActAmount) { continue; } int confirmstaff = (int)Session["UserID"]; if (_bll.Model.PrepareMode > 1 && _bll.Model.DeliveryMan > 0) { //车销与预售模式,在确认时,如果有送货人,则以送货人为确认人。以便将收款记录关联在该员工头上 confirmstaff = _bll.Model.DeliveryMan; } if (_bll.Confirm(confirmstaff) == 0) { success++; } } } } MessageBox.Show(this, "成功确认" + success.ToString() + "条发货单!"); gv_Summary.PageIndex = 0; gv_List.PageIndex = 0; BindGrid(); }
protected void bt_Delete_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); _bll.Delete(); Response.Redirect("InventoryAdjustList.aspx"); } }
protected void bt_Delete_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); _bll.Delete(); Response.Redirect("TransferList.aspx?Classify=" + _bll.Model.Classify.ToString()); } }
protected void bt_Cancel_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); _bll.Cancel((int)Session["UserID"], ""); Response.Redirect("SaleOutList.aspx?Classify=" + _bll.Model.Classify.ToString() + "&PrepareMode=" + _bll.Model.PrepareMode.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region 获取页面参数 string[] strIDs = Request.QueryString["ID"] != null ? Request.QueryString["ID"].ToString().Split(new char[] { ',' }, System.StringSplitOptions.None) : new string[] { "" }; int[] ids = new int[strIDs.Length]; bool flag = false;//为true标识转换出错退回列表界面 int classify = 0; if (strIDs == null || strIDs.Length == 0 || (strIDs.Length == 1 && string.IsNullOrEmpty(strIDs[0]))) { flag = true; } else { for (int i = 0; i < strIDs.Length; i++) { try { int _id = int.Parse(strIDs[i]); PBM_DeliveryBLL _bllDelivery = new PBM_DeliveryBLL(_id); if (_bllDelivery == null || _bllDelivery.Model.ID == 0) { flag = true; break; } if (classify == 0) { classify = _bllDelivery.Model.Classify; //初始化分类 } else if (classify != _bllDelivery.Model.Classify) { flag = true; break; } //分类不一致也退回列表界面 ids[i] = _id; } catch { flag = true; break; } } } if (flag) { if (classify > 0) { Response.Redirect("PurchaseList.aspx?Classify=" + classify.ToString()); } else { Response.Redirect("PurchaseList.aspx"); } } ViewState["ids"] = ids; #endregion Repeater2.DataSource = ids; Repeater2.DataBind(); //BindData(); } }
protected void bt_Confirm_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { if (!Save()) { return; } PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); IList <PBM_DeliveryPayInfo> payinfos = _bll.GetPayInfoList(); if (payinfos.Sum(p => p.Amount) != _bll.Model.ActAmount) { MessageBox.Show(this, "对不起,收款信息的总金额与实际销售单金额不符,不可确认!"); BindData(); return; } int confirmstaff = (int)Session["UserID"]; if (_bll.Model.PrepareMode > 1 && _bll.Model.DeliveryMan > 0) { //车销与预售模式,在确认时,如果有送货人,则以送货人为确认人。以便将收款记录关联在该员工头上 confirmstaff = _bll.Model.DeliveryMan; } int ret = _bll.Confirm(confirmstaff); switch (ret) { case 0: Response.Redirect("SaleOutList.aspx?Classify=" + _bll.Model.Classify.ToString() + "&PrepareMode=" + _bll.Model.PrepareMode.ToString()); return; case -1: MessageBox.Show(this, "对不起,单据确认失败! 单据状态不可操作"); return; case -2: case -3: MessageBox.Show(this, "对不起,单据确认失败! 未指定正确的仓库"); return; case -10: MessageBox.Show(this, "对不起,单据确认失败! 库存数量不够出库"); return; default: MessageBox.Show(this, "对不起,单据确认失败! Ret=" + ret.ToString()); break; } Response.Redirect("SaleOutList.aspx?Classify=" + _bll.Model.Classify.ToString() + "&PrepareMode=" + _bll.Model.PrepareMode.ToString()); } }
protected void bt_BatConfirm_Click(object sender, EventArgs e) { int success = 0; foreach (GridViewRow row in gv_List.Rows) { int id = (int)gv_List.DataKeys[row.RowIndex]["PBM_Delivery_ID"]; CheckBox cbx = (CheckBox)row.FindControl("cbx"); { if (cbx != null && cbx.Checked) { PBM_DeliveryBLL _bll = new PBM_DeliveryBLL(id); if (_bll.Model == null) continue; if (_bll.Model.State >= 4) continue; IList<PBM_DeliveryPayInfo> payinfos = _bll.GetPayInfoList(); if (payinfos.Count == 0 && _bll.Model.ActAmount != 0) { #region 默认现金收款 PBM_DeliveryPayInfoBLL paybll = new PBM_DeliveryPayInfoBLL(); paybll.Model.DeliveryID = _bll.Model.ID; paybll.Model.PayMode = 1; paybll.Model.Amount = _bll.Model.ActAmount; paybll.Model.ApproveFlag = 2; paybll.Model.InsertStaff = (int)Session["UserID"]; paybll.Add(); #endregion } else if (payinfos.Sum(p => p.Amount) != _bll.Model.ActAmount) { continue; } int confirmstaff = (int)Session["UserID"]; if (_bll.Model.PrepareMode > 1 && _bll.Model.DeliveryMan > 0) { //车销与预售模式,在确认时,如果有送货人,则以送货人为确认人。以便将收款记录关联在该员工头上 confirmstaff = _bll.Model.DeliveryMan; } if (_bll.Confirm(confirmstaff) == 0) success++; } } } MessageBox.Show(this, "成功确认" + success.ToString() + "条发货单!"); gv_Summary.PageIndex = 0; gv_List.PageIndex = 0; BindGrid(); }
protected void bt_Confirm_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { if (!Save()) { return; } PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); IList <PBM_DeliveryPayInfo> payinfos = _bll.GetPayInfoList(); if (payinfos.Sum(p => p.Amount) != _bll.Model.ActAmount) { BindData(); MessageBox.Show(this, "对不起,付款信息的总金额与实际采购单金额不符,不可确认!"); return; } int ret = _bll.Confirm((int)Session["UserID"]); switch (ret) { case 0: Response.Redirect("PurchaseList.aspx?Classify=" + _bll.Model.Classify.ToString()); return; case -1: MessageBox.Show(this, "对不起,单据确认失败! 单据状态不可操作"); return; case -2: case -3: MessageBox.Show(this, "对不起,单据确认失败! 未指定正确的仓库"); return; case -10: MessageBox.Show(this, "对不起,单据确认失败! 库存数量不够出库"); return; default: MessageBox.Show(this, "对不起,单据确认失败! Ret=" + ret.ToString()); break; } Response.Redirect("PurchaseList.aspx?Classify=" + _bll.Model.Classify.ToString()); } }
private void BindData() { DataTable dt = PBM_DeliveryBLL.GetNeedDeliverySummary((DateTime)ViewState["PreArrivalDate_BeginDate"], (DateTime)ViewState["PreArrivalDate_EndDate"], (int)Session["OwnerClient"], (int)ViewState["SupplierWareHouse"], (int)ViewState["SalesMan"], (int)ViewState["DeliveryMan"]); #region 求合计行 int q_t = 0, q_p = 0; decimal w = 0, a = 0; foreach (DataRow row in dt.Rows) { q_t += (int)row["Quantity_T"]; q_p += (int)row["Quantity_P"]; a += (decimal)row["Amount"]; w += (decimal)row["Weight"]; } DataRow dr = dt.NewRow(); dr["ProductName"] = "合计"; dr["Quantity_T"] = q_t; dr["Packagint_T"] = "件"; dr["Quantity_P"] = q_p; dr["Packagint_P"] = "散"; dr["Amount"] = a; dr["Weight"] = w; dt.Rows.Add(dr); #endregion ViewState["DataTable"] = dt; //获取分页数量 int totlaItem = dt.Rows.Count; int pageNum = (totlaItem / PRINTPAGESIZE) + (totlaItem % PRINTPAGESIZE == 0 ? 0 : 1); ViewState["TotalPageCount"] = pageNum; int[] intTemp = new int[pageNum]; for (int i = 0; i < pageNum; i++) { intTemp[i] = i; } Repeater1.DataSource = intTemp; Repeater1.DataBind(); }
private void FillModel(AC_ARAPList m) { if (m == null) { return; } ID = m.ID; TradeClient = m.TradeClient; Type = m.Type; Amount = m.Amount; OpStaff = m.OpStaff; RelateDeliveryId = m.RelateDeliveryId; BalanceFlag = m.BalanceFlag; BalanceDate = m.BalanceDate; CashFlowId = m.CashFlowId; Remark = m.Remark; InsertTime = m.InsertTime; TypeName = m.Type == 1 ? "应收" : "应付"; if (m.TradeClient > 0) { CM_Client c = new CM_ClientBLL(m.TradeClient).Model; if (c != null) { TradeClientName = c.FullName; } } if (m.OpStaff > 0) { Org_Staff s = new Org_StaffBLL(m.OpStaff).Model; if (s != null) { OpStaffName = s.RealName; } } if (m.RelateDeliveryId > 0) { PBM_Delivery d = new PBM_DeliveryBLL(m.RelateDeliveryId).Model; RelateDeliveryCode = d.SheetCode == "" ? d.ID.ToString() : d.SheetCode; } }
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { int[] ids = ViewState["ids"] as int[]; ViewState["ID"] = ids[e.Item.ItemIndex]; PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if ((int)ViewState["ID"] == 0 || bll.Model == null) { Response.Redirect("SaleOutList.aspx"); } if (Session["OwnerType"] != null && (int)Session["OwnerType"] == 3 && bll.Model.Supplier != (int)Session["OwnerClient"]) { Response.Redirect("SaleOutList.aspx"); } ListTable <PBM_DeliveryDetail> listDelivery = new ListTable <PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["Details"] = listDelivery; //获取分页数量 int totlaItem = ((ListTable <PBM_DeliveryDetail>)ViewState["Details"]).GetListItem().Count; int pageNum = (totlaItem / PRINTPAGESIZE) + (totlaItem % PRINTPAGESIZE == 0 ? 0 : 1); ViewState["TotalPageCount"] = pageNum; int[] intTemp = new int[pageNum]; for (int i = 0; i < pageNum; i++) { intTemp[i] = i; } Repeater Repeater1 = (Repeater)e.Item.FindControl("Repeater1"); if (intTemp.Count() > 0 && Repeater1 != null) { Repeater1.DataSource = intTemp; Repeater1.DataBind(); } Literal _c = (Literal)e.Item.FindControl("lb_RepeaterNextPage2"); if (e.Item.ItemIndex > 0 && _c != null) { _c.Text = "<br/><div class='PageNext'></div><br/>"; } } }
protected void bt_OK_Click(object sender, EventArgs e) { int warehouse = 0; int.TryParse(ddl_SupplierWareHouse.SelectedValue, out warehouse); if (warehouse == 0) { MessageBox.Show(this, "请正确选择供货出库仓库!"); return; } int id = PBM_DeliveryBLL.AdjustInit(warehouse, (int)Session["UserID"]); if (id < 0) { MessageBox.Show(this, "创建盘点单失败!RET=" + id.ToString()); return; } Response.Redirect("InventoryAdjustDetail.aspx?ID=" + id.ToString()); }
protected void bt_OK_Click(object sender, EventArgs e) { int supplierwarehouse = 0, clientwarehouse = 0, salesman = 0; int.TryParse(ddl_SupplierWareHouse.SelectedValue, out supplierwarehouse); int.TryParse(ddl_ClientWareHouse.SelectedValue, out clientwarehouse); int.TryParse(ddl_Salesman.SelectedValue, out salesman); if (supplierwarehouse == 0) { MessageBox.Show(this, "请正确选择调出仓库!"); return; } if (clientwarehouse == 0) { MessageBox.Show(this, "请正确选择调入仓库!"); return; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); bll.Model.Supplier = (int)Session["OwnerClient"]; bll.Model.SupplierWareHouse = supplierwarehouse; bll.Model.Client = (int)Session["OwnerClient"];; bll.Model.ClientWareHouse = clientwarehouse; bll.Model.Classify = int.Parse(ddl_Classify.SelectedValue); bll.Model.SalesMan = salesman; bll.Model.PrepareMode = 1; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model.State = 1; bll.Model.ApproveFlag = 2; int id = bll.Add(); Response.Redirect("TransferDetail.aspx?ID=" + id.ToString()); //Response.Redirect("TransferDeail.aspx?Supplier=" + ddl_Supplier.SelectedValue + // "&WareHouse=" + ddl_ClientWareHouse.SelectedValue + "&Salesman=" + ddl_Salesman.SelectedValue); }
protected void bt_Adjust_Click(object sender, EventArgs e) { int warehouse = 0; int.TryParse(ddl_WareHouse.SelectedValue, out warehouse); string ids = ""; foreach (GridViewRow row in gv_List.Rows) { long id = (long)gv_List.DataKeys[row.RowIndex]["ID"]; CheckBox cbx = (CheckBox)row.FindControl("cbx"); if (cbx != null && cbx.Checked) { ids += id.ToString() + ","; } } if (ids.EndsWith(",")) { ids = ids.Substring(0, ids.Length - 1); } if (warehouse == 0) { MessageBox.Show(this, "请指定要调整库存的仓库!"); return; } if (ids == "") { MessageBox.Show(this, "请打勾选中要调整库存的产品!"); return; } int deliveryid = PBM_DeliveryBLL.AdjustInit(warehouse, (int)Session["UserID"], ids); if (deliveryid > 0) { Response.Redirect("InventoryAdjustDetail.aspx?ID=" + deliveryid.ToString()); } }
protected void bt_Confirm_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { if (!Save()) { return; } PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); int ret = _bll.Confirm((int)Session["UserID"]); switch (ret) { case 0: Response.Redirect("InventoryAdjustList.aspx"); return; case -1: MessageBox.Show(this, "对不起,单据确认失败! 单据状态不可操作"); return; case -2: MessageBox.Show(this, "对不起,单据确认失败! 未指定正确的仓库"); return; case -10: MessageBox.Show(this, "对不起,单据确认失败! 库存数量不够盘亏"); return; default: MessageBox.Show(this, "对不起,单据确认失败! Ret=" + ret.ToString()); break; } Response.Redirect("InventoryAdjustList.aspx"); } }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model != null) { pl_detail.BindData(bll.Model); ViewState["Client"] = bll.Model.Client; ViewState["Supplier"] = bll.Model.Supplier; ViewState["Details"] = new ListTable <PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["WareHouse"] = bll.Model.SupplierWareHouse; ViewState["State"] = bll.Model.State; ViewState["Classify"] = bll.Model.Classify; BindGrid(); #region 界面控件可视状态 if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2) { bt_OK.Visible = false; tb_AddDetail.Visible = false; bt_Delete.Visible = false; pl_detail.SetControlsEnable(false); tr_AddDetail.Visible = false; gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = false; } if (!((bll.Model.State == 1 && bll.Model.PrepareMode == 1) || (bll.Model.State == 3 && bll.Model.PrepareMode == 3))) { bt_Confirm.Visible = false; } #endregion bt_Print.OnClientClick = "javascript:doprint(" + bll.Model.ID.ToString() + ");"; } }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model != null) { pl_detail.BindData(bll.Model); ViewState["Client"] = bll.Model.Client; ViewState["Supplier"] = bll.Model.Supplier; ViewState["Details"] = new ListTable<PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["WareHouse"] = bll.Model.SupplierWareHouse; ViewState["State"] = bll.Model.State; ViewState["Classify"] = bll.Model.Classify; BindGrid(); #region 界面控件可视状态 if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2) { bt_OK.Visible = false; tb_AddDetail.Visible = false; bt_Delete.Visible = false; pl_detail.SetControlsEnable(false); tr_AddDetail.Visible = false; gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = false; } if (!((bll.Model.State == 1 && bll.Model.PrepareMode == 1) || (bll.Model.State == 3 && bll.Model.PrepareMode == 3))) { bt_Confirm.Visible = false; } #endregion bt_Print.OnClientClick = "javascript:doprint(" + bll.Model.ID.ToString() + ");"; } }
/// <summary> /// 验证销售单,当在执行预售送货时,或在收款单变更了销售单明细时,需要调用此接口更新销售单 /// </summary> /// <param name="User"></param> /// <param name="DeliveryInfo"></param> /// <param name="ErrorInfo"></param> /// <returns></returns> public static int SaleOut_Update(UserInfo User, Delivery DeliveryInfo, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.SaleOut_Update:UserName="******",DeliveryInfo=" + JsonConvert.SerializeObject(DeliveryInfo)); if (DeliveryInfo.ID == 0) { ErrorInfo = "销售单不存在,请先新增销售单!"; return -1; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryInfo.ID); if (bll.Model == null) { ErrorInfo = "销售单不存在,请先新增销售单!"; return -1; } if (bll.Model.State > 3 || bll.Model.ApproveFlag == 1) { ErrorInfo = "销售单状态不允许执行此操作!"; return -1; } if (bll.Model.Supplier == 0) bll.Model.Supplier = DeliveryInfo.Supplier; if (bll.Model.Client == 0) bll.Model.Client = DeliveryInfo.Client; //如果有送货车辆,默认出货仓库为该车辆所关联仓库 if (DeliveryInfo.DeliveryVehicle != 0 && DeliveryInfo.SupplierWareHouse == 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryInfo.DeliveryVehicle).Model; if (v == null) { ErrorInfo = "送货车辆无效!"; return -1; } DeliveryInfo.SupplierWareHouse = v.RelateWareHouse; } //默认业务人员为当前员工 if (DeliveryInfo.SalesMan == 0) DeliveryInfo.SalesMan = User.StaffID; #region 必填字段校验 if (bll.Model.Supplier == 0) { ErrorInfo = "无效的供货客户!"; return -2; } if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "无效的供货客户!"; return -2; } if (bll.Model.Client == 0) { ErrorInfo = "无效的购买客户!"; return -2; } if (DeliveryInfo.SupplierWareHouse == 0) { ErrorInfo = "无效的供货仓库!"; return -2; } if (DeliveryInfo.Items == null || DeliveryInfo.Items.Count == 0) { ErrorInfo = "无销售产品明细!"; return -10; } #endregion #region 保存销售单头信息 bll.Model.SalesMan = DeliveryInfo.SalesMan; bll.Model.DeliveryVehicle = DeliveryInfo.DeliveryVehicle; bll.Model.SupplierWareHouse = DeliveryInfo.SupplierWareHouse; bll.Model.WipeAmount = DeliveryInfo.WipeAmount; bll.Model.WorkList = DeliveryInfo.WorkList; bll.Model.Remark = DeliveryInfo.Remark; #endregion #region 循环处理每个订单明细 foreach (Delivery.DeliveryDetail item in DeliveryInfo.Items) { if (item.Product == 0) continue; if (item.DeliveryQuantity <= 0 && item.SignInQuantity <= 0) { if (item.DetailID == 0) continue; else bll.DeleteDetail(item.DetailID); } string lotnumber = item.LotNumber.Trim(); int quantity = 0; if (bll.Model.State == 1) quantity = item.DeliveryQuantity == 0 ? item.SignInQuantity : item.DeliveryQuantity; else quantity = item.SignInQuantity; string remark = item.Remark; PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product); if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; } PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier); if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; } if (bll.Model.Classify != 2) { //不为退货单时,判断车库存是否够销售 int inv_quantity = INV_InventoryBLL.GetProductQuantity(bll.Model.SupplierWareHouse, item.Product, lotnumber); if (quantity > inv_quantity) { ErrorInfo = "产品[" + productbll.Model.FullName + "]库存不足,当前库存:" + inv_quantity.ToString(); return -11; } } if (item.DetailID > 0) { PBM_DeliveryDetail d = bll.GetDetailModel(item.DetailID); if (bll.Model.State == 1) d.DeliveryQuantity = quantity; d.SignInQuantity = item.SignInQuantity; d.LotNumber = lotnumber; d.Remark = item.Remark; bll.UpdateDetail(d); } else { #region 新增商品明细品项 PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = item.Product; d.LotNumber = lotnumber; d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode; //默认为“销售” d.Price = PDT_StandardPriceBLL.GetSalePrice(bll.Model.Client, bll.Model.Supplier, d.Product); if (d.SalesMode == 1) d.DiscountRate = (item.DiscountRate <= 0 || item.DiscountRate > 1) ? 1 : item.DiscountRate; else d.DiscountRate = 0; d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor; d.DeliveryQuantity = item.DeliveryQuantity; d.SignInQuantity = d.DeliveryQuantity; d.Remark = item.Remark; bll.AddDetail(d); #endregion } } #endregion //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor); //计算实际销售金额 bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) * bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor) - bll.Model.WipeAmount, 2); int ret = bll.Update(); if (ret < 0) { ErrorInfo = "销售单保存失败!"; return ret; } return 0; }
/// <summary> /// 确认销售并收款 /// </summary> /// <param name="User"></param> /// <param name="WipeAmount">优惠金额</param> /// <param name="DeliveryID"></param> /// <returns></returns> public static int SaleOut_Confirm(UserInfo User, int DeliveryID, decimal WipeAmount, List<Delivery.DeliveryPayInfo> PayInfoList, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.SaleOut_Confirm:UserName="******",DeliveryID=" + DeliveryID.ToString() + ",PayInfoList=" + JsonConvert.SerializeObject(PayInfoList)); if (DeliveryID <= 0) { ErrorInfo = "销售单ID无效"; return -1; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryID); if (bll.Model == null) { ErrorInfo = "销售单ID无效"; return -1; } if (bll.Model.State > 3) { ErrorInfo = "销售单状态无效"; return -1; } if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "不可确认该销售单"; return -2; } bll.Model.WipeAmount = WipeAmount; bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) * bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor) - bll.Model.WipeAmount, 2); bll.Update(); if (Math.Abs(PayInfoList.Sum(p => p.Amount) - bll.Model.ActAmount) >= 0.1m) { ErrorInfo = "收款额与销售金额不符!"; return -20; } if (bll.Model.Classify == 1) { decimal d = PayInfoList.Sum(p => p.PayMode == 11 ? p.Amount : 0); //余额支付 if (d > 0) { AC_CurrentAccount ac = AC_CurrentAccountBLL.GetByTradeClient(bll.Model.Supplier, bll.Model.Client); if (ac == null || d > ac.PreReceivedAmount) { ErrorInfo = "预收款不够支付!当前预收款余额为:" + ac.PreReceivedAmount.ToString("0.##"); return -21; } } } #region 写入收款明细 //先清除之前的付款信息 if (bll.GetPayInfoList().Count > 0) bll.ClearPayInfo(); foreach (Delivery.DeliveryPayInfo item in PayInfoList) { PBM_DeliveryPayInfoBLL paybll = new PBM_DeliveryPayInfoBLL(); paybll.Model.DeliveryID = DeliveryID; paybll.Model.PayMode = item.PayMode; paybll.Model.Amount = item.Amount; paybll.Model.Remark = item.Remark; paybll.Model.ApproveFlag = 2; paybll.Model.InsertStaff = User.StaffID; paybll.Add(); } #endregion int ret = bll.Confirm(User.StaffID); if (ret < 0) { switch (ret) { case -10: ErrorInfo = "库存不足,确认失败!"; break; case -20: ErrorInfo = "收款额与销售金额不符!"; break; case -21: ErrorInfo = "预收款不够支付!"; break; default: ErrorInfo = "销售单确认失败!"; break; } return ret; } return 0; }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model != null) { pl_detail.BindData(bll.Model); ViewState["Details"] = new ListTable <PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["WareHouse"] = bll.Model.ClientWareHouse; ViewState["State"] = bll.Model.State; ViewState["Classify"] = bll.Model.Classify; if ((int)ViewState["Classify"] == 12) { //采购退货 rbl_ln.SelectedValue = "Y"; rbl_ln.Items.FindByValue("N").Enabled = false; rbl_ln.Items.Remove(rbl_ln.Items.FindByValue("N")); ddl_LotNumber.Visible = true; tbx_LotNumber.Visible = false; } #region 绑定付款信息 IList <PBM_DeliveryPayInfo> paylist = bll.GetPayInfoList(); if (paylist.Count == 0) { tbx_PayAmount1.Text = bll.Model.ActAmount.ToString("0.##"); } else { if (paylist.Sum(p => p.Amount) != bll.Model.ActAmount) { //收款金额与实际金额不符的,清除原收款信息 bll.ClearPayInfo(); tbx_PayAmount1.Text = bll.Model.ActAmount.ToString("0.##"); } else { if (paylist.Count > 0) { ddl_PayMode1.SelectedValue = paylist[0].PayMode.ToString(); tbx_PayAmount1.Text = paylist[0].Amount.ToString("0.##"); } if (paylist.Count > 1) { ddl_PayMode2.SelectedValue = paylist[1].PayMode.ToString(); tbx_PayAmount2.Text = paylist[1].Amount.ToString("0.##"); } } } #endregion BindGrid(); #region 界面控件可视状态 if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2) { bt_OK.Visible = false; tb_AddDetail.Visible = false; tr_AddDetail.Visible = false; bt_Delete.Visible = false; pl_detail.SetControlsEnable(false); gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = false; } if (!((bll.Model.State == 1 && bll.Model.PrepareMode == 1) || (bll.Model.State == 3 && bll.Model.PrepareMode == 3))) { ddl_PayMode1.Enabled = false; ddl_PayMode2.Enabled = false; tbx_PayAmount1.Enabled = false; tbx_PayAmount2.Enabled = false; bt_Confirm.Visible = false; } #endregion bt_Print.OnClientClick = "javascript:doprint(" + bll.Model.ID.ToString() + ");"; } }
private bool Save() { if (ViewState["Details"] == null) { return(false); } ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"]; PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.Supplier == 0) { MessageBox.Show(this, "请正确选择供货商!"); return(false); } if (_bll.Model.SupplierWareHouse == 0) { MessageBox.Show(this, "请正确选择盘点仓库!"); return(false); } #endregion #region 循环设置盘点调整数量 foreach (GridViewRow row in gv_List.Rows) { int _id = (int)gv_List.DataKeys[row.RowIndex]["ID"]; PBM_DeliveryDetail d = Details[_id.ToString()]; if (d == null) { continue; } int quantity = 0; TextBox tbx_Quantity_T = (TextBox)row.FindControl("tbx_Quantity_T"); TextBox tbx_Quantity_P = (TextBox)row.FindControl("tbx_Quantity_P"); if (tbx_Quantity_T != null) { int.TryParse(tbx_Quantity_T.Text, out quantity); d.DeliveryQuantity = quantity * d.ConvertFactor; } if (tbx_Quantity_P != null) { int.TryParse(tbx_Quantity_P.Text, out quantity); d.DeliveryQuantity += quantity; } DropDownList ddl_Mode = (DropDownList)row.FindControl("ddl_Mode"); if (ddl_Mode != null && ddl_Mode.SelectedValue == "D") { int inv_quantity = 0; int.TryParse(d["PreInventoryQuantity"], out inv_quantity); if (inv_quantity < d.DeliveryQuantity) { MessageBox.Show(this, "盘亏数量不能大于当前库存!"); return(false); } d.DeliveryQuantity = -1 * d.DeliveryQuantity; d.SignInQuantity = d.DeliveryQuantity; } Details.Update(d); } #endregion _bll.Model.DiscountAmount = 0; _bll.Model.WipeAmount = 0; //实际成交价 _bll.Model.ActAmount = Math.Round(Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor), 2); if ((int)ViewState["ID"] != 0) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; #region 保存明细 foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Modified)) { _bll.UpdateDetail(d); } #endregion if (_bll.Update() == 0) { return(true); } } return(false); }
protected void bt_AddDetail_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] == 0) { return; } PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (ViewState["Details"] == null) { return; } ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"]; int product = 0; int.TryParse(select_Product.SelectValue, out product); //int.TryParse(RadComboBox1.SelectedValue, out product); if (product != 0) { PDT_ProductBLL productbll = new PDT_ProductBLL(product, true); if (productbll.Model == null) { return; } if (productbll.Model.ConvertFactor == 0) { productbll.Model.ConvertFactor = 1; productbll.Update(); } string lotnumber = ""; int quantity = 0; decimal price = 0; DateTime producedate = new DateTime(1900, 1, 1); int.TryParse(tbx_Quantity.Text, out quantity); decimal.TryParse(tbx_Price.Text, out price); DateTime.TryParse(tbx_ProductDate.Text, out producedate); if (producedate.Year < 1900) { producedate = new DateTime(1900, 1, 1); } if (ddl_Unit.SelectedValue == "T") { //整件单位 quantity = quantity * productbll.Model.ConvertFactor; price = price / productbll.Model.ConvertFactor; } if (quantity == 0) { //MessageBox.Show(this, "请选择采购数量!"); return; } lotnumber = rbl_ln.SelectedValue == "N" ? tbx_LotNumber.Text : ddl_LotNumber.SelectedValue; if (lotnumber == "" && producedate.Year > 1900) { lotnumber = producedate.ToString("yyyyMMdd"); } if ((int)ViewState["Classify"] == 12) { #region 判断库存数量是否够退货 int inv_quantity = INV_InventoryBLL.GetProductQuantity((int)ViewState["WareHouse"], product, lotnumber); if (quantity > inv_quantity) { MessageBox.Show(this, "库存不足,不可采购退货!"); return; } #endregion } PBM_DeliveryDetail d = null; if (ViewState["SelectedDetail"] != null) { d = (PBM_DeliveryDetail)ViewState["SelectedDetail"]; } else { d = new PBM_DeliveryDetail(); d.DeliveryID = (int)ViewState["ID"]; if (Details.GetListItem().Count == 0) { d.ID = 1; } else { d.ID = Details.GetListItem().Max(p => p.ID) + 1; } } decimal discountrate = 100; decimal.TryParse(tbx_DiscountRate.Text, out discountrate); d.Product = product; d.LotNumber = lotnumber; d.ProductDate = producedate.Year < 1900 ? new DateTime(1900, 1, 1) : producedate; d.CostPrice = price; d.Price = d.CostPrice; d.DiscountRate = discountrate / 100; //默认100为全价 d.ConvertFactor = productbll.Model.ConvertFactor; d.DeliveryQuantity = quantity; d.SignInQuantity = d.DeliveryQuantity; d.LostQuantity = 0; d.BadQuantity = 0; d.SalesMode = int.Parse(ddl_SalesMode.SelectedValue); if (d.SalesMode == 2) { d.Price = 0; } //赠送模式采购价自动设为0 if (ViewState["SelectedDetail"] != null) { Details.Update(d); ViewState["SelectedDetail"] = null; bt_AddDetail.Text = "新 增"; gv_List.SelectedIndex = -1; } else { Details.Add(d); //_bll.AddDetail(d); } tbx_LotNumber.Text = ""; tbx_Quantity.Text = "0"; BindGrid(); } }
protected void bt_Confirm_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { if (!Save()) return; PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); IList<PBM_DeliveryPayInfo> payinfos = _bll.GetPayInfoList(); if (payinfos.Sum(p => p.Amount) != _bll.Model.ActAmount) { BindData(); MessageBox.Show(this, "对不起,付款信息的总金额与实际采购单金额不符,不可确认!"); return; } int ret = _bll.Confirm((int)Session["UserID"]); switch (ret) { case 0: Response.Redirect("PurchaseList.aspx?Classify=" + _bll.Model.Classify.ToString()); return; case -1: MessageBox.Show(this, "对不起,单据确认失败! 单据状态不可操作"); return; case -2: case -3: MessageBox.Show(this, "对不起,单据确认失败! 未指定正确的仓库"); return; case -10: MessageBox.Show(this, "对不起,单据确认失败! 库存数量不够出库"); return; default: MessageBox.Show(this, "对不起,单据确认失败! Ret=" + ret.ToString()); break; } Response.Redirect("PurchaseList.aspx?Classify=" + _bll.Model.Classify.ToString()); } }
protected void bt_AddDetail_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] == 0) return; PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (ViewState["Details"] == null) return; ListTable<PBM_DeliveryDetail> Details = (ListTable<PBM_DeliveryDetail>)ViewState["Details"]; int product = 0; int.TryParse(select_Product.SelectValue, out product); //int.TryParse(RadComboBox1.SelectedValue, out product); if (product != 0) { PDT_ProductBLL productbll = new PDT_ProductBLL(product, true); if (productbll.Model == null) return; if (productbll.Model.ConvertFactor == 0) { productbll.Model.ConvertFactor = 1; productbll.Update(); } string lotnumber = ""; int quantity = 0; decimal price = 0; DateTime producedate = new DateTime(1900, 1, 1); int.TryParse(tbx_Quantity.Text, out quantity); decimal.TryParse(tbx_Price.Text, out price); DateTime.TryParse(tbx_ProductDate.Text, out producedate); if (producedate.Year < 1900) producedate = new DateTime(1900, 1, 1); if (ddl_Unit.SelectedValue == "T") { //整件单位 quantity = quantity * productbll.Model.ConvertFactor; price = price / productbll.Model.ConvertFactor; } if (quantity == 0) { //MessageBox.Show(this, "请选择采购数量!"); return; } lotnumber = rbl_ln.SelectedValue == "N" ? tbx_LotNumber.Text : ddl_LotNumber.SelectedValue; if (lotnumber == "" && producedate.Year > 1900) lotnumber = producedate.ToString("yyyyMMdd"); if ((int)ViewState["Classify"] == 12) { #region 判断库存数量是否够退货 int inv_quantity = INV_InventoryBLL.GetProductQuantity((int)ViewState["WareHouse"], product, lotnumber); if (quantity > inv_quantity) { MessageBox.Show(this, "库存不足,不可采购退货!"); return; } #endregion } PBM_DeliveryDetail d = null; if (ViewState["SelectedDetail"] != null) { d = (PBM_DeliveryDetail)ViewState["SelectedDetail"]; } else { d = new PBM_DeliveryDetail(); d.DeliveryID = (int)ViewState["ID"]; if (Details.GetListItem().Count == 0) d.ID = 1; else d.ID = Details.GetListItem().Max(p => p.ID) + 1; } decimal discountrate = 100; decimal.TryParse(tbx_DiscountRate.Text, out discountrate); d.Product = product; d.LotNumber = lotnumber; d.ProductDate = producedate.Year < 1900 ? new DateTime(1900, 1, 1) : producedate; d.CostPrice = price; d.Price = d.CostPrice; d.DiscountRate = discountrate / 100; //默认100为全价 d.ConvertFactor = productbll.Model.ConvertFactor; d.DeliveryQuantity = quantity; d.SignInQuantity = d.DeliveryQuantity; d.LostQuantity = 0; d.BadQuantity = 0; d.SalesMode = int.Parse(ddl_SalesMode.SelectedValue); if (d.SalesMode == 2) { d.Price = 0; } //赠送模式采购价自动设为0 if (ViewState["SelectedDetail"] != null) { Details.Update(d); ViewState["SelectedDetail"] = null; bt_AddDetail.Text = "新 增"; gv_List.SelectedIndex = -1; } else { Details.Add(d); //_bll.AddDetail(d); } tbx_LotNumber.Text = ""; tbx_Quantity.Text = "0"; BindGrid(); } }
private void FillModel(AC_ARAPList m) { if (m == null) return; ID = m.ID; TradeClient = m.TradeClient; Type = m.Type; Amount = m.Amount; OpStaff = m.OpStaff; RelateDeliveryId = m.RelateDeliveryId; BalanceFlag = m.BalanceFlag; BalanceDate = m.BalanceDate; CashFlowId = m.CashFlowId; Remark = m.Remark; InsertTime = m.InsertTime; TypeName = m.Type == 1 ? "应收" : "应付"; if (m.TradeClient > 0) { CM_Client c = new CM_ClientBLL(m.TradeClient).Model; if (c != null) TradeClientName = c.FullName; } if (m.OpStaff > 0) { Org_Staff s = new Org_StaffBLL(m.OpStaff).Model; if (s != null) OpStaffName = s.RealName; } if (m.RelateDeliveryId > 0) { PBM_Delivery d = new PBM_DeliveryBLL(m.RelateDeliveryId).Model; RelateDeliveryCode = d.SheetCode == "" ? d.ID.ToString() : d.SheetCode; } }
public void ImportSAPService() { while (bIsRunning) { try { ImportExcelTDP.SAP_ZSD.Z_SD_SD_SHService sd = new ImportExcelTDP.SAP_ZSD.Z_SD_SD_SHService(); NetworkCredential c = new NetworkCredential(); c.UserName = ConfigHelper.GetConfigString("SAP_ZSD_User"); c.Password = ConfigHelper.GetConfigString("SAP_ZSD_Password"); sd.Credentials = c; ImportExcelTDP.SAP_ZSD.Ztdplog[] results1 = new ImportExcelTDP.SAP_ZSD.Ztdplog[1024]; ImportExcelTDP.SAP_ZSD.Ztdplog[] results2 = new ImportExcelTDP.SAP_ZSD.Ztdplog[1024]; sd.ZSdSdSh("1", "5200", DateTime.Today.AddDays(-1).ToString("yyyyMMdd"), ref results1); sd.ZSdSdSh("2", "5200", DateTime.Today.AddDays(-1).ToString("yyyyMMdd"), ref results1); sd.ZSdSdSh("1", "5200", DateTime.Today.ToString("yyyyMMdd"), ref results1); sd.ZSdSdSh("2", "5200", DateTime.Today.ToString("yyyyMMdd"), ref results2); List<ImportExcelTDP.SAP_ZSD.Ztdplog> results = new List<ImportExcelTDP.SAP_ZSD.Ztdplog>(); results.AddRange(results1); results.AddRange(results2); SendMessage("ImportSAPService", "获取到" + results.Count().ToString() + "条发货数量!"); if (results.Count() == 0) { Thread.Sleep(3600 * 1000); continue; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); decimal totalamount = 0; foreach (ImportExcelTDP.SAP_ZSD.Ztdplog item in results.OrderBy(p => p.Vgbel)) { if (item.Vgbel != bll.Model.SheetCode) { #region 更新发货单 if (bll.Model.SheetCode != "" && bll.Items.Count > 0) { //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor); //明细合计金额 decimal actamount = Math.Round(bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor), 2); //优惠金额(明细合计金额与实际采购金额的差额) bll.Model.WipeAmount = actamount - totalamount; //计算实际销售金额 bll.Model.ActAmount = (bll.Model.Classify == 12 ? -1 : 1) * (actamount - bll.Model.WipeAmount); int ret = bll.Add(); if (ret > 0) SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",正在提交,总金额" + bll.Model.ActAmount.ToString("0.##") + "!"); else SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",提交失败!Ret=" + ret.ToString()); bll = null; totalamount = 0; } #endregion #region 新增采购单据 //判断单号有没有导入过 if (PBM_DeliveryBLL.GetModelList("SheetCode='" + item.Vgbel + "' AND Supplier=1000 AND Classify IN (11,12)").Count > 0) { SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",之前已存在!"); continue; } bll = new PBM_DeliveryBLL(); bll.Model.Classify = 11; #region 判断TDP编码Kunage string tdpcode = item.Kunag.Substring(3); IList<CM_ClientManufactInfo> _clients = CM_ClientManufactInfoBLL.GetModelList("Code='" + tdpcode + "' AND Manufacturer=1000 AND State = 1"); if (_clients.Count == 0) { SendMessage("ImportSAPService", "门店编码无效,单据号" + item.Vgbel + ",客户编号:" + tdpcode); continue; } #endregion bll.Model.SheetCode = item.Vgbel; bll.Model.Supplier = 1000; bll.Model.Client = _clients[0].Client; #region 获取经销商主仓库 IList<CM_WareHouse> _warehouses = CM_WareHouseBLL.GetEnbaledByClient(bll.Model.Client).Where(p => p.Classify == 1).OrderBy(p => p.ID).ToList(); if (_warehouses.Count == 0) { SendMessage("ImportSAPService", "未找到客户主仓库,单据号" + item.Vgbel + ",客户编号:" + tdpcode); continue; } #endregion bll.Model.ClientWareHouse = _warehouses[0].ID; bll.Model.PrepareMode = 1; bll.Model.State = 1; //默认制单状态 bll.Model.WipeAmount = 0; bll.Model.Remark = "SAP导入"; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = 1; DateTime _prearrivaldate = DateTime.Today; DateTime.TryParse(item.WadatIst, out _prearrivaldate); bll.Model.PreArrivalDate = _prearrivaldate; #endregion } #region 新增商品明细 string productcode = item.Matnr.Substring(item.Matnr.Length - 6); IList<PDT_Product> _products = PDT_ProductBLL.GetModelList("FactoryCode='" + productcode + "' AND State=1"); if (_products.Count == 0) { SendMessage("ImportSAPService", "商品编码无效,单据号" + item.Vgbel + ",商品编号:" + productcode); continue; } int productid = _products[0].ID; PDT_ProductBLL productbll = new PDT_ProductBLL(productid); PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = productid; d.ConvertFactor = _products[0].ConvertFactor == 0 ? 1 : _products[0].ConvertFactor; d.SalesMode = 1; d.DeliveryQuantity = (int)Math.Round(item.Fkimg * d.ConvertFactor, 0); if (d.DeliveryQuantity < 0) { bll.Model.Classify = 12; //采购退库单 d.DeliveryQuantity = 0 - d.DeliveryQuantity; } d.SignInQuantity = d.DeliveryQuantity; d.CostPrice = Math.Round(item.Kzwi / d.DeliveryQuantity, 4); d.Price = d.CostPrice; d.DiscountRate = Math.Round(item.Kzwi5 / item.Kzwi, 4); d.LotNumber = item.Charg; totalamount += item.Kzwi5; DateTime _productdate = new DateTime(1900, 1, 1); DateTime.TryParse(item.Hsdat, out _productdate); if (_productdate.Year < 1900) _productdate = new DateTime(1900, 1, 1); d.ProductDate = _productdate; d.Remark = item.Fkart; bll.Items.Add(d); #endregion #region 判断是否在默认价表中 PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Client); if (extinfo == null) { extinfo = new PDT_ProductExtInfo(); extinfo.Supplier = bll.Model.Client; extinfo.Product = productid; extinfo.Category = productbll.Model.Category; extinfo.Code = productbll.Model.FactoryCode; extinfo.SalesState = 1; extinfo.BuyPrice = d.Price; extinfo.SalesPrice = d.Price; new PDT_ProductBLL(productid).SetProductExtInfo(extinfo); } #endregion } #region 更新发货单 if (bll.Model.SheetCode != "" && bll.Items.Count > 0) { //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor); //计算实际销售金额 bll.Model.ActAmount = Math.Round((bll.Model.Classify == 12 ? -1 : 1) * bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor) - bll.Model.WipeAmount, 2); int ret = bll.Add(); if (ret > 0) SendMessage("ImportSAPService", "单据号" + bll.Model.SheetCode + ",提交成功,总金额" + bll.Model.ActAmount.ToString("0.##") + "!"); else SendMessage("ImportSAPService", "单据号" + bll.Model.SheetCode + ",提交失败!Ret=" + ret.ToString()); } #endregion Thread.Sleep(3600 * 1000); } catch (ThreadAbortException e) { this.SendMessage("ImportSAPService.ThreadAbortException", e.Message); Thread.Sleep(10000); continue; } catch (Exception ex) { this.SendMessage("ImportSAPService.Exception", ex.Message); Thread.Sleep(10000); continue; } } }
private bool Save() { if (ViewState["Details"] == null) return false; ListTable<PBM_DeliveryDetail> Details = (ListTable<PBM_DeliveryDetail>)ViewState["Details"]; PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.Supplier == 0) { MessageBox.Show(this, "请正确选择供货商!"); return false; } if (_bll.Model.SupplierWareHouse == 0) { MessageBox.Show(this, "请正确选择盘点仓库!"); return false; } #endregion #region 循环设置盘点调整数量 foreach (GridViewRow row in gv_List.Rows) { int _id = (int)gv_List.DataKeys[row.RowIndex]["ID"]; PBM_DeliveryDetail d = Details[_id.ToString()]; if (d == null) continue; int quantity = 0; TextBox tbx_Quantity_T = (TextBox)row.FindControl("tbx_Quantity_T"); TextBox tbx_Quantity_P = (TextBox)row.FindControl("tbx_Quantity_P"); if (tbx_Quantity_T != null) { int.TryParse(tbx_Quantity_T.Text, out quantity); d.DeliveryQuantity = quantity * d.ConvertFactor; } if (tbx_Quantity_P != null) { int.TryParse(tbx_Quantity_P.Text, out quantity); d.DeliveryQuantity += quantity; } DropDownList ddl_Mode = (DropDownList)row.FindControl("ddl_Mode"); if (ddl_Mode != null && ddl_Mode.SelectedValue == "D") { int inv_quantity = 0; int.TryParse(d["PreInventoryQuantity"], out inv_quantity); if (inv_quantity < d.DeliveryQuantity) { MessageBox.Show(this, "盘亏数量不能大于当前库存!"); return false; } d.DeliveryQuantity = -1 * d.DeliveryQuantity; d.SignInQuantity = d.DeliveryQuantity; } Details.Update(d); } #endregion _bll.Model.DiscountAmount = 0; _bll.Model.WipeAmount = 0; //实际成交价 _bll.Model.ActAmount = Math.Round(Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor), 2); if ((int)ViewState["ID"] != 0) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; #region 保存明细 foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Modified)) { _bll.UpdateDetail(d); } #endregion if (_bll.Update() == 0) { return true; } } return false; }
private void FillModel(AC_CashFlowList m) { if (m == null) return; ID = m.ID; TradeClient = m.TradeClient; PayDate = m.PayDate; AgentStaff = m.AgentStaff; PayMode = m.PayMode; PayClassify = m.PayClassify; Amount = m.Amount; RelateDeliveryId = m.RelateDeliveryId; ConfirmState = m.ConfirmState; RelateOrderId = m.RelateOrderId; WorkList = m.WorkList; Remark = m.Remark; if (m.TradeClient > 0) { CM_Client c = new CM_ClientBLL(m.TradeClient).Model; if (c != null) TradeClientName = c.FullName; } if (m.AgentStaff > 0) { Org_Staff s = new Org_StaffBLL(m.AgentStaff).Model; if (s != null) AgentStaffName = s.RealName; } if (m.RelateDeliveryId > 0) { PBM_Delivery d = new PBM_DeliveryBLL(m.RelateDeliveryId).Model; RelateDeliveryCode = d.SheetCode == "" ? d.ID.ToString() : d.SheetCode; } if (m.RelateDeliveryId > 0) { PBM_Delivery d = new PBM_DeliveryBLL(m.RelateDeliveryId).Model; RelateDeliveryCode = d.SheetCode == "" ? d.ID.ToString() : d.SheetCode; } if (m.PayMode > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_AC_PayMode")[m.PayMode.ToString()]; if (dic != null) PayModeName = dic.Name; } if (m.PayClassify > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_AC_PayClassify")[m.PayClassify.ToString()]; if (dic != null) PayClassifyName = dic.Name; } if (m.ConfirmState > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_AC_BillConfirmState")[m.ConfirmState.ToString()]; if (dic != null) ConfirmStateName = dic.Name; } }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model != null) { pl_detail.BindData(bll.Model); ViewState["Client"] = bll.Model.Client; ViewState["Supplier"] = bll.Model.Supplier; ViewState["Details"] = new ListTable<PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["WareHouse"] = bll.Model.SupplierWareHouse; ViewState["State"] = bll.Model.State; ViewState["Classify"] = bll.Model.Classify; #region 绑定收款信息 IList<PBM_DeliveryPayInfo> paylist = bll.GetPayInfoList(); if (paylist.Count == 0) { if (bll.Model.State != 9) tbx_PayAmount1.Text = bll.Model.ActAmount.ToString("0.##"); } else { if (paylist.Sum(p => p.Amount) != bll.Model.ActAmount) { //收款金额与实际金额不符的,清除原收款信息 bll.ClearPayInfo(); if (bll.Model.State != 9) tbx_PayAmount1.Text = bll.Model.ActAmount.ToString("0.##"); } else { if (paylist.Count > 0) { ddl_PayMode1.SelectedValue = paylist[0].PayMode.ToString(); tbx_PayAmount1.Text = paylist[0].Amount.ToString("0.##"); } if (paylist.Count > 1) { ddl_PayMode2.SelectedValue = paylist[1].PayMode.ToString(); tbx_PayAmount2.Text = paylist[1].Amount.ToString("0.##"); } } } #endregion BindGrid(); #region 界面控件可视状态 if (bll.Model.State >= 4 || bll.Model.ApproveFlag == 1) { bt_OK.Visible = false; tb_AddDetail.Visible = false; tr_AddDetail.Visible = false; gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = false; } if (bll.Model.State >= 4) { bt_Cancel.Visible = false; } if (bll.Model.State != 1) bt_Delete.Visible = false; if (bll.Model.State == 9) bt_Print.Visible = false; if (!((bll.Model.State == 1 && (bll.Model.PrepareMode == 1 || bll.Model.PrepareMode == 2)) || ((bll.Model.State == 2 || bll.Model.State == 3) && bll.Model.PrepareMode == 3))) { pl_detail.SetControlsEnable(false); ddl_PayMode1.Enabled = false; ddl_PayMode2.Enabled = false; tbx_PayAmount1.Enabled = false; tbx_PayAmount2.Enabled = false; bt_Confirm.Visible = false; } if (bll.Model.PrepareMode != 1) { bt_Confirm.Text = "确认销售"; } #endregion bt_Print.OnClientClick = "javascript:doprint(" + bll.Model.ID.ToString() + ");"; } }
/// <summary> /// 取消销售单 /// </summary> /// <param name="User"></param> /// <param name="DeliveryID"></param> /// <param name="CancelReason"></param> /// <returns></returns> public static int Delivery_Cancel(UserInfo User, int DeliveryID, string CancelReason, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.Declivery_Cancel:UserName="******",DeliveryID=" + DeliveryID.ToString() + ",CancelReason=" + CancelReason); if (DeliveryID <= 0) { ErrorInfo = "销售单ID无效"; return -1; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryID); if (bll.Model == null) { ErrorInfo = "销售单ID无效"; return -1; } if (bll.Model.State > 3) { ErrorInfo = "销售单状态无效"; return -1; } if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "不可取消该销售单"; return -2; } int ret = bll.Cancel(User.StaffID, CancelReason); if (ret < 0) { ErrorInfo = "销售单取消失败!"; return -1; } return 0; }
public void ImportSAPService() { while (bIsRunning) { try { ImportExcelTDP.SAP_ZSD.Z_SD_SD_SHService sd = new ImportExcelTDP.SAP_ZSD.Z_SD_SD_SHService(); NetworkCredential c = new NetworkCredential(); c.UserName = ConfigHelper.GetConfigString("SAP_ZSD_User"); c.Password = ConfigHelper.GetConfigString("SAP_ZSD_Password"); sd.Credentials = c; ImportExcelTDP.SAP_ZSD.Ztdplog[] results1 = new ImportExcelTDP.SAP_ZSD.Ztdplog[1024]; ImportExcelTDP.SAP_ZSD.Ztdplog[] results2 = new ImportExcelTDP.SAP_ZSD.Ztdplog[1024]; sd.ZSdSdSh("1", "5200", DateTime.Today.AddDays(-1).ToString("yyyyMMdd"), ref results1); sd.ZSdSdSh("2", "5200", DateTime.Today.AddDays(-1).ToString("yyyyMMdd"), ref results1); sd.ZSdSdSh("1", "5200", DateTime.Today.ToString("yyyyMMdd"), ref results1); sd.ZSdSdSh("2", "5200", DateTime.Today.ToString("yyyyMMdd"), ref results2); List <ImportExcelTDP.SAP_ZSD.Ztdplog> results = new List <ImportExcelTDP.SAP_ZSD.Ztdplog>(); results.AddRange(results1); results.AddRange(results2); SendMessage("ImportSAPService", "获取到" + results.Count().ToString() + "条发货数量!"); if (results.Count() == 0) { Thread.Sleep(3600 * 1000); continue; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); decimal totalamount = 0; foreach (ImportExcelTDP.SAP_ZSD.Ztdplog item in results.OrderBy(p => p.Vgbel)) { if (item.Vgbel != bll.Model.SheetCode) { #region 更新发货单 if (bll.Model.SheetCode != "" && bll.Items.Count > 0) { //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor); //明细合计金额 decimal actamount = Math.Round(bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor), 2); //优惠金额(明细合计金额与实际采购金额的差额) bll.Model.WipeAmount = actamount - totalamount; //计算实际销售金额 bll.Model.ActAmount = (bll.Model.Classify == 12 ? -1 : 1) * (actamount - bll.Model.WipeAmount); int ret = bll.Add(); if (ret > 0) { SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",正在提交,总金额" + bll.Model.ActAmount.ToString("0.##") + "!"); } else { SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",提交失败!Ret=" + ret.ToString()); } bll = null; totalamount = 0; } #endregion #region 新增采购单据 //判断单号有没有导入过 if (PBM_DeliveryBLL.GetModelList("SheetCode='" + item.Vgbel + "' AND Supplier=1000 AND Classify IN (11,12)").Count > 0) { SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",之前已存在!"); continue; } bll = new PBM_DeliveryBLL(); bll.Model.Classify = 11; #region 判断TDP编码Kunage string tdpcode = item.Kunag.Substring(3); IList <CM_ClientManufactInfo> _clients = CM_ClientManufactInfoBLL.GetModelList("Code='" + tdpcode + "' AND Manufacturer=1000 AND State = 1"); if (_clients.Count == 0) { SendMessage("ImportSAPService", "门店编码无效,单据号" + item.Vgbel + ",客户编号:" + tdpcode); continue; } #endregion bll.Model.SheetCode = item.Vgbel; bll.Model.Supplier = 1000; bll.Model.Client = _clients[0].Client; #region 获取经销商主仓库 IList <CM_WareHouse> _warehouses = CM_WareHouseBLL.GetEnbaledByClient(bll.Model.Client).Where(p => p.Classify == 1).OrderBy(p => p.ID).ToList(); if (_warehouses.Count == 0) { SendMessage("ImportSAPService", "未找到客户主仓库,单据号" + item.Vgbel + ",客户编号:" + tdpcode); continue; } #endregion bll.Model.ClientWareHouse = _warehouses[0].ID; bll.Model.PrepareMode = 1; bll.Model.State = 1; //默认制单状态 bll.Model.WipeAmount = 0; bll.Model.Remark = "SAP导入"; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = 1; DateTime _prearrivaldate = DateTime.Today; DateTime.TryParse(item.WadatIst, out _prearrivaldate); bll.Model.PreArrivalDate = _prearrivaldate; #endregion } #region 新增商品明细 string productcode = item.Matnr.Substring(item.Matnr.Length - 6); IList <PDT_Product> _products = PDT_ProductBLL.GetModelList("FactoryCode='" + productcode + "' AND State=1"); if (_products.Count == 0) { SendMessage("ImportSAPService", "商品编码无效,单据号" + item.Vgbel + ",商品编号:" + productcode); continue; } int productid = _products[0].ID; PDT_ProductBLL productbll = new PDT_ProductBLL(productid); PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = productid; d.ConvertFactor = _products[0].ConvertFactor == 0 ? 1 : _products[0].ConvertFactor; d.SalesMode = 1; d.DeliveryQuantity = (int)Math.Round(item.Fkimg * d.ConvertFactor, 0); if (d.DeliveryQuantity < 0) { bll.Model.Classify = 12; //采购退库单 d.DeliveryQuantity = 0 - d.DeliveryQuantity; } d.SignInQuantity = d.DeliveryQuantity; d.CostPrice = Math.Round(item.Kzwi / d.DeliveryQuantity, 4); d.Price = d.CostPrice; d.DiscountRate = Math.Round(item.Kzwi5 / item.Kzwi, 4); d.LotNumber = item.Charg; totalamount += item.Kzwi5; DateTime _productdate = new DateTime(1900, 1, 1); DateTime.TryParse(item.Hsdat, out _productdate); if (_productdate.Year < 1900) { _productdate = new DateTime(1900, 1, 1); } d.ProductDate = _productdate; d.Remark = item.Fkart; bll.Items.Add(d); #endregion #region 判断是否在默认价表中 PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Client); if (extinfo == null) { extinfo = new PDT_ProductExtInfo(); extinfo.Supplier = bll.Model.Client; extinfo.Product = productid; extinfo.Category = productbll.Model.Category; extinfo.Code = productbll.Model.FactoryCode; extinfo.SalesState = 1; extinfo.BuyPrice = d.Price; extinfo.SalesPrice = d.Price; new PDT_ProductBLL(productid).SetProductExtInfo(extinfo); } #endregion } #region 更新发货单 if (bll.Model.SheetCode != "" && bll.Items.Count > 0) { //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor); //计算实际销售金额 bll.Model.ActAmount = Math.Round((bll.Model.Classify == 12 ? -1 : 1) * bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor) - bll.Model.WipeAmount, 2); int ret = bll.Add(); if (ret > 0) { SendMessage("ImportSAPService", "单据号" + bll.Model.SheetCode + ",提交成功,总金额" + bll.Model.ActAmount.ToString("0.##") + "!"); } else { SendMessage("ImportSAPService", "单据号" + bll.Model.SheetCode + ",提交失败!Ret=" + ret.ToString()); } } #endregion Thread.Sleep(3600 * 1000); } catch (ThreadAbortException e) { this.SendMessage("ImportSAPService.ThreadAbortException", e.Message); Thread.Sleep(10000); continue; } catch (Exception ex) { this.SendMessage("ImportSAPService.Exception", ex.Message); Thread.Sleep(10000); continue; } } }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model != null) { pl_detail.BindData(bll.Model); ViewState["Details"] = new ListTable<PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["WareHouse"] = bll.Model.ClientWareHouse; ViewState["State"] = bll.Model.State; ViewState["Classify"] = bll.Model.Classify; if ((int)ViewState["Classify"] == 12) { //采购退货 rbl_ln.SelectedValue = "Y"; rbl_ln.Items.FindByValue("N").Enabled = false; rbl_ln.Items.Remove(rbl_ln.Items.FindByValue("N")); ddl_LotNumber.Visible = true; tbx_LotNumber.Visible = false; } #region 绑定付款信息 IList<PBM_DeliveryPayInfo> paylist = bll.GetPayInfoList(); if (paylist.Count == 0) { tbx_PayAmount1.Text = bll.Model.ActAmount.ToString("0.##"); } else { if (paylist.Sum(p => p.Amount) != bll.Model.ActAmount) { //收款金额与实际金额不符的,清除原收款信息 bll.ClearPayInfo(); tbx_PayAmount1.Text = bll.Model.ActAmount.ToString("0.##"); } else { if (paylist.Count > 0) { ddl_PayMode1.SelectedValue = paylist[0].PayMode.ToString(); tbx_PayAmount1.Text = paylist[0].Amount.ToString("0.##"); } if (paylist.Count > 1) { ddl_PayMode2.SelectedValue = paylist[1].PayMode.ToString(); tbx_PayAmount2.Text = paylist[1].Amount.ToString("0.##"); } } } #endregion BindGrid(); #region 界面控件可视状态 if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2) { bt_OK.Visible = false; tb_AddDetail.Visible = false; tr_AddDetail.Visible = false; bt_Delete.Visible = false; pl_detail.SetControlsEnable(false); gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; gv_List.Columns[gv_List.Columns.Count - 2].Visible = false; } if (!((bll.Model.State == 1 && bll.Model.PrepareMode == 1) || (bll.Model.State == 3 && bll.Model.PrepareMode == 3))) { ddl_PayMode1.Enabled = false; ddl_PayMode2.Enabled = false; tbx_PayAmount1.Enabled = false; tbx_PayAmount2.Enabled = false; bt_Confirm.Visible = false; } #endregion bt_Print.OnClientClick = "javascript:doprint(" + bll.Model.ID.ToString() + ");"; } }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model == null) { return; } //设置打印换页 Literal _c = (Literal)e.Item.FindControl("lb_RepeaterNextPage"); if (e.Item.ItemIndex > 0 && _c != null) { _c.Text = "<br/><div class='PageNext'></div><br/>"; } Literal lbTitle = (Literal)e.Item.FindControl("lbTitle");//打印单标题 if (lbTitle != null) { MCSFramework.Model.Dictionary_Data dicClassify = DictionaryBLL.GetDicCollections("PBM_DeliveryClassify", true).FirstOrDefault(m => m.Key == bll.Model.Classify.ToString()).Value; lbTitle.Text = string.Format("{0} - {1}", new CM_ClientBLL(bll.Model.Supplier).Model.FullName, dicClassify); } //单号 Label lbSheetCode = (Label)e.Item.FindControl("lbSheetCode"); if (lbSheetCode != null) { lbSheetCode.Text = bll.Model.SheetCode; } //日期 Label lbDeliveryTime = (Label)e.Item.FindControl("lbDeliveryTime"); if (lbDeliveryTime != null) { lbDeliveryTime.Text = bll.Model.InsertTime.ToString("yyyy-MM-dd"); } //业务员 Label lbSalesMan = (Label)e.Item.FindControl("lbSalesMan"); Org_StaffBLL _bllStaff = new Org_StaffBLL(bll.Model.SalesMan); if (lbSalesMan != null && bll.Model.SalesMan > 0) { lbSalesMan.Text = _bllStaff.Model.RealName + "(" + _bllStaff.Model.Mobile + ")"; } //出库仓库 Label lbSupplierWareHouse = (Label)e.Item.FindControl("lbSupplierWareHouse"); if (lbSupplierWareHouse != null && bll.Model.SupplierWareHouse > 0) { lbSupplierWareHouse.Text = new CM_WareHouseBLL(bll.Model.SupplierWareHouse).Model.Name; } //零售商 Label lbClient = (Label)e.Item.FindControl("lbClient"); if (lbClient != null && bll.Model.Client > 0) { CM_Client c = new CM_ClientBLL(bll.Model.Client).Model; if (c != null) { lbClient.Text = c.FullName + " (" + c.LinkManName + ":" + c.Mobile + ")"; } } if (e.Item.ItemIndex == (int)ViewState["TotalPageCount"] - 1) { //大写金额 Label lbTotalCostCN = (Label)e.Item.FindControl("lbTotalCostCN"); if (lbTotalCostCN != null) { lbTotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(bll.Model.ActAmount); } //小写金额 Label lbTotalCost = (Label)e.Item.FindControl("lbTotalCost"); if (lbTotalCost != null) { lbTotalCost.Text = bll.Model.ActAmount.ToString("0.##元"); } Label lbWipeAmount = (Label)e.Item.FindControl("lbWipeAmount"); if (lbWipeAmount != null) { lbWipeAmount.Text = bll.Model.WipeAmount.ToString("0.##元"); } Label lbDiscountAmount = (Label)e.Item.FindControl("lbDiscountAmount"); if (lbDiscountAmount != null) { lbDiscountAmount.Text = bll.Model.DiscountAmount.ToString("0.##元"); } //总数量 Label lbTotalCount = (Label)e.Item.FindControl("lbTotalCount"); if (lbTotalCount != null) { int t, p; GetTotoalCount(out t, out p); lbTotalCount.Text = t.ToString() + "件"; if (p != 0) { lbTotalCount.Text += p.ToString() + "散"; } } } else { e.Item.FindControl("tr_TotalInfo").Visible = false; } Label lb_PageInfo = (Label)e.Item.FindControl("lb_PageInfo"); if (lb_PageInfo != null) { lb_PageInfo.Text = string.Format("第{0}页,共{1}页", e.Item.ItemIndex + 1, (int)ViewState["TotalPageCount"]); } IList <PBM_DeliveryDetail> listD = null; if (ViewState["Details"] != null) { IList <PBM_DeliveryDetail> listDelivery = ((ListTable <PBM_DeliveryDetail>)ViewState["Details"]).GetListItem(); listD = GetListNow(e.Item.ItemIndex, listDelivery); } GridView gv_List = (GridView)e.Item.FindControl("gv_List"); if (gv_List != null) { gv_List.DataSource = listD; gv_List.DataBind(); } }
private void FillModel(int DeliveryID) { PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryID); if (bll.Model == null) { ID = -1; return; } PBM_Delivery m = bll.Model; ID = m.ID; SheetCode = m.SheetCode; Supplier = m.Supplier; SupplierWareHouse = m.SupplierWareHouse; ClientWareHouse = m.ClientWareHouse; Client = m.Client; SalesMan = m.SalesMan; DeliveryMan = m.DeliveryMan; Classify = m.Classify; PrepareMode = m.PrepareMode; State = m.State; StandardPrice = m.StandardPrice; OrderID = m.OrderId; DiscountAmount = m.DiscountAmount; WipeAmount = m.WipeAmount; ActAmount = m.ActAmount; DeliveryVehicle = m.DeliveryVehicle; PreArrivalDate = m.PreArrivalDate; LoadingTime = m.LoadingTime; DepartTime = m.DepartTime; ActArriveTime = m.ActArriveTime; InsertTime = m.InsertTime; WorkList = m.WorkList; ApproveFlag = m.ApproveFlag; Remark = m.Remark; //发货单明细 Items = new List<DeliveryDetail>(); foreach (PBM_DeliveryDetail item in bll.Items) { Items.Add(new DeliveryDetail(item)); } //付款信息列表 PayInfos = new List<DeliveryPayInfo>(); foreach (PBM_DeliveryPayInfo item in bll.GetPayInfoList()) { PayInfos.Add(new DeliveryPayInfo(item)); } #region 获取各字段ID对应的名称 if (Supplier > 0) { CM_Client c = new CM_ClientBLL(Supplier).Model; if (c != null) SupplierName = c.FullName; } if (Client > 0) { CM_Client c = new CM_ClientBLL(Client).Model; if (c != null) { ClientName = c.FullName; ClientAddress = c.DeliveryAddress == "" ? c.Address : c.DeliveryAddress; ClientLinkMan = c.LinkManName; ClientTeleNum = c.Mobile == "" ? c.TeleNum : c.Mobile; } } if (SupplierWareHouse > 0) { CM_WareHouse w = new CM_WareHouseBLL(SupplierWareHouse).Model; if (w != null) SupplierWareHouseName = w.Name; } if (ClientWareHouse > 0) { CM_WareHouse w = new CM_WareHouseBLL(ClientWareHouse).Model; if (w != null) ClientWareHouseName = w.Name; } if (SalesMan > 0) { Org_Staff s = new Org_StaffBLL(SalesMan).Model; if (s != null) SalesManName = s.RealName; } if (DeliveryMan > 0) { Org_Staff s = new Org_StaffBLL(DeliveryMan).Model; if (s != null) DeliveryManName = s.RealName; } if (StandardPrice > 0) { PDT_StandardPrice s = new PDT_StandardPriceBLL(StandardPrice).Model; if (s != null) StandardPriceName = s.Name; } if (DeliveryVehicle > 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryVehicle).Model; if (v != null) DeliveryVehicleName = v.VehicleNo; } #endregion #region 获取字典表名称 try { if (m.Classify > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryClassify")[m.Classify.ToString()]; if (dic != null) ClassifyName = dic.Name; } if (m.PrepareMode > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryPrepareMode")[m.PrepareMode.ToString()]; if (dic != null) PrepareModeName = dic.Name; } if (m.State > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryState")[m.State.ToString()]; if (dic != null) StateName = dic.Name; } } catch (System.Exception err) { LogWriter.WriteLog("MCSFramework.WSI.Delivery", err); } #endregion }
private void FillModel(AC_CashFlowList m) { if (m == null) { return; } ID = m.ID; TradeClient = m.TradeClient; PayDate = m.PayDate; AgentStaff = m.AgentStaff; PayMode = m.PayMode; PayClassify = m.PayClassify; Amount = m.Amount; RelateDeliveryId = m.RelateDeliveryId; ConfirmState = m.ConfirmState; RelateOrderId = m.RelateOrderId; WorkList = m.WorkList; Remark = m.Remark; if (m.TradeClient > 0) { CM_Client c = new CM_ClientBLL(m.TradeClient).Model; if (c != null) { TradeClientName = c.FullName; } } if (m.AgentStaff > 0) { Org_Staff s = new Org_StaffBLL(m.AgentStaff).Model; if (s != null) { AgentStaffName = s.RealName; } } if (m.RelateDeliveryId > 0) { PBM_Delivery d = new PBM_DeliveryBLL(m.RelateDeliveryId).Model; RelateDeliveryCode = d.SheetCode == "" ? d.ID.ToString() : d.SheetCode; } if (m.RelateDeliveryId > 0) { PBM_Delivery d = new PBM_DeliveryBLL(m.RelateDeliveryId).Model; RelateDeliveryCode = d.SheetCode == "" ? d.ID.ToString() : d.SheetCode; } if (m.PayMode > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_AC_PayMode")[m.PayMode.ToString()]; if (dic != null) { PayModeName = dic.Name; } } if (m.PayClassify > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_AC_PayClassify")[m.PayClassify.ToString()]; if (dic != null) { PayClassifyName = dic.Name; } } if (m.ConfirmState > 0) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_AC_BillConfirmState")[m.ConfirmState.ToString()]; if (dic != null) { ConfirmStateName = dic.Name; } } }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model == null) return; //设置打印换页 Literal _c = (Literal)e.Item.FindControl("lb_RepeaterNextPage"); if (e.Item.ItemIndex > 0 && _c != null) _c.Text = "<br/><div class='PageNext'></div><br/>"; Literal lbTitle = (Literal)e.Item.FindControl("lbTitle");//打印单标题 if (lbTitle != null) { MCSFramework.Model.Dictionary_Data dicClassify = DictionaryBLL.GetDicCollections("PBM_DeliveryClassify", true).FirstOrDefault(m => m.Key == bll.Model.Classify.ToString()).Value; lbTitle.Text = string.Format("{0} - {1}", new CM_ClientBLL(bll.Model.Supplier).Model.FullName, dicClassify); } //单号 Label lbSheetCode = (Label)e.Item.FindControl("lbSheetCode"); if (lbSheetCode != null) lbSheetCode.Text = bll.Model.SheetCode; //日期 Label lbDeliveryTime = (Label)e.Item.FindControl("lbDeliveryTime"); if (lbDeliveryTime != null) lbDeliveryTime.Text = bll.Model.InsertTime.ToString("yyyy-MM-dd"); //业务员 Label lbSalesMan = (Label)e.Item.FindControl("lbSalesMan"); Org_StaffBLL _bllStaff = new Org_StaffBLL(bll.Model.SalesMan); if (lbSalesMan != null && bll.Model.SalesMan > 0) lbSalesMan.Text = _bllStaff.Model.RealName + "(" + _bllStaff.Model.Mobile + ")"; //出库仓库 Label lbSupplierWareHouse = (Label)e.Item.FindControl("lbSupplierWareHouse"); if (lbSupplierWareHouse != null && bll.Model.SupplierWareHouse > 0) lbSupplierWareHouse.Text = new CM_WareHouseBLL(bll.Model.SupplierWareHouse).Model.Name; //零售商 Label lbClient = (Label)e.Item.FindControl("lbClient"); if (lbClient != null && bll.Model.Client > 0) { CM_Client c = new CM_ClientBLL(bll.Model.Client).Model; if (c != null) { lbClient.Text = c.FullName + " (" + c.LinkManName + ":" + c.Mobile + ")"; } } if (e.Item.ItemIndex == (int)ViewState["TotalPageCount"] - 1) { //大写金额 Label lbTotalCostCN = (Label)e.Item.FindControl("lbTotalCostCN"); if (lbTotalCostCN != null) lbTotalCostCN.Text = MCSFramework.Common.Rmb.CmycurD(bll.Model.ActAmount); //小写金额 Label lbTotalCost = (Label)e.Item.FindControl("lbTotalCost"); if (lbTotalCost != null) lbTotalCost.Text = bll.Model.ActAmount.ToString("0.##元"); Label lbWipeAmount = (Label)e.Item.FindControl("lbWipeAmount"); if (lbWipeAmount != null) lbWipeAmount.Text = bll.Model.WipeAmount.ToString("0.##元"); Label lbDiscountAmount = (Label)e.Item.FindControl("lbDiscountAmount"); if (lbDiscountAmount != null) lbDiscountAmount.Text = bll.Model.DiscountAmount.ToString("0.##元"); //总数量 Label lbTotalCount = (Label)e.Item.FindControl("lbTotalCount"); if (lbTotalCount != null) { int t, p; GetTotoalCount(out t, out p); lbTotalCount.Text = t.ToString() + "件"; if (p != 0) lbTotalCount.Text += p.ToString() + "散"; } } else { e.Item.FindControl("tr_TotalInfo").Visible = false; } Label lb_PageInfo = (Label)e.Item.FindControl("lb_PageInfo"); if (lb_PageInfo != null) lb_PageInfo.Text = string.Format("第{0}页,共{1}页", e.Item.ItemIndex + 1, (int)ViewState["TotalPageCount"]); IList<PBM_DeliveryDetail> listD = null; if (ViewState["Details"] != null) { IList<PBM_DeliveryDetail> listDelivery = ((ListTable<PBM_DeliveryDetail>)ViewState["Details"]).GetListItem(); listD = GetListNow(e.Item.ItemIndex, listDelivery); } GridView gv_List = (GridView)e.Item.FindControl("gv_List"); if (gv_List != null) { gv_List.DataSource = listD; gv_List.DataBind(); } }
private void BindGrid() { gv_Summary.Visible = false; gv_List.Visible = false; bt_SummaryPrint.Visible = false; bt_DetailPrint.Visible = false; bt_BatConfirm.Enabled = false; if (MCSTabControl1.SelectedIndex == 0) { DataTable dt = PBM_DeliveryBLL.GetNeedDeliverySummary(DateTime.Parse(tbx_begin.Text), DateTime.Parse(tbx_end.Text), (int)Session["OwnerClient"], int.Parse(ddl_SupplierWareHouse.SelectedValue), int.Parse(ddl_Salesman.SelectedValue), int.Parse(ddl_DeliveryMan.SelectedValue)); #region 求合计行 int q_t = 0, q_p = 0; decimal w = 0, a = 0; foreach (DataRow row in dt.Rows) { q_t += (int)row["Quantity_T"]; q_p += (int)row["Quantity_P"]; a += (decimal)row["Amount"]; w += (decimal)row["Weight"]; } DataRow dr = dt.NewRow(); dr["ProductName"] = "合计"; dr["Quantity_T"] = q_t; dr["Packagint_T"] = "件"; dr["Quantity_P"] = q_p; dr["Packagint_P"] = "散"; dr["Amount"] = a; dr["Weight"] = w; dt.Rows.Add(dr); #endregion gv_Summary.DataSource = dt; gv_Summary.DataBind(); gv_Summary.Visible = true; bt_SummaryPrint.Visible = true; bt_SummaryPrint.OnClientClick = "javascript:window.open('" + string.Format("DeliveryListHasAssign_Print.aspx?PreArrivalDate_BeginDate={0}&PreArrivalDate_EndDate={1}&SupplierWareHouse={2}&SalesMan={3}&DeliveryMan={4}", tbx_begin.Text, tbx_end.Text, ddl_SupplierWareHouse.SelectedValue, ddl_Salesman.SelectedValue, ddl_DeliveryMan.SelectedValue) + "');"; } else { string condition = GetFindCondition(); gv_List.ConditionString = condition; gv_List.BindGrid(); gv_List.Visible = true; IList <PBM_Delivery> lists = PBM_DeliveryBLL.GetModelList(condition); string ids = ""; foreach (PBM_Delivery item in lists) { ids += item.ID.ToString() + ","; } if (ids.EndsWith(",")) { ids = ids.Substring(0, ids.Length - 1); } bt_BatConfirm.Enabled = true; bt_DetailPrint.Visible = true; bt_DetailPrint.OnClientClick = "javascript:window.open('../Delivery/SaleOut/SaleOutDetail_Print.aspx?ID=" + ids + "');"; } }
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { int[] ids = ViewState["ids"] as int[]; ViewState["ID"] = ids[e.Item.ItemIndex]; PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if ((int)ViewState["ID"] == 0 || bll.Model == null) Response.Redirect("SaleOutList.aspx"); if (Session["OwnerType"] != null && (int)Session["OwnerType"] == 3 && bll.Model.Supplier != (int)Session["OwnerClient"]) Response.Redirect("SaleOutList.aspx"); ListTable<PBM_DeliveryDetail> listDelivery = new ListTable<PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["Details"] = listDelivery; //获取分页数量 int totlaItem = ((ListTable<PBM_DeliveryDetail>)ViewState["Details"]).GetListItem().Count; int pageNum = (totlaItem / PRINTPAGESIZE) + (totlaItem % PRINTPAGESIZE == 0 ? 0 : 1); ViewState["TotalPageCount"] = pageNum; int[] intTemp = new int[pageNum]; for (int i = 0; i < pageNum; i++) intTemp[i] = i; Repeater Repeater1 = (Repeater)e.Item.FindControl("Repeater1"); if (intTemp.Count() > 0 && Repeater1 != null) { Repeater1.DataSource = intTemp; Repeater1.DataBind(); } Literal _c = (Literal)e.Item.FindControl("lb_RepeaterNextPage2"); if (e.Item.ItemIndex > 0 && _c != null) _c.Text = "<br/><div class='PageNext'></div><br/>"; } }
/// <summary> /// 新增销售发货单 /// </summary> /// <param name="User"></param> /// <param name="DeliveryInfo">发货单信息</param> /// <param name="ErrorInfo">出错消息</param> /// <returns></returns> public static int SaleOut_Add(UserInfo User, Delivery DeliveryInfo, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.SaleOut_Add:UserName="******",DeliveryInfo=" + JsonConvert.SerializeObject(DeliveryInfo)); //经销商级人员,供货商只能是自己所属的经销商 if (User.OwnerType == 3) DeliveryInfo.Supplier = User.ClientID; //如果有送货车辆,默认出货仓库为该车辆所关联仓库 if (DeliveryInfo.DeliveryVehicle != 0 && DeliveryInfo.SupplierWareHouse == 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryInfo.DeliveryVehicle).Model; if (v == null) { ErrorInfo = "送货车辆无效!"; return -1; } DeliveryInfo.SupplierWareHouse = v.RelateWareHouse; } //默认业务人员为当前员工 if (DeliveryInfo.SalesMan == 0) DeliveryInfo.SalesMan = User.StaffID; #region 必填字段校验 if (DeliveryInfo.Supplier == 0) { ErrorInfo = "无效的供货客户!"; return -2; } if (DeliveryInfo.Client == 0) { ErrorInfo = "无效的购买客户!"; return -2; } if (DeliveryInfo.SupplierWareHouse == 0) { ErrorInfo = "无效的供货仓库!"; return -2; } if (DeliveryInfo.Items == null || DeliveryInfo.Items.Count == 0) { ErrorInfo = "无销售产品明细!"; return -10; } #endregion PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); #region 保存销售单头信息 bll.Model.SheetCode = ""; bll.Model.Supplier = DeliveryInfo.Supplier; bll.Model.SupplierWareHouse = DeliveryInfo.SupplierWareHouse; bll.Model.Client = DeliveryInfo.Client; bll.Model.SalesMan = DeliveryInfo.SalesMan; bll.Model.Classify = (DeliveryInfo.Classify == 0 ? 1 : DeliveryInfo.Classify); //默认销售单 bll.Model.PrepareMode = (DeliveryInfo.PrepareMode == 0 ? 2 : DeliveryInfo.PrepareMode); //默认车销模式 bll.Model.State = 1; //默认制单状态 bll.Model.StandardPrice = DeliveryInfo.StandardPrice; bll.Model.OrderId = DeliveryInfo.OrderID; bll.Model.WipeAmount = DeliveryInfo.WipeAmount; bll.Model.DeliveryVehicle = DeliveryInfo.DeliveryVehicle; bll.Model.WorkList = DeliveryInfo.WorkList; bll.Model.Remark = DeliveryInfo.Remark; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = User.StaffID; #endregion #region 循环处理每个订单明细 foreach (Delivery.DeliveryDetail item in DeliveryInfo.Items) { if (item.Product == 0) continue; if (item.DeliveryQuantity <= 0 && item.SignInQuantity <= 0) continue; string lotnumber = item.LotNumber.Trim(); int deliveryquantity = item.DeliveryQuantity <= 0 ? item.SignInQuantity : item.DeliveryQuantity; PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product); if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; } PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier); if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; } if (bll.Model.Classify != 2) { //不为退货单时,判断车库存是否够销售 int inv_quantity = INV_InventoryBLL.GetProductQuantity(bll.Model.SupplierWareHouse, item.Product, lotnumber); if (deliveryquantity > inv_quantity) { ErrorInfo = "产品[" + productbll.Model.FullName + "]库存不足,当前库存:" + inv_quantity.ToString(); return -11; } } #region 新增销售明细 PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = item.Product; d.LotNumber = lotnumber; d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode; //默认为“销售” if (item.Price > 0) d.Price = item.Price; else d.Price = PDT_StandardPriceBLL.GetSalePrice(bll.Model.Client, bll.Model.Supplier, d.Product); //默认销售价 if (d.SalesMode == 1) d.DiscountRate = (item.DiscountRate <= 0 || item.DiscountRate > 1) ? 1 : item.DiscountRate; else d.DiscountRate = 0; //非销售时,0折销售 d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor; d.DeliveryQuantity = deliveryquantity; d.SignInQuantity = d.DeliveryQuantity; d.Remark = item.Remark; bll.Items.Add(d); #endregion } #endregion //计算折扣金额 bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor); //计算实际销售金额 bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) * bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor) - bll.Model.WipeAmount, 2); int deliveryid = bll.Add(); if (deliveryid <= 0) { ErrorInfo = "销售单保存失败!"; return deliveryid; } #region 销售单直接完成 if (DeliveryInfo.State == 4 && DeliveryInfo.PayInfos != null && DeliveryInfo.PayInfos.Count > 0) { LogWriter.WriteLog("PBMIFService.SaleOut_Add:UserName="******",DeliveryID=" + deliveryid.ToString() + ",Auto submit order!"); int ret = SaleOut_Confirm(User, deliveryid, DeliveryInfo.WipeAmount, DeliveryInfo.PayInfos, out ErrorInfo); if (ret < 0) { LogWriter.WriteLog("PBMIFService.SaleOut_Add:UserName="******",DeliveryID=" + deliveryid.ToString() + ",Auto confirm failed!ErrorInfo=" + ErrorInfo); return ret; } } #endregion return deliveryid; }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if ((int)ViewState["ID"] == 0 || bll.Model == null) Response.Redirect("SaleOutList.aspx"); if (Session["OwnerType"] != null && (int)Session["OwnerType"] == 3 && bll.Model.Supplier != (int)Session["OwnerClient"]) Response.Redirect("SaleOutList.aspx"); ListTable<PBM_DeliveryDetail> listDelivery = new ListTable<PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["Details"] = listDelivery; //获取分页数量 int totlaItem = ((ListTable<PBM_DeliveryDetail>)ViewState["Details"]).GetListItem().Count; int pageNum = (totlaItem / PRINTPAGESIZE) + (totlaItem % PRINTPAGESIZE == 0 ? 0 : 1); ViewState["TotalPageCount"] = pageNum; //int[] intTemp = new int[pageNum]; //for (int i = 0; i < pageNum; i++) intTemp[i] = i; //Repeater1.DataSource = intTemp; //Repeater1.DataBind(); }
/// <summary> /// 提交销售单,并输出提交后的订单信息 /// </summary> /// <param name="User"></param> /// <param name="DeliveryID">销售单ID</param> /// <param name="DeliveryInfo">输出:销售单结构</param> /// <param name="ErrorInfo">输出:出错信息</param> /// <returns>0:成功 小于0:失败</returns> public static int SaleOut_Submit(UserInfo User, int DeliveryID, out Delivery DeliveryInfo, out string ErrorInfo) { ErrorInfo = ""; DeliveryInfo = null; LogWriter.WriteLog("PBMIFService.SaleOut_Submit:UserName="******",DeliveryID=" + DeliveryID.ToString()); if (DeliveryID <= 0) { ErrorInfo = "销售单ID无效"; return -1; } PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryID); if (bll.Model == null) { ErrorInfo = "销售单ID无效"; return -1; } if (bll.Model.State > 3 || bll.Model.ApproveFlag == 1) { ErrorInfo = "销售单状态无效"; return -1; } if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "不可提交该销售单"; return -2; } int ret = bll.Approve(); if (ret < 0) { ErrorInfo = "销售单提交失败!"; return -1; } DeliveryInfo = new Delivery(bll.Model.ID); return 0; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region 获取页面参数 string[] strIDs = Request.QueryString["ID"] != null ? Request.QueryString["ID"].ToString().Split(new char[] { ',' }, System.StringSplitOptions.None) : new string[] { "" }; int[] ids = new int[strIDs.Length]; bool flag = false;//为true标识转换出错退回列表界面 if (strIDs == null || strIDs.Length == 0 || (strIDs.Length == 1 && string.IsNullOrEmpty(strIDs[0]))) { flag = true; } else { for (int i = 0; i < strIDs.Length; i++) { try { int _id = int.Parse(strIDs[i]); PBM_DeliveryBLL _bllDelivery = new PBM_DeliveryBLL(_id); if (_bllDelivery == null || _bllDelivery.Model.ID == 0) { flag = true; break; } ids[i] = _id; } catch { flag = true; break; } } } if (flag) { Response.Redirect("~/SubModule/desktop.aspx"); } ViewState["ids"] = ids; #endregion Repeater2.DataSource = ids; Repeater2.DataBind(); //BindData(); } }
/// <summary> /// 移库调拨申请 /// </summary> /// <param name="User"></param> /// <param name="DeliveryInfo">移库单信息</param> /// <param name="ErrorInfo">出错消息</param> /// <returns></returns> public static int TransWithVehicle(UserInfo User, Delivery DeliveryInfo, out string ErrorInfo) { ErrorInfo = ""; LogWriter.WriteLog("PBMIFService.TransWithVehicle:UserName="******",DeliveryInfo=" + JsonConvert.SerializeObject(DeliveryInfo)); //经销商级人员,供货商只能是自己所属的经销商 if (User.OwnerType == 3) { DeliveryInfo.Supplier = User.ClientID; DeliveryInfo.Client = User.ClientID; } if (DeliveryInfo.Classify != 5 && DeliveryInfo.Classify != 6) { ErrorInfo = "单据类别无效"; return -1; } #region 根据车辆设置调入或调出车仓库 //如果有送货车辆,默认出货仓库为该车辆所关联仓库 if (DeliveryInfo.DeliveryVehicle != 0) { CM_Vehicle v = new CM_VehicleBLL(DeliveryInfo.DeliveryVehicle).Model; if (v == null) { ErrorInfo = "送货车辆无效!"; return -1; } if (DeliveryInfo.Classify == 5) { //车销移库 DeliveryInfo.ClientWareHouse = v.RelateWareHouse; } else if (DeliveryInfo.Classify == 6) { //车销退库 DeliveryInfo.SupplierWareHouse = v.RelateWareHouse; } } #endregion //默认业务人员为当前员工 if (DeliveryInfo.SalesMan == 0) DeliveryInfo.SalesMan = User.StaffID; #region 必填字段校验 if (DeliveryInfo.Supplier == 0 && DeliveryInfo.SupplierWareHouse != 0) { DeliveryInfo.Supplier = new CM_WareHouseBLL(DeliveryInfo.SupplierWareHouse).Model.Client; } if (DeliveryInfo.Supplier == 0) { ErrorInfo = "无效的客户!"; return -2; } if (DeliveryInfo.SupplierWareHouse == 0) { ErrorInfo = "无效的调出仓库!"; return -2; } if (DeliveryInfo.Client == 0) { DeliveryInfo.Client = DeliveryInfo.Supplier; } if (DeliveryInfo.ClientWareHouse == 0) { ErrorInfo = "无效的调入仓库!"; return -2; } if (DeliveryInfo.Items == null || DeliveryInfo.Items.Count == 0) { ErrorInfo = "无调拨产品明细!"; return -10; } #endregion PBM_DeliveryBLL bll = new PBM_DeliveryBLL(); #region 保存发货单头信息 bll.Model.SheetCode = ""; bll.Model.Supplier = DeliveryInfo.Supplier; bll.Model.SupplierWareHouse = DeliveryInfo.SupplierWareHouse; bll.Model.Client = DeliveryInfo.Client; bll.Model.ClientWareHouse = DeliveryInfo.ClientWareHouse; bll.Model.Classify = DeliveryInfo.Classify; //5:车销移库 6:车销退库 bll.Model.SalesMan = User.StaffID; bll.Model.PrepareMode = 1; //1:快捷模式 bll.Model.State = 1; //默认制单状态 bll.Model.DeliveryVehicle = DeliveryInfo.DeliveryVehicle; bll.Model.Remark = DeliveryInfo.Remark; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = User.StaffID; #endregion #region 循环处理每个发货单明细 foreach (Delivery.DeliveryDetail item in DeliveryInfo.Items) { if (item.Product == 0) continue; if (item.DeliveryQuantity <= 0 && item.SignInQuantity <= 0) continue; string lotnumber = item.LotNumber.Trim(); int quantity = item.DeliveryQuantity <= 0 ? item.SignInQuantity : item.DeliveryQuantity; PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product); if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; } PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier); if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; } //判断库存是否够销售 int inv_quantity = INV_InventoryBLL.GetProductQuantity(bll.Model.SupplierWareHouse, item.Product, lotnumber); if (quantity > inv_quantity) { ErrorInfo = "产品[" + productbll.Model.FullName + "]库存不足,当前库存:" + inv_quantity.ToString(); return -11; } #region 新增库存明细 PBM_DeliveryDetail d = new PBM_DeliveryDetail(); d.Product = item.Product; d.LotNumber = lotnumber; d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode; //默认为“销售” d.Price = extinfo.SalesPrice; //默认销售价 d.DiscountRate = 1; d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor; d.DeliveryQuantity = quantity; d.SignInQuantity = d.DeliveryQuantity; d.Remark = item.Remark; bll.Items.Add(d); #endregion } #endregion //计算折扣金额 bll.Model.DiscountAmount = 0; bll.Model.WipeAmount = 0; //计算实际销售金额 bll.Model.ActAmount = Math.Round(bll.Items.Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor), 2); int ret = bll.Add(); if (ret <= 0) { ErrorInfo = "销售单保存失败!"; return ret; } return ret; }
protected void bt_AddDetail_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] == 0) { return; } PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (ViewState["Details"] == null) { return; } ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"]; int product = 0; int.TryParse(select_Product.SelectValue, out product); //int.TryParse(RadComboBox1.SelectedValue, out product); if (product != 0) { PDT_ProductBLL productbll = new PDT_ProductBLL(product, true); if (productbll.Model == null) { return; } if (productbll.Model.ConvertFactor == 0) { productbll.Model.ConvertFactor = 1; productbll.Update(); } int quantity = 0; decimal price = 0; int.TryParse(tbx_Quantity.Text, out quantity); decimal.TryParse(tbx_Price.Text, out price); if (ddl_Unit.SelectedValue == "T") { //整件单位 quantity = quantity * productbll.Model.ConvertFactor; price = price / productbll.Model.ConvertFactor; } if (quantity == 0) { MessageBox.Show(this, "请填写数量!"); return; } if ((int)ViewState["Classify"] != 2) { #region 销售时判断库存数量是否够退货 int inv_quantity = INV_InventoryBLL.GetProductQuantity((int)ViewState["WareHouse"], product, ddl_LotNumber.SelectedValue); if (quantity > inv_quantity) { MessageBox.Show(this, "库存不足,不可销售出库!"); return; } #endregion } INV_Inventory inv = INV_InventoryBLL.GetInventoryByProductAndLotNumber((int)ViewState["WareHouse"], product, ddl_LotNumber.SelectedValue); if (inv == null) { MessageBox.Show(this, "请正确选择销售批号!"); return; } PBM_DeliveryDetail d = null; if (ViewState["SelectedDetail"] != null) { d = (PBM_DeliveryDetail)ViewState["SelectedDetail"]; } else { d = new PBM_DeliveryDetail(); d.DeliveryID = (int)ViewState["ID"]; if (Details.GetListItem().Count == 0) { d.ID = 1; } else { d.ID = Details.GetListItem().Max(p => p.ID) + 1; } } d.Product = product; d.LotNumber = ddl_LotNumber.SelectedValue; d.CostPrice = inv.Price; //成本价取当前库存表的价格 d.Price = price; //实际销售价 d.ConvertFactor = productbll.Model.ConvertFactor; d.DiscountRate = 1; //默认全价 d.DeliveryQuantity = quantity; d.SignInQuantity = d.DeliveryQuantity; d.LostQuantity = 0; d.BadQuantity = 0; d.SalesMode = 1; if (d.SalesMode == 2) { d.Price = 0; } if (ViewState["SelectedDetail"] != null) { Details.Update(d); //_bll.UpdateDetail(d); ViewState["SelectedDetail"] = null; bt_AddDetail.Text = "新 增"; gv_List.SelectedIndex = -1; } else { Details.Add(d); //_bll.AddDetail(d); } tbx_Quantity.Text = "0"; BindGrid(); } }
protected void bt_AddDetail_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] == 0) return; PBM_DeliveryBLL _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (ViewState["Details"] == null) return; ListTable<PBM_DeliveryDetail> Details = (ListTable<PBM_DeliveryDetail>)ViewState["Details"]; int product = 0; int.TryParse(select_Product.SelectValue, out product); //int.TryParse(RadComboBox1.SelectedValue, out product); if (product != 0) { PDT_ProductBLL productbll = new PDT_ProductBLL(product, true); if (productbll.Model == null) return; if (productbll.Model.ConvertFactor == 0) { productbll.Model.ConvertFactor = 1; productbll.Update(); } int quantity = 0; decimal price = 0; int.TryParse(tbx_Quantity.Text, out quantity); decimal.TryParse(tbx_Price.Text, out price); if (ddl_Unit.SelectedValue == "T") { //整件单位 quantity = quantity * productbll.Model.ConvertFactor; price = price / productbll.Model.ConvertFactor; } if (quantity == 0) { MessageBox.Show(this, "请填写数量!"); return; } if ((int)ViewState["Classify"] != 2) { #region 销售时判断库存数量是否够退货 int inv_quantity = INV_InventoryBLL.GetProductQuantity((int)ViewState["WareHouse"], product, ddl_LotNumber.SelectedValue); if (quantity > inv_quantity) { MessageBox.Show(this, "库存不足,不可销售出库!"); return; } #endregion } INV_Inventory inv = INV_InventoryBLL.GetInventoryByProductAndLotNumber((int)ViewState["WareHouse"], product, ddl_LotNumber.SelectedValue); if (inv == null) { MessageBox.Show(this, "请正确选择销售批号!"); return; } PBM_DeliveryDetail d = null; if (ViewState["SelectedDetail"] != null) { d = (PBM_DeliveryDetail)ViewState["SelectedDetail"]; } else { d = new PBM_DeliveryDetail(); d.DeliveryID = (int)ViewState["ID"]; if (Details.GetListItem().Count == 0) d.ID = 1; else d.ID = Details.GetListItem().Max(p => p.ID) + 1; } d.Product = product; d.LotNumber = ddl_LotNumber.SelectedValue; d.CostPrice = inv.Price; //成本价取当前库存表的价格 d.Price = price; //实际销售价 d.ConvertFactor = productbll.Model.ConvertFactor; d.DiscountRate = 1; //默认全价 d.DeliveryQuantity = quantity; d.SignInQuantity = d.DeliveryQuantity; d.LostQuantity = 0; d.BadQuantity = 0; d.SalesMode = 1; if (d.SalesMode == 2) { d.Price = 0; } if (ViewState["SelectedDetail"] != null) { Details.Update(d); //_bll.UpdateDetail(d); ViewState["SelectedDetail"] = null; bt_AddDetail.Text = "新 增"; gv_List.SelectedIndex = -1; } else { Details.Add(d); //_bll.AddDetail(d); } tbx_Quantity.Text = "0"; BindGrid(); } }
private bool Save() { if (ViewState["Details"] == null) { return(false); } ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"]; PBM_DeliveryBLL _bll; if ((int)ViewState["ID"] != 0) { //修改 _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); } else { //新增 _bll = new PBM_DeliveryBLL(); } pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.Supplier == 0) { MessageBox.Show(this, "请正确选择供货商!"); return(false); } if (_bll.Model.SupplierWareHouse == 0) { MessageBox.Show(this, "请正确选择出库仓库!"); return(false); } #endregion //折扣价 _bll.Model.DiscountAmount = 0; //实际成交价 _bll.Model.ActAmount = Math.Round(Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor), 2); if ((int)ViewState["ID"] != 0) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; #region 保存明细 if (ViewState["Details"] == null) { return(false); } foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Added)) { _bll.AddDetail(d); } foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Modified)) { _bll.UpdateDetail(d); } foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Deleted)) { _bll.DeleteDetail(d.ID); } #endregion if (_bll.Update() == 0) { return(true); } } else { //新增 _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Items = Details.GetListItem(); ViewState["ID"] = _bll.Add(); if ((int)ViewState["ID"] > 0) { return(true); } } return(false); }
private bool Save() { if (ViewState["Details"] == null) return false; ListTable<PBM_DeliveryDetail> Details = (ListTable<PBM_DeliveryDetail>)ViewState["Details"]; PBM_DeliveryBLL _bll; if ((int)ViewState["ID"] != 0) { //修改 _bll = new PBM_DeliveryBLL((int)ViewState["ID"]); } else { //新增 _bll = new PBM_DeliveryBLL(); } pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.Supplier == 0) { MessageBox.Show(this, "请正确选择供货商!"); return false; } if (_bll.Model.SupplierWareHouse == 0) { MessageBox.Show(this, "请正确选择出库仓库!"); return false; } #endregion //折扣价 _bll.Model.DiscountAmount = 0; //实际成交价 _bll.Model.ActAmount = Math.Round(Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor), 2); if ((int)ViewState["ID"] != 0) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; #region 保存明细 if (ViewState["Details"] == null) return false; foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Added)) { _bll.AddDetail(d); } foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Modified)) { _bll.UpdateDetail(d); } foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Deleted)) { _bll.DeleteDetail(d.ID); } #endregion if (_bll.Update() == 0) { return true; } } else { //新增 _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Items = Details.GetListItem(); ViewState["ID"] = _bll.Add(); if ((int)ViewState["ID"] > 0) { return true; } } return false; }
private void BindData() { PBM_DeliveryBLL bll = new PBM_DeliveryBLL((int)ViewState["ID"]); if (bll.Model != null) { pl_detail.BindData(bll.Model); ViewState["Details"] = new ListTable<PBM_DeliveryDetail>(bll.Items, "ID"); ViewState["WareHouse"] = bll.Model.ClientWareHouse; ViewState["State"] = bll.Model.State; ViewState["Classify"] = bll.Model.Classify; BindGrid(); #region 界面控件可视状态 if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2) { bt_OK.Visible = false; bt_Delete.Visible = false; pl_detail.SetControlsEnable(false); gv_List.SetControlsEnable(false); } if (!((bll.Model.State == 1 && bll.Model.PrepareMode == 1) || (bll.Model.State == 3 && bll.Model.PrepareMode == 3))) { bt_Confirm.Visible = false; } #endregion } }