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 = ""; }
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(); } }