コード例 #1
0
ファイル: SaleOutStoreBLL.cs プロジェクト: mosdong/PSI
        /// <summary>
        /// 修改销售单
        /// </summary>
        /// <param name="saleInfo"></param>
        /// <param name="saleGoodsList"></param>
        /// <returns></returns>
        public bool UpdateSaleInfo(SaleOutStoreInfoModel saleInfo, List <ViewSaleGoodsInfoModel> saleGoodsList)
        {
            List <SaleGoodsInfoModel> listGoods = ViewToSaleGoodsInfoModelList(saleGoodsList);

            return(saleDAL.UpdateSaleOutStoreInfo(saleInfo, listGoods));
        }
コード例 #2
0
ファイル: FrmSaleOutStore.cs プロジェクト: mosdong/PSI
        /// <summary>
        /// 初始化工作
        /// </summary>
        private void InitInfo()
        {
            if (saleId == 0)
            {
                //清空处理
                ClearInfo();
                SetBtnsEnabled(0);
            }
            else  //修改状态
            {
                //加载指定的销售单信息
                SaleOutStoreInfoModel saleInfo = RequestStar.GetSaleInfo(saleId);
                if (saleInfo != null)
                {
                    txtCustomers.Text = RequestStar.GetUnitInfo(saleInfo.UnitId).UnitName;
                    selCust           = new UnitInfoModel()
                    {
                        UnitId   = saleInfo.UnitId,
                        UnitName = txtCustomers.Text
                    };
                    txtOutStore.Text = RequestStar.GetStoreInfo(saleInfo.StoreId).StoreName;
                    store            = new StoreInfoModel()
                    {
                        StoreId   = saleInfo.StoreId,
                        StoreName = txtOutStore.Text
                    };
                    txtDealPerson.Text  = saleInfo.DealPerson;
                    txtCollectType.Text = saleInfo.PayDesp;
                    txtThisAmount.Text  = saleInfo.ThisAmount.ToString("0.00");
                    txtRemark.Text      = saleInfo.Remark;
                    txtTotalAmount.Text = saleInfo.TotalAmount.ToString("0.00");
                    txtYHAmount.Text    = saleInfo.YHAmount.ToString("0.00");
                    txtCreator.Text     = saleInfo.Creator;
                    txtCreateTime.Text  = saleInfo.CreateTime.ToShortDateString();
                    lblSaleNo.Text      = saleInfo.SaleOutNo;
                    switch (saleInfo.IsChecked)
                    {
                    case 0:
                        lblCheckState.Text = "待审核";
                        break;

                    case 1:
                        lblCheckState.Text = "已审核";
                        break;

                    case 2:
                        lblCheckState.Text = "已作废";    //未审核作废
                        break;

                    case 3:
                        lblCheckState.Text = "已红冲";    //已审核作废称红冲
                        break;
                    }
                    SetBtnsEnabled(saleInfo.IsChecked); //设置页面工具项或页面按钮的可用
                    if (saleInfo.IsPayed == 1)          //已经付款但并不定付完
                    {
                        hasPay = 1;
                    }
                    if (saleInfo.IsPayFull == 1) //付完
                    {
                        hasFullPay = 1;
                    }

                    //加载商品列表
                    List <ViewSaleGoodsInfoModel> saleGoodsList = RequestStar.GetSaleGoodsList(saleId);

                    dgvGoods.AutoGenerateColumns = false;
                    dgvGoods.DataSource          = saleGoodsList;
                    SetTotalInfo(saleGoodsList);//总计  数量  金额
                }
            }
            isOpened = RequestStar.GetOpenState(1);//获取开账状态
            if (!isOpened)
            {
                tsbtnAdd.Enabled      = false;
                tsbtnSave.Enabled     = false;
                tsbtnCheck.Enabled    = false;
                tsddbtnAct.Enabled    = false;
                btnAddGoods.Enabled   = false;
                btnDelete.Enabled     = false;
                storeList.Visible     = false;
                customersList.Visible = false;
                picPayType.Visible    = false;
                lblUnOpenDesp.Visible = true;
            }
            else
            {
                lblUnOpenDesp.Visible = false;
            }
        }
コード例 #3
0
ファイル: SaleOutStoreBLL.cs プロジェクト: mosdong/PSI
        /// <summary>
        /// 添加销售单
        /// </summary>
        /// <param name="saleInfo"></param>
        /// <param name="saleGoodsList"></param>
        /// <returns></returns>
        public string AddSaleInfo(SaleOutStoreInfoModel saleInfo, List <ViewSaleGoodsInfoModel> saleGoodsList)
        {
            List <SaleGoodsInfoModel> listGoods = ViewToSaleGoodsInfoModelList(saleGoodsList);

            return(saleDAL.AddSaleOutStoreInfo(saleInfo, listGoods));
        }
