8 Replies - 1095 Views - Last Post: 07 August 2012 - 09:57 AM Rate Topic: -----

#1 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Reverse engineering an existing web form to windows form.

Posted 06 August 2012 - 11:55 AM

Good Afternoon,

I am trying to recreate this code from a VB web client to a C# web form.

So far I was able to solve with help on connecting to DSN, and pulling data from a datagridview.

Now my next challenge is pulling two select statements from two sources.

Here is what I have so far:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RSQ_App_V1
{
    public partial class Queue : Form
    {
        public Queue()
        {
            InitializeComponent();



            try
            {
                //Initialize variables
                int contactsWaiting = 0;
                //rtcsqssummary = callswaiting
                int oldestContact = 0;
                //rtcsqssummary = oldestcontact
                int totalContacts = 0;
                //rtcsqssummary = totalcalls
                int contactsHandled = 0;
                //rtcsqssummary = callshandled
                int contactsAbandoned = 0;
                //rtcsqssummary = callsabandoned
                double percentageHandled = 0;



                // Establishes Connection to UCCX
                OdbcConnection connection = new OdbcConnection();
                connection.ConnectionString = "DSN=UCCX";
                // Selects Data  
                string queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
                // Query Command
                OdbcCommand command = new OdbcCommand(queryString, connection);
                //Open Connection
                connection.Open();                
                //Executes Data Reader
                OdbcDataReader reader = command.ExecuteReader();
                DataTable dt = new DataTable("UCCXData");
                dt.Load(reader);
                reader.Close();
                connection.Close();
                //Fill the dataview
                dvData.DataSource = dt;
                totalCalls.Text = Convert.ToString(dvData.Rows[0].Cells[0].Value).ToString();
                callsWaiting.Text = Convert.ToString(dvData.Rows[0].Cells[1].Value).ToString();
                oldestCall.Text = Convert.ToString(dvData.Rows[0].Cells[2].Value).ToString();
                callsHandled.Text = Convert.ToString(dvData.Rows[0].Cells[3].Value).ToString();
                callsAbandoned.Text = Convert.ToString(dvData.Rows[0].Cells[4].Value).ToString();
                longestCallDuration.Text = Convert.ToString(dvData.Rows[0].Cells[5].Value).ToString();
                

              

                      
            }
            catch (Exception ex)
            {
                //Error Textbox
                MessageBox.Show("there was an error - " + ex);
                textBox1.Text = " " + ex;
                
                
            }

        }
    

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet1.rtcsqssummary' table. You can move, or remove it, as needed.
            this.rtcsqssummaryTableAdapter.Fill(this.dataSet1.rtcsqssummary);
              
        }

        
      
    }
}



The VB code had the following:

Imports System.Data.Odbc

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'Get Castle Group data - queue=1
        GetUCCXData(1)
        'Get Connections data - queue=2
        GetUCCXData(2)

    End Sub

    Private Sub GetUCCXData(ByVal queue As Integer)

        'Initialize variables
        Dim contactsWaiting As Integer = 0 'rtcsqssummary = callswaiting
        Dim oldestContact As Integer = 0 'rtcsqssummary = oldestcontact
        Dim totalContacts As Integer = 0 'rtcsqssummary = totalcalls
        Dim contactsHandled As Integer = 0 'rtcsqssummary = callshandled
        Dim contactsAbandoned As Integer = 0 'rtcsqssummary = callsabandoned
        Dim percentageHandled As Double = 0 'Calculated field

        Try
            'ODBC Connection
            Dim connection As New OdbcConnection
            connection.ConnectionString = "Dsn=UCCX"

            'Query - using SQL SUM function with Informix DB
            Dim queryString As String = ""
            If queue = 1 Then
                queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'"
            ElseIf queue = 2 Then
                queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Elevator'"
            End If

            'Set command
            Dim command As New OdbcCommand(queryString, connection)

            'Open connection
            connection.Open()

            'Execute reader
            Dim reader As OdbcDataReader = command.ExecuteReader

            'Check if reader has any rows
            If reader.HasRows Then

                'Check that first column is not Null
                If reader.IsDBNull(0) = False Then
                    Dim dt As New DataTable("CSQ")
                    dt.Load(reader)

                    'Set data values
                    contactsWaiting = dt.Rows(0).Item("scallswaiting")
                    totalContacts = dt.Rows(0).Item("stotalcalls")
                    oldestContact = dt.Rows(0).Item("soldestcontact")
                    contactsHandled = dt.Rows(0).Item("scallshandled")
                    contactsAbandoned = dt.Rows(0).Item("scallsabandoned")

                    If queue = 1 Then
                        lblCGStatus.Text = ""
                    ElseIf queue = 2 Then
                        lblCEStatus.Text = ""
                    End If
                Else

                    If queue = 1 Then
                        lblCGStatus.Text = "Restart - NULL"
                    ElseIf queue = 2 Then
                        lblCEStatus.Text = "Restart - NULL"
                    End If
                End If

            Else
                If queue = 1 Then
                    lblCGStatus.Text = "Restart - NO ROWS"
                ElseIf queue = 2 Then
                    lblCEStatus.Text = "Restart - NO ROWS"
                End If
            End If

            reader.Close()
            connection.Close()

            'Render contacts waiting display - red / blink
            RenderContactsWaiting(oldestContact, contactsWaiting, queue)

            'Set web form values to data values
            If queue = 1 Then
                valCGWaiting.Text = contactsWaiting
                valCGTotal.Text = totalContacts
                valCGOldest.Text = CalculateTime(oldestContact)
                valCGHandled.Text = contactsHandled
                valCGAbandoned.Text = contactsAbandoned
                valCGPercentHandled.Text = CalculatePercentHandled(contactsHandled, totalContacts) + "%"
            ElseIf queue = 2 Then
                valCEWaiting.Text = contactsWaiting
                valCETotal.Text = totalContacts
                valCEOldest.Text = CalculateTime(oldestContact)
                valCEHandled.Text = contactsHandled
                valCEAbandoned.Text = contactsAbandoned
                valCEPercentHandled.Text = CalculatePercentHandled(contactsHandled, totalContacts) + "%"
            End If

            'Reset div views if needed
            If exceptionMessage.Attributes("class").ToString = "showDiv" Then

                lblException.Text = ""
                exceptionMessage.Attributes.Add("class", "hideDiv")
                wallboardContainer.Attributes.Add("class", "showDiv")
                UpdatePanelMain.Update()

            End If

        Catch ex As Exception

            lblException.Text = "Queue: " + queue.ToString + " - Error: " + ex.ToString
            exceptionMessage.Attributes.Add("class", "showDiv")
            wallboardContainer.Attributes.Add("class", "hideDiv")
            UpdatePanelMain.Update()

        End Try

    End Sub

    Private Sub RenderContactsWaiting(ByVal oldest As Integer, ByVal waiting As Integer, ByVal queue As Integer)

        If queue = 1 Then
            If oldest > 60000 Then
                divCGWaiting.Attributes.Add("class", "waitingDivRedBlink")
            ElseIf oldest > 40000 Or waiting > 2 Then
                divCGWaiting.Attributes.Add("class", "waitingDivRed")
            Else
                divCGWaiting.Attributes.Add("class", "waitingDivDefault")
            End If
        ElseIf queue = 2 Then
            If oldest > 60000 Then
                divCEWaiting.Attributes.Add("class", "waitingDivRedBlink")
            ElseIf oldest > 40000 Or waiting > 2 Then
                divCEWaiting.Attributes.Add("class", "waitingDivRed")
            Else
                divCEWaiting.Attributes.Add("class", "waitingDivDefault")
            End If
        End If

    End Sub

    Private Function CalculateTime(ByVal millis As Integer) As String

        Dim Hours As Integer = TimeSpan.FromMilliseconds(millis).Hours
        Dim Minutes As Integer = TimeSpan.FromMilliseconds(millis).Minutes
        Dim Seconds As Integer = TimeSpan.FromMilliseconds(millis).Seconds

        Return Hours.ToString("D2") + ":" + Minutes.ToString("D2") + ":" + Seconds.ToString("D2")

    End Function

    Private Function CalculatePercentHandled(ByVal handled As Integer, ByVal total As Integer) As String

        If total > 0 Then
            Return Math.Round(((handled / total) * 100)).ToString
        Else
            Return "0"
        End If

    End Function

End Class


