I have a strange problem in asp . net that couldn't find any solution over internet. i have a page that print a Letter for user and insert the info of user in DB. i put the code in the bottom. when user click insert button it write-in the data to Db then create a pdf file for downloading and send to client. but if user download it with browser, everything going well but if download with internet download manager(i test with IDM) the insert in DB Method Repeat for 2-3 or 4 times. can you HELP me?!!!
protected void VacationInserted()
{
R1.Load(Server.MapPath("~/App_Data/Report.mrt"));
ATA.Fill(ADT, User.Identity.Name);
R1.Dictionary.Variables["Automobile"].Value = ADT.Rows[0]["Model"].ToString();
R1.Dictionary.Variables["No"].Value = ADT.Rows[0]["No_"].ToString();
UTA.Fill(UDT, User.Identity.Name);
R1.Dictionary.Variables["Name"].Value = UDT.Rows[0]["FirstName"].ToString() + " " + UDT.Rows[0]["LastName"].ToString();
R1.Dictionary.Variables["StartDate"].Value = StartVacationDate.Text;
R1.Dictionary.Variables["EndDate"].Value = EndVacationDate.Text;
R1.Dictionary.Variables["Period"].Value = Diff.ToString();
R1.Dictionary.Variables["Destination"].Value = TxtDestination.Text;
R1.Dictionary.Variables["LetterNumber"].Value = LDT.Rows[0]["LetterNumber"].ToString();
R1.Dictionary.Variables["InsertDate"].Value = Converter.Today();
LTA.Update((((double)LDT.Rows[0]["LetterNumber"]) + 0.01), ((int)LDT.Rows[0]["LetterCount"]) + 1);
Update_VacRemain();
if (PrintSelect.SelectedValue == "pdf")
{
pdfexport();
}
}
protected void pdfexport()
{
MemoryStream ms = new MemoryStream();
R1.Render();
Stimulsoft.Report.Export.StiBitmapExportSettings s = new Stimulsoft.Report.Export.StiBitmapExportSettings();
Stimulsoft.Report.Export.StiPdfExportSettings s1 = new Stimulsoft.Report.Export.StiPdfExportSettings();
Stimulsoft.Report.Export.StiPdfExportService pdfservice = new Stimulsoft.Report.Export.StiPdfExportService();
s1.Compressed = true;
s1.EmbeddedFonts = true;
s1.ImageCompressionMethod = Stimulsoft.Report.Export.StiPdfImageCompressionMethod.Jpeg;
s1.ImageQuality = 100;
s1.SubjectNameString = "Vacation";
pdfservice.ExportPdf(R1, ms, s1);
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "Application/PDF";
Response.AddHeader("Content-Disposition", "attachment;filename=Print_Vac.pdf");
ms.Position = 0;
ms.WriteTo(Response.OutputStream);
ms.Dispose();
Page.Response.End();
}
protected void InsertVacation_Click(object sender, EventArgs e)
{
LTA.Fill(LDT);
Start = (DateTime)StartVacationDate.DateValue;
End = (DateTime)EndVacationDate.DateValue;
Diff = ((End - Start).TotalDays) + 1;
TextBox Txt_VacRemainder = (TextBox)DetailsView2.FindControl("Txt_VacRemainder");
Remain = Convert.ToInt32(Txt_VacRemainder.Text) - Convert.ToInt32(Diff);
if (Remain < 0)
{
Page.ClientScript.RegisterStartupScript(GetType(), "hwa", "a()", true);
}
else
{
if (Diff < 0)
{
Page.ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('...');", true);
}
else
{
NationalNumber = User.Identity.Name;
InsertDate = DateTime.Now;
LetterNumber = Math.Round(float.Parse(LDT.Rows[0]["LetterNumber"].ToString()), 2).ToString();
VTA.Insert(NationalNumber, InsertDate, Start, End, Remain, true, TxtDestination.Text, Math.Round(float.Parse(LDT.Rows[0]["LetterNumber"].ToString()), 2));
VacationInserted();
}
}
}