コード例 #1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (this.gvPODetails.GetFocusedRow() == null)
            {
                return;
            }

            T_PurchaseOrderDetail detail = this.gvPODetails.GetFocusedRow() as T_PurchaseOrderDetail;

            EnteringWindow window = new EnteringWindow();

            window.Material      = detail.Material;
            window.Quantity      = detail.Quantity;
            window.ExistQuantity = _StockMaterials.Where(o => o.PODetailId == (this.gvPODetails.GetFocusedRow() as T_PurchaseOrderDetail).Id).Sum(o => o.Quantity);

            window.FormClosed += (o, ee) =>
            {
                if (window.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    if (_StockMaterials.Where(m => m.StockCode == window.StockCode.Code && m.MatCode == SelectedDetail.Material.MatCode).Count() > 0)
                    {
                        T_StockMaterial material = _StockMaterials.Find(m => m.StockCode == window.StockCode.Code && m.MatCode == SelectedDetail.Material.MatCode && m.PODetailId == SelectedDetail.Id);
                        material.Quantity          += window.EnteringQuantity;
                        material.AvailableQuantity += window.EnteringQuantity;

                        if (!_AddList.Contains(material))
                        {
                            _EditList.Add(material);
                        }
                    }
                    else
                    {
                        T_StockMaterial material = new T_StockMaterial()
                        {
                            PONo              = SelectedDetail.PONo,
                            PODetailId        = SelectedDetail.Id,
                            Unit              = SelectedDetail.Unit,
                            MatCode           = SelectedDetail.Material.MatCode,
                            MatDesc           = SelectedDetail.Material.MatDesc,
                            MatTypeCode       = SelectedDetail.Material.MatTypeCode,
                            MatModeCode       = SelectedDetail.Material.MatModeCode,
                            StockCode         = window.StockCode.Code,
                            StockDesc         = window.StockCode.Desc,
                            Quantity          = window.EnteringQuantity,
                            AvailableQuantity = window.EnteringQuantity
                        };

                        (this.gcStockMaterials.DataSource as List <T_StockMaterial>).Add(material);
                        _StockMaterials.Add(material);
                        _AddList.Add(material);
                    }

                    this.gvStockMaterials.RefreshData();
                }
            };

            window.ShowDialog();
        }
コード例 #2
0
        public void AddApplyUserOrderDetail(T_ApplyUseOrderDetail detail)
        {
            T_StockMaterial stockMaterial = StockMaterialList.Find(o => o.MatCode == detail.MatCode && o.Unit == detail.Unit);

            ApplyUseOrderDetailList.Add(detail);

            if (stockMaterial != null)
            {
                stockMaterial.AvailableQuantity -= detail.Quantity;
            }
        }
コード例 #3
0
        public void DeleteApplyUserOrderDetail(string id)
        {
            T_ApplyUseOrderDetail detail = ApplyUseOrderDetailList.Find(o => o.Id == id);

            if (detail != null)
            {
                T_StockMaterial stockMaterial = StockMaterialList.Find(o => o.MatCode == detail.MatCode);
                if (stockMaterial != null)
                {
                    stockMaterial.AvailableQuantity += detail.Quantity;
                }

                ApplyUseOrderDetailList.Remove(ApplyUseOrderDetailList.Find(o => o.Id == id));
            }
        }
コード例 #4
0
        public List <T_StockMaterial> GetMergeStockMaterials()
        {
            List <T_StockMaterial> materialList = new List <T_StockMaterial>();

            foreach (var item in StockMaterialList.GroupBy(o => new { o.MatCode, o.MatDesc, o.MatTypeCode, o.MatModeCode, o.Unit }).Select(g => new { g.Key.MatCode, g.Key.MatDesc, g.Key.MatTypeCode, g.Key.MatModeCode, g.Key.Unit, AvailableQuantity = g.Sum(t => t.AvailableQuantity) }))
            {
                T_StockMaterial material = new T_StockMaterial();
                material.MatCode           = item.MatCode;
                material.MatDesc           = item.MatDesc;
                material.MatTypeCode       = item.MatTypeCode;
                material.MatModeCode       = item.MatModeCode;
                material.Unit              = item.Unit;
                material.AvailableQuantity = item.AvailableQuantity;

                materialList.Add(material);
            }

            return(materialList);
        }
コード例 #5
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (this.gvStockMaterials.GetFocusedRow() == null)
            {
                return;
            }

            T_StockMaterial material = this.gvStockMaterials.GetFocusedRow() as T_StockMaterial;

            if (_AddList.Contains(material))
            {
                _AddList.Remove(material);
            }
            else
            {
                _DelList.Add(material);
            }

            (this.gcStockMaterials.DataSource as List <T_StockMaterial>).Remove(material);
            _StockMaterials.Remove(material);
            this.gvStockMaterials.RefreshData();
        }
コード例 #6
0
 public void UpdateStockMaterial(T_StockMaterial stockMaterial)
 {
     StockMaterialList.Remove(StockMaterialList.Find(o => o.StockCode == stockMaterial.StockCode && o.MatCode == stockMaterial.MatCode));
     StockMaterialList.Add(stockMaterial);
 }