I am trying to grab the second select statement which would be: "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Elevator'"

I tried putting it in an if else statement and got an error that "Queue" was invalid.

I am trying to pull both statements so they can fill the labels accordingly.

I know I am going to have to add another if else statement or something similar later in order to display the two "Queue's".

Aside from that I have been able to run it successfully until I try to place it in an if else statement.

Any help will be greatly appreciated as always..

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Reverse engineering an existing web form to windows form.

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3576
  • View blog
  • Posts: 11,125
  • Joined: 05-May 12

Re: Reverse engineering an existing web form to windows form.

Posted 06 August 2012 - 01:00 PM

View PostCmore86, on 06 August 2012 - 11:55 AM, said:

I am trying to grab the second select statement which would be: "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Elevator'"

I tried putting it in an if else statement and got an error that "Queue" was invalid.


Can you show us the code where you are trying this and the exact error that you are getting?

I suspect that you may have been missing the fact that there is a queue parameter on line 15 of the VB code. If you were trying to just type in "if (queue ", Visual Studio has an annoying habit of replacing the lower case "queue" with the capitalized "Queue". It thinks that you wanted to refer to the Queue class. It can't read your mind and know that you intend to create a queue variable later.
Was This Post Helpful? 1
  • +
  • -

#3 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Reverse engineering an existing web form to windows form.

Posted 06 August 2012 - 01:58 PM

View PostSkydiver, on 06 August 2012 - 01:00 PM, said:

View PostCmore86, on 06 August 2012 - 11:55 AM, said:

I am trying to grab the second select statement which would be: "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Elevator'"

I tried putting it in an if else statement and got an error that "Queue" was invalid.


Can you show us the code where you are trying this and the exact error that you are getting?

I suspect that you may have been missing the fact that there is a queue parameter on line 15 of the VB code. If you were trying to just type in "if (queue ", Visual Studio has an annoying habit of replacing the lower case "queue" with the capitalized "Queue". It thinks that you wanted to refer to the Queue class. It can't read your mind and know that you intend to create a queue variable later.



That sounds about right. I would just have to declare the queue as what kind of variable and would it matter?
Was This Post Helpful? 0
  • +
  • -

#4 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Reverse engineering an existing web form to windows form.

Posted 06 August 2012 - 02:09 PM

This is what I am trying to establish:

if (queue == 1)
                string queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
                else
                string queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname= 'RSQ-Elevator'";



I get the following error:

Error 1 Embedded statement cannot be a declaration or labeled statement \\cmi-fs-1\redirected folders - Offsite\cesarm\My Documents\Resident Services App\RSQ App\Project\RSQ App\RSQ App Projects\RSQ App Simple\RSQ(Simple).cs 43 17 RSQ App V1
Error 2 Embedded statement cannot be a declaration or labeled statement \\cmi-fs-1\redirected folders - Offsite\cesarm\My Documents\Resident Services App\RSQ App\Project\RSQ App\RSQ App Projects\RSQ App Simple\RSQ(Simple).cs 45 17 RSQ App V1
This will pull the data and should populate the labels afterwards, and needs to be done in realtime or constantly.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3576
  • View blog
  • Posts: 11,125
  • Joined: 05-May 12

Re: Reverse engineering an existing web form to windows form.

Posted 06 August 2012 - 02:35 PM

Try this instead:
string queryString;
if (queue == 1)
    queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
else
    queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname= 'RSQ-Elevator'";


or better:
string queryString = "SELECT SUM(totalcalls) AS stotalcalls, " +
                            "SUM(callswaiting) AS scallswaiting, " +
                            "SUM(oldestcontact) AS soldestcontact, " +
                            "SUM(callshandled) AS scallshandled, " +
                            "SUM(callsabandoned) AS scallsabandoned, " +
                            "SUM(longesttalkduration) AS slongesttalkduration " +
                            "FROM rtcsqssummary ";
if (queue == 1)
    queryString.Append("WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'");
else
    queryString.Append("WHERE csqname='RSQ-Elevator'");


This post has been edited by Skydiver: 06 August 2012 - 02:36 PM

Was This Post Helpful? 1
  • +
  • -

#6 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Reverse engineering an existing web form to windows form.

Posted 07 August 2012 - 06:31 AM

