示例#1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string wareHouse = WareHouseHelper.GetWareHouse(LoginUserInfo.ID, LoginUserInfo.Name)[0].Value;

            //低库存预警检查
            bool lowWarning = BLLFactory <Stock> .Instance.CheckStockLowWarning(wareHouse);

            if (lowWarning)
            {
                string message = string.Format("{0} 库存已经处于低库存预警状态\r\n请及时补充库存", wareHouse);
                WareHouseHelper.Notify(string.Format("{0} 低库存预警", wareHouse), message);
            }

            //超库存预警检查
            bool highWarning = BLLFactory <Stock> .Instance.CheckStockHighWarning(wareHouse);

            if (highWarning)
            {
                string message = string.Format("{0} 库存量已经高过超预警库存量\r\n请注意减少库存积压", wareHouse);
                WareHouseHelper.Notify(string.Format("{0} 超库存预警", wareHouse), message);
            }

            if (!lowWarning && !highWarning)
            {
                string message = string.Format("暂无相关的系统提示信息");
                WareHouseHelper.Notify(message, message);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证输入

            //检查是否可以入库出库
            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.Text, detailInfo.ItemNo);

                    if (!isInit)
                    {
                        if (MessageDxUtil.ShowYesNoAndTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,您是否要进行期初建账,初始化库存为0?\r\n按【是】初始化库房并继续,按【否】退出。",
                                                                         detailInfo.ItemNo, this.txtWareHouse.Text)) == DialogResult.No)
                        {
                            return;
                        }
                        else
                        {
                            ItemDetailInfo itemInfo = new ItemDetailInfo();
                            itemInfo.ItemNo      = detailInfo.ItemNo;
                            itemInfo.ItemName    = detailInfo.ItemName;
                            itemInfo.ItemBigType = detailInfo.ItemBigType;
                            itemInfo.ItemType    = detailInfo.ItemType;

                            BLLFactory <Stock> .Instance.InitStockQuantity(itemInfo, 0, this.txtWareHouse.Text);
                        }
                    }
                }
            }

            if (this.txtHandNo.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("货单编号不能为空");
                this.txtHandNo.Focus();
                return;
            }
            else if (this.txtManufacture.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择供应商");
                this.txtManufacture.Focus();
                return;
            }
            else if (this.txtWareHouse.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择仓库");
                this.txtWareHouse.Focus();
                return;
            }
            else if (this.lvwDetail.Items.Count == 0)
            {
                MessageDxUtil.ShowTips("请添加商品");
                return;
            }
            else if (this.txtCreator.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请选择经手人");
                this.txtCreator.Focus();
                return;
            }
            #endregion

            try
            {
                PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();
                headInfo.CreateDate    = txtCreateDate.DateTime;
                headInfo.Creator       = this.txtCreator.Text;
                headInfo.HandNo        = this.txtHandNo.Text;
                headInfo.Manufacture   = this.txtManufacture.Text;
                headInfo.Note          = this.txtNote.Text;
                headInfo.OperationType = "入库";
                headInfo.WareHouse     = this.txtWareHouse.Text;
                headInfo.CreateYear    = DateTime.Now.Year;
                headInfo.CreateMonth   = DateTime.Now.Month;

                int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo);

                if (headId > 0)
                {
                    for (int i = 0; i < this.lvwDetail.Items.Count; i++)
                    {
                        PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                        if (detailInfo != null)
                        {
                            detailInfo.PurchaseHead_ID = headId;
                            BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo);

                            AddStockQuantity(detailInfo);//增加库存
                        }
                    }

                    MessageDxUtil.ShowTips("保存成功");
                    ClearContent();

                    //超库存预警检查
                    bool highWarning = BLLFactory <Stock> .Instance.CheckStockHighWarning(this.txtWareHouse.Text);

                    if (highWarning)
                    {
                        string message = string.Format("{0} 库存量已经高过超预警库存量\r\n请注意减少库存积压", this.txtWareHouse.Text);
                        WareHouseHelper.Notify(string.Format("{0} 超库存预警", this.txtWareHouse.Text), message);
                    }
                }
                else
                {
                    MessageDxUtil.ShowError("保存失败");
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
        }
示例#3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证输入

            //检查是否可以入库出库
            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.Text, detailInfo.ItemNo);

                    if (!isInit)
                    {
                        MessageDxUtil.ShowTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,请先在备件信息管理中进行期初建账。", detailInfo.ItemNo, this.txtWareHouse.Text));
                        return;
                    }
                }
            }

            if (this.txtHandNo.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("货单编号不能为空");
                this.txtHandNo.Focus();
                return;
            }
            else if (this.txtManufacture.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择供应商");
                this.txtManufacture.Focus();
                return;
            }
            else if (this.txtCostCenter.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择成本中心");
                this.txtCostCenter.Focus();
                return;
            }
            else if (this.txtWareHouse.Text.Trim() == "")
            {
                MessageDxUtil.ShowTips("请选择仓库");
                this.txtWareHouse.Focus();
                return;
            }
            else if (this.lvwDetail.Items.Count == 0)
            {
                MessageDxUtil.ShowTips("请添加商品");
                return;
            }
            else if (this.txtCreator.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请选择经手人");
                this.txtCreator.Focus();
                return;
            }
            else if (this.txtPickingPeople.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请输入领料人");
                this.txtPickingPeople.Focus();
                return;
            }
            #endregion

            try
            {
                PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();
                headInfo.CreateDate    = txtCreateDate.DateTime;
                headInfo.Creator       = this.txtCreator.Text;
                headInfo.HandNo        = this.txtHandNo.Text;
                headInfo.Manufacture   = this.txtManufacture.Text;
                headInfo.Note          = this.txtNote.Text;
                headInfo.OperationType = "出库";
                headInfo.WareHouse     = this.txtWareHouse.Text;
                headInfo.CostCenter    = this.txtCostCenter.Text;
                headInfo.CreateYear    = DateTime.Now.Year;
                headInfo.CreateMonth   = DateTime.Now.Month;
                //领料人
                headInfo.PickingPeople = this.txtPickingPeople.Text;

                int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo);

                if (headId > 0)
                {
                    for (int i = 0; i < this.lvwDetail.Items.Count; i++)
                    {
                        PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                        if (detailInfo != null)
                        {
                            detailInfo.PurchaseHead_ID = headId;
                            BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo);

                            AddStockQuantity(detailInfo);//增加库存
                        }
                    }

                    MessageDxUtil.ShowTips("保存成功");
                    ClearContent();

                    //低库存预警检查
                    bool lowWarning = BLLFactory <Stock> .Instance.CheckStockLowWarning(this.txtWareHouse.Text);

                    if (lowWarning)
                    {
                        string message = string.Format("{0} 库存已经处于低库存预警状态\r\n请及时补充库存", this.txtWareHouse.Text);
                        WareHouseHelper.Notify(string.Format("{0} 低库存预警", this.txtWareHouse.Text), message);
                    }
                }
                else
                {
                    MessageDxUtil.ShowError("保存失败");
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
        }