hi
I am following this page Export RDLC Report to PDF without using ReportViewer in ASP.Net with C# and VB.Net
can i add date today and name
Response.AppendHeader("Content-Disposition", "attachment; filename=RDLC." + extension);
name in textbox txtUsername.Text
so in output = RDL_kankon_04-02-2023
protected void Insert2(object sender, EventArgs e)
{
if (txtUsername.Text == String.Empty)
{
ClientScript.RegisterStartupScript(this.GetType(), "randomtext", " alertmecheck()", true);
}
else
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/reportviewer/ReportVback.rdlc");
ReportParameter[] param = new ReportParameter[12];
param[0] = new ReportParameter("Reportbackname", txtUsername.Text);
param[1] = new ReportParameter("Reportbackjoptitil", joptitel.Text);
param[2] = new ReportParameter("Reportbackqsem", markazel3mel.Text);
param[3] = new ReportParameter("Reportbackeldarajah", eldarajah.Text);
param[4] = new ReportParameter("Reportbackfileid", filenumber.Text);
param[5] = new ReportParameter("Reportbackcivilid", civilid.Text);
param[6] = new ReportParameter("Reportbackdatestart", txtBoxDate8.Text);
param[7] = new ReportParameter("Reportbackdateend", txtBoxDate10.Text);
param[8] = new ReportParameter("Reportbackdateorderfromstart", txtBoxDate7.Text);
param[11] = new ReportParameter("Reportbackdateorderfromback1", txtBoxDate11.Text);
param[9] = new ReportParameter("Reportbackvacationback", ddlPC.Text);
param[10] = new ReportParameter("Reportbacknote", textmsg.Text);
ReportViewer1.LocalReport.SetParameters(param);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.Refresh();
string usernamemove = this.Page.User.Identity.Name;
string constr = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
SqlConnection con;
SqlCommand cmd;
using (con = new SqlConnection(constr))
{
string query = "insert into Table_vacation (idnamev,jop,eldarajah,el3malv,datesp10,idcivilv,datestart,dateend,vacationdata,totalva,infovacation,namevacation,iPAddress,dataaddtime,edit) " +
"VALUES (@idnamev,@jop,@eldarajah,@el3malv,@datesp10,@idcivilv,@datestart,@dateend,@vacationdata,@totalva,@infovacation,@namevacation,@iPAddress,@dataaddtime,@edit)";
using (cmd = new SqlCommand(query))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@idnamev", txtUsername.Text);
cmd.Parameters.AddWithValue("@jop", joptitel.Text);
cmd.Parameters.AddWithValue("@eldarajah", eldarajah.Text);
cmd.Parameters.AddWithValue("@el3malv", markazel3mel.Text);
cmd.Parameters.AddWithValue("@datesp10", filenumber.Text);
cmd.Parameters.AddWithValue("@idcivilv", civilid.Text);
cmd.Parameters.AddWithValue("@datestart", txtBoxDate8.Text);
cmd.Parameters.AddWithValue("@dateend", txtBoxDate10.Text);
cmd.Parameters.AddWithValue("@vacationdata", txtBoxDate7.Text);
cmd.Parameters.AddWithValue("@totalva", lblLabel2.Text);
cmd.Parameters.AddWithValue("@infovacation", ddlPC.Text);
cmd.Parameters.AddWithValue("@namevacation", "اجازة دورية");
cmd.Parameters.AddWithValue("@iPAddress", usernamemove);
cmd.Parameters.AddWithValue("@dataaddtime", Convert.ToDateTime(DateTime.Now.ToLongTimeString()));
cmd.Parameters.AddWithValue("@edit", "(جديد)");
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
//insert date vacation into user data start date vacation to end date vacation
using (con = new SqlConnection(constr))
{
string query = "UPDATE Table_infoname SET DateTimePicker1 = @DateTimePicker1,DateTimePicker2 = @DateTimePicker2 WHERE civilid = @Civilid";
using (cmd = new SqlCommand(query))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue("@civilid", civilid.Text.ToString());
cmd.Parameters.AddWithValue("@DateTimePicker1", txtBoxDate8.Text.ToString());
cmd.Parameters.AddWithValue("@DateTimePicker2", txtBoxDate10.Text.ToString());
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(this.GetType(), "randomtext", " alertADD1()", true);
con.Close();
}
}
Warning[] warnings1;
string[] streamIds1;
string contentType1;
string encoding1;
string extension1;
//Export the RDLC Report to Byte Array.
byte[] bytes1 = ReportViewer1.LocalReport.Render(rbFormat.SelectedItem.Value, null, out contentType1, out encoding1, out extension1, out streamIds1, out warnings1);
//Download the RDLC Report in Word, Excel, PDF and Image formats.
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType1;
Response.AppendHeader("Content-Disposition", "attachment; filename=RDL." + extension1);
Response.BinaryWrite(bytes1);
Response.Flush();
Response.End();
}
}