//private void Button_Click_Update(object sender, RoutedEventArgs e) //{ // AddGodown addGodownWindow = new AddGodown(); // if (datagrid.SelectedIndex >= 0) // { // godown_master godown = datagrid.SelectedItem as godown_master; // addGodownWindow.GodownName.Text = godown.name; // addGodownWindow.Address.Text = godown.Address; // addGodownWindow.GodownId.Text = godown.id.ToString(); // addGodownWindow.btnModify.Visibility = Visibility.Visible; // addGodownWindow.btnSave.Visibility = Visibility.Hidden; // addGodownWindow.ShowDialog(); // } // else { // MessageBox.Show("Something went wroung!"); // } //} private void Button_Click_Delete(object sender, RoutedEventArgs e) { MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { if (datagrid.SelectedIndex >= 0) { product_master product = datagrid.SelectedItem as product_master; using (invetoryEntities db = new invetoryEntities()) { if (db.product_master.Where(x => x.id == product.id).ToList().Count > 0) { db.product_master.Remove(db.product_master.Find(product.id)); db.SaveChanges(); MessageBox.Show("Product deleted successfully."); LoadGrid(); } else { MessageBox.Show("Something went wrong please try again."); } } } } else { MessageBox.Show("Delete operation Terminated"); } }
private void SaveProduct() { if (ProductName.Text != "") { using (invetoryEntities db = new invetoryEntities()) { product_master product_Master = new product_master { product = ProductName.Text, category_id = 1, //item_group_id = Convert.ToInt32(ItemGroup.SelectedValue), unit_id = Convert.ToInt32(Unit.SelectedValue), alternat_unit_id = Convert.ToInt32(AlternetUnit.SelectedValue), mrp = Convert.ToDecimal(MRP.Text), rate_on = 1, tax_type = 1, sale_rate_on = 1, rate_persantage = 1, discount_consumer = 1, discount_other = 1, discount_on_qty = 1, brokerage = 1, min_qty = 1, order_qty = 1, status = 1, created_on = DateTime.Now, }; db.product_master.Add(product_Master); db.SaveChanges(); product_expenses_master product_Expenses_Master = new product_expenses_master { adhat = (Adhat.Text == ""?0:Convert.ToDecimal(Adhat.Text)), adhat_unit_id = Convert.ToInt32(AdhatPer.SelectedValue), taulai = (Taulai.Text == "" ? 0 : Convert.ToDecimal(Taulai.Text)), taulai_unit_id = Convert.ToInt32(TaulaiPer.SelectedValue), majoori = (Majoori.Text == "" ? 0 : Convert.ToDecimal(Majoori.Text)), majoori_unit_id = Convert.ToInt32(MajooriPer.SelectedValue), packing = (Packing.Text == "" ? 0 : Convert.ToDecimal(Packing.Text)), packing_unit_id = Convert.ToInt32(PackingPer.SelectedValue), mandi_sulk = (MundiSulk.Text == "" ? 0 : Convert.ToDecimal(MundiSulk.Text)), mandi_sulk_unit_id = Convert.ToInt32(MundiSulkPer.SelectedValue), vikash_sesh = (VikashSesh.Text == "" ? 0 : Convert.ToDecimal(VikashSesh.Text)), vikash_sesh_unit_id = Convert.ToInt32(VikashSeshPer.SelectedValue), packing_less = (PackingLess.Text == "" ? 0 : Convert.ToDecimal(VikashSesh.Text)), packing_less_unit_id = Convert.ToInt32(PackingLessPer.SelectedValue), product_id = product_Master.id, created_on = DateTime.Now, status = 1 }; db.product_expenses_master.Add(product_Expenses_Master); db.SaveChanges(); MessageBox.Show("Product save successfully."); //Clear_Form(); } } else { MessageBox.Show("Please fill compulsory data."); } }