コード例 #1
0
    private PenerimaanDomain GeneratePenerimaan(string noId)
    {
        SqlConnection conn  = Common.getConnection();
        string        query = "";
        SqlCommand    cmd   = new SqlCommand();

        cmd.Connection  = conn;
        cmd.CommandType = System.Data.CommandType.Text;
        PenerimaanDomain pDomain = new PenerimaanDomain();

        /*
         * select a.*, b.username from t_penerimaan_inventaris a left join m_user b on a.id_user_kabag = b.id where a.id = " + HiddenIDPenerimaan.Value + "";
         */

        query = "select a.*, b.username from t_penerimaan a left join m_user b on a.id_user = b.id_user where a.id_penerimaan ='" + noId + "' or no_penerimaan ='" + noId + "'";
        System.Diagnostics.Debug.WriteLine(query);
        cmd.CommandText = query;

        conn.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.Read())
        {
            pDomain.id  = reader["id_penerimaan"].ToString();
            pDomain.Hal = reader["judul_penerimaan"].ToString().Trim();
            //  pDomain.Pengaju = reader["kabag"].ToString();
            pDomain.Keterangan = reader["keterangan"].ToString();
            // pDomain.RefPengajuan = reader["no_pengajuan"].ToString();
            pDomain.Tipe = reader["tipe_ref"].ToString();

            if (pDomain.Tipe.Equals("1"))
            {
                pDomain.RefPengajuan = reader["id_pembelian"].ToString();
            }
            else
            {
                pDomain.RefPengajuan = reader["id_service_keluar"].ToString();
            }
        }

        conn.Close();

        return(pDomain);
    }
コード例 #2
0
    private DataTable GetData(PenerimaanDomain peDomain)
    {
        DataTable dt = new DataTable();

        SqlConnection conn  = Common.getConnection();
        string        query = "";

        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.Connection  = conn;
            cmd.CommandType = System.Data.CommandType.Text;

            string cond = "where id_penerimaan = '" + peDomain.id + "'";
            query = "select * from v_penerimaan_report_detail " + cond;
            System.Diagnostics.Debug.WriteLine(query);
            cmd.CommandText = query;
            SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd);
            dataAdapter.Fill(dt);
        }
        return(dt);
    }
コード例 #3
0
    private void GenerateReport()
    {
        //dataTable

        ReportViewer1.Reset();
        ReportViewer1.LocalReport.ReportPath = "Laporan/PenerimaanDetail.rdlc";

        PenerimaanDomain peDomain = GeneratePenerimaan(TbID.Text);

        ReportParameter[] parameters = new ReportParameter[5];
        parameters[0] = new ReportParameter("NoPenerimaan", peDomain.No);
        parameters[1] = new ReportParameter("TglPenerimaan", peDomain.TglPenerimaan);
        parameters[2] = new ReportParameter("Hal", peDomain.Hal);
        parameters[3] = new ReportParameter("Keterangan", peDomain.Keterangan);

        /*
         * if (peDomain.Tipe.Equals("1"))
         * {
         *    parameters[4] = new ReportParameter("Tipe", "Dengan Pengajuan Barang");
         *
         * }
         * else if (peDomain.Tipe.Equals("2"))
         * {
         *    parameters[4] = new ReportParameter("Tipe", "Dengan Pengajuan Service");
         *
         * }
         * else
         * {
         *    parameters[5] = new ReportParameter("Tipe", "Tanpa Pengajuan");
         * }
         *
         * SqlConnection conn = Common.getConnection();
         * string query = "";
         * SqlCommand cmd = new SqlCommand();
         * cmd.Connection = conn;
         * cmd.CommandType = System.Data.CommandType.Text;
         *
         *
         * if (peDomain.Tipe.Equals("1"))
         * {
         *    query = "select no_pengajuan from t_pengajuan_inventaris where id = " + peDomain.id + "";
         *
         * }
         * else if (peDomain.Tipe.Equals("2"))
         * {
         *    query = "select no_pengajuan from t_pengajuan_service where id = " + peDomain.id + "";
         *
         * }
         * cmd.CommandText = query;
         *
         * conn.Open();
         * try
         * {
         *    SqlDataReader reader = cmd.ExecuteReader();
         *    reader.Read();
         *    string pengajuan = reader["no_pengajuan"].ToString().Trim();
         *    parameters[5] = new ReportParameter("RefPengajuan", pengajuan);
         *
         * }
         * catch
         * {
         * }
         *
         * conn.Close();
         */
        parameters[4] = new ReportParameter("RefPengajuan", peDomain.RefPengajuan);

        ReportViewer1.LocalReport.SetParameters(parameters);

        DataTable        dt         = GetData(peDomain);
        ReportDataSource dataSource = new ReportDataSource("DataSet1", dt);

        ReportViewer1.LocalReport.DataSources.Add(dataSource);
        ReportViewer1.ShowPrintButton = true;



        PageSettings pg = new System.Drawing.Printing.PageSettings();

        pg.Margins.Top    = 0;
        pg.Margins.Bottom = 0;
        pg.Margins.Left   = 0;
        pg.Margins.Right  = 0;

        PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();

        ps.PrinterName = "Microsoft XPS Document Writer";

        PaperSize size = new PaperSize();

        size.RawKind       = (int)PaperKind.A4;
        pg.PaperSize       = size;
        pg.PrinterSettings = ps;
        ReportViewer1.SetPageSettings(pg);
        System.Diagnostics.Debug.WriteLine("RPT " + ReportViewer1.Width);

        ReportViewer1.LocalReport.Refresh();
    }