View PostSkydiver, on 06 August 2012 - 02:35 PM, said:

Try this instead:
string queryString;
if (queue == 1)
    queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
else
    queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname= 'RSQ-Elevator'";


or better:
string queryString = "SELECT SUM(totalcalls) AS stotalcalls, " +
                            "SUM(callswaiting) AS scallswaiting, " +
                            "SUM(oldestcontact) AS soldestcontact, " +
                            "SUM(callshandled) AS scallshandled, " +
                            "SUM(callsabandoned) AS scallsabandoned, " +
                            "SUM(longesttalkduration) AS slongesttalkduration " +
                            "FROM rtcsqssummary ";
if (queue == 1)
    queryString.Append("WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'");
else
    queryString.Append("WHERE csqname='RSQ-Elevator'");



I tried both methods and like the second one which is cleaner however.

string queryString;  

if (queue == 1)  

queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";  

else 

queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname= 'RSQ-Elevator'"; 




I got this error:

Error 7 Use of unassigned local variable 'queue' \\cmi-fs-1\redirected folders - Offsite\cesarm\My Documents\Resident Services App\RSQ App\Project\RSQ App\RSQ App Projects\RSQ App Simple\RSQ(Simple).cs 45 5 RSQ App V1

When attempting this one I get:

view sourceprint?
01 string queryString = "SELECT SUM(totalcalls) AS stotalcalls, " +  

02                             "SUM(callswaiting) AS scallswaiting, " +  

03                             "SUM(oldestcontact) AS soldestcontact, " +  

04                             "SUM(callshandled) AS scallshandled, " +  

05                             "SUM(callsabandoned) AS scallsabandoned, " +  

06                             "SUM(longesttalkduration) AS slongesttalkduration " +  

07                             "FROM rtcsqssummary ";  

08 if (queue == 1)  

09     queryString.Append("WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'");  

10 else 

11     queryString.Append("WHERE csqname='RSQ-Elevator'"); 



I get these errors:

Error 1 'string' does not contain a definition for 'Append' and no extension method 'Append' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) \\cmi-fs-1\redirected folders - Offsite\cesarm\My Documents\Resident Services App\RSQ App\Project\RSQ App\RSQ App Projects\RSQ App Simple\RSQ(Simple).cs 59 17 RSQ App V1

Error 2 'string' does not contain a definition for 'Append' and no extension method 'Append' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) \\cmi-fs-1\redirected folders - Offsite\cesarm\My Documents\Resident Services App\RSQ App\Project\RSQ App\RSQ App Projects\RSQ App Simple\RSQ(Simple).cs 63 18 RSQ App V1

Let me know what I can do, it looks like I am missing an extension on one and the other is missing a local variable.
Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4490
  • View blog
  • Posts: 7,822
  • Joined: 08-June 10

Re: Reverse engineering an existing web form to windows form.

Posted 07 August 2012 - 07:21 AM

Instead of using queryString.Append("...");, use queryString += "...";. The Append method would work if it were a StringBuilder, which you might consider using if you were doing more manipulations to the string.
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,519
  • Joined: 23-August 08

Re: Reverse engineering an existing web form to windows form.

Posted 07 August 2012 - 07:30 AM

You also need to learn how to read your error messages and fix them! Your location says US, and this is pretty clear English:

Quote

Use of unassigned local variable 'queue'


You're trying to use a variable to which you've given no value.

As is this:

Quote

'string' does not contain a definition for 'Append' and no extension method 'Append' accepting a first argument of type 'string' could be found


meaning that the type string does not have a method called Append. If you go to the documentation, you'll find available methods for your classes.
Was This Post Helpful? 0
  • +
  • -

#9 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Reverse engineering an existing web form to windows form.

Posted 07 August 2012 - 09:57 AM

This is the updated code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RSQ_App_V1
{
    public partial class RSQ : Form
    {
        public RSQ()
        {
            InitializeComponent();
            //Get Castle Group data - queue =1
            GetUCCXData(1);
            //Get Connection data - quueue =2
            GetUCCXData(2);
        }
      
        private void GetUCCXData(int queue)
        {
            try
            {
                //Initialize variables
                int contactsWaiting = 0;
                //rtcsqssummary = callswaiting
                int oldestContact = 0;
                //rtcsqssummary = oldestcontact
                int totalContacts = 0;
                //rtcsqssummary = totalcalls
                int contactsHandled = 0;
                //rtcsqssummary = callshandled
                int contactsAbandoned = 0;
                //rtcsqssummary = callsabandoned
                double percentageHandled = 0;

                // Establishes Connection to UCCX
                OdbcConnection connection = new OdbcConnection();
                connection.ConnectionString = "DSN=UCCX";

                // Selects Data 1
                //string queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";

                // Selects Data 2
                //string queryString = "SELECT SUM(totalcalls) AS stotalcalls, " +
                //    "SUM(callswaiting) AS scallswaiting, " +
                //    "SUM(oldestcontact) AS soldestcontact, " +
                //    "SUM(callshandled) AS scallshandled, " +
                //    "SUM(longesttalkduration) AS slongesttalkduration " +
                //    "FROM rtcsqssummary ";
                //if (queue == 1)
                //    queryString.Append += "WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
                //else queryString.Append += "WHERE csqname='RSQ-Elevator'"; 

                //Selects Data 3
                string queryString = "";
                if (queue == 1)
                {
                    queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
                }
                else if (queue == 2)
                {
                    queryString = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname= 'RSQ-Elevator'";
                }
               
                // Query Command
                OdbcCommand command = new OdbcCommand(queryString, connection);
                //Open Connection
                connection.Open();
                //Executes Data Reader
                OdbcDataReader reader = command.ExecuteReader();
                DataTable dt = new DataTable("UCCXData");
                dt.Load(reader);
                reader.Close();
                connection.Close();
                //Fills the dataview
                dvData.DataSource = dt;

                //Resident Services
                totalCalls1.Text = Convert.ToString(dvData.Rows[0].Cells[0].Value).ToString();
                callsWaiting1.Text = Convert.ToString(dvData.Rows[0].Cells[1].Value).ToString();
                oldestCall1.Text = Convert.ToString(dvData.Rows[0].Cells[2].Value).ToString();
                callsHandled1.Text = Convert.ToString(dvData.Rows[0].Cells[3].Value).ToString();
                callsAbandoned1.Text = Convert.ToString(dvData.Rows[0].Cells[4].Value).ToString();
                longestCallDuration1.Text = Convert.ToString(dvData.Rows[0].Cells[5].Value).ToString();
                //Elevator 
                totalCalls2.Text = Convert.ToString(dvData.Rows[1].Cells[0].Value).ToString();
                callsWaiting2.Text = Convert.ToString(dvData.Rows[1].Cells[1].Value).ToString();
                oldestCall2.Text = Convert.ToString(dvData.Rows[1].Cells[2].Value).ToString();
                callsHandled2.Text = Convert.ToString(dvData.Rows[1].Cells[3].Value).ToString();
                callsAbandoned2.Text = Convert.ToString(dvData.Rows[1].Cells[4].Value).ToString();
                longestCallDuration2.Text = Convert.ToString(dvData.Rows[1].Cells[5].Value).ToString();

            }
            catch (Exception ex)
            {
                //Error Textbox
                MessageBox.Show("there was an error - " + ex);
                errorBox1.Text = " " + ex;
            }
        }
    

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet1.rtcsqssummary' table. You can move, or remove it, as needed.
            this.rtcsqssummaryTableAdapter.Fill(this.dataSet1.rtcsqssummary);
              
        }

        
      
    }
}



I have restructured the code and have figured out the error that was going on and fixed. However I am trying to figure out why the second set of data is not being pulled. It is pulling an error

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Windows.Forms.DataGridViewRowCollection.SharedRow(Int32 rowIndex)
at System.Windows.Forms.DataGridViewRowCollection.get_Item(Int32 index)
at RSQ_App_V1.RSQ.GetUCCXData(Int32 queue) in \\cmi-fs-1\redirected folders - Offsite\cesarm\My Documents\Resident Services App\RSQ App\Project\RSQ App\RSQ App Projects\RSQ App Simple\RSQ(Simple).cs:line 90

Simply because it is not running the second select statement.

More than likely I need to add something to the code so it constantly updates.

I apologize if I was naive in not reading into the error, but I did not understand and was following from what was suggested.

Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1