using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using InfoSoftGlobal;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
using DataConnection;
using System.Web.Caching;
using System.Collections.Specialized;
public partial class customers_assigntrack : System.Web.UI.Page
{
public string _UserName = "";
private string _CustCode = "";
public string _AssignCode = "";
public string _QSet = "";
public string _QNo = "";
public string _Date = "";
public string _Location = "";
public string _param = "";
public string _ANo = "";
public string rowtype = "";
public string responsetype = "";
public string sGraphSet;
public string Qtext = "";
public string _ImageURL = "";
public string _ddlQSetStyle = "";
public string _question_text;
public string sRtn;
public string _help = "display:none;";
public string _url;
public string query;
public string sp_name;
public SqlConnection conn;
public SqlConnection conn2;
public SqlCommand comm;
public string _QSet2 = "";
public string _QNo2 = "";
public string _Date2 = "";
public string _note = "";
public int c_qno = 0;
public int c_atext = 1;
public int c_loc = 2;
public int c_date = 3;
public int c_notes = 4;
public int c_person = 5;
public int c_callerid = 6;
public int c_ano = 7;
public Boolean b_sum_graph_click = false; //set the summary graph flag to "not clicked" initially
public int i_graph_type; //collation chart type
public int i_question_count; //The number of questions being collated
public Boolean b_summary_flag = true; //set flag to "Summary" mode initially
public string _detail_placeholder_text = "Click 'Show Detail' and select a specific question or answer from the lefthand grid to view further information from the promotion"; //if the gvSummary & gvResults GridViews are empty then show some explanatory text
public int caller_id;
public int qset;
// Status Flags
public string s_summary = "1";
public string s_detail = "2";
//PAGE_LOAD EVENT
protected void Page_Load(object sender, System.EventArgs e)
{
//get the logged in user's name
_UserName = User.Identity.Name;
//get the customer code for the user
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string dbconn = ConfigurationManager.ConnectionStrings["dbConnectionString"].ConnectionString;
conn = new SqlConnection(connectionString);
conn2 = new SqlConnection(webdbconn);
comm = new SqlCommand("spname", conn);
comm.CommandType = System.Data.CommandType.StoredProcedure;
comm.Parameters.Add("@uname", System.Data.SqlDbType.NVarChar, 20);
comm.Parameters["@uname"].Value = _UserName;
conn.Open();
object obj = comm.ExecuteScalar();
_CustCode = obj.ToString();
CustomerCode.Text = obj.ToString();
conn.Close();
if (!IsPostBack)
{
gvSummary.Visible = true;
ScrollingResultsPanel.Visible = false;
gvSummary.DataBind();
}
if (gvSummary.Visible == false)
{
ScrollingResultsPanel.Visible = true;
_detail_placeholder_text = "Click 'Show Summary' to view Collated Reporting Information and Charts";
}
}
//PAGE_PRERENDERCOMPLETE EVENT
protected void Page_PreRenderComplete(object sender, System.EventArgs e)
{
//if there are any Question Sets then show the dropdown controls
if (ddlQSets.Items.Count > 1)
{
_ddlQSetStyle = "display:block;";
ddlQSets.Width = 35;
ddlQSetsLabel.Visible = true;
}
//if there aren't any Question Sets then don't show the dropdown controls
else
{
_ddlQSetStyle = "display:none;";
ddlQSets.Width = 0;
ddlQSetsLabel.Visible = false;
}
}
//RENDER FUSION CHART FUNCTION
public string SetGraphParams()
{
//show fullscreen button, make all detail buttons invisible
FullScreen.Visible = true;
Export.Visible = false;
Report.Visible = false;
Notes.Visible = false;
Photo.Visible = false;
//if the summary graph flag has been updated (Previous or Next buttons OnClick has been fired) then...
if (b_sum_graph_click == true)
{
if (i_graph_type == 2)
{
if (i_question_count == 1)
{
sp_name = "spname_sp ";
}
else
{
sp_name = "spname_sp ";
}
}
else
{
if (i_question_count == 1)
{
sp_name = "spname_sp ";
}
else
{
sp_name = "spname_sp ";
}
}
}
//make gvLayout columns visible in order to get the values and databind
gvLayout.Columns[5].Visible = true;
gvLayout.Columns[4].Visible = true;
gvLayout.Columns[1].Visible = true;
gvLayout.Columns[13].Visible = true;
gvLayout.DataBind();
//if a row has been highlighted in gvLayout then...
if (gvLayout.SelectedIndex >= 0)
{
QuestionNo.Text = gvLayout.Rows[gvLayout.SelectedIndex].Cells[1].Text;
AnswerNo.Text = gvLayout.Rows[gvLayout.SelectedIndex].Cells[5].Text;
//if neither of the Prev/Next OnClicks have been fired...
if (b_sum_graph_click == false)
{
_QNo = gvLayout.Rows[gvLayout.SelectedIndex].Cells[1].Text;
rowtype = gvLayout.Rows[gvLayout.SelectedIndex].Cells[13].Text;
responsetype = gvLayout.Rows[gvLayout.SelectedIndex].Cells[4].Text;
if (responsetype == "1")
{
sp_name = "spname_sp ";
}
else
{
sp_name = "spname_sp ";
}
}
//if one of the Prev/Next OnClicks HAVE been fired...
else
{
if (i_graph_type == 2)
{
responsetype = "1";
}
else
{
responsetype = "0";
}
rowtype = "Q";
}
_question_text = gvLayout.Rows[gvLayout.SelectedIndex].Cells[2].Text;
}
//if a row hasn't been highlighted in gvLayout then...
else
{
rowtype = "Q";
if (i_graph_type == 2)
{
responsetype = "1";
}
else
{
responsetype = "0";
}
}
//set variables from the dropdown values
_QSet = ddlQSets.SelectedValue;
_AssignCode = ddlAssignments.SelectedValue;
_Date = ddlDates.SelectedValue;
_Location = ddlLocation.SelectedValue;
//set the gvLayout fields to be invisible again
gvLayout.Columns[5].Visible = false;
gvLayout.Columns[4].Visible = false;
gvLayout.Columns[1].Visible = false;
gvLayout.Columns[13].Visible = false;
//what is GraphSet?
GraphSet.Visible = true;
sGraphSet = GraphSet.Text;
GraphSet.Visible = false;
//set Location and Date to be null if not used
if (_Location == "{All Locations}")
{
_Location = " null ";
}
else
{
_Location = "'" + _Location + "'";
}
if (_Date == "{All Dates}")
{
_Date = " null ";
}
else
{
_Date = "'" + _Date + "'";
}
//if QUESTION rowtype...
if (rowtype == "Q")
{
//NOTE: It's necessary to encode the dataURL if you've added parameters to it
String dataURL = Server.UrlEncode("Data.aspx?animate=1&rowtype=" + rowtype + "&responsetype=" + responsetype + "&assign=" + _AssignCode + "&qset=" + _QSet + "&qno=" + _QNo + "&date=" + _Date + "&location=" + _Location + "&graphset=" + sGraphSet + "&sp_name=" + sp_name);
//hide Summary & Results GridViews, show Help, FullScreen and Refresh
gvSummary.Visible = false;
gvResults.Visible = false;
ScrollingResultsPanel.Visible = false;
_help = "display:block;";
FullScreen.Visible = true;
//Refresh.Visible = true;
if (rowtype == "Q" && responsetype == "0")
{
//To debug, change the penultimate var from false to true
return FusionCharts.RenderChart("../FusionCharts/Pie3D.swf", dataURL, "", "PieSum", "430", "362", false, false);
}
if (rowtype == "Q" && responsetype == "1")
{
FullScreen.Visible = true;
if (b_sum_graph_click == true)
{
//To debug, change the penultimate var from false to true
return FusionCharts.RenderChart("../FusionCharts/Column3D.swf", dataURL, "", "Col3D", "430", "362", false, false);
}
else
{
//To debug, change the penultimate var from false to true
return FusionCharts.RenderChart("../FusionCharts/ScrollColumn2D.swf", dataURL, "", "Scroll2D", "430", "362", false, false);
}
}
return "";
}
else
{
gvResults.Columns[1].Visible = false;
gvResults.Columns[2].Visible = true;
gvResults.Columns[3].Visible = true;
gvSummary.Visible = false;
gvResults.Visible = true;
ScrollingResultsPanel.Visible = true;
gvResults.DataBind();
}
return "";
}
protected void gvLayout_SelectedIndexChanged(object sender, EventArgs e)
{
GraphSet.Text = "1";
_param = SetGraphParams();
DetailImageButton.ImageUrl = "~/images/summary.gif";
DetailImageButton.AlternateText = "Click to view Summary";
Previous.Visible = false;
Next.Visible = false;
//Refresh.Visible = true;
FullScreen.Visible = true;
}
protected void ddlDates_SelectedIndexChanged(object sender, EventArgs e)
{
if (DetailImageButton.ImageUrl == "~/images/detail.gif")
{
b_summary_flag = false;
}
if (b_summary_flag == false)
{
gvSummary.Visible = true;
Previous.Visible = false;
Next.Visible = false;
//Refresh.Visible = false;
}
else
{
_param = SetGraphParams();
}
}
protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e)
{
if (DetailImageButton.ImageUrl == "~/images/detail.gif")
{
b_summary_flag = false;
}
if (b_summary_flag == false)
{
gvSummary.Visible = true;
Previous.Visible = false;
Next.Visible = false;
//Refresh.Visible = false;
}
else
{
_param = SetGraphParams();
}
}
protected void DetailImageButton_Click(object sender, ImageClickEventArgs e)
{
if (FormState.Text == s_summary)
{
FormState.Text = s_detail;
gvSummary.Visible = false;
gvResults.Visible = true;
ScrollingResultsPanel.Visible = true;
DetailImageButton.ImageUrl = "~/images/summary.gif";
DetailImageButton.AlternateText = "Click to view Summary";
_detail_placeholder_text = "Click 'Show Summary' to view Collated Reporting Information and Charts";
Previous.Visible = false;
Next.Visible = false;
gvLayout.Enabled = true;
gvLayout.DataBind();
if (gvResults.Rows.Count <= 0 & gvLayout.SelectedIndex >= 0)
{
_param = SetGraphParams();
}
}
else
{
FormState.Text = s_summary;
gvSummary.Visible = true;
gvResults.Visible = false;
ScrollingResultsPanel.Visible = false;
DetailImageButton.ImageUrl = "~/images/detail.gif";
DetailImageButton.AlternateText = "Click to view Detail";
_detail_placeholder_text = "Click 'Show Detail' and select a specific question or answer from the lefthand grid to view further information from the promotion";
Previous.Visible = true;
Next.Visible = true;
Export.Visible = false;
FullScreen.Visible = false;
Notes.Visible = false;
Report.Visible = false;
Photo.Visible = false;
gvLayout.Enabled = false;
}
//gvResults.DataBind();
gvSummary.DataBind();
}
protected void ddlAssignments_SelectedIndexChanged(object sender, EventArgs e)
{
GraphSet.Text = "1";
FullScreen.Visible = false;
Export.Visible = false;
Report.Visible = false;
Notes.Visible = false;
Photo.Visible = false;
if (ddlQSets.Items.Count > 1)
{
_ddlQSetStyle = "display:block;";
ddlQSets.Width = 35;
ddlQSetsLabel.Visible = true;
}
else
{
_ddlQSetStyle = "display:none;";
ddlQSets.Width = 0;
ddlQSetsLabel.Visible = false;
}
ddlQSets.DataBind();
gvLayout.DataBind();
}
//SET THE COLOR OF THE SELECTED ROW
public string gvLayout_sortcolors()
{
int lLoopVar;
string sRowType;
lLoopVar = 0;
while (lLoopVar < gvLayout.Rows.Count)
{
sRowType = gvLayout.Rows[lLoopVar].Cells[13].Text;
if (sRowType == "A")
{
gvLayout.Rows[lLoopVar].BackColor = System.Drawing.Color.Snow;
gvLayout.Rows[lLoopVar].Cells[13].ForeColor = System.Drawing.Color.Snow;
}
lLoopVar = lLoopVar + 1;
}
// set the selected row colour
if (gvLayout.SelectedIndex >= 0)
{
}
return "";
}
//RETURN THE COLORS TO THE GRIDVIEW
protected void gvLayout_DataBound(object sender, EventArgs e)
{
sRtn = gvLayout_sortcolors();
}
//EXPORT THE DATA TO A .CSV FILE
protected void Export_Click(object sender, ImageClickEventArgs e)
{
string attachment = "attachment; filename=output.csv";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.xls";
StringWriter sw = new StringWriter();
// Write the headers
DataTable csv_export = GetData();
int iColCount = csv_export.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
sw.Write(csv_export.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
// Write the rows
foreach (DataRow dr in csv_export.Rows)
{
for (int i = 0; i < iColCount; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(dr[i].ToString());
}
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
}
Response.Write(sw.ToString());
Response.End();
sw.Close();
}
public override void VerifyRenderingInServerForm(Control control)
{
// Confused me, but now I understand it, the 'override argument is preventing this 'standard' function/event from running
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
}
public DataTable GetData()
{
gvLayout.Columns[5].Visible = true;
gvLayout.Columns[1].Visible = true;
gvLayout.DataBind();
if (gvLayout.SelectedIndex >= 0)
{
_ANo = gvLayout.Rows[gvLayout.SelectedIndex].Cells[5].Text;
_QNo = gvLayout.Rows[gvLayout.SelectedIndex].Cells[1].Text;
}
_QSet = ddlQSets.SelectedValue;
_Date = ddlDates.SelectedValue;
_Location = ddlLocation.SelectedValue;
gvLayout.Columns[5].Visible = false;
gvLayout.Columns[1].Visible = false;
SqlConnection conn2;
string dbconn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
conn2 = new SqlConnection(dbconn);
SqlCommand cmd = new SqlCommand("spname_sp ", conn2);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("@question_set", System.Data.SqlDbType.Int);
cmd.Parameters["@question_set"].Value = Convert.ToInt64(_QSet);
cmd.Parameters.Add("@question_no", System.Data.SqlDbType.Int);
cmd.Parameters["@question_no"].Value = Convert.ToInt64(_QNo);
cmd.Parameters.Add("@answer_no", System.Data.SqlDbType.Int);
cmd.Parameters["@answer_no"].Value = Convert.ToInt64(_ANo);
cmd.Parameters.Add("@orig_date", System.Data.SqlDbType.NVarChar, 20);
cmd.Parameters["@orig_date"].Value = _Date;
cmd.Parameters.Add("@location_id", System.Data.SqlDbType.NVarChar, 32);
cmd.Parameters["@location_id"].Value = _Location;
DataTable csv_output = new DataTable();
try
{
using (SqlDataAdapter adapt = new SqlDataAdapter(cmd))
{
adapt.SelectCommand = cmd;
conn2.Open();
adapt.Fill(csv_output);
conn2.Close();
}
return csv_output;
}
catch (SqlException ex) { throw ex; }
}
//DISPLAY THE IMAGE - pass in the row count (starting at zero)
public string ShowEmpImage(int i_row)
{
string s_assignment_code;
long l_caller_id;
long l_question_number;
l_question_number = 0;
l_caller_id = 0;
gvLayout.Columns[1].Visible = true;
gvLayout.DataBind();
if (gvLayout.SelectedIndex >= 0)
{
l_question_number = Convert.ToInt64(gvLayout.Rows[gvLayout.SelectedIndex].Cells[1].Text);
}
s_assignment_code = ddlAssignments.SelectedValue;
//get the data from the row count
if (i_row >= 0 )
{
//gvResults.Columns[7].Visible = true;
gvResults.Columns[6].Visible = true;
gvResults.DataBind();
l_caller_id = Convert.ToInt64(gvResults.Rows[i_row].Cells[c_callerid].Text);
gvResults.Columns[6].Visible = false;
//gvResults.Columns[7].Visible = false;
}
SqlConnection conn2;
string webdbconn = ConfigurationManager.ConnectionStrings["webdbConnectionString"].ConnectionString;
conn2 = new SqlConnection(webdbconn);
string sql = "SELECT statement";
SqlCommand cmd = new SqlCommand(sql, conn2);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("@assignment", System.Data.SqlDbType.NVarChar, 30);
cmd.Parameters["@assignment"].Value = s_assignment_code;
cmd.Parameters.Add("@caller_id", System.Data.SqlDbType.Int);
cmd.Parameters["@caller_id"].Value = l_caller_id;
cmd.Parameters.Add("@question_number", System.Data.SqlDbType.Int);
cmd.Parameters["@question_number"].Value = l_question_number;
cmd.CommandTimeout = 500;
conn2.Open();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
try
{
byte[] bindata = (byte[])dr.GetValue(0);
Cache["Bindata"] = bindata;
conn2.Close();
}
catch
{
conn2.Close();
return "";
}
finally
{
conn2.Close();
}
return "";
}
public bool IsReusable
{
get
{
return false;
}
}
protected void SwitchStylesheets(object sender, EventArgs e)
{
if (radioBlue.Checked)
stylesheet.Href = "~/blue.css";
if (radioGreen.Checked)
stylesheet.Href = "~/green.css";
}
//UPDATE THE SUMMARY WHEN A DIFFERENT QUESTION SET IS CHOSEN
protected void ddlQSets_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewSummary.DataBind();
}
//OPEN THE CHART IN A NEW WINDOW
protected void FullScreen_Click(object sender, ImageClickEventArgs e)
{
int i_group;
int i_count;
string s_question;
_QSet2 = ddlQSets.SelectedValue;
_Date2 = ddlDates.SelectedValue;
if (_Date2 == "{All Dates}")
{
_Date2 = " null ";
}
else
{
_Date2 = "'" + _Date2 + "'";
}
gvLayout.Columns[1].Visible = true;
gvLayout.Columns[5].Visible = true;
gvLayout.Columns[4].Visible = true;
gvLayout.Columns[13].Visible = true;
gvLayout.Enabled = true;
gvLayout.DataBind();
if (gvLayout.SelectedIndex >= 0)
{
rowtype = gvLayout.Rows[gvLayout.SelectedIndex].Cells[13].Text;
responsetype = gvLayout.Rows[gvLayout.SelectedIndex].Cells[4].Text;
AnswerNo.Text = gvLayout.Rows[gvLayout.SelectedIndex].Cells[5].Text;
_question_text = gvLayout.Rows[gvLayout.SelectedIndex].Cells[2].Text;
_QNo2 = gvLayout.Rows[gvLayout.SelectedIndex].Cells[1].Text;
}
else
{
_question_text = "";
}
_AssignCode = ddlAssignments.SelectedValue;
_Location = ddlLocation.SelectedValue;
GraphSet.Visible = true;
sGraphSet = GraphSet.Text;
GraphSet.Visible = false;
if (_Location == "{All Locations}")
{
_Location = " null ";
}
else
{
_Location = "'" + _Location + "'";
}
if (FormState.Text == s_summary)
{
collation_groups.Visible = true;
collation_groups.DataBind();
if (current_group.Text == "")
{
i_group = 0;
}
else
{
i_group = Convert.ToInt32(current_group.Text);
}
i_count = 0;
while (i_count < collation_groups.Rows.Count)
{
if (Convert.ToInt32(collation_groups.Rows[i_count].Cells[1].Text) == i_group)
{
i_group = Convert.ToInt32(collation_groups.Rows[i_count].Cells[1].Text);
_QNo2 = collation_groups.Rows[i_count].Cells[0].Text;
i_graph_type = Convert.ToInt32(collation_groups.Rows[i_count].Cells[2].Text);
i_question_count = Convert.ToInt32(collation_groups.Rows[i_count].Cells[3].Text);
// in this instance only (e.g when showing the summary graphs, don't show a graph (2) show a pie chart (1) where there is only one question
current_group.Text = i_group.ToString();
break;
}
i_count = i_count + 1;
}
collation_groups.Visible = false;
}
Cache["Qtext"] = _question_text;
Response.Redirect("ChartPopUp.aspx?qset="+_QSet2+"&qno="+ _QNo2 +"&dt="+_Date2+"&ro="+rowtype+"&re="+responsetype+"&a="+_AssignCode+"&l="+_Location+"&sG="+sGraphSet+"&f="+FormState.Text+"&g="+i_graph_type+"&qc="+i_question_count);
gvLayout.Columns[5].Visible = false;
gvLayout.Columns[4].Visible = false;
gvLayout.Columns[1].Visible = false;
gvLayout.Columns[13].Visible = false;
gvLayout.Enabled = false;
}
//OPEN THE NOTES IN A NEW WINDOW
protected void Notes_Click(object sender, ImageClickEventArgs e)
{
string note;
gvResults.Columns[4].Visible = true;
gvResults.DataBind();
note = gvResults.Rows[gvResults.SelectedIndex].Cells[c_notes].Text;
Response.Redirect("NotesPopUp.aspx?note="+note);
gvResults.Columns[4].Visible = false;
}
//OPEN THE FULL REPORT IN A NEW WINDOW
protected void Report_Click(object sender, ImageClickEventArgs e)
{
//This needs to be working but I'm not sure how to get both working at present
//if (gvResults.SelectedIndex > 0)
//{
gvResults.Columns[6].Visible = true;
gvResults.DataBind();
caller_id = Convert.ToInt32(gvResults.Rows[gvResults.SelectedIndex].Cells[c_callerid].Text);
gvResults.Columns[6].Visible = false;
//}
qset = Convert.ToInt32(ddlQSets.SelectedValue);
Response.Redirect("ReportPopUp.aspx?caller_id=" + caller_id + "&qset=" + qset);
}
//OPEN THE PERSON'S PHOTO IN A NEW WINDOW
protected void Photo_Click(object sender, ImageClickEventArgs e)
{
int i_row;
i_row = gvResults.SelectedIndex;
ShowEmpImage(i_row);
}
//protected void Refresh_Click(object sender, ImageClickEventArgs e)
//{
// b_summary_flag = true;
// _param = SetGraphParams();
//}
protected void gvResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
Export.Visible = true;
Photo.Visible = true;
Report.Visible = true;
Notes.Visible = true;
string _hidebuttons;
_hidebuttons = "display:block;";
_help = "display:none;";
}
protected void Next_Click(object sender, ImageClickEventArgs e)
{
int i_group;
int i_count;
string s_question;
//set the summary graph click to true
b_sum_graph_click = true;
//make the GridView readable and bind the data
collation_groups.Visible = true;
collation_groups.DataBind();
if (current_group.Text == "")
{
i_group = 0;
}
else
{
i_group = Convert.ToInt32(current_group.Text);
}
i_count = 0;
while (i_count < collation_groups.Rows.Count)
{
if (Convert.ToInt32(collation_groups.Rows[i_count].Cells[1].Text) > i_group)
{
i_group = Convert.ToInt32(collation_groups.Rows[i_count].Cells[1].Text);
_QNo = collation_groups.Rows[i_count].Cells[0].Text;
i_graph_type = Convert.ToInt32(collation_groups.Rows[i_count].Cells[2].Text);
i_question_count = Convert.ToInt32(collation_groups.Rows[i_count].Cells[3].Text);
// in this instance only (e.g when showing the summary graphs, don't show a graph (2) show a pie chart (1) where there is only one question
if (i_graph_type == 2 && i_question_count == 1)
{
i_graph_type = 1;
}
current_group.Text = i_group.ToString();
break;
}
i_count = i_count + 1;
}
//if the count reaches the number of rows or more then show the Summary otherwise keep showing Charts
if (i_count >= collation_groups.Rows.Count)
{
gvSummary.Visible = true;
}
else
{
_param = SetGraphParams();
}
//hide the GridView
collation_groups.Visible = false;
//set the summary graph click to false
b_sum_graph_click = false;
//Set the Summary flag so that gvLayout is disabled
b_summary_flag = true;
}
protected void Previous_Click(object sender, ImageClickEventArgs e)
{
int i_group;
int i_count;
string s_question;
//set the summary graph click to true
b_sum_graph_click = true;
//make the GridView readable and bind the data
collation_groups.Visible = true;
collation_groups.DataBind();
if (current_group.Text == "")
{
i_group = 0;
gvSummary.Visible = true;
}
else
{
i_group = Convert.ToInt32(current_group.Text);
}
i_count = collation_groups.Rows.Count - 1;
while (i_count > 0)
{
if (Convert.ToInt32(collation_groups.Rows[i_count].Cells[1].Text) < i_group)
{
i_group = Convert.ToInt32(collation_groups.Rows[i_count].Cells[1].Text);
_QNo = collation_groups.Rows[i_count].Cells[0].Text;
current_group.Text = i_group.ToString();
i_graph_type = Convert.ToInt32(collation_groups.Rows[i_count].Cells[2].Text);
i_question_count = Convert.ToInt32(collation_groups.Rows[i_count].Cells[3].Text);
if (i_graph_type == 2 && i_question_count == 1) // in this instance only (e.g when showing the summary graphs, don't show a graph (2) show a pie chart (1)
// where there is only one question
{
i_graph_type = 1;
}
break;
}
i_count = i_count - 1;
}
//if the current_group is zero then just show the Summary GridView
if (i_count == 0 && current_group.Text == "1")
{
gvSummary.Visible = true;
}
else
{
//call the Charts
_param = SetGraphParams();
}
//hide the GridView
collation_groups.Visible = false;
//set the summary graph click to false
b_sum_graph_click = false;
//Set the Summary flag so that gvLayout is disabled
b_summary_flag = true;
}
}