コード例 #4
0
ファイル: FrmSaleOutStore.cs プロジェクト: mosdong/PSI
        /// <summary>
        /// 销售单保存:新增  修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbtnSave_Click(object sender, EventArgs e)
        {
            Action act = () =>
            {
                //信息接收
                int storeId = 0;
                if (store != null)
                {
                    storeId = store.StoreId;
                }
                int unitId = 0;
                if (selCust != null)
                {
                    unitId = selCust.UnitId;
                }
                string   dealPerson  = txtDealPerson.Text.Trim();
                string   payDesp     = txtCollectType.Text.Trim();
                decimal  thisAmount  = txtThisAmount.Text.GetDecimal();
                string   remark      = txtRemark.Text.Trim();
                decimal  totalAmount = txtTotalAmount.Text.GetDecimal();
                decimal  yhAmount    = txtYHAmount.Text.GetDecimal();
                string   creator     = txtCreator.Text.Trim();
                DateTime createTime  = DateTime.Today;
                DateTime?payTime     = null;
                if (storeId == 0)
                {
                    MsgBoxHelper.MsgErrorShow("请选择出货仓库!");
                    txtOutStore.Focus();
                    return;
                }
                if (unitId == 0)
                {
                    MsgBoxHelper.MsgErrorShow("请选择客户!");
                    txtCustomers.Focus();
                    return;
                }
                if (thisAmount > totalAmount)
                {
                    MsgBoxHelper.MsgErrorShow("收款金额不能大于应收金额!");
                    txtThisAmount.Focus();
                    return;
                }
                else if (thisAmount > 0 && thisAmount <= totalAmount)
                {
                    hasPay = 1;//已收款
                    if (thisAmount == totalAmount)
                    {
                        hasFullPay = 1;//已收完
                    }
                    payTime = DateTime.Now;
                }
                if (dgvGoods.DataSource == null)
                {
                    MsgBoxHelper.MsgErrorShow("请选择销售商品!");
                    return;
                }
                else
                {
                    List <ViewSaleGoodsInfoModel> list  = dgvGoods.DataSource as List <ViewSaleGoodsInfoModel>;
                    List <ViewSaleGoodsInfoModel> list2 = list;
                    foreach (var vpi in list)
                    {
                        if (string.IsNullOrEmpty(vpi.GoodsName))
                        {
                            DialogResult dr = MsgBoxHelper.MsgBoxConfirm("销售商品", $"商品不能为空,是否删除这行?");
                            if (dr == DialogResult.Yes)
                            {
                                dgvGoods.DataSource = null;
                                list2.Remove(vpi);
                                dgvGoods.DataSource = list2;
                            }
                            return;
                        }
                        else if (vpi.SalePrice == 0)
                        {
                            MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的销售单价不能为0!");
                            return;
                        }
                        else if (vpi.Count == 0)
                        {
                            MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的销售数量不能为0!");
                            return;
                        }
                    }
                }
                //信息封装:单据信息   明细信息
                SaleOutStoreInfoModel saleInfo = new SaleOutStoreInfoModel()
                {
                    StoreId     = storeId,
                    UnitId      = unitId,
                    PayDesp     = payDesp,
                    ThisAmount  = thisAmount,
                    TotalAmount = totalAmount,
                    YHAmount    = yhAmount,
                    DealPerson  = dealPerson,
                    Remark      = remark,
                    IsPayed     = hasPay,
                    IsPayFull   = hasFullPay,
                    Creator     = creator,
                    CreateTime  = createTime
                };
                if (hasPay == 1)
                {
                    saleInfo.PayTime = payTime;
                }

                //获取采购商品列表
                List <ViewSaleGoodsInfoModel> listGoods = dgvGoods.DataSource as List <ViewSaleGoodsInfoModel>;
                //提交
                if (saleId == 0)            //新单保存
                {
                    //reStr  saleId,SaleNo
                    string reStr = RequestStar.AddSaleInfo(saleInfo, listGoods);
                    if (!string.IsNullOrEmpty(reStr))
                    {
                        MsgBoxHelper.MsgBoxShow("销售单保存", "销售单新增保存成功!");
                        string[] reStrs = reStr.Split(',');
                        saleId             = reStrs[0].GetInt(); //生成的销售单编号
                        lblSaleNo.Text     = reStrs[1];          //生成的销售单号
                        actType            = 2;                  //修改页面
                        tsddbtnAct.Enabled = true;
                        SetBtnsEnabled(0);                       //更新页面按钮的可用状态
                        this.ReloadListHandler();
                    }
                    else
                    {
                        MsgBoxHelper.MsgErrorShow("销售单保存失败!");
                        return;
                    }
                }
                else//修改保存   新增后修改     单据列表页进来
                {
                    saleInfo.SaleId = saleId;
                    bool bl = RequestStar.UpdateSaleInfo(saleInfo, listGoods);
                    if (bl)
                    {
                        MsgBoxHelper.MsgBoxShow("销售单保存", "销售单修改保存成功!");
                        this.ReloadListHandler();
                    }
                }
            };

            act.TryCatch("销售单提交出现异常!");
        }