//Update Recode void iExpenses.UpdateExpensesRecode(cExpenses Expenses) { if (Expenses.expensesID > 0) { SqlCommand cmd = new SqlCommand("UPDATE expensesPayment SET expensesUnitName = @EUName, expensesType = @ExpensesType, expensesAmount = @ExpensesAmount, expensesDate = @ExpensesDate, expensesDescription = @ExpensesDescription WHERE expensesID = @EID", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@EUName", Expenses.expensesUnitName); cmd.Parameters.AddWithValue("@ExpensesType", Expenses.expensesType); cmd.Parameters.AddWithValue("@ExpensesAmount", Expenses.expensesAmount); cmd.Parameters.AddWithValue("@ExpensesDate", Expenses.expensesDate); cmd.Parameters.AddWithValue("@ExpensesDescription", Expenses.expensesDescription); cmd.Parameters.AddWithValue("@EID", Expenses.expensesID); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("A New Expenses Recode is Update Successfully", "Successfully Inserted"); InUC.Show(); } else { InUC.Hide(); ErrorDialogBox.ShowDialog("Please Select a Expenses Recode to Update", "Error"); InUC.Show(); } }
private void btnExpensesUpdate_Click(object sender, EventArgs e) { if (IsEmpty() && IsValid()) { cExpenses cEx = new cExpenses(ExpensesID.expensesID, dropExpensesUnitName.Text, dropExpensesType.Text, txtExpensesAmount.Text, txtExpensesDate.Text, txtExpensesDescription.Text); iExpenses iEx = new ExpensesImpl(); iEx.UpdateExpensesRecode(cEx); ReadRecode(); ResetExpensesRecode(); } }
//Insert Recode void iExpenses.InsertExpensesRecode(cExpenses Expenses) { SqlCommand cmd = new SqlCommand("INSERT INTO expensesPayment VALUES (@EUName, @ExpensesType, @ExpensesAmount, @ExpensesDate, @ExpensesDescription)", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@EUName", Expenses.expensesUnitName); cmd.Parameters.AddWithValue("@ExpensesType", Expenses.expensesType); cmd.Parameters.AddWithValue("@ExpensesAmount", Expenses.expensesAmount); cmd.Parameters.AddWithValue("@ExpensesDate", Expenses.expensesDate); cmd.Parameters.AddWithValue("@ExpensesDescription", Expenses.expensesDescription); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("A New Expenses Recode is Insert Successfully", "Successfully Inserted"); InUC.Show(); }
//Delete Recode void iExpenses.DeleteExpensesRecode(cExpenses Expenses) { if (Expenses.expensesID > 0) { SqlCommand cmd = new SqlCommand("DELETE FROM expensesPayment WHERE expensesID = @EID", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@EID", Expenses.expensesID); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("Expenses Recode is Delete Successfully", "Successfully Deleted"); InUC.Show(); } else { InUC.Hide(); ErrorDialogBox.ShowDialog("Please Select a Expenses Recode to Delete", "Error"); InUC.Show(); } }