Exemplo n.º 1
0
        private void addNewOrUpdateMunitButton_Click(object sender, EventArgs e)
        {
            try
            {
                var munitName = munitAddTextBox.Text;

                if (munitName != "")
                {
                    WWS.WarehouseServiceClient munitAdaptor = new WWS.WarehouseServiceClient(ServiceParametor.Parametor);
                    if (munit == null)
                    {
                        munit = new WWS.Munit()
                        {
                            MunitName = munitName
                        };
                    }
                    else
                    {
                        munit.MunitName = munitName;
                    }

                    munitAdaptor.CreateOrUpdateMunit(munit);


                    WWS.WarehouseServiceClient munitManager = new WWS.WarehouseServiceClient(ServiceParametor.Parametor);

                    var allMunit = munitManager.GetActiveMunit();

                    Constants.ApplicationData.Munits = new Dictionary <int, WWS.Munit>();

                    foreach (var item in allMunit)
                    {
                        Constants.ApplicationData.Munits.Add(item.Id.Value, item);
                    }



                    munitForm.LoadMunitToGrid(true);


                    this.Close();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 2
0
        private void addProductCategoryButton_Click(object sender, EventArgs e)
        {
            ProductCategory product = new ProductCategory();

            product.Id   = -1;
            product.Name = PCTextBox1.Text.ToString();
            var selItem = (ComboBoxKeyValuePair)productCategoryComboBox.SelectedItem;

            if (selItem.m_objKey != null)
            {
                product.ParentId = ((ProductCategory)selItem.m_objKey).Id.Value;
            }


            WWS.WarehouseServiceClient manager = new WWS.WarehouseServiceClient();
            int result = manager.CreateOrUpdateProductCategory(product);

            if (result == 0 || result == 1)
            {
                #region Load Product Categories

                var prodCategoryBL = new WWS.WarehouseServiceClient();

                var allCats = prodCategoryBL.GetAllProductCategories();

                Constants.ApplicationData.ProductCategory.Clear();

                foreach (var item in allCats)
                {
                    Constants.ApplicationData.ProductCategory.Add(item.Id.Value, item);
                }

                #endregion
            }

            mainForm.ProductCategoryRefresh();
            mainForm.Enabled = true;
            Close();
        }
Exemplo n.º 3
0
        private void newProductAddAndUpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                var productCategorySelect = ((IList <ProductCategory>)productCategorySelectProductComboBox1.Tag).Where(p => p.Name == productCategorySelectProductComboBox1.Text).ToList()[0];

                var munitSelect = ((IList <WWS.Munit>)munitSelectProductComboBox2.Tag).Where(m => m.MunitName == munitSelectProductComboBox2.Text).ToList()[0];


                var productName = newProductNameTextBox.Text;

                if (munitSelect != null && productCategorySelect != null && productName != "")
                {
                    WWS.WarehouseServiceClient productAdaptor = new WWS.WarehouseServiceClient(ServiceParametor.Parametor);
                    if (product == null)
                    {
                        product = new WWS.Product()
                        {
                            Name = productName, Munit = munitSelect.Id.Value, ProductCategoryId = productCategorySelect.Id
                        };
                    }
                    else
                    {
                        product.Name              = productName;
                        product.Munit             = munitSelect.Id.Value;
                        product.ProductCategoryId = productCategorySelect.Id;
                    }
                    productAdaptor.CreateOrUpdateProduct(product);

                    mainFrm.loadProductsInToGrid(true);
                    this.Close();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }