コード例 #1
0
ファイル: FrmAddPurchaseItem.cs プロジェクト: yyan/winform
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int count = Convert.ToInt32(this.txtQuantity.Text);

            if (count <= 0)
            {
                MessageDxUtil.ShowTips("数量必须大于0");
                this.txtQuantity.Focus();
                return;
            }

            ItemDetailInfo info = lvwGoods.gridView1.GetFocusedRow() as ItemDetailInfo;

            if (info != null)
            {
                //出库检查数量是否超过库存
                if (!IsPurchase)
                {
                    int stockQuantity = BLLFactory <Stock> .Instance.GetStockQuantity(info.ItemNo, this.WareHourseId);

                    if (stockQuantity < count)
                    {
                        MessageDxUtil.ShowTips(string.Format("库存数量小于出库数量,请调整出库数量。\r\n该备件最大库存量为 {0} 。", stockQuantity));
                        this.txtQuantity.Focus();
                        return;
                    }
                }

                InsertOnItem(info);
            }

            ShowGoodDetailView();
        }
コード例 #2
0
ファイル: FrmEditItemDetail.cs プロジェクト: yyan/winform
        /// <summary>
        /// 数据显示的函数
        /// </summary>
        public override void DisplayData()
        {
            InitDictItem();//数据字典加载(公用)

            if (!string.IsNullOrEmpty(ID))
            {
                #region 显示客户信息
                ItemDetailInfo info = BLLFactory <ItemDetail> .Instance.FindByID(ID);

                if (info != null)
                {
                    this.txtItemNo.Properties.ReadOnly = true;
                    this.txtItemNo.ForeColor           = Color.Pink;

                    txtBigType.Text         = info.ItemBigType;
                    txtItemName.Text        = info.ItemName;
                    txtItemNo.Text          = info.ItemNo;
                    txtItemType.Text        = info.ItemType;
                    txtManufacture.Text     = info.Manufacture;
                    txtMapNo.Text           = info.MapNo;
                    txtMaterial.Text        = info.Material;
                    txtNote.Text            = info.Note;
                    txtPrice.Text           = info.Price.ToString("f2");
                    txtSource.Text          = info.Source;
                    txtSpecNumber.Text      = info.Specification;
                    txtStockPos.Text        = info.StoragePos;
                    txtUnit.Text            = info.Unit;
                    txtUsagePos.Text        = info.UsagePos;
                    txtBelongWareHouse.Text = info.WareHouse;
                    txtBelongWareHouse.Tag  = info.WareHouse;//用来识别是否变化
                    txtBelongDept.Text      = info.Dept;
                }
                #endregion
            }
        }
コード例 #3
0
        private void lvwGoods_DoubleClick(object sender, EventArgs e)
        {
            foreach (ListViewItem item in this.lvwGoods.SelectedItems)
            {
                ItemDetailInfo info = item.Tag as ItemDetailInfo;
                if (info != null)
                {
                    //出库检查数量是否超过库存
                    if (!IsPurchase)
                    {
                        int count         = Convert.ToInt32(this.txtQuantity.Text);
                        int stockQuantity = BLLFactory <Stock> .Instance.GetStockQuantity(info.ItemNo, this.WareHourse);

                        if (stockQuantity < count)
                        {
                            MessageDxUtil.ShowTips(string.Format("库存数量小于出库数量,请调整出库数量。\r\n该备件最大库存量为 {0} 。", stockQuantity));
                            this.txtQuantity.Focus();
                            return;
                        }
                    }

                    InsertOnItem(info);
                }
            }
            BindData();
        }
コード例 #4
0
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            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;

            List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>();

            for (int i = 0; i < this.lvwDetail.Items.Count; i++)
            {
                PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.Text);

                    if (stockInfo != null)
                    {
                        int            oldQuantity = stockInfo.StockQuantity;
                        decimal        oldPrice    = 0M;
                        ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                        if (info != null)
                        {
                            oldPrice = info.Price;
                            decimal newPrice = ((Convert.ToInt32(detailInfo.Quantity) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Quantity) + oldQuantity);

                            detailInfo.Price = newPrice;
                        }
                    }

                    detailList.Add(detailInfo);
                }
            }

            ReportViewerDialog dlg = new ReportViewerDialog();

            dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>()
            {
                headInfo
            });
            dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList);
            dlg.ReportFilePath = "Report/WHC.WareHouseMis.PurchaseReport.rdlc";

            dlg.Parameters.Add("CompanyName", this.AppInfo.AppUnit);
            dlg.ShowDialog();
        }
