Пример #1
0
        /// <summary>
        /// 页面初始化工作
        /// </summary>
        private void InitInfo()
        {
            if (perId == 0)
            {
                //清空处理
                ClearInfo();
                SetBtnsEnabled(0);
            }
            else  //修改状态
            {
                //加载指定的采购单信息
                PerchaseInStoreInfoModel perInfo = RequestStar.GetPerchaseInfo(perId);
                if (perInfo != null)
                {
                    txtSuppliers.Text = RequestStar.GetUnitInfo(perInfo.UnitId).UnitName;
                    selUnit           = new UnitInfoModel()
                    {
                        UnitId   = perInfo.UnitId,
                        UnitName = txtSuppliers.Text
                    };
                    txtInStore.Text = RequestStar.GetStoreInfo(perInfo.StoreId).StoreName;
                    store           = new StoreInfoModel()
                    {
                        StoreId   = perInfo.StoreId,
                        StoreName = txtInStore.Text
                    };
                    txtDealPerson.Text  = perInfo.DealPerson;
                    txtPayForType.Text  = perInfo.PayDesp;
                    txtThisAmount.Text  = perInfo.ThisAmount.ToString("0.00");
                    txtRemark.Text      = perInfo.Remark;
                    txtTotalAmount.Text = perInfo.TotalAmount.ToString("0.00");
                    txtYHAmount.Text    = perInfo.YHAmount.ToString("0.00");
                    txtCreator.Text     = perInfo.Creator;
                    txtCreateTime.Text  = perInfo.CreateTime.ToShortDateString();
                    lblPerNo.Text       = perInfo.PerchaseNo;
                    switch (perInfo.IsChecked)
                    {
                    case 0:
                        lblCheckState.Text = "待审核";
                        break;

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

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

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

                    //加载商品列表
                    List <ViewPerGoodsInfoModel> perGoodsList = RequestStar.GetPerGoodsList(perId);

                    dgvGoods.AutoGenerateColumns = false;
                    dgvGoods.DataSource          = perGoodsList;
                    SetTotalInfo(perGoodsList);//总计  数量  金额
                }
            }
            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;
                suppliersList.Visible = false;
                picPayType.Visible    = false;
                lblUnOpenDesp.Visible = true;
            }
            else
            {
                lblUnOpenDesp.Visible = false;
            }
        }
Пример #2
0
        /// <summary>
        /// 修改采购单
        /// </summary>
        /// <param name="perInfo"></param>
        /// <param name="perGoodsList"></param>
        /// <returns></returns>
        public bool UpdatePerchaseInfo(PerchaseInStoreInfoModel perInfo, List <ViewPerGoodsInfoModel> perGoodsList)
        {
            List <PerchaseGoodsInfoModel> listGoods = ViewToPerGoodsInfoModelList(perGoodsList);

            return(perchaseDAL.UpdatePerchaseInfo(perInfo, listGoods));
        }
Пример #3
0
        /// <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 (selUnit != null)
                {
                    unitId = selUnit.UnitId;
                }
                string   dealPerson  = txtDealPerson.Text.Trim();
                string   payDesp     = txtPayForType.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("请选择入货仓库!");
                    txtInStore.Focus();
                    return;
                }
                if (unitId == 0)
                {
                    MsgBoxHelper.MsgErrorShow("请选择供应商!");
                    txtSuppliers.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 <ViewPerGoodsInfoModel> list  = dgvGoods.DataSource as List <ViewPerGoodsInfoModel>;
                    List <ViewPerGoodsInfoModel> 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.PerPrice == 0)
                        {
                            MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的采购单价不能为0!");
                            return;
                        }
                        else if (vpi.Count == 0)
                        {
                            MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的采购数量不能为0!");
                            return;
                        }
                    }
                }
                //信息封装:单据信息   明细信息
                PerchaseInStoreInfoModel perInfo = new PerchaseInStoreInfoModel()
                {
                    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)
                {
                    perInfo.PayTime = payTime;
                }

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

            act.TryCatch("采购单提交出现异常!");
        }
Пример #4
0
        /// <summary>
        /// 添加采购单
        /// </summary>
        /// <param name="perInfo"></param>
        /// <param name="perGoodsList"></param>
        /// <returns></returns>
        public string AddPerchaseInfo(PerchaseInStoreInfoModel perInfo, List <ViewPerGoodsInfoModel> perGoodsList)
        {
            List <PerchaseGoodsInfoModel> listGoods = ViewToPerGoodsInfoModelList(perGoodsList);

            return(perchaseDAL.AddPerchaseInfo(perInfo, listGoods));
        }