예제 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (Applcn_no.Text != "")
            {
                string    xxx_tname = string.Empty, xxx_fname = string.Empty;
                DataTable ddt_jbb_ind = new DataTable();
                ddt_jbb_ind = DBCon.Ora_Execute_table("select app_current_jbb_ind from jpa_application where app_applcn_no='" + Applcn_no.Text + "'");

                if (ddt_jbb_ind.Rows.Count != 0)
                {
                    string jbbind = ddt_jbb_ind.Rows[0]["app_current_jbb_ind"].ToString();
                    if (jbbind == "P")
                    {
                        xxx_tname = "pjs";
                        xxx_fname = "pjs";
                    }
                    else if (jbbind == "H")
                    {
                        xxx_tname = "holiday";
                        xxx_fname = "hol";
                    }
                    else if (jbbind == "E")
                    {
                        xxx_tname = "extension";
                        xxx_fname = "ext";
                    }
                    else if (jbbind == "L")
                    {
                        xxx_tname = "writeoff";
                        xxx_fname = "jwo";
                    }
                    else
                    {
                        xxx_tname = "normal";
                        xxx_fname = "jno";
                    }
                }
                //Path
                DataSet   ds = new DataSet();
                DataTable dt = new DataTable();
                dt = DBCon.Ora_Execute_table("select * from (select app_new_icno,app_name,app_applcn_no,ISNULL(app_mailing_address,'') app_mailing_address,app_mailing_postcode,ISNULL(KA.Area_Name, '') AS Area_Name,app_end_pay_dt,RJP.Description,jg.gua_name from jpa_application JA Left join jpa_guarantor as jg on jg.gua_applcn_no=ja.app_applcn_no Left Join jpa_jkkpa_approval as JJA ON JJA.jkk_applcn_no=JA.app_applcn_no Left Join Ref_Wilayah as RW ON RW.Wilayah_Code=JA.app_region_cd Left join ref_branch AS RB ON RB.branch_cd=JA.app_branch_cd left join Ref_Kawasan as KA ON KA.Area_Code=JA.app_mailing_state_cd left join Ref_Jenis_Pelaburan as RJP ON RJP.Description_Code=JA.app_loan_type_cd where JA.app_applcn_no='" + Applcn_no.Text + "' and JJA.jkk_result_ind='L') as a full outer join (select cmn_applcn_no,cmn_ref_no from cmn_ref_no where cmn_applcn_no='" + Applcn_no.Text + "' and cmn_crt_dt IN (SELECT max(cmn_crt_dt) FROM cmn_ref_no where cmn_applcn_no='" + Applcn_no.Text + "')) as b on b.cmn_applcn_no='" + Applcn_no.Text + "'");

                Reportviwer.Reset();
                ds.Tables.Add(dt);
                DataTable jbb_lpdt = new DataTable();
                jbb_lpdt = DBCon.Ora_Execute_table("select FORMAT(" + xxx_fname + "_pay_date,'dd/MM/yyyy', 'en-us') as pdt from jpa_jbb_" + xxx_tname + " where " + xxx_fname + "_applcn_no='" + Applcn_no.Text + "' and " + xxx_fname + "_actual_pay_date != '1900-01-01' and " + xxx_fname + "_upd_dt =  (select top (1) " + xxx_fname + "_upd_dt from jpa_jbb_" + xxx_tname + " where " + xxx_fname + "_applcn_no='" + Applcn_no.Text + "' and " + xxx_fname + "_actual_pay_date != '1900-01-01' order by " + xxx_fname + "_pay_date DESC)");
                Reportviwer.LocalReport.DataSources.Clear();
                if (jbb_lpdt.Rows.Count != 0)
                {
                    Reportviwer.LocalReport.ReportPath = "PELABURAN_ANGGOTA/Penyelesaian_Pembiayaan.rdlc";
                    ReportDataSource  rds       = new ReportDataSource("CSPP", dt);
                    ReportParameter[] rptParams = new ReportParameter[] {
                        new ReportParameter("lpdt", jbb_lpdt.Rows[0]["pdt"].ToString())
                    };


                    Reportviwer.LocalReport.SetParameters(rptParams);
                    Reportviwer.LocalReport.DataSources.Add(rds);

                    //Refresh
                    Reportviwer.LocalReport.Refresh();
                    Warning[] warnings;

                    string[] streamids;

                    string mimeType;

                    string encoding;

                    string extension;

                    string fname = DateTime.Now.ToString("dd_MM_yyyy");

                    string devinfo;
                    devinfo = "<DeviceInfo>" + "<OutputFormat>EMF</OutputFormat>" + "<PageWidth>8.5in</PageWidth>" + "<PageHeight>11in</PageHeight>" + "<MarginTop>0.25in</MarginTop>" +
                              "<MarginLeft>0.25in</MarginLeft>" + "<MarginRight>0.25in</MarginRight>" + "<MarginBottom>0.25in</MarginBottom>" + "</DeviceInfo>";

                    byte[] bytes = Reportviwer.LocalReport.Render("PDF", devinfo, out mimeType, out encoding, out extension, out streamids, out warnings);
                    Response.Buffer = true;
                    Response.Clear();
                    Response.ClearHeaders();
                    Response.ClearContent();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-disposition", "attachment; filename=Pelepasan_Pembiayaan_" + Applcn_no.Text + "." + extension);
                    Response.BinaryWrite(bytes);
                    Response.Flush();
                    Response.End();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "$.Zebra_Dialog('Rekod Tidak Dijumpai.',{'type': 'warning','title': 'Warning','auto_close': 2000});", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "$.Zebra_Dialog('Medan Input Adalah Mandatori.',{'type': 'warning','title': 'Warning','auto_close': 2000});", true);
            }
        }
        catch (Exception ex)
        {
            throw ex;
            //Request.Redirect(url, false);
        }
    }