コード例 #5
0
ファイル: FrmPurchase.cs プロジェクト: 15831944/winform-1
        private void btnPrintBill_Click(object sender, EventArgs e)
        {
            PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();

            headInfo.CreatorTime   = txtCreateDate.DateTime;
            headInfo.CreatorId     = this.txtCreator.Text.ToInt32();
            headInfo.OrderNo       = this.txtHandNo.Text;
            headInfo.Manufacture   = this.txtManufacture.Text;
            headInfo.Remark        = this.txtNote.Text;
            headInfo.OperationType = (short)OperationType.新增;
            headInfo.WareHouseId   = this.txtWareHouse.GetComboBoxStrValue().ToInt32();
            headInfo.CreatorYear   = DateTimeHelper.GetServerDateTime2().Year;
            headInfo.CreatorMonth  = (short)DateTimeHelper.GetServerDateTime2().Month;

            List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>();

            for (int i = 0; i < this.lvwDetail.gridView1.RowCount; i++)
            {
                PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.GetComboBoxStrValue());

                    if (wareInfo != null)
                    {
                        int            oldQuantity = wareInfo.Amount;
                        double         oldPrice    = 0;
                        ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                        if (info != null)
                        {
                            oldPrice = info.Price;
                            double newPrice = ((Convert.ToInt32(detailInfo.Amount) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Amount) + oldQuantity);

                            detailInfo.Price = newPrice;
                        }
                    }

                    detailList.Add(detailInfo);
                }
            }

            ReportViewerDialog dlg = new ReportViewerDialog();

            dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>()
            {
                headInfo
            });
            dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList);
            dlg.ReportFilePath = "Report/WHC.WareHouseMis.PurchaseReport.rdlc";
            dlg.Parameters.Add("CompanyName", this.AppInfo.AppUnit);
            dlg.ShowDialog();
        }
コード例 #6
0
    private void AddItem(string pid)
    {
        ItemDetailFacade facade   = new ItemDetailFacade();
        ItemDetailInfo   itemInfo = new ItemDetailInfo();

        itemInfo.Id = Guid.NewGuid();
        itemInfo.ItsCollectionId = new Guid(pid);
        itemInfo.Name            = txtName.Text;
        itemInfo.TitleHtml       = txtTitle.Text;
        itemInfo.AllHtml         = txtContent.Text;
        itemInfo.SummaryHtml     = txtSummary.Text;
        facade.AddItem(itemInfo);
    }
コード例 #7
0
ファイル: FrmAddPurchaseItem.cs プロジェクト: yyan/winform
        private void lvwDetail_OnDeleteSelected(object sender, EventArgs e)
        {
            ItemDetailInfo info = lvwGoods.gridView1.GetFocusedRow() as ItemDetailInfo;

            if (info != null)
            {
                if (detailDict.ContainsKey(info.ItemNo))
                {
                    detailDict.Remove(info.ItemNo);
                }

                ShowGoodDetailView();
            }
        }
コード例 #8
0
        /// <summary>
        /// 新增状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveAddNew()
        {
            ItemDetailInfo info = new ItemDetailInfo();

            SetInfo(info);

            try
            {
                #region 新增数据
                bool exist = BLLFactory <ItemDetail> .Instance.IsExistKey("ItemNo", info.ItemNo);

                if (exist)
                {
                    MessageDxUtil.ShowTips("指定的备件编号已经存在,不能重复添加,请修改");
                    return(false);
                }

                bool succeed = BLLFactory <ItemDetail> .Instance.Insert(info);

                if (succeed)
                {
                    try
                    {
                        //不管是更新还是新增,如果对应的备件编码在库房没有初始化,初始化之
                        bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtBelongWareHouse.Text, this.txtItemNo.Text);

                        if (!isInit)
                        {
                            BLLFactory <Stock> .Instance.InitStockQuantity(info, 0, this.txtBelongWareHouse.Text);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageDxUtil.ShowTips(string.Format("初始化库存为0失败:", ex.Message));
                    }

                    return(true);
                    //MessageDxUtil.ShowTips("备件数据保存成功");
                    //this.DialogResult = DialogResult.OK;
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
            return(false);
        }
コード例 #9
0
        private void treeGoods_DoubleClick(object sender, EventArgs e)
        {
            if (this.treeGoods.SelectedNode != null)
            {
                TreeNode       item  = this.treeGoods.SelectedNode;//按钮默认加第一个
                ItemDetailInfo info  = item.Tag as ItemDetailInfo;
                int            count = Convert.ToInt32(this.txtQuantity.Text);
                if (info != null)
                {
                    InsertOnItem(info);
                }

                BindData();
            }
        }
コード例 #10
0
ファイル: FrmEditItemDetail.cs プロジェクト: yyan/winform
        /// <summary>
        /// 新增状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveAddNew()
        {
            ItemDetailInfo info = new ItemDetailInfo();

            SetInfo(info);

            try
            {
                #region 新增数据
                bool exist = BLLFactory <ItemDetail> .Instance.IsExistKey("ItemNo", info.ItemNo);

                if (exist)
                {
                    MessageDxUtil.ShowTips("指定的备件编号已经存在,不能重复添加,请修改");
                    return(false);
                }

                bool succeed = BLLFactory <ItemDetail> .Instance.Insert(info);

                if (succeed)
                {
                    try
                    {
                        //不管是更新还是新增,如果对应的备件编码在库房没有初始化,初始化之
                        bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtBelongWareHouse.Text, this.txtItemNo.Text);

                        if (!isInit)
                        {
                            BLLFactory <Stock> .Instance.InitStockQuantity(info, 0, this.txtBelongWareHouse.Text);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemDetail));
                        MessageDxUtil.ShowError("初始化库存为0失败:" + ex.Message);
                    }

                    return(true);
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemDetail));
                MessageDxUtil.ShowError(ex.Message);
            }
            return(false);
        }
