Пример #1
0
        private void btnLevelAdd_Click(object sender, EventArgs e)
        {
            var oForm = new LocationProductForm(this.OfflineMode);

            if (oForm.ShowDialog() == DialogResult.OK)
            {
                if (oForm.ProductLocation == null)
                {
                    return;
                }

                if (bsLocation.DataSource == null)
                {
                    bsLocation.DataSource = new List <ProductLocation>();
                }

                var location  = oForm.ProductLocation;
                var locations = (List <ProductLocation>)bsLocation.DataSource;

                var productLocation = locations.Find(p => p.ProductCode == location.ProductCode);
                if (productLocation != null)// update
                {
                    if (GlobalMessageBox.ShowQuestion("มีสินค้านี้อยู่ในตำแหน่งแล้ว\nคุณต้องการแก้ไขสินค้านี้ ใช่หรือไม่ ?") == DialogResult.Yes)
                    {
                        productLocation.ProductBarcode             = oForm.ProductLocation.ProductBarcode;
                        productLocation.ProductCode                = oForm.ProductLocation.ProductCode;
                        productLocation.PutLevel                   = oForm.ProductLocation.PutLevel;
                        productLocation.ProductName                = oForm.ProductLocation.ProductName;
                        productLocation.PutQuantity                = oForm.ProductLocation.PutQuantity;
                        productLocation.ProductUnitCode            = oForm.ProductLocation.ProductUnitCode;
                        productLocation.ProductUnitName            = oForm.ProductLocation.ProductUnitName;
                        productLocation.RequestPrintLabel          = oForm.ProductLocation.RequestPrintLabel;
                        productLocation.RequestPrintLabelSpecified = true;
                        productLocation.MaxStock                   = oForm.ProductLocation.MaxStock;
                        productLocation.MaxStockSpecified          = true;

                        bsLocation.ResetBindings(false);
                        btnAdd.Focus();
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
                else // add
                {
                    locations.Add(location);
                    bsLocation.ResetBindings(false);

                    this.Reindex();
                    btnLevelAdd_Click(sender, e);
                }
            }

            _currentRowIndex = dgLocation.VisibleRowCount - 1;
            GridSelected();
        }
Пример #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dgLocation.VisibleRowCount > 0)
            {
                var productCode  = GetCurrentProductCode();
                var displayOrder = GetCurrentRowIndex();
                var locations    = (List <ProductLocation>)bsLocation.DataSource;
                var localtion    = locations.Find(p => p.ProductCode == productCode && p.DisplayOrder == displayOrder);
                //var location = localtion;
                var oForm = new LocationProductForm(localtion, OfflineMode);
                if (oForm.ShowDialog() == DialogResult.OK)
                {
                    if (oForm.ProductLocation != null)
                    {
                        //localtion = locations.Find(p => p.ProductBarcode == barcode);

                        //localtion = oForm.ProductLocation
                        localtion.ProductBarcode             = oForm.ProductLocation.ProductBarcode;
                        localtion.ProductCode                = oForm.ProductLocation.ProductCode;
                        localtion.PutLevel                   = oForm.ProductLocation.PutLevel;
                        localtion.ProductName                = oForm.ProductLocation.ProductName;
                        localtion.PutQuantity                = oForm.ProductLocation.PutQuantity;
                        localtion.ProductUnitCode            = oForm.ProductLocation.ProductUnitCode;
                        localtion.ProductUnitName            = oForm.ProductLocation.ProductUnitName;
                        localtion.RequestPrintLabel          = oForm.ProductLocation.RequestPrintLabel;
                        localtion.RequestPrintLabelSpecified = true;
                        localtion.MaxStock                   = oForm.ProductLocation.MaxStock;
                        localtion.MaxStockSpecified          = true;

                        bsLocation.ResetBindings(false);
                    }
                }

                GridSelected();
            }
        }
Пример #3
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            //var rowIndex = dgLocation.CurrentCell.RowNumber;
            var locations = (List <ProductLocation>)bsLocation.DataSource;
            //var displayOrder = locations.Find(p => p.ProductCode == this.GetCurrentProductCode()).DisplayOrder;
            var displayOrder = _currentRowIndex;
            var oForm        = new LocationProductForm(this.OfflineMode);

            if (oForm.ShowDialog() == DialogResult.OK)
            {
                if (bsLocation.DataSource == null)
                {
                    bsLocation.DataSource = new List <ProductLocation>();
                }

                var location = oForm.ProductLocation;
                if (location == null)
                {
                    return;
                }

                var productLocation = locations.Find(p => p.ProductBarcode == location.ProductBarcode);
                if (productLocation != null)
                {
                    if (GlobalMessageBox.ShowQuestion("มีสินค้านี้อยู่ในตำแหน่งแล้ว\nคุณต้องการแก้ไขสินค้านี้ ใช่หรือไม่ ?") == DialogResult.Yes)
                    {
                        productLocation.ProductBarcode             = oForm.ProductLocation.ProductBarcode;
                        productLocation.ProductCode                = oForm.ProductLocation.ProductCode;
                        productLocation.PutLevel                   = oForm.ProductLocation.PutLevel;
                        productLocation.ProductName                = oForm.ProductLocation.ProductName;
                        productLocation.PutQuantity                = oForm.ProductLocation.PutQuantity;
                        productLocation.ProductUnitCode            = oForm.ProductLocation.ProductUnitCode;
                        productLocation.ProductUnitName            = oForm.ProductLocation.ProductUnitName;
                        productLocation.RequestPrintLabel          = oForm.ProductLocation.RequestPrintLabel;
                        productLocation.RequestPrintLabelSpecified = true;
                        productLocation.MaxStock                   = oForm.ProductLocation.MaxStock;
                        productLocation.MaxStockSpecified          = true;
                        bsLocation.ResetBindings(false);
                        return;
                    }
                    else
                    {
                        return;
                    }
                }

                if (displayOrder == 0)
                {
                    locations.Insert(0, location);
                }
                else
                {
                    locations.Insert(displayOrder, location);
                }
                //locations.Insert(displayOrder - 1, location);

                bsLocation.ResetBindings(false);

                this.Reindex();

                _currentRowIndex = displayOrder;
                GridSelected();
            }
        }