Esempio n. 1
0
    protected void ctk_values(object sender, EventArgs e)
    {
        DataSet   ds = new DataSet();
        DataTable dt = new DataTable();
        string    sqry = string.Empty, st_dt = string.Empty, ed_dt = string.Empty;

        string query = "with Recurse as ( select a.Id as DirectChildId, a.Id, a.kod_akaun from KW_Ref_Carta_Akaun a where kat_akaun In ('01','02','03')  union all select b.DirectChildId, a.Id, a.kod_akaun from KW_Ref_Carta_Akaun a  join Recurse b on b.Id = a.under_parent) select * from "
                       + "(select a.DirectChildId, isnull(sum(cast(replace(opn_kredit_amt,'-','') as money)),'0.00')  as Amount , isnull(sum(cast(replace(opn_debit_amt,'-','') as money)),'0.00')  as Amount1  from Recurse a  left join KW_Opening_Balance b on a.kod_akaun = b.kod_akaun and Status='A' and set_sts='1' and opening_year='" + tah_kewangan.SelectedValue + "' "
                       + " group by DirectChildId)  as a   inner join  (select m1.Id,m1.jenis_akaun_type,ISNULL(kw_acc_header,'0') isHeader,m1.kat_akaun ,m1.nama_akaun,m1.kod_akaun,m1.jenis_akaun,ISNULL(b.opn_kredit_amt,'0.00') as KW_kredit_amt,ISNULL(b.opn_debit_amt,'0.00') as KW_Debit_amt from KW_Ref_Carta_Akaun m1 "
                       + "left join KW_Opening_Balance b on m1.kod_akaun = b.kod_akaun and b.Status='A' and set_sts='1' and opening_year='" + tah_kewangan.SelectedValue + "' "
                       + " where m1.Status='A') as b on b.Id=a.DirectChildId  ";

        dt = DBCon.Ora_Execute_table(query);
        Rptviwer_baki.Reset();
        ds.Tables.Add(dt);

        List <DataRow> listResult = dt.AsEnumerable().ToList();

        listResult.Count();
        int countRow = 0;

        countRow = listResult.Count();

        Rptviwer_baki.LocalReport.DataSources.Clear();
        if (countRow != 0)
        {
            StringBuilder builder     = new StringBuilder();
            string        strFileName = string.Format("{0}.{1}", "BAKI_PEMBUKAAN_" + DateTime.Now.ToString("yyyyMMdd") + "", "csv");
            builder.Append("NAMA AKAUN,KOD AKAUN, KREDIT (RM), DEBIT (RM)" + Environment.NewLine);
            string oamt = string.Empty;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                builder.Append(dt.Rows[i]["nama_akaun"].ToString() + "," + dt.Rows[i]["kod_akaun"].ToString() + "," + dt.Rows[i]["Amount"].ToString() + "," + dt.Rows[i]["Amount1"].ToString() + Environment.NewLine);
            }
            Response.Clear();
            Response.ContentType = "text/csv";
            Response.AddHeader("Content-Disposition", "attachment;filename=" + strFileName);
            Response.Write(builder.ToString());
            Response.End();
        }
        else if (countRow == 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Rekod tidak dijumpai. Sila Pastikan Semua Maklumat Dimasukkan Dengan Betul');", true);
        }
    }
Esempio n. 2
0
    protected void ctk_values(object sender, EventArgs e)
    {
        DataSet   ds    = new DataSet();
        DataTable dt    = new DataTable();
        string    query = " with Recurse as ("
                          + " select a.bjt_Id as DirectChildId, a.bjt_Id, a.kod_bajet"
                          + " from KW_Ref_kod_bajet a     union all"
                          + " select b.DirectChildId, a.bjt_Id, a.kod_bajet "
                          + " from KW_Ref_kod_bajet a "
                          + " join Recurse b on b.bjt_Id = a.bjt_under_parent)"
                          + " select * from (select a.DirectChildId, isnull(sum(cast(Ref_jumlah_bajet as money)),'0.00')  as Amount "
                          + ", (isnull(sum(cast(Ref_jumlah_bajet as money)),'0.00') - isnull(sum(cast(Ref_used_bajet as money)),'0.00'))  as baki "
                          + " , (isnull(sum(cast(Ref_used_bajet as money)),'0.00'))  as pengg "
                          + " , '0' as per"
                          + " from Recurse a"
                          + " left join KW_Ref_Bajet b on a.kod_bajet = b.Ref_kod_bajet"
                          + " group by DirectChildId) as a "
                          + " inner join  (select m1.bjt_Id,m1.jenis_bajet_type,m1.kat_bajet,m1.nama_bajet,m1.kod_bajet,m1.jenis_bajet,m1.bjt_under_parent,isHeader,ISNULL(s1.Ref_jumlah_bajet,'0.00') as KW_Debit_amt,Ref_kat_bajet,Ref_tk_mula,Ref_tk_akhir "
                          + " from KW_Ref_kod_bajet m1 left join KW_Ref_Bajet s1 on s1.Ref_kod_bajet=m1.kod_bajet where m1.bjt_Status='A') as b on b.bjt_Id=a.DirectChildId";

        dt = DBCon.Ora_Execute_table(query);
        Rptviwer_baki.Reset();
        ds.Tables.Add(dt);

        List <DataRow> listResult = dt.AsEnumerable().ToList();

        listResult.Count();
        int countRow = 0;

        countRow = listResult.Count();

        Rptviwer_baki.LocalReport.DataSources.Clear();
        if (countRow != 0)
        {
            StringBuilder builder     = new StringBuilder();
            string        strFileName = string.Format("{0}.{1}", "LAPORAN_BAJET_" + DateTime.Now.ToString("yyyyMMdd") + "", "csv");
            builder.Append("NAMA BAJET ,KOD BAJET, BAJET (RM), BAKI (RM), PENGGUNAAN (RM), %" + Environment.NewLine);
            string oamt = string.Empty;
            foreach (GridViewRow row in GridView1.Rows)
            {
                string kodakaun  = ((Label)row.FindControl("bal_type")).Text.ToString();
                string akaunname = ((Label)row.FindControl("kat_cd")).Text.ToString();
                string openamt   = ((Label)row.FindControl("Label3")).Text.ToString();
                string baki      = ((Label)row.FindControl("Label3_1")).Text.ToString();
                string peng      = ((Label)row.FindControl("Label3_2")).Text.ToString();
                string percent   = ((Label)row.FindControl("Label3_3")).Text.ToString();
                //string type = ((Label)row.FindControl("lbl4")).Text.ToString();
                //if (type == "1")
                //{
                //    oamt = "";
                //}
                //else
                //{
                //    oamt = openamt;
                //}

                builder.Append(akaunname.Replace(",", "").ToUpper() + "," + kodakaun + "," + openamt.Replace(",", "") + "," + baki.Replace(",", "") + "," + peng.Replace(",", "") + "," + percent + Environment.NewLine);
            }
            Response.Clear();
            Response.ContentType = "text/csv";
            Response.AddHeader("Content-Disposition", "attachment;filename=" + strFileName);
            Response.Write(builder.ToString());
            Response.End();
        }
        else if (countRow == 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Rekod tidak dijumpai. Sila Pastikan Semua Maklumat Dimasukkan Dengan Betul');", true);
        }
    }