コード例 #11
0
        private void FrmEditProduct_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(ID))
            {
                this.Text = "编辑 " + this.Text;
                StockInfo info = BLLFactory <Stock> .Instance.FindByID(ID);

                if (info != null)
                {
                    try
                    {
                        ItemDetailInfo detailInfo = BLLFactory <ItemDetail> .Instance.FindByItemNo(info.ItemNo);

                        if (detailInfo != null)
                        {
                            txtItemNo.Text        = info.ItemNo;
                            txtItemName.Text      = info.ItemName;
                            txtStockQuantity.Text = info.StockQuantity.ToString();
                            txtStockMoney.Text    = (info.StockQuantity * detailInfo.Price).ToString("f2");
                            txtHighWarning.Text   = info.HighWarning.ToString();
                            txtLowWarning.Text    = info.LowWarning.ToString();
                            txtNote.Text          = info.Note;
                            txtItemType.Text      = info.ItemType;
                            txtBigType.Text       = info.ItemBigType;
                            txtManufacturer.Text  = detailInfo.Manufacture;
                            txtMapNo.Text         = detailInfo.MapNo;
                            txtSpecification.Text = detailInfo.Specification;
                            txtWareHouse.Text     = info.WareHouse;
                        }
                    }
                    catch (Exception ex)
                    {
                        LogTextHelper.Error(ex);
                        MessageDxUtil.ShowError(ex.Message);
                        return;
                    }
                }
                this.btnOK.Enabled = HasFunction("Stock/Modify");
            }
            else
            {
                this.Text          = "新建 " + this.Text;
                this.btnOK.Enabled = HasFunction("Stock/Modify");
            }
        }
コード例 #12
0
    private void BindItem(string itemId, string url)
    {
        Guid             id       = new Guid(itemId);
        ItemDetailFacade facade   = new ItemDetailFacade();
        ItemDetailInfo   itemInfo = facade.GetItemById(id) as ItemDetailInfo;

        if (itemInfo != null)
        {
            txtName.Text    = itemInfo.Name;
            txtTitle.Text   = itemInfo.TitleHtml;
            txtContent.Text = itemInfo.AllHtml;
            txtSummary.Text = itemInfo.SummaryHtml;
        }
        else
        {
            JavascriptAlertAndRedirect("参数错误 - 对象不存在!", url);
        }
    }
コード例 #13
0
        private void InsertOnItem(ItemDetailInfo itemDetailInfo)
        {
            int count = Convert.ToInt32(this.txtQuantity.Text);

            if (count <= 0)
            {
                MessageDxUtil.ShowTips("数量必须大于0");
                this.txtQuantity.Focus();
                return;
            }

            #region 构造入库信息
            PurchaseDetailInfo detailInfo = new PurchaseDetailInfo();
            detailInfo.Amount        = itemDetailInfo.Price * count;
            detailInfo.ItemName      = itemDetailInfo.ItemName;
            detailInfo.ItemNo        = itemDetailInfo.ItemNo;
            detailInfo.OperationType = "入库";
            detailInfo.ItemBigType   = itemDetailInfo.ItemBigType;
            detailInfo.ItemType      = itemDetailInfo.ItemType;
            detailInfo.MapNo         = itemDetailInfo.MapNo;
            detailInfo.Material      = itemDetailInfo.Material;
            detailInfo.Source        = itemDetailInfo.Source;
            detailInfo.Specification = itemDetailInfo.Specification;
            detailInfo.StoragePos    = itemDetailInfo.StoragePos;
            detailInfo.UsagePos      = itemDetailInfo.UsagePos;
            detailInfo.Price         = itemDetailInfo.Price;
            detailInfo.Quantity      = count;
            detailInfo.Unit          = itemDetailInfo.Unit;
            detailInfo.WareHouse     = itemDetailInfo.WareHouse;
            detailInfo.Dept          = itemDetailInfo.Dept;
            //detailInfo.PurchaseHead_ID =
            #endregion

            if (detailDict.ContainsKey(itemDetailInfo.ItemNo))
            {
                PurchaseDetailInfo tempInfo = detailDict[itemDetailInfo.ItemNo];
                tempInfo.Amount   += itemDetailInfo.Price * count;
                tempInfo.Quantity += count;
            }
            else
            {
                detailDict.Add(itemDetailInfo.ItemNo, detailInfo);
            }
        }
