Example #1
0
        private void Button_Click_Delete(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)  // error is here
            {
                if (datagrid.SelectedIndex >= 0)
                {
                    godown_master godown = datagrid.SelectedItem as godown_master;
                    using (invetoryEntities db = new invetoryEntities())
                    {
                        if (db.godown_master.Where(x => x.id == godown.id).ToList().Count > 0)
                        {
                            db.godown_master.Remove(db.godown_master.Find(godown.id));
                            db.SaveChanges();
                            MessageBox.Show("Godown deleted successfully.");
                            LoadGrid();
                        }
                        else
                        {
                            MessageBox.Show("Something went wrong please try again.");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Delete operation Terminated");
            }
        }
Example #2
0
        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!");
            }
        }