protected void btnExportPdf_Command(object sender, CommandEventArgs e)
    {
        GridView gv = ((GridView)((ImageButton)sender).FindControl("gvRpt"));

        if (e.CommandArgument.ToString() == "1")
        {
            btnGenerate_Click(null, null);
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=AttendanceRegister.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            Panel11.RenderControl(hw);
            StringReader sr         = new StringReader(sw.ToString());
            Document     pdfDoc     = new Document(PageSize.A2, 0f, 0f, 10f, 0f);
            HTMLWorker   htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
            htmlparser.Parse(sr);
            pdfDoc.Close();
            Response.Write(pdfDoc);
            Response.End();
        }
        else if (e.CommandArgument.ToString() == "2")
        {
            btnGenerate_Click(null, null);
            btnExportPdf.Visible     = false;
            btnExportToExcel.Visible = false;
            Panel11.OpenInBrowser    = true;
            Panel11.ExportType       = ControlFreak.ExportPanel.AppType.Excel;
        }
    }
Beispiel #2
0
    protected void SummitView_Click(object sender, EventArgs e)
    {
        Guid   ppds = new Guid(DropDownList3.SelectedValue);
        string view = TextBox12.Text;
        int    a    = dp.Update_DepView(ppds, Session["UserName"].ToString(), view);

        if (a > 0)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('提交成功!')", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('提交失败!')", true);
        }
        Panel11.Visible = false;
        UpdatePanel11.Update();
        Panel11.Dispose();
        GridView1.DataSource = dp.Query_DefectProduct();
        GridView1.DataBind();
        UpdatePanel2.Update();
    }