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) { 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()); } }
/// <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 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 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 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 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() { 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() + ");"; } }
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()); } }