hi everyone i need ur help here is the problem i want to insert this values into my table at the same time (Member_ID,Interest_ID,Reference,date,interest_Recived ) at the end of every month then my code is look like this
private void Icalculater()
{
decimal x = Convert.ToDecimal(i_RateComboBox.Text);
DateTime t = Convert.ToDateTime(this.fmonthtextBox.Text);
DateTime v = Convert.ToDateTime(this.LmonthtextBox.Text);
String text = String.Format("{0:MMM-yyyy} Interest", v);
try
{
Adp.InsertCommand = new SqlCommand("insert into Received_Interest(Member_ID,Interest_Recived) select Member_ID,round(round((" + x + "/100/12),4)*sum(Amount_deposited),2)as I_R from Deposit_Statement where Deposit_Statement.Date between '" + t + "' and '" + v + "' group by Member_ID", con);
Adp.UpdateCommand = new SqlCommand("Update Received_Interest Set Interest_ID=@Interest_ID,Date=@Date,Reference=@Reference ", con);
Adp.UpdateCommand.Parameters.Add("@Interest_ID", SqlDbType.Int).Value = int.Parse(i_RateComboBox.SelectedValue.ToString());
Adp.UpdateCommand.Parameters.Add("@Date", SqlDbType.DateTime).Value = DateTime.Parse(dateTimePicker1.Text);
Adp.UpdateCommand.Parameters.Add("@Reference", SqlDbType.NVarChar).Value = text;
con.Open();
Adp.InsertCommand.ExecuteNonQuery();
Adp.UpdateCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Successfully you Enter the Interest", "Successfully you Enter the Interest");
}
catch
{
Console.Beep();
MessageBox.Show("Enter All the Information Correctly Please", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
the problem of this code is when i calculate the interest for the next month it also update the last month data
pls any one help me to edit my code the other thing if sum of deposit is less than 800 the interest is not calculated thanks in advance