コード例 #1
0
        private void Btn_SaveProduct_Click(object sender, EventArgs e)
        {
            var nameFilter = store.products.FirstOrDefault(p => p.ProductName == Txt_ProductNameUp.Text);

            if (nameFilter == null)
            {
                Products product = new Products();
                product.ProductName            = Txt_ProductNameUp.Text;
                product.Discount               = double.Parse(numericDiscountProUp.Text);
                product.IncomePrice            = double.Parse(numericIncomingPriceProUp.Text);
                product.NumberOfProductInGroup = double.Parse(numericQuantityPackageProUp.Value.ToString());
                product.quantityPerProducts    = double.Parse(numericQuantityPackageProUp.Text);
                product.Price_customer         = double.Parse(numericTotalPriceProUp.Text);
                //string n = Como_productBillBuySupplier.SelectedIndex.ToString();
                // MessageBox.Show();
                //product.Supplier =
                int s_id = int.Parse(Como_productBuySupplierUp.SelectedValue.ToString());
                product.supplier_id = s_id;

                product.categories_id  = int.Parse(Como_productCategoryUpdate.SelectedValue.ToString());
                product.ProductUnit_id = int.Parse(Como_productUnitUpdate.SelectedValue.ToString());


                store.products.Add(product);
                store.SaveChanges();
                AddProPanel.Hide();
                bindGridView();
            }
            else
            {
                MessageBox.Show("هذا المنتج  موجود  بالفعل");
                Txt_ProductNameUp.Text = null;
                // AllPro allPro = new AllPro();
            }
        }
コード例 #2
0
        private void btn_addPro_Click(object sender, EventArgs e)
        {
            AddProPanel.Show();
            EditBtn.Hide();
            Btn_SaveProduct.Show();

            Txt_ProductNameUp.Text                  = "";
            numericDiscountProUp.Text               = "";
            numericIncomingPriceProUp.Text          = "";
            numericIndvidualPriceProUp.Text         = "";
            numericQuantityProUp.Text               = "";
            numericQuantityPackageProUp.Text        = "";
            Como_productCategoryUpdate.SelectedText = "";
            Como_productBuySupplierUp.SelectedText  = "";
            Como_productUnitUpdate.SelectedText     = "";
        }
コード例 #3
0
        private void editBtnProduct_Click(object sender, EventArgs e)
        {
            if (dgv_SalesBill.SelectedRows.Count == 0)
            {
                MessageBoxIcon.Warning.ToString();
                MessageBox.Show("يجب ان تختار منتج من المنتجات");
            }
            else
            {
                AddProPanel.Show();
                Btn_SaveProduct.Hide();
                EditBtn.Show();
                var P_id = int.Parse(dgv_SalesBill.SelectedRows[0].Cells[6].Value.ToString());

                Como_productCategoryUpdate.DataSource    = store.categories.ToList();
                Como_productCategoryUpdate.DisplayMember = "CategoryName";
                Como_productCategoryUpdate.ValueMember   = "ID";

                //////suplier
                Como_productBuySupplierUp.DataSource    = store.suppliers.ToList();
                Como_productBuySupplierUp.DisplayMember = "Name";
                Como_productBuySupplierUp.ValueMember   = "ID";
                ////unt
                Como_productUnitUpdate.DataSource    = store.ProductUnits.ToList();
                Como_productUnitUpdate.DisplayMember = "Name";
                Como_productUnitUpdate.ValueMember   = "ID";

                var query = store.products.FirstOrDefault(d => d.ID == P_id);


                Txt_ProductNameUp.Text                  = query.ProductName;
                numericDiscountProUp.Text               = query.Discount.ToString();
                numericIncomingPriceProUp.Text          = query.IncomePrice.ToString();
                numericIndvidualPriceProUp.Text         = query.Price_individual.ToString();
                numericQuantityProUp.Text               = query.quantityPerProducts.ToString();
                numericQuantityPackageProUp.Value       = query.quantityPerGroup;
                Como_productCategoryUpdate.SelectedText = query.categories.CategoryName.ToString();
                Como_productBuySupplierUp.SelectedText  = query.Supplier.Name.ToString();
                Como_productUnitUpdate.SelectedText     = query.ProductUnit.Name.ToString();
            }
        }
コード例 #4
0
        private void EditBtn_Click(object sender, EventArgs e)
        {
            var      P_id     = int.Parse(dgv_SalesBill.SelectedRows[0].Cells[6].Value.ToString());
            Products products = store.products.FirstOrDefault(p => p.ID == P_id);

            products.ProductName            = Txt_ProductNameUp.Text;
            products.Discount               = double.Parse(numericDiscountProUp.Text);
            products.IncomePrice            = double.Parse(numericIncomingPriceProUp.Text);
            products.NumberOfProductInGroup = int.Parse(numericQuantityPackageProUp.Value.ToString());
            products.quantityPerProducts    = int.Parse(numericQuantityProUp.Value.ToString());
            products.Price_customer         = double.Parse(numericIndvidualPriceProUp.Text);
            int s_id = int.Parse(Como_productBuySupplierUp.SelectedValue.ToString());

            products.supplier_id    = s_id;
            products.categories_id  = int.Parse(Como_productCategoryUpdate.SelectedValue.ToString());
            products.ProductUnit_id = int.Parse(Como_productUnitUpdate.SelectedValue.ToString());
            // store.products.Add(products);
            store.SaveChanges();
            MessageBox.Show("تم تعديل المنتج");
            AddProPanel.Hide();

            bindGridView();
        }