public void UpdateTransaction(DTO_Class.TransactionDTO transactionDTO) { sqlConnection.Open(); string sqlQuery = "Update trans SET MonthYear='" + transactionDTO.DATE + "' where MonthYear='" + transactionDTO.DATE + "'"; sqlCommand = new SqlCommand(sqlQuery, sqlConnection); sqlCommand.ExecuteNonQuery(); string sqlQuery1 = "Update trans SET Revenue='" + transactionDTO.REVENUE + "' where MonthYear='" + transactionDTO.DATE + "'"; sqlCommand1 = new SqlCommand(sqlQuery1, sqlConnection); sqlCommand1.ExecuteNonQuery(); string sqlQuery2 = "Update trans SET Expense='" + transactionDTO.EXPENSE + "' where MonthYear='" + transactionDTO.DATE + "'"; sqlCommand2 = new SqlCommand(sqlQuery2, sqlConnection); sqlCommand2.ExecuteNonQuery(); string sqlQuery3 = "Update trans SET Profit='" + transactionDTO.PROFIT + "' where MonthYear='" + transactionDTO.DATE + "'"; sqlCommand3 = new SqlCommand(sqlQuery3, sqlConnection); sqlCommand3.ExecuteNonQuery(); sqlConnection.Close(); }
public void CreateTransaction(DTO_Class.TransactionDTO transactionDTO) { try { sqlConnection.Open(); string sqlQuery = " insert into trans values('" + transactionDTO.DATE + "','" + transactionDTO.REVENUE + "','" + transactionDTO.EXPENSE + "','" + transactionDTO.PROFIT + "')"; sqlCommand = new SqlCommand(sqlQuery, sqlConnection); sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); } catch (Exception ex) { MessageBox.Show("Invalid Input!", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error); } }