Really Strange, the breakpoint in the oninserted method is not caught and no emails were sent
Strange thing is that the master record of issue has actually been created, and the support document as well
Update:
Just wondering how to trigger the oninserted command with a custom insert image button?
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:RCS_2_02ConnectionString %>"
DeleteCommand="DELETE FROM [IssueLog] WHERE [ItemNo] = @ItemNo"
InsertCommand="INSERT INTO [IssueLog] ([ProjectCode], [RespRaisedDate], [Lname], [Fname], [MobileNum],
[Email], [RespDesc]) VALUES (@ProjectCode, @RespRaisedDate, @Lname, @Fname, @MobileNum, @Email,
@RespDesc);
INSERT INTO SupportDoc(ItemNo, Image_Data) VALUES (@ItemNo, @SupportDoc);
SET @NewItemNo = Scope_Identity()"
SelectCommand="SELECT i.[ItemNo], i.[ProjectCode], i.[RespRaisedDate], i.[Lname], i.[Fname],
i.[MobileNum], i.[Email], i.[RespDesc]
, s.[Image_Data] AS [SupportDoc]
FROM [IssueLog] AS i
LEFT JOIN
[SupportDoc] AS s
ON i.ItemNo = s.ItemNo"
UpdateCommand="UPDATE [IssueLog] SET [ProjectCode] = @ProjectCode, [RespRaisedDate] = @RespRaisedDate, [Lname] = @Lname, [Fname] = @Fname, [MobileNum] = @MobileNum, [Email] = @Email, [RespDesc] = @RespDesc WHERE [ItemNo] = @ItemNo; UPDATE SupportDoc SET Image_Data = @SupportDoc WHERE ItemNo = @ItemNo"
oninserted="SqlDataSource4_Inserted"><DeleteParameters><asp:Parameter Name="ItemNo" /></DeleteParameters><InsertParameters><asp:Parameter Name="ProjectCode" /><asp:Parameter Name="RespRaisedDate" /><asp:Parameter Name="Lname" /><asp:Parameter Name="Fname" /><asp:Parameter Name="MobileNum" /><asp:Parameter Name="Email" /><asp:Parameter Name="RespDesc" /><asp:Parameter Name="ItemNo" /><asp:Parameter Name="SupportDoc" /><asp:Parameter Name="NewItemNo" Direction="Output" Type="Int32" /></InsertParameters><UpdateParameters><asp:Parameter Name="ProjectCode" /><asp:Parameter Name="RespRaisedDate" /><asp:Parameter Name="Lname" /><asp:Parameter Name="Fname" /><asp:Parameter Name="MobileNum" /><asp:Parameter Name="Email" /><asp:Parameter Name="RespDesc" /><asp:Parameter Name="ItemNo" /><asp:Parameter Name="SupportDoc" /></UpdateParameters></asp:SqlDataSource>
protected void SqlDataSource4_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
try
{
// Enter a approval record, awaiting for supervisor to assign
// get the generated item no
Int32 ItemNo = (Int32)e.Command.Parameters["@NewItemNo"].Value;
Approvals app = new Approvals();
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings
["RCS_2_02ConnectionString"].ConnectionString;
SqlCommand command = new SqlCommand("insert into Approvals (ItemNo, AppType, ApprovePersonID, Reason) VALUES (@ItemNo, @AppType, @ApprovePersonID, @Reason)", conn);
command.Parameters.AddWithValue("@ItemNo", ItemNo);
// Enter Issue Log Type
command.Parameters.AddWithValue("@AppType", 1);
command.Parameters.AddWithValue("@ApprovePersonID", Session["userId"]);
command.Parameters.AddWithValue("@Reason", "N/A");
conn.Open();
command.ExecuteNonQuery();
conn.Close();
String ClerkEmail = "";
String SupervisorEmail = "";
Helpers.GetEmailAddresses(ref ClerkEmail, ref SupervisorEmail);
// 2) Send an Email notification to the followup person
Helpers.SendingMail(ClerkEmail, SupervisorEmail, "New Issue Log Created", "New Issue Log Created");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}