private void Remove_Click(object sender, RoutedEventArgs e) { RemoveDialogView handle = new RemoveDialogView(); if (handle.ShowDialog() == true) { using (SqlConnection con = new SqlConnection(@Connection.ConnectionString)) { if (handle.FirstInput != handle.SecondInput) { MessageBox.Show("Entry No. did not match.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Connection conn = new Connection(); conn.OpenConection(); int isLogin = 0; string query = "SELECT * From Stuff "; SqlDataReader reader = conn.DataReader(query); while (reader.Read()) { stuff_name = (string)reader["Stuff_Name"]; stuff_pass = (string)reader["Stuff_Password"]; if (stuff_name.Equals(Login.GlobalStuffName) && stuff_pass.Equals(handle.GetPassword)) { isLogin = 1; break; } } if (isLogin != 1) { MessageBox.Show("Wrong Password.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } using (SqlCommand command = new SqlCommand("DELETE FROM LoanCollection WHERE LoanCollection_Id = " + handle.FirstInput, con)) { con.Open(); command.ExecuteNonQuery(); con.Close(); } Id = Convert.ToInt32(handle.FirstInput); dateTime = (DateTime)Login.GlobalDate; string table = "Loan Collection Ledger"; string type = "Removed"; string color = "Red"; EntryLog entry = new EntryLog(); entry.Add_Entry(table, type, Id, dateTime, color); conn.CloseConnection(); LoanLedger data = new LoanLedger(); int tempId = Convert.ToInt32(Loan.Text); DailyLedger.ItemsSource = data.GetDataIndividual(method, tempId, 2); DataContext = data; } } }
private void Remove_Click(object sender, RoutedEventArgs e) { RemoveDialogView handle = new RemoveDialogView(); handle.ChangeLabelForMember(); if (handle.ShowDialog() == true) { using (SqlConnection con = new SqlConnection(@Connection.ConnectionString)) { if (handle.FirstInput != handle.SecondInput) { MessageBox.Show("Member ID did not match.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Connection conn = new Connection(); conn.OpenConection(); int isLogin = 0; string query = "SELECT * From Stuff "; SqlDataReader reader = conn.DataReader(query); while (reader.Read()) { stuff_name = (string)reader["Stuff_Name"]; stuff_pass = (string)reader["Stuff_Password"]; if (stuff_name.Equals(Login.GlobalStuffName) && stuff_pass.Equals(handle.GetPassword)) { isLogin = 1; break; } } if (isLogin != 1) { MessageBox.Show("Wrong Password.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } using (SqlCommand command = new SqlCommand("DELETE FROM MonthlyDepositDetails WHERE MemberId = " + handle.FirstInput, con)) { con.Open(); command.ExecuteNonQuery(); con.Close(); } Id = Convert.ToInt32(handle.FirstInput); dateTime = DateTime.Today; string table = "MonthlyDepositDetails"; string type = "Removed"; string color = "Red"; EntryLog entry = new EntryLog(); entry.Add_Entry(table, type, Id, dateTime, color); conn.CloseConnection(); GeneralLedger data = new GeneralLedger(); //next click } } }