예제 #2
0
    public void showreport()
    {
        try
        {
            string   t1    = Txtfromdate.Text;
            string   t2    = Txttodate.Text;
            DateTime ft    = DateTime.ParseExact(t1, "dd/mm/yyyy", CultureInfo.InvariantCulture);
            string   fdate = ft.ToString("yyyy-mm-dd");
            DateTime td    = DateTime.ParseExact(t2, "dd/mm/yyyy", CultureInfo.InvariantCulture);
            string   tdate = td.ToString("yyyy-mm-dd");
            //Path
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();
            dt = DBCon.Ora_Execute_table("select app_applcn_no,JA.app_new_icno,JA.app_age,JA.app_name,rt.tujuan_desc,JA.app_apply_amt,JA.app_apply_dur,JJA.jkk_approve_amt,JJA.jkk_approve_dur,cal_stamp_duty_amt,cal_process_fee,cal_deposit_amt,cal_installment_amt, cal_tkh_amt, cal_credit_fee, cal_profit_amt from jpa_application as JA LEFT join jpa_calculate_fee cf on cf.cal_applcn_no = JA.app_applcn_no Left join ref_tujuan as rt on rt.tujuan_cd=JA.app_loan_purpose_cd Inner join jpa_jkkpa_approval as JJA ON JJA.jkk_applcn_no = JA.app_applcn_no where JJA.jkk_meeting_dt>=DATEADD(day, DATEDIFF(day, 0, '" + fdate + "'), 0) and JJA.jkk_meeting_dt<=DATEADD(day, DATEDIFF(day, 0, '" + tdate + "'), +1) and ISNULL(JJA.jkk_result_ind,'') =''");

            Reportviwer.Reset();
            ds.Tables.Add(dt);
            Reportviwer.LocalReport.DataSources.Clear();



            if (dt.Rows.Count != 0)
            {
                txtkel.Text = "PA" + DateTime.Now.ToString("yyyyMMdd");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string Inssql = "Update jpa_jkkpa_approval set pa_batch_no='" + txtkel.Text + "',jkk_upd_id='" + Session["New"].ToString() + "' ,jkk_upd_dt='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where jkk_applcn_no='" + dt.Rows[i]["app_applcn_no"].ToString() + "' and ISNULL(jkk_result_ind,'') =''";
                    Status = DBCon.Ora_Execute_CommamdText(Inssql);

                    string Inssql1 = "Update jpa_application set jpa_batch_no='" + txtkel.Text + "' where app_applcn_no='" + dt.Rows[i]["app_applcn_no"].ToString() + "'";
                    Status = DBCon.Ora_Execute_CommamdText(Inssql1);
                }

                if (Status == "SUCCESS")
                {
                    Reportviwer.LocalReport.ReportPath = "PELABURAN_ANGGOTA/jkkpa_batch.rdlc";
                    ReportDataSource  rds       = new ReportDataSource("jkbatch", dt);
                    ReportParameter[] rptParams = new ReportParameter[] {
                        new ReportParameter("fromDate", Txtfromdate.Text),
                        new ReportParameter("toDate", Txttodate.Text),
                        new ReportParameter("Kelompok", txtkel.Text),
                        new ReportParameter("current_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                    };


                    Reportviwer.LocalReport.SetParameters(rptParams);
                    Reportviwer.LocalReport.DataSources.Add(rds);

                    //Refresh
                    Reportviwer.LocalReport.Refresh();
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "$.Zebra_Dialog('Rekod Tidak Dijumpai.',{'type': 'warning','title': 'Warning','auto_close': 2000});", true);
            }
        }
        catch (Exception ex)
        {
            throw ex;
            //Request.Redirect(url, false);
        }
    }