private void deleteRecord_Click(object sender, RoutedEventArgs e) { int row; dc = new DataClasses1DataContext(); WithdrawItemTable ins = new WithdrawItemTable(); ins = mygridview.SelectedItem as WithdrawItemTable; row = Convert.ToInt32(ins.Id); if (MessageBox.Show("Do you want to delete data?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { } else { // Do not close the window } var selectQuery = from rows in dc.WithdrawItemTables where rows.Id == row select rows; foreach (var c in selectQuery) { dc.WithdrawItemTables.DeleteOnSubmit(c); dc.SubmitChanges(); } MessageBox.Show("Data Deleted Successfully!!"); mygridview.ItemsSource = dc.WithdrawItemTables; }
public Window3() { InitializeComponent(); dc = new DataClasses1DataContext(); //for SHowing withraw data WithdrawItemTable wt = new WithdrawItemTable(); var qu = from a in dc.WithdrawItemTables select a; mygridview3.ItemsSource = qu.ToList(); myadmingrid2.ItemsSource = dc.logins; combobox.Items.Add("Manager"); combobox.Items.Add("Employee"); // For Showing Stocks var que = from a in dc.InsertStocks select a; mygridview1.ItemsSource = que.ToList(); }
//this will sub data and insert into database when user try to withdraw data private void Button_Click_1(object sender, RoutedEventArgs e) { if (noitem.Text.Length != 0) { total = itemNum - Convert.ToDouble(noitem.Text); // MessageBox.Show(total.ToString()); dc = new DataClasses1DataContext(); WithdrawItemTable wit = new WithdrawItemTable(); wit.itemType = fetchType.Text; wit.itemName = fetchName.Text; wit.oldQuantity = itemNum.ToString(); wit.quantityWithdraw = noitem.Text; wit.updateQuantity = total.ToString(); wit.empName = value2; wit.datetime = dt; dc.WithdrawItemTables.InsertOnSubmit(wit); dc.SubmitChanges(); updateInsertStock(); MessageBox.Show("Withdraw Done Successfully!!"); } }
partial void DeleteWithdrawItemTable(WithdrawItemTable instance);
partial void UpdateWithdrawItemTable(WithdrawItemTable instance);
partial void InsertWithdrawItemTable(WithdrawItemTable instance);