protected void btnadminsearch_Click(object sender, EventArgs e)
    {
        SearchAgeing itmsearch = new SearchAgeing();

        itmsearch.div = src_div.Text;
        itmsearch.rsm = src_rsm.Text;
        // itmsearch.asm = src_asm.Text;
        itmsearch.msr      = src_msr.Text;
        itmsearch.area     = src_area.Text;
        itmsearch.doctor   = src_doctor.Text;
        itmsearch.fromdate = src_month4m.Text;
        // itmsearch.todate = src_monthto.Text;
        itmsearch.intFrom = Common.GetPositionof(itmsearch.fromdate);
        itmsearch.intTo   = Common.GetPositionof(itmsearch.todate);

        bool blncontinue = true;

        //if ((itmsearch.intFrom > 0 && itmsearch.intTo > 0 && itmsearch.intFrom < itmsearch.intTo) || (itmsearch.intFrom == 0 && itmsearch.intTo == 0))
        //{
        //    blncontinue = true;
        //    lblmsg.Text = "";
        //}
        //else
        //{
        //    lblmsg.Text = "Wrong month range selection";
        //}


        if (blncontinue)
        {
            GenerateReportFunction(itmsearch);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            populatestaticdrops();

            //initially execute the ageing report SP

            /*      string div = ddlDivision.Text;
             *    string mn = ddlmonth.Text;
             *    (new RptAgeingDL()).populateReportFromSP(div, mn); */

            populatedropdowns();        //populate search dropdowns
            applyrole();


            //generate report
            SearchAgeing newsearch = new SearchAgeing();
            //    newsearch.rsm = "mad";
            newsearch.div      = "eva";
            newsearch.fromdate = src_month4m.Text;
            //newsearch.todate = src_monthto.Text;
            newsearch.intFrom = Common.GetPositionof(newsearch.fromdate);
            //newsearch.intTo = Common.GetPositionof(newsearch.todate);



            GenerateReportFunction(newsearch, 500);
        }
    }
    private void GenerateReportFunction(SearchAgeing newsearch, int rows)
    {
        // ReportViewer1.ProcessingMode = ProcessingMode.Local;
        //ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/rdlcs/Report2.rdlc");

        DataSet dt = (new RptAgeingDL()).GetAgeingReportDataDynamic(newsearch, rows);

        dt.Tables[0].Columns.Remove("AsmHQ");
        dt.Tables[0].Columns.Remove("MfsoHQ");
        dt.Tables[0].Columns.Remove("rptageingID");
        dt.Tables[0].Columns.Remove("MfsoVisitPlan");
        dt.Tables[0].Columns.Remove("MfsoVisitDays");

        if (newsearch.div.ToLower() == "eva")
        {
            dt.Tables[0].Columns["MsrVisitDays"].ColumnName = "MFSOVisitDays";
            dt.Tables[0].Columns["MsrVisitPlan"].ColumnName = "MFSOVisitPlan";
        }
        else if (newsearch.div.ToLower() == "phoenix")
        {
            dt.Tables[0].Columns["MsrVisitDays"].ColumnName = "SOVisitDays";
            dt.Tables[0].Columns["MsrVisitPlan"].ColumnName = "SOVisitPlan";
        }
        else if (newsearch.div.ToLower() == "concord")
        {
            dt.Tables[0].Columns["MsrVisitDays"].ColumnName = "MFSOVisitDays";
            dt.Tables[0].Columns["MsrVisitPlan"].ColumnName = "MFSOVisitPlan";
        }

        rpt_ageing.ReportTitle = "Ageing Report";
        rpt_ageing.ReportName  = "AgeingReport";

        /*   DataTable newdt = dt.Tables[0];
         * foreach(DataColumn dc in newdt.Columns)
         * {
         *     String cname = dc.ColumnName;
         *     if (Common.GetInt(newdt.Compute("COUNT("+cname+")", cname+" <> NULL")) == 0)
         *         newdt.Columns.Remove(cname);
         * }*/

        rpt_ageing.DataBind(dt.Tables[0].Copy());
        rpt_ageing.Visible = true;



        /*ReportViewer1.LocalReport.DataSources.Clear();
         * ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource()
         * {
         *  Name = "ageingDS",
         *  Value = dt.Tables[0]
         * });
         *
         * ReportViewer1.LocalReport.Refresh();*/
    }
    protected void btnadminReset_Click(object sender, EventArgs e)
    {
        SearchAgeing itmsearch = new SearchAgeing();

        GenerateReportFunction(itmsearch);

        src_rsm.SelectedIndex = 0;
        // src_asm.SelectedIndex = 0;
        src_area.SelectedIndex    = 0;
        src_msr.SelectedIndex     = 0;
        src_doctor.SelectedIndex  = 0;
        src_month4m.SelectedIndex = 0;
        //src_monthto.SelectedIndex = 0;

        lblmsg.Text = "";
    }
Exemplo n.º 5
0
        public DataSet GetAgeingReportDataDynamic(SearchAgeing itmsearch, int rows)
        {
            RptAgeingList lstAgeing = new RptAgeingList();

            Common.OpenConnection();
            String sql = "select * from rpt_ageing";

            if (rows > 0)
            {
                sql = "select top " + rows + " * from rpt_ageing";
            }

            string whsql     = "";
            string strconcat = "";

            if (itmsearch.div != null && itmsearch.div != "" && itmsearch.div != "select")
            {
                whsql     = whsql + strconcat + " division like '%" + itmsearch.div + "%'";
                strconcat = " and ";
            }

            if (itmsearch.rsm != null && itmsearch.rsm != "" && itmsearch.rsm != "select")
            {
                whsql     = whsql + strconcat + " RSMHQ like '%" + itmsearch.rsm + "%'";
                strconcat = " and ";
            }
            if (itmsearch.asm != null && itmsearch.asm != "" && itmsearch.asm != "select")
            {
                whsql     = whsql + strconcat + " ASMHQ like '%" + itmsearch.asm + "%'";
                strconcat = " and ";
            }
            if (itmsearch.msr != null && itmsearch.msr != "" && itmsearch.msr != "select")
            {
                whsql     = whsql + strconcat + " MSRHQ like '%" + itmsearch.msr + "%'";
                strconcat = " and ";
            }
            if (itmsearch.area != null && itmsearch.area != "" && itmsearch.area != "select")
            {
                whsql     = whsql + strconcat + " Area like '%" + itmsearch.area + "%'";
                strconcat = " and ";
            }
            if (itmsearch.doctor != null && itmsearch.doctor != "" && itmsearch.doctor != "select")
            {
                whsql     = whsql + strconcat + " DoctorName like '%" + itmsearch.doctor + "%'";
                strconcat = " and ";
            }

            //date range not required
            //if (itmsearch.intFrom > 0 && itmsearch.intTo > 0)
            //{
            //    string months = "";
            //    string separator = "";
            //    int count = itmsearch.intFrom;
            //    while (count <= itmsearch.intTo)
            //    {
            //        months = months + separator + "'" + Common.monthlist.ElementAt(count) + "'";
            //        separator = ",";
            //        count++;
            //    }

            //    whsql = whsql + strconcat + " month in (" + months + ")";
            //}

            if (itmsearch.intFrom > 0)
            {
                string months    = "";
                string separator = "";
                int    count     = itmsearch.intFrom;
                months = "'" + Common.monthlist.ElementAt(count) + "'";

                whsql = whsql + strconcat + " month = " + months;
            }

            if (whsql != null && whsql != "")
            {
                sql = sql + " where " + whsql;
            }

            SqlCommand cmd = new SqlCommand(sql, Common.conn);
            //SqlDataAdapter da = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            //da.Fill(dt);
            //return dt;

            //MendineMasterdummyDataSet dsCustomers = new MendineMasterdummyDataSet();
            DataSet dsCustomers = new DataSet();

            using (SqlDataAdapter sda = new SqlDataAdapter())
            {
                sda.SelectCommand = cmd;
                //sda.Fill(dsCustomers, "rpt_ageing");
                sda.Fill(dsCustomers);
            }

            return(dsCustomers);



            //using (SqlDataReader rdr = cmd.ExecuteReader())
            //{
            //    while (rdr.Read())
            //    {
            //        RptAgeing itmaging = new RptAgeing();
            //        itmaging.ZsmHQ = Common.GetString(rdr["ZsmHQ"]);
            //        itmaging.Area = Common.GetString(rdr["Area"]);
            //        itmaging.AreaType = Common.GetString(rdr["AreaType"]);
            //        itmaging.DoctorName = Common.GetString(rdr["DoctorName"]);
            //        lstAgeing.Add(itmaging);
            //    }
            //}
        }
 private void GenerateReportFunction(SearchAgeing newsearch)
 {
     GenerateReportFunction(newsearch, 0);
 }