Exemplo n.º 1
0
 public NewProductAddForm(MainForm mainFrm, bool flag, WWS.Product product)
 {
     InitializeComponent();
     this.mainFrm = mainFrm;
     this.flag    = flag;
     this.product = product;
 }
Exemplo n.º 2
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);
            }
        }