コード例 #4
0
    // Create a local report for Report.rdlc, load the data,
    //    export the report to an .emf file, and print it.
    private void RunPrint()
    {
        LocalReport report = new LocalReport();

        report.ReportPath = "Laporan/PenerimaanDetail.rdlc";
        PenerimaanDomain peDomain = GeneratePenerimaan(TbID.Text);


        ReportParameter[] parameters = new ReportParameter[6];
        parameters[0] = new ReportParameter("No", peDomain.No);
        parameters[1] = new ReportParameter("TglPenerimaan", peDomain.TglPenerimaan);
        parameters[2] = new ReportParameter("Hal", peDomain.Hal);
        parameters[3] = new ReportParameter("Keterangan", peDomain.Keterangan);

        if (peDomain.Tipe.Equals("1"))
        {
            parameters[4] = new ReportParameter("Tipe", "Dengan Pengajuan Barang");
        }
        else if (peDomain.Tipe.Equals("2"))
        {
            parameters[4] = new ReportParameter("Tipe", "Dengan Pengajuan Service");
        }
        else
        {
            parameters[5] = new ReportParameter("Tipe", "Tanpa Pengajuan");
        }
        SqlConnection conn  = Common.getConnection();
        string        query = "";
        SqlCommand    cmd   = new SqlCommand();

        cmd.Connection  = conn;
        cmd.CommandType = System.Data.CommandType.Text;


        if (peDomain.Tipe.Equals("1"))
        {
            query = "select no_pengajuan from t_pengajuan_inventaris where id = " + peDomain.id + "";
        }
        else if (peDomain.Tipe.Equals("2"))
        {
            query = "select no_pengajuan from t_service_inventaris where id = " + peDomain.id + "";
        }
        cmd.CommandText = query;

        conn.Open();
        try
        {
            SqlDataReader reader = cmd.ExecuteReader();
            reader.Read();
            string pengajuan = reader["no_pengajuan"].ToString().Trim();
            parameters[5] = new ReportParameter("RefPengajuan", pengajuan);
        }
        catch
        {
        }

        conn.Close();
        report.SetParameters(parameters);

        DataTable dt = GetData(peDomain);

        report.DataSources.Add(new ReportDataSource("DataSet1", dt));



        Export(report);
        Print();
    }