Exemplo n.º 1
0
    /// <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();
            }
        }
    }
    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_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();
    }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 提交订货单,并输出提交后的订单信息
        /// </summary>
        /// <param name="User"></param>
        /// <param name="OrderID">订货单ID</param>
        /// <param name="OrderInfo">输出:订货单结构</param>
        /// <param name="ErrorInfo">输出:出错信息</param>
        /// <returns>0:成功 小于0:失败</returns>
        public static int Order_Submit(UserInfo User, int OrderID, decimal WipeAmount, List<Order.OrderPayInfo> PayInfoList, out Order OrderInfo, out string ErrorInfo)
        {
            ErrorInfo = "";
            OrderInfo = null;
            LogWriter.WriteLog("PBMIFService.Order_Submit:UserName="******",OrderID=" + OrderID.ToString());

            if (OrderID <= 0) { ErrorInfo = "订货单ID无效"; return -1; }

            PBM_OrderBLL bll = new PBM_OrderBLL(OrderID);
            if (bll.Model == null) { ErrorInfo = "订货单ID无效"; return -1; }
            if (bll.Model.State > 1 || bll.Model.ApproveFlag == 1) { 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.ConfirmQuantity / p.ConvertFactor)
                - bll.Model.WipeAmount, 2);
            bll.Update();

            #region 写入收款明细
            //先清除之前的付款信息
            if (bll.GetPayInfoList().Count > 0) bll.ClearPayInfo();

            foreach (Order.OrderPayInfo item in PayInfoList)
            {
                PBM_DeliveryPayInfoBLL paybll = new PBM_DeliveryPayInfoBLL();
                paybll.Model.DeliveryID = OrderID;
                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.Submit(User.StaffID);
            if (ret < 0) { ErrorInfo = "订货单提交失败!"; return -1; }

            OrderInfo = new Order(bll.Model.ID);
            return 0;
        }
    /// <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();
            }
        }
    }