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();
    }
예제 #3
0
    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();
    }
예제 #5
0
    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_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");
        }
    }
예제 #7
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;
        }
    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_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());
        }
    }