Ejemplo n.º 1
0
    public static DataTable getClientAtRisk(string strQS, out string strTotalClientCount)
    {
        String[] QS           = strQS.Split('^');
        string   dateFrom     = QS[0];
        string   dateTo       = QS[1];
        string   strSessionID = "";

        strTotalClientCount = "";

        DataTable dtRawData = DL_ProblemAnalysisReport.getClientAtRisk(dateFrom, dateTo, QS[2], out strSessionID);

        if (dtRawData != null)
        {
            dtRawData.Columns.Add("Rev1", typeof(double));
            dtRawData.Columns.Add("Rev2", typeof(double));
            dtRawData.Columns.Add("Rev3", typeof(double));
            dtRawData.Columns.Add("DetailTable", typeof(DataTable));

            DataTable dtDetailTable      = DL_ProblemAnalysisReport.getClientAtRiskDetails();
            DataTable dtDetailTableChild = DL_ProblemAnalysisReport.getClientAtRiskDetailsChild();
            strTotalClientCount = DL_ProblemAnalysisReport.getTotalClientCount(strSessionID);

            DataTable dtReportSchema = new DataTable();
            dtReportSchema.Columns.Add("ProblemGroup", typeof(string));
            dtReportSchema.Columns.Add("ProblemDesc", typeof(string));
            dtReportSchema.Columns.Add("Count", typeof(int));

            string[] strRevenue;
            string   strClientDR = "";

            for (int iCount = 0; iCount < dtRawData.Rows.Count; iCount++)
            {
                strClientDR = dtRawData.Rows[iCount]["BICAR_RowID"].ToString();
                strRevenue  = dtRawData.Rows[iCount]["ClientRevenue"].ToString().Split('^');
                dtRawData.Rows[iCount]["Rev1"] = (strRevenue[0].Length == 0 ? 0.000 : Convert.ToDouble(strRevenue[0]));
                dtRawData.Rows[iCount]["Rev2"] = (strRevenue[1].Length == 0 ? 0.000 : Convert.ToDouble(strRevenue[1]));
                dtRawData.Rows[iCount]["Rev3"] = (strRevenue[2].Length == 0 ? 0.000 : Convert.ToDouble(strRevenue[2]));
                DataTable dtChild = getClientAtRiskChild(dtDetailTable, dtReportSchema.Clone(), strClientDR, dtDetailTableChild);
                dtRawData.Rows[iCount]["DetailTable"] = dtChild;
            }
        }
        return(dtRawData);
    }
Ejemplo n.º 2
0
    public static DataTable getClientAtRiskSummary(string strQS, out string strTotalClientCount)
    {
        String[] QS           = strQS.Split('^');
        string   dateFrom     = QS[0];
        string   dateTo       = QS[1];
        string   strSessionID = "";

        strTotalClientCount = "";

        DataTable dtReport = new DataTable();

        dtReport.Columns.Add("Acct", typeof(string));
        dtReport.Columns.Add("AcctName", typeof(string));
        dtReport.Columns.Add("Territory", typeof(string));
        dtReport.Columns.Add("SalesRep", typeof(string));
        dtReport.Columns.Add("Rev1", typeof(double));
        dtReport.Columns.Add("Rev2", typeof(double));
        dtReport.Columns.Add("Rev3", typeof(double));
        dtReport.Columns.Add("TotalProbs", typeof(string));
        dtReport.Columns.Add("LabProbs", typeof(string));
        dtReport.Columns.Add("TransProbs", typeof(string));
        dtReport.Columns.Add("MissingProbs", typeof(string));
        dtReport.Columns.Add("SubmissionProbs", typeof(string));
        dtReport.Columns.Add("OtherProbs", typeof(string));

        string strAcct = "", strAcctName = "", strTerritory = "", strSalesRep = "", strProbType = "", strClientDR = "";

        string[] strRevenue;
        double   dRev1 = 0.000; double dRev2 = 0.000; double dRev3 = 0.000;

        int    intTotalProbs = 0;
        string strProblemCount = "", strLabProbs = "", strTransProbs = "", strMissingProbs = "", strSubmissionProbs = "", strOtherProbs = "";

        DataTable dtRawData = DL_ProblemAnalysisReport.getClientAtRisk(dateFrom, dateTo, QS[2], out strSessionID);

        if (dtRawData != null && dtRawData.Rows.Count > 0)
        {
            DataTable dtDetailTable      = DL_ProblemAnalysisReport.getClientAtRiskDetails();
            DataTable dtDetailTableChild = DL_ProblemAnalysisReport.getClientAtRiskDetailsChild();
            strTotalClientCount = DL_ProblemAnalysisReport.getTotalClientCount(strSessionID);


            for (int iCount = 0; iCount < dtRawData.Rows.Count; iCount++)
            {
                intTotalProbs = 0;
                strLabProbs   = "0"; strTransProbs = "0"; strMissingProbs = "0"; strSubmissionProbs = "0"; strOtherProbs = "0";

                strAcct      = dtRawData.Rows[iCount]["AccountNumber"].ToString();
                strAcctName  = dtRawData.Rows[iCount]["AccountName"].ToString();
                strTerritory = dtRawData.Rows[iCount]["Territory"].ToString();
                strSalesRep  = dtRawData.Rows[iCount]["SalesRepName"].ToString();

                strClientDR = dtRawData.Rows[iCount]["BICAR_RowID"].ToString();

                strRevenue = dtRawData.Rows[iCount]["ClientRevenue"].ToString().Split('^');
                dRev1      = (strRevenue[0].Length == 0 ? 0.000 : Convert.ToDouble(strRevenue[0]));
                dRev2      = (strRevenue[1].Length == 0 ? 0.000 : Convert.ToDouble(strRevenue[1]));
                dRev3      = (strRevenue[2].Length == 0 ? 0.000 : Convert.ToDouble(strRevenue[2]));

                DataRow[] drarray = dtDetailTable.Select("BICD_BICAR_PR='" + strClientDR + "'");
                if (drarray != null && drarray.Length > 0)
                {
                    for (int i = 0; i < drarray.Length; i++)
                    {
                        DataRow[] drReportChild = dtDetailTableChild.Select("CPTPL_BICD_PR='" + drarray[i]["BICD_RowID"] + "'", "CPTPL_ProblemTypeDR ASC");
                        int       count         = 0;
                        for (int iCnt = 0; iCnt < drReportChild.Length; iCnt++)
                        {
                            count += Convert.ToInt32(drReportChild[iCnt]["CPTPL_Count"]);
                        }
                        strProbType     = drarray[i]["BICD_ProblemTypeGroupDR"].ToString();
                        strProblemCount = count.ToString();

                        if (strProblemCount.Trim().Length > 0)
                        {
                            intTotalProbs += Convert.ToInt32(strProblemCount.Trim());
                        }

                        switch (strProbType)
                        {
                        case "LAB":
                            strLabProbs = strProblemCount;
                            break;

                        case "TRANSPORTATION":
                            strTransProbs = strProblemCount;
                            break;

                        case "MISSING":
                            strMissingProbs = strProblemCount;
                            break;

                        case "SUBMISSION":
                            strSubmissionProbs = strProblemCount;
                            break;

                        case "OTHER":
                            strOtherProbs = strProblemCount;
                            break;
                        }
                    }
                }

                DataRow drNewRow = dtReport.NewRow();
                drNewRow["Acct"]            = strAcct;
                drNewRow["AcctName"]        = strAcctName;
                drNewRow["Territory"]       = strTerritory;
                drNewRow["SalesRep"]        = strSalesRep;
                drNewRow["Rev1"]            = dRev1;
                drNewRow["Rev2"]            = dRev2;
                drNewRow["Rev3"]            = dRev3;
                drNewRow["TotalProbs"]      = intTotalProbs.ToString();
                drNewRow["LabProbs"]        = strLabProbs;
                drNewRow["TransProbs"]      = strTransProbs;
                drNewRow["MissingProbs"]    = strMissingProbs;
                drNewRow["SubmissionProbs"] = strSubmissionProbs;
                drNewRow["OtherProbs"]      = strOtherProbs;
                dtReport.Rows.Add(drNewRow);
            }
        }

        return(dtReport);
    }