コード例 #14
0
ファイル: FrmEditStock.cs プロジェクト: 15831944/winform-1
        private void FrmEditProduct_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(ID))
            {
                WareInfo info = BLLFactory <Stock> .Instance.FindById(ID);

                if (info != null)
                {
                    try
                    {
                        ItemDetailInfo detailInfo = BLLFactory <ItemDetail> .Instance.FindByItemNo(info.ItemNo);

                        if (detailInfo != null)
                        {
                            txtItemNo.Text        = info.ItemNo;
                            txtItemName.Text      = info.Name;
                            txtStockQuantity.Text = info.Amount.ToString();
                            txtStockMoney.Text    = (info.Amount * detailInfo.Price).ToString("f2");
                            txtHighWarning.Text   = info.HighAmountWarning.ToString();
                            txtLowWarning.Text    = info.LowAmountWarning.ToString();
                            txtNote.Text          = info.Remark;
                            txtItemType.Text      = info.ItemType.ToString();
                            txtBigType.Text       = info.ItemBigtype.ToString();
                            txtManufacturer.Text  = detailInfo.Manufacture;
                            txtMapNo.Text         = detailInfo.MapNo;
                            txtSpecification.Text = detailInfo.Specification;
                            txtWareHouse.Text     = info.WareHouseId.ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditStock));
                        MessageDxUtil.ShowError(ex.Message);
                        return;
                    }
                }
                this.btnOK.Enabled = HasFunction("Stock/Modify");
            }
            else
            {
                this.btnOK.Enabled = HasFunction("Stock/Modify");
            }
        }
コード例 #15
0
 /// <summary>
 /// 编辑或者保存状态下取值函数
 /// </summary>
 /// <param name="info"></param>
 private void SetInfo(ItemDetailInfo info)
 {
     info.ItemBigType   = txtBigType.Text;
     info.ItemName      = txtItemName.Text;
     info.ItemNo        = txtItemNo.Text;
     info.ItemType      = txtItemType.Text;
     info.Manufacture   = txtManufacture.Text;
     info.MapNo         = txtMapNo.Text;
     info.Material      = txtMaterial.Text;
     info.Note          = txtNote.Text;
     info.Price         = Convert.ToDecimal(txtPrice.Text);
     info.Source        = txtSource.Text;
     info.Specification = txtSpecNumber.Text;
     info.StoragePos    = txtStockPos.Text;
     info.Unit          = txtUnit.Text;
     info.UsagePos      = txtUsagePos.Text;
     info.Dept          = txtBelongDept.Text;
     info.WareHouse     = txtBelongWareHouse.Text;
 }
コード例 #16
0
 /// <summary>
 /// 编辑或者保存状态下取值函数
 /// </summary>
 /// <param name="info"></param>
 private void SetInfo(ItemDetailInfo info)
 {
     info.ItemBigtype   = (Int32)txtBigType.GetComboBoxIntValue();
     info.Name          = txtItemName.Text;
     info.ItemNo        = txtItemNo.Text;
     info.ItemType      = (Int32)txtItemType.GetComboBoxIntValue();
     info.Manufacture   = txtManufacture.GetComboBoxStrValue();
     info.MapNo         = txtMapNo.Text;
     info.Material      = txtMaterial.Text;
     info.Remark        = txtNote.Text;
     info.Price         = Convert.ToDouble(txtPrice.Text);
     info.ItemSource    = txtSource.Text;
     info.Specification = txtSpecNumber.Text;
     info.StoragePos    = txtStockPos.Text;
     info.ItemUnit      = (Int32)txtUnit.GetComboBoxIntValue();
     info.UsagePos      = txtUsagePos.Text;
     info.DeptId        = txtBelongDept.Text.ToInt32();
     info.WareHouseId   = txtBelongWareHouse.GetComboBoxStrValue().ToInt32();
 }
コード例 #17
0
 private TreeNode FindNode(ListViewItem item)
 {
     foreach (TreeNode typeNode in this.treeGoods.Nodes)
     {
         foreach (TreeNode node in typeNode.Nodes)
         {
             if (node.Tag != null)
             {
                 ItemDetailInfo info           = item.Tag as ItemDetailInfo;
                 ItemDetailInfo ItemDetailInfo = node.Tag as ItemDetailInfo;
                 if (ItemDetailInfo != null &&
                     ItemDetailInfo.ID == info.ID)
                 {
                     return(node);
                 }
             }
         }
     }
     return(null);
 }
コード例 #18
0
        /// <summary>
        /// 初始化库房信息
        /// </summary>
        /// <param name="detailInfo">备件详细信息</param>
        /// <param name="quantity">期初数量</param>
        /// <param name="wareHouse">库房名称</param>
        /// <returns></returns>
        public bool InitStockQuantity(ItemDetailInfo detailInfo, int quantity, string wareHouse)
        {
            bool exist = base.IsExistRecord(string.Format("ItemNo='{0}' AND WareHouse='{1}'", detailInfo.ItemNo, wareHouse));

            if (exist)
            {
                throw new ArgumentException("库房已经存在该项目的信息,不能设置");
            }

            StockInfo stockInfo = new StockInfo();

            stockInfo.ItemBigType   = detailInfo.ItemBigType;
            stockInfo.ItemName      = detailInfo.ItemName;
            stockInfo.ItemNo        = detailInfo.ItemNo;
            stockInfo.ItemType      = detailInfo.ItemType;
            stockInfo.StockQuantity = quantity;
            stockInfo.WareHouse     = wareHouse;
            //stockInfo.HighWarning =
            //stockInfo.LowWarning =
            return(base.Insert(stockInfo));
        }
コード例 #19
0
        /// <summary>
        /// 初始化库房信息
        /// </summary>
        /// <param name="detailInfo">备件详细信息</param>
        /// <param name="quantity">期初数量</param>
        /// <param name="wareHouse">库房名称</param>
        /// <returns></returns>
        public bool InitStockQuantity(ItemDetailInfo detailInfo, int quantity, Int32 wareHouseId)
        {
            bool exist = base.IsExistRecord(string.Format("ItemNo='{0}' AND WareHouse='{1}'", detailInfo.ItemNo, wareHouseId));

            if (exist)
            {
                throw new ArgumentException("库房已经存在该项目的信息,不能设置");
            }

            WareInfo wareInfo = new WareInfo();

            wareInfo.ItemBigtype = detailInfo.ItemBigtype;
            wareInfo.Name        = detailInfo.Name;
            wareInfo.ItemNo      = detailInfo.ItemNo;
            wareInfo.ItemType    = detailInfo.ItemType;
            wareInfo.Amount      = quantity;
            wareInfo.WareHouseId = wareHouseId;
            //stockInfo.HighWarning =
            //stockInfo.LowWarning =
            return(base.Insert(wareInfo));
        }
コード例 #20
0
        private void txtStockQuantity_Validated(object sender, EventArgs e)
        {
            StockInfo info = BLLFactory <Stock> .Instance.FindByID(ID);

            if (info != null)
            {
                try
                {
                    ItemDetailInfo detailInfo = BLLFactory <ItemDetail> .Instance.FindByItemNo(info.ItemNo);

                    if (detailInfo != null)
                    {
                        this.txtStockMoney.Text = (Convert.ToInt32(this.txtStockQuantity.Text) * detailInfo.Price).ToString("f2");
                        Application.DoEvents();
                        Thread.Sleep(10);
                    }
                }
                catch (Exception ex)
                {
                    MessageDxUtil.ShowError(ex.Message);
                    LogTextHelper.Error(ex);
                }
            }
        }
コード例 #21
0
        private void AddStockQuantity(PurchaseDetailInfo detailInfo)
        {
            //先更新库存的价格为加权价格
            StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.Text);

            if (stockInfo != null)
            {
                int            oldQuantity = stockInfo.StockQuantity;
                decimal        oldPrice    = 0M;
                ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                if (info != null)
                {
                    oldPrice = info.Price;
                    decimal newPrice = ((Convert.ToInt32(detailInfo.Quantity) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Quantity) + oldQuantity);

                    info.Price = newPrice;
                    BLLFactory <ItemDetail> .Instance.Update(info, info.ID.ToString());
                }
            }

            BLLFactory <Stock> .Instance.AddStockQuantiy(detailInfo.ItemNo, detailInfo.ItemName,
                                                         Convert.ToInt32(detailInfo.Quantity), this.txtWareHouse.Text);
        }
コード例 #22
0
ファイル: FrmPurchase.cs プロジェクト: 15831944/winform-1
        private void AddStockQuantity(PurchaseDetailInfo detailInfo)
        {
            //先更新库存的价格为加权价格
            WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.GetComboBoxStrValue());

            if (wareInfo != null)
            {
                int            oldQuantity = wareInfo.Amount;
                double         oldPrice    = 0;
                ItemDetailInfo info        = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo);

                if (info != null)
                {
                    oldPrice = info.Price;
                    double newPrice = ((Convert.ToInt32(detailInfo.Amount) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Amount) + oldQuantity);

                    info.Price = (double)newPrice;
                    BLLFactory <ItemDetail> .Instance.Update(info, info.Id);
                }
            }

            BLLFactory <Stock> .Instance.AddStockQuantiy(detailInfo.ItemNo, detailInfo.Name,
                                                         Convert.ToInt32(detailInfo.Amount), this.txtWareHouse.GetComboBoxStrValue().ToInt32());
        }
コード例 #23
0
ファイル: FrmEditStock.cs プロジェクト: 15831944/winform-1
        private void txtStockQuantity_Validated(object sender, EventArgs e)
        {
            WareInfo info = BLLFactory <Stock> .Instance.FindById(ID);

            if (info != null)
            {
                try
                {
                    ItemDetailInfo detailInfo = BLLFactory <ItemDetail> .Instance.FindByItemNo(info.ItemNo);

                    if (detailInfo != null)
                    {
                        this.txtStockMoney.Text = (Convert.ToInt32(this.txtStockQuantity.Text) * detailInfo.Price).ToString("f2");
                        Application.DoEvents();
                        Thread.Sleep(10);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditStock));
                    MessageDxUtil.ShowError(ex.Message);
                }
            }
        }
コード例 #24
0
ファイル: Stock.cs プロジェクト: 15831944/winform-1
        /// <summary>
        /// 初始化库房信息
        /// </summary>
        /// <param name="detailInfo">备件详细信息</param>
        /// <param name="quantity">期初数量</param>
        /// <param name="wareHouse">库房名称</param>
        /// <returns></returns>
        public bool InitStockQuantity(ItemDetailInfo detailInfo, int quantity, Int32 wareHouseId)
        {
            IWare dal = baseDal as IWare;

            return(dal.InitStockQuantity(detailInfo, quantity, wareHouseId));
        }
コード例 #25
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)
                    {
                        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);
            }
        }
コード例 #26
0
        /// <summary>
        /// 编辑状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveUpdated()
        {
            bool exist = BLLFactory <ItemDetail> .Instance.CheckExist(this.txtItemNo.Text, ID);

            if (exist)
            {
                MessageDxUtil.ShowTips("指定的备件编号已经存在,不能重复添加,请修改");
                return(false);
            }

            ItemDetailInfo info = BLLFactory <ItemDetail> .Instance.FindByID(ID);

            if (info != null)
            {
                if (txtBelongWareHouse.Text != txtBelongWareHouse.Tag.ToString())
                {
                    if (MessageDxUtil.ShowYesNoAndWarning("您的备件所属库存发生了修改,是否继续更改库房数据") == DialogResult.No)
                    {
                        return(false);
                    }
                }

                SetInfo(info);

                try
                {
                    #region 更新数据
                    bool succeed = BLLFactory <ItemDetail> .Instance.Update(info, info.ID.ToString());

                    if (succeed)
                    {
                        try
                        {
                            StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(this.txtItemNo.Text, this.txtBelongWareHouse.Tag.ToString());

                            if (stockInfo != null)
                            {
                                stockInfo.WareHouse = txtBelongWareHouse.Text;
                                BLLFactory <Stock> .Instance.Update(stockInfo, stockInfo.ID.ToString());
                            }

                            //不管是更新还是新增,如果对应的备件编码在库房没有初始化,初始化之
                            bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtBelongWareHouse.Text, this.txtItemNo.Text);

                            if (!isInit)
                            {
                                BLLFactory <Stock> .Instance.InitStockQuantity(info, 0, this.txtBelongWareHouse.Text);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageDxUtil.ShowTips(string.Format("初始化库存为0失败:", ex.Message));
                        }
                        //MessageDxUtil.ShowTips("备件数据保存成功");
                        //this.DialogResult = DialogResult.OK;
                        return(true);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    LogTextHelper.Error(ex);
                    MessageDxUtil.ShowError(ex.Message);
                }
            }
            return(false);
        }
コード例 #27
0
ファイル: FrmPurchase.cs プロジェクト: 15831944/winform-1
        private void btnOK_Click(object sender, EventArgs e)
        {
            #region 验证输入

            //检查是否可以入库出库
            for (int i = 0; i < this.lvwDetail.gridView1.DataRowCount; i++)
            {
                PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                if (detailInfo != null)
                {
                    bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.GetComboBoxStrValue(), 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.Name        = detailInfo.Name;
                            itemInfo.ItemBigtype = detailInfo.ItemBigtype;
                            itemInfo.ItemType    = detailInfo.ItemType;

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

            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.gridView1.RowCount == 0)
            {
                MessageDxUtil.ShowTips("请添加商品");
                return;
            }
            else if (this.txtCreator.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请选择经手人");
                this.txtCreator.Focus();
                return;
            }
            #endregion

            try
            {
                PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo();
                headInfo.CreatorTime   = txtCreateDate.DateTime;
                headInfo.CreatorId     = this.txtCreator.Text.ToInt32();
                headInfo.OrderNo       = this.txtHandNo.Text;
                headInfo.Manufacture   = this.txtManufacture.GetComboBoxStrValue();
                headInfo.Remark        = this.txtNote.Text;
                headInfo.OperationType = (short)OperationType.新增;// 入库
                headInfo.WareHouseId   = this.txtWareHouse.GetComboBoxStrValue().ToInt32();
                headInfo.CreatorYear   = DateTimeHelper.GetServerDateTime2().Year;
                headInfo.CreatorMonth  = (short)DateTimeHelper.GetServerDateTime2().Month;

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

                if (headId > 0)
                {
                    for (int i = 0; i < this.lvwDetail.gridView1.DataRowCount; i++)
                    {
                        PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo;
                        if (detailInfo != null)
                        {
                            detailInfo.PurchaseHeadId = headId;
                            BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo);

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

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

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

                    if (highWarning)
                    {
                        string message = string.Format("{0} 库存量已经高过超预警库存量\r\n请注意减少库存积压", this.txtWareHouse.Text);
                        Portal.gc.Notify(string.Format("{0} 超库存预警", this.txtWareHouse.Text), message);
                    }
                }
                else
                {
                    MessageDxUtil.ShowError("保存失败");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmPurchase));
                MessageDxUtil.ShowError(ex.Message);
            }
        }
コード例 #28
0
        /// <summary>
        /// 初始化库房信息
        /// </summary>
        /// <param name="detailInfo">备件详细信息</param>
        /// <param name="quantity">期初数量</param>
        /// <param name="wareHouse">库房名称</param>
        /// <returns></returns>
        public bool InitStockQuantity(ItemDetailInfo detailInfo, int quantity, string wareHouse)
        {
            IStock dal = baseDal as IStock;

            return(dal.InitStockQuantity(detailInfo, quantity, wareHouse));
        }
コード例 #29
0
        /// <summary>
        /// 写入备件明细信息
        /// </summary>
        private int InsertItemDetailData(Dictionary <string, string> WareHouseDict)
        {
            int  intOk        = 0;
            int  intFail      = 0;
            bool isFirstError = true;


            if (myDs != null && myDs.Tables[0].Rows.Count > 0)
            {
                double    step = 50 * (1.0 / myDs.Tables[0].Rows.Count);
                DataTable dt   = myDs.Tables[0];
                try
                {
                    int i = 1;
                    foreach (DataRow dr in dt.Rows)
                    {
                        #region 单条记录操作代码
                        if (dr[0].ToString() == "")
                        {
                            continue;
                        }

                        string itemNo       = dr["备件编号(mm码)"].ToString();
                        string wareHouseKey = dr["库房编号"].ToString();
                        if (string.IsNullOrEmpty(itemNo) || string.IsNullOrEmpty(wareHouseKey))
                        {
                            continue;
                        }

                        try
                        {
                            string         wareHouse = WareHouseDict[wareHouseKey];
                            ItemDetailInfo itemInfo  = BLLFactory <ItemDetail> .Instance.FindByItemNo(itemNo);

                            if (itemInfo != null)
                            {
                                #region 更新
                                itemInfo.ItemBigType = dr["备件属类"].ToString();
                                itemInfo.ItemName    = dr["备件名称"].ToString();
                                itemInfo.ItemNo      = itemNo;
                                itemInfo.ItemType    = dr["备件类别"].ToString();
                                itemInfo.MapNo       = dr["图号"].ToString();
                                itemInfo.Material    = dr["材质"].ToString();
                                try
                                {
                                    itemInfo.Price = Convert.ToDecimal(dr["单价(元)"].ToString());
                                }
                                catch { }
                                itemInfo.Source        = dr["来源"].ToString();
                                itemInfo.Specification = dr["规格型号"].ToString();
                                itemInfo.StoragePos    = dr["库位"].ToString();
                                itemInfo.Unit          = dr["单位"].ToString();
                                itemInfo.UsagePos      = dr["使用位置"].ToString();
                                itemInfo.WareHouse     = wareHouse;
                                itemInfo.Dept          = dr["部门"].ToString();

                                bool success = BLLFactory <ItemDetail> .Instance.Update(itemInfo, itemInfo.ID.ToString());

                                if (success)
                                {
                                    intOk++;
                                }
                                #endregion
                            }
                            else
                            {
                                #region 添加
                                itemInfo             = new ItemDetailInfo();
                                itemInfo.ItemBigType = dr["备件属类"].ToString();
                                itemInfo.ItemName    = dr["备件名称"].ToString();
                                itemInfo.ItemNo      = itemNo;
                                itemInfo.ItemType    = dr["备件类别"].ToString();
                                itemInfo.MapNo       = dr["图号"].ToString();
                                itemInfo.Material    = dr["材质"].ToString();
                                try
                                {
                                    itemInfo.Price = Convert.ToDecimal(dr["单价(元)"].ToString());
                                }
                                catch { }
                                itemInfo.Source        = dr["来源"].ToString();
                                itemInfo.Specification = dr["规格型号"].ToString();
                                itemInfo.StoragePos    = dr["库位"].ToString();
                                itemInfo.Unit          = dr["单位"].ToString();
                                itemInfo.UsagePos      = dr["使用位置"].ToString();
                                itemInfo.WareHouse     = wareHouse;
                                itemInfo.Dept          = dr["部门"].ToString();

                                bool success = BLLFactory <ItemDetail> .Instance.Insert(itemInfo);

                                if (success)
                                {
                                    intOk++;
                                }
                                #endregion
                            }
                        }
                        catch (Exception ex)
                        {
                            intFail++;
                            LogTextHelper.Error(ex);
                            if (isFirstError)
                            {
                                MessageDxUtil.ShowError(ex.Message);
                                isFirstError = false;
                            }
                        }
                        #endregion

                        int currentStep = Convert.ToInt32(step * i);
                        worker.ReportProgress(currentStep);
                        i++;
                    }
                }
                catch (Exception ex)
                {
                    LogTextHelper.Error(ex);
                    MessageDxUtil.ShowError(ex.ToString());
                }
            }
            return(intOk);
        }
コード例 #30
0
        /// <summary>
        /// 编辑状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveUpdated()
        {
            bool exist = BLLFactory <ItemDetail> .Instance.CheckExist(this.txtItemNo.Text, Id);

            if (exist)
            {
                MessageDxUtil.ShowTips("指定的备件编号已经存在,不能重复添加,请修改");
                return(false);
            }

            ItemDetailInfo info = BLLFactory <ItemDetail> .Instance.FindById(Id);

            if (info != null)
            {
                if (txtBelongWareHouse.Text != txtBelongWareHouse.Tag.ToString())
                {
                    if (MessageDxUtil.ShowYesNoAndWarning("您的备件所属库存发生了修改,是否继续更改库房数据") == DialogResult.No)
                    {
                        return(false);
                    }
                }

                SetInfo(info);

                try
                {
                    #region 更新数据
                    bool succeed = BLLFactory <ItemDetail> .Instance.Update(info, info.Id);

                    if (succeed)
                    {
                        try
                        {
                            WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(this.txtItemNo.Text, this.txtBelongWareHouse.Tag.ToString());

                            if (wareInfo != null)
                            {
                                //wareInfo.wareInfo = txtBelongWareHouse.Text;
                                BLLFactory <Stock> .Instance.Update(wareInfo, wareInfo.Id);
                            }

                            //不管是更新还是新增,如果对应的备件编码在库房没有初始化,初始化之
                            bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtBelongWareHouse.Text, this.txtItemNo.Text);

                            if (!isInit)
                            {
                                BLLFactory <Stock> .Instance.InitStockQuantity(info, 0, this.txtBelongWareHouse.Text.ToInt32());
                            }
                        }
                        catch (Exception ex)
                        {
                            LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemDetail));
                            MessageDxUtil.ShowError("初始化库存为0失败:" + ex.Message);
                        }
                        //MessageDxUtil.ShowTips("备件数据保存成功");
                        //this.DialogResult = DialogResult.OK;
                        return(true);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemDetail));
                    MessageDxUtil.ShowError(ex.Message);
                }
            }
            return(false);
        }