submitting form - object creation timing
using the flixon generator - when i submit a form, is the following order of events correct:
1. in code-behind:
protected void btnSubmit_Click(object sender, EventArgs e)
{
int result = Report.InsertReport(Convert.ToDateTime(Date.Text), Time.Text, Details.Text)
}
================================================== ===================
2. this goes to the Report.cs file:
public static int[] InsertReport(DateTime Date,
string Time,
string Details)
{
int result
result = SiteProvider.Report.InsertReport(new ReportsEntity(0,Date,Time,Details));
}
================================================== ====================
3. this then passes to the SqlReportProvider:
public override int InsertReport(ReportsEntity report)
{
int result;
try
{
using (SqlConnection cn = new SqlConnection(ConnectionString))
{
SqlCommand cmd = new SqlCommand("up_ReportsAdd", cn);
cmd.Parameters.Add("@ReportID", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@Date", SqlDbType.SmallDateTime).Value = Report.Date;
cmd.Parameters.Add("@Time", SqlDbType.Char).Value = Report.Time;
cmd.Parameters.Add("@Details", SqlDbType.NVarChar).Value = Report.Details;
cmd.CommandType = CommandType.StoredProcedure;
cn.Open();
ExecuteNonQuery(cmd);
result = (int)cmd.Parameters["@tReportID"].Value;
}
}
catch (SqlException e)
{
CommonFunctions.LogError(e.Message, (int)ErrorID.Report);
result = -1;
}
return result;
}
|