Пример #1
0
    public string TotalAtendimentos(string mesAno)
    {
        int mes   = Convert.ToInt32(mesAno.Substring(0, 2));
        int ano   = Convert.ToInt32(mesAno.Substring(3, 4));
        var dados = new List <ResgateMes>();

        using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["psConnectionString"].ToString()))
        {
            SqlCommand cmm = cnn.CreateCommand();

            cmm.CommandText = "SELECT [1],[2],[3],[4],[5],[6],[7],[8],[9],[10]" +
                              ",[11],[12],[13],[14],[15],[16],[17],[18],[19],[20]" +
                              ",[21],[22],[23],[24],[25],[26],[27],[28],[29]" +
                              ",[30],[31]" +
                              ",[TOTAL]" +
                              " FROM [hspmPs].[dbo].[vw_con_be_total_mes]" +
                              " where BE_MONTH = " + mes + " AND BE_YEAR =  " + ano;
            try
            {
                cnn.Open();
                SqlDataReader dr1 = cmm.ExecuteReader();

                while (dr1.Read())
                {
                    ResgateMes r = new ResgateMes();
                    r.procedencia = "Total";

                    r.dia1  = dr1.GetInt32(0);
                    r.dia2  = dr1.GetInt32(1);
                    r.dia3  = dr1.GetInt32(2);
                    r.dia4  = dr1.GetInt32(3);
                    r.dia5  = dr1.GetInt32(4);
                    r.dia6  = dr1.GetInt32(5);
                    r.dia7  = dr1.GetInt32(6);
                    r.dia8  = dr1.GetInt32(7);
                    r.dia9  = dr1.GetInt32(8);
                    r.dia10 = dr1.GetInt32(9);
                    r.dia11 = dr1.GetInt32(10);
                    r.dia12 = dr1.GetInt32(11);
                    r.dia13 = dr1.GetInt32(12);
                    r.dia14 = dr1.GetInt32(13);
                    r.dia15 = dr1.GetInt32(14);
                    r.dia16 = dr1.GetInt32(15);
                    r.dia17 = dr1.GetInt32(16);
                    r.dia18 = dr1.GetInt32(17);
                    r.dia19 = dr1.GetInt32(18);
                    r.dia20 = dr1.GetInt32(19);
                    r.dia21 = dr1.GetInt32(20);
                    r.dia22 = dr1.GetInt32(21);
                    r.dia23 = dr1.GetInt32(22);
                    r.dia24 = dr1.GetInt32(23);
                    r.dia25 = dr1.GetInt32(24);
                    r.dia26 = dr1.GetInt32(25);
                    r.dia27 = dr1.GetInt32(26);
                    r.dia28 = dr1.GetInt32(27);
                    r.dia29 = dr1.GetInt32(28);
                    r.dia30 = dr1.GetInt32(29);
                    r.dia31 = dr1.GetInt32(30);
                    r.total = dr1.GetInt32(31);

                    dados.Add(r);
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }
        JavaScriptSerializer js = new JavaScriptSerializer();

        return(js.Serialize(dados));
    }
Пример #2
0
    public string TotalAtendimentosResgate(string mesAno)
    {
        int mes   = Convert.ToInt32(mesAno.Substring(0, 2));
        int ano   = Convert.ToInt32(mesAno.Substring(3, 4));
        var dados = new List <ResgateMes>();


        int t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0,
            t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0,
            t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0,
            t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, t31 = 0, ttotal = 0;


        using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["psConnectionString"].ToString()))
        {
            SqlCommand cmm = cnn.CreateCommand();

            cmm.CommandText = "SELECT [procedencia] " +
                              ",[1],[2],[3],[4],[5],[6],[7],[8],[9],[10]" +
                              ",[11],[12],[13],[14],[15],[16],[17],[18],[19],[20]" +
                              ",[21],[22],[23],[24],[25],[26],[27],[28],[29]" +
                              ",[30],[31]" +
                              ",[TOTAL]" +
                              " FROM [hspmPs].[dbo].[vw_con_be_total_procedencia]" +
                              " where BE_MONTH = " + mes + " AND BE_YEAR =" + ano +
                              " and procedencia != 'ESPONTÂNEA'";
            try
            {
                cnn.Open();
                SqlDataReader dr1    = cmm.ExecuteReader();
                ResgateMes    rtotal = new ResgateMes();
                //char[] ponto = { '.', ' ' };
                while (dr1.Read())
                {
                    ResgateMes r = new ResgateMes();

                    r.procedencia = dr1.GetString(0);
                    r.dia1        = dr1.GetInt32(1);
                    t1           += r.dia1;
                    r.dia2        = dr1.GetInt32(2);
                    t2           += r.dia2;
                    r.dia3        = dr1.GetInt32(3);
                    t3           += r.dia3;
                    r.dia4        = dr1.GetInt32(4);
                    t4           += r.dia4;
                    r.dia5        = dr1.GetInt32(5);
                    t5           += r.dia5;
                    r.dia6        = dr1.GetInt32(6);
                    t6           += r.dia6;
                    r.dia7        = dr1.GetInt32(7);
                    t7           += r.dia7;
                    r.dia8        = dr1.GetInt32(8);
                    t8           += r.dia8;
                    r.dia9        = dr1.GetInt32(9);
                    t9           += r.dia9;
                    r.dia10       = dr1.GetInt32(10);
                    t10          += r.dia10;
                    r.dia11       = dr1.GetInt32(11);
                    t11          += r.dia11;
                    r.dia12       = dr1.GetInt32(12);
                    t12          += r.dia12;
                    r.dia13       = dr1.GetInt32(13);
                    t13          += r.dia13;
                    r.dia14       = dr1.GetInt32(14);
                    t14          += r.dia14;
                    r.dia15       = dr1.GetInt32(15);
                    t15          += r.dia15;
                    r.dia16       = dr1.GetInt32(16);
                    t16          += r.dia16;
                    r.dia17       = dr1.GetInt32(17);
                    t17          += r.dia17;
                    r.dia18       = dr1.GetInt32(18);
                    t18          += r.dia18;
                    r.dia19       = dr1.GetInt32(19);
                    t19          += r.dia19;
                    r.dia20       = dr1.GetInt32(20);
                    t20          += r.dia20;
                    r.dia21       = dr1.GetInt32(21);
                    t21          += r.dia21;
                    r.dia22       = dr1.GetInt32(22);
                    t22          += r.dia22;
                    r.dia23       = dr1.GetInt32(23);
                    t23          += r.dia23;
                    r.dia24       = dr1.GetInt32(24);
                    t24          += r.dia24;
                    r.dia25       = dr1.GetInt32(25);
                    t25          += r.dia25;
                    r.dia26       = dr1.GetInt32(26);
                    t26          += r.dia26;
                    r.dia27       = dr1.GetInt32(27);
                    t27          += r.dia27;
                    r.dia28       = dr1.GetInt32(28);
                    t28          += r.dia28;
                    r.dia29       = dr1.GetInt32(29);
                    t29          += r.dia29;
                    r.dia30       = dr1.GetInt32(30);
                    t30          += r.dia30;
                    r.dia31       = dr1.GetInt32(31);
                    t31          += r.dia31;
                    r.total       = dr1.GetInt32(32);
                    ttotal       += r.total;

                    dados.Add(r);
                }
                rtotal.procedencia = "Total";
                rtotal.dia1        = t1;
                rtotal.dia2        = t2;
                rtotal.dia3        = t3;
                rtotal.dia4        = t4;
                rtotal.dia5        = t5;
                rtotal.dia6        = t6;
                rtotal.dia7        = t7;
                rtotal.dia8        = t8;
                rtotal.dia9        = t9;
                rtotal.dia10       = t10;
                rtotal.dia11       = t11;
                rtotal.dia12       = t12;
                rtotal.dia13       = t13;
                rtotal.dia14       = t14;
                rtotal.dia15       = t15;
                rtotal.dia16       = t16;
                rtotal.dia17       = t17;
                rtotal.dia18       = t18;
                rtotal.dia19       = t19;
                rtotal.dia20       = t20;
                rtotal.dia21       = t21;
                rtotal.dia22       = t22;
                rtotal.dia23       = t23;
                rtotal.dia24       = t24;
                rtotal.dia25       = t25;
                rtotal.dia26       = t26;
                rtotal.dia27       = t27;
                rtotal.dia28       = t28;
                rtotal.dia29       = t29;
                rtotal.dia30       = t30;
                rtotal.dia31       = t31;
                rtotal.total       = ttotal;
                dados.Add(rtotal);
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }
        JavaScriptSerializer js = new JavaScriptSerializer();

        return(js.Serialize(dados));
    }