<|start_filename|>IEDC_webapp/frmDatabaseHome.aspx.cs<|end_filename|>
﻿//using ClosedXML.Excel;
using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
//using Microsoft.Office.Interop.Excel;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class frmDatabaseHome : System.Web.UI.Page
    {
        clsDataHandling clsD = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            

            if (!Page.IsPostBack)
            {
                //clsD.datasetDropDown(drdDataSet);
                clsD.getYear(hdnYear);
                clsD.getCountry(hdnCountry);
                clsD.datasetGridView(grdDataSet);

            }

        }

        protected void btnDatasetGridSelect_Click(object sender, EventArgs e)
        {
            rdoProcessType.Enabled = true;
            System.Web.UI.WebControls.Button  btn = (System.Web.UI.WebControls.Button)sender;
            GridViewRow gvr = (GridViewRow)btn.NamingContainer;
            string datasetId = gvr.Cells[1].Text;
            //clsD.processListGridView(grdProcessList, datasetId);

            clsD.processListDropDown(drdStocks, datasetId);
            clsD.processListDropDown(drdSourceFlows, datasetId);
            clsD.processListDropDown(drdTargetFlows, datasetId);
        }

        protected void btnProcessListGridSelect_Click(object sender, EventArgs e)
        {
            System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)sender;
            GridViewRow gvr = (GridViewRow)btn.NamingContainer;
            string processId = gvr.Cells[2].Text;

            bindGrid(processId);


            //clsD.processListGridView(grdProcessList, datasetId);
        }

        protected void bindGrid(string processId)
        {
            string type = rdoProcessType.SelectedValue;

            if (type == "1")
            {
                //clsD.stocksGridView(grdStocks, processId);
            }

            else if (type == "2")
            {
                //clsD.flowsGridView(grdFlows, processId);
            }
        }

        protected void rdoProcessType_SelectedIndexChanged(object sender, EventArgs e)
        {
            string type = rdoProcessType.SelectedValue;

            if (type == "1")
            {
                drdStocks.Enabled = true;
                drdSourceFlows.Enabled = false;
                drdTargetFlows.Enabled = false;
            }

            else if (type == "2")
            {
                drdSourceFlows.Enabled = true;
                drdTargetFlows.Enabled = true;
                drdStocks.Enabled = false;
            }
        }

        protected void drdStocks_SelectedIndexChanged(object sender, EventArgs e)
        {
            string param = "stocks.time in (" + hdnYear.Value + ")";
            clsD.stocksGridView(grdStocks, Convert.ToString(drdStocks.SelectedValue), param);
        }

        protected void drdSourceFlows_SelectedIndexChanged(object sender, EventArgs e)
        {
            clsD.flowsGridView(grdFlows, Convert.ToString(drdSourceFlows.SelectedValue), Convert.ToString(drdTargetFlows.SelectedValue));
        }

        protected void drdTargetFlows_SelectedIndexChanged(object sender, EventArgs e)
        {
            clsD.flowsGridView(grdFlows, Convert.ToString(drdSourceFlows.SelectedValue), Convert.ToString(drdTargetFlows.SelectedValue));
        }

        protected void btnLoggOut_Click(object sender, EventArgs e)
        {

        }

        protected void grdDataSet_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grdDataSet.PageIndex = e.NewPageIndex;
            clsD.datasetGridView(grdDataSet);
        }

        protected void grdProcessList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void grdStocks_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            string param = "stocks.time in (" + hdnYear.Value + ")";
            grdStocks.PageIndex = e.NewPageIndex;
            clsD.stocksGridView(grdStocks, Convert.ToString(drdStocks.SelectedValue), param);
        }

        protected void grdFlows_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grdFlows.PageIndex = e.NewPageIndex;
            clsD.flowsGridView(grdFlows, Convert.ToString(drdSourceFlows.SelectedValue), Convert.ToString(drdTargetFlows.SelectedValue));
        }

        protected void btnFilter_Click(object sender, EventArgs e)
        {
            string type = rdoProcessType.SelectedValue;

            if (type == "1")
            {

                string param = "stocks.time in (" + hdnSelectedYear.Value + ")";
                string paramss = "stocks.time in (" + hdnSelectedCountry.Value + ")";

                clsD.stocksGridView(grdStocks, Convert.ToString(drdStocks.SelectedValue), param);
            }

            else if (type == "2")
            {
                drdSourceFlows.Enabled = true;
                drdTargetFlows.Enabled = true;
                drdStocks.Enabled = false;
            }
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {

            //string type = rdoProcessType.SelectedValue;
            //DataSet ds = new DataSet();
            //if (type == "1")
            //{
            //    string param = "";
            //    if (hdnSelectedYear.Value != "")
            //    {
            //        param = "stocks.time in (" + hdnSelectedYear.Value + ")";
            //    }

            //    string paramss = "stocks.time in (" + hdnSelectedCountry.Value + ")";

            //    ds = clsD.stocksDataSet(Convert.ToString(drdStocks.SelectedValue), param);
            //}

            //else if (type == "2")
            //{
            //    drdSourceFlows.Enabled = true;
            //    drdTargetFlows.Enabled = true;
            //    drdStocks.Enabled = false;
            //}


            ////exportToExcel(ds);

            //using (XLWorkbook wb = new XLWorkbook())
            //{
            //    foreach (System.Data.DataTable dt in ds.Tables)
            //    {
            //        wb.Worksheets.Add(dt);
            //    }

            //    //Export the Excel file.
            //    Response.Clear();
            //    Response.Buffer = true;
            //    Response.Charset = "";
            //    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            //    Response.AddHeader("content-disposition", "attachment;filename=DataSet.xlsx");
            //    using (MemoryStream MyMemoryStream = new MemoryStream())
            //    {
            //        wb.SaveAs(MyMemoryStream);
            //        MyMemoryStream.WriteTo(Response.OutputStream);
            //        Response.Flush();
            //        Response.End();
            //    }
            //}
        }

    }
}

<|start_filename|>IEDC_webapp/cls/JqGridView.cs<|end_filename|>
namespace IEF_Database.cls
{
    public abstract class JqGridView
    {
        private readonly int _total;
        private readonly int _page;

        protected JqGridView(int total, int page)
        {
            _total = total;
            _page = page;
        }

        public int Total
        {
            get { return _total; }
        }

        public int Page
        {
            get { return _page; }
        }

        public abstract string ToJson();

        protected string SurrondWithQuote(string data)
        {
            return "'" + data + "'";
        }

        protected string SurrondWithQuote(int data)
        {
            return "'" + data + "'";
        }
    }
}

<|start_filename|>IEDC_webapp/css/body.css<|end_filename|>
﻿ body {
            margin-left: 10%;
          margin-right: 10%;
          font-size: 13px;
        background-color: #f2f2f2;
}
     
      .jumbotron{
          padding-bottom: 10px;
          padding-top: 10px;
      }
    /* Remove the navbar's default rounded borders and increase the bottom margin */ 
    .navbar {
      border-radius: 0;
      background-color: #215daa;
        border: none;
        color: #215daa;
    }
    
      .navbar ul li{
          color: #215daa;
      }
    /* Remove the jumbotron's default bottom margin */ 
     .jumbotron {
      margin-bottom: 0;
      background-color: #ccdff5;
    }
   
    /* Add a gray background color and some padding to the footer */
    footer {
      background-color: #f2f2f2;
      padding: 15px;
        
    }

    .col-md-9{
        padding-right:10%;
        text-align: justify;
        
    }
    .caption{
        text-align:center;
    }
    /*.row{
        background-color: #ffffff;
    }*/
    .col-md-3{
        background-color: #CCDFF5;
    }
      footer a {
          text-align: left;
      }
      
      .container{
           text-align: justify;
            text-justify: inter-word;
          padding-left: 0px;
          margin-right: 10%;
          margin-left:0px;
         
          
      }
      .navbar-custom {
    background-color:#229922;
    color:#ffffff;
    border-radius:0;
}

.navbar-custom .navbar-nav > li > a {
    color:#fff;
    font-size: 12px;
    text-transform: uppercase;

}

.navbar-custom .navbar-nav > .active > a {
    color: #ffffff;
    background-color: #33aa33;
}

.navbar-custom .navbar-nav > li > a:hover,
.navbar-custom .navbar-nav > li > a:focus,
.navbar-custom .navbar-nav > .active > a:hover,
.navbar-custom .navbar-nav > .active > a:focus,
.navbar-custom .navbar-nav > .open >a {
    text-decoration: none;
    background-color: #33aa33;
}

.navbar-custom .navbar-brand {
    color:#eeeeee;
}
.navbar-custom .navbar-toggle {
    background-color:#eeeeee;
}
.navbar-custom .icon-bar {
    background-color:#33aa33;
}

<|start_filename|>IEDC_webapp/cls/clsDataHandling.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;

namespace IEF_Database.cls
{

    public class clsDataHandling
    {
        dbConnect cn = new dbConnect();

        //string time = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt");
        string time = DateTime.Now.Year + "." + DateTime.Now.Month + "." + DateTime.Now.Day +
               " " + DateTime.Now.Hour + (":") + DateTime.Now.Minute + (":") + DateTime.Now.Second;

      

        public string createJobID(string user_name)
        {
            string job_id = "";
            string query = "select max(id)+1 as id from data_master";


            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    job_id = user_name + Convert.ToString(reader["id"]);
                }

                reader.Close();
                cn.close_connection();
            }

            return job_id;
        }

        public string DataSetName(string dataset_id)
        {
            string dataset_name = "";
            string query = "select distinct dataset_name from iedc.datasets where id = " + dataset_id + "";


            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    dataset_name = Convert.ToString(reader["dataset_name"]);
                }

                reader.Close();
                cn.close_connection();
            }

            return dataset_name;
        }

        


        public void datasetGridView(GridView gv)
        {
            //string query = "select * from sankey.dataset";
            string query = "SELECT System_ID SI, System_definition SD, Dataset_name DN, Reference_date RD, ";
            query += "Most_recent_update MRU, Corresponding_author_info CAI, Other_author_info OAI, ";
            query += "Document_reference DR, region R, Time_period_of_analysis TPA, Indicator_element IE  ";
            query += "FROM sankey.dataset";
             
            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);
                gv.DataSource = ds;
                gv.DataBind();

                cn.close_connection();
            }
        }

        public DataTable DataSet()
        {
            DataTable table = new DataTable();
            string query = "SELECT System_ID SI, System_definition SD, Dataset_name DN, Reference_date RD, ";
            query += "Most_recent_update MRU, Corresponding_author_info CAI, Other_author_info OAI, ";
            query += "Document_reference DR, region R, Time_period_of_analysis TPA, Indicator_element IE  ";
            query += "FROM sankey.dataset";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }



        public void processListGridView(GridView gv, string datasetId)
        {
            string query = "select * from sankey.process_list where system_id = "+ datasetId + "";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);
                gv.DataSource = ds;
                gv.DataBind();

                cn.close_connection();
            }
        }
        public DataTable stocksDataTable(string stock_id, string selectedYear, string selectedCountry)
        {
            DataTable table = new DataTable();
            string filter = "";

            string[] modifiedSelectedCountry = selectedCountry.Split(',');
            string mselectedCountry= "'" + string.Join("','", modifiedSelectedCountry) + "'";

            if (selectedYear == "" && selectedCountry=="")
            {
                filter = " ";
            }
            else if(selectedYear == "" && selectedCountry != "")
            {
                filter = "and countries.country_name in (" + mselectedCountry + ") ";
            }
            else if (selectedYear != "" && selectedCountry == "")
            {
                filter = "and stocks.year in(" + selectedYear + ") ";
            }
            else
            {
                filter = "and stocks.year in(" + selectedYear + ") and countries.country_name in (" + mselectedCountry + ") ";
            }

            string query = "select stocks.system_id SI, stocks.stock_dataset_number SDN, stocks.process_id PID, proc.process_name PN, stocks.country_iso_code CIC, ";
            query += "countries.country_name C, stocks.year T, stocks.age_cohort AC, stocks.indicator_element IE,  stocks.aspect_of_dataset AD, stocks.value V, ";
            query += "stocks.error_type ET, stocks.error_value_1 EV1, stocks.error_value_2 EV2, stocks.data_quality DQ, stocks.unit_id UID, stocks.comment CM  ";
            query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
            query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
            query += "where stocks.process_id = " + stock_id + " " + filter + " ";

            //string query = "select stocks.system_id SI, stocks.stock_dataset_number SDN ";
            //query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
            //query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
            //query += "where stocks.process_id = 12 limit 5 ";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }

        public DataTable flowsDataTable(string source_flow_id, string target_flow_id, string selectedYear, string selectedCountry)
        {
            DataTable table = new DataTable();

            if (target_flow_id == null || target_flow_id == "")
                target_flow_id = "0";
            if (source_flow_id == null || source_flow_id == "")
                source_flow_id = "0";

            string filter = "";

            string[] modifiedSelectedCountry = selectedCountry.Split(',');
            string mselectedCountry = "'" + string.Join("','", modifiedSelectedCountry) + "'";
            string mselectedCountryISO = "";
            string query = "select c.ISO_code as ISO_code from sankey.countries c where c.country_name in ("+ mselectedCountry + ") ";
            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataReader reader = cmd.ExecuteReader();
                int counter = 0;
                while (reader.Read())
                {
                    if (counter == 0)
                        mselectedCountryISO += Convert.ToString(reader["ISO_code"]);
                    else
                        mselectedCountryISO += "," + Convert.ToString(reader["ISO_code"]);

                    counter++;
                    //countries.Add(Convert.ToString(reader["ISO"]));
                    //countries.Add(Convert.ToString(reader["COUNTRY"]));
                    //countries.Add(new string[2] { Convert.ToString(reader["ISO"]), Convert.ToString(reader["COUNTRY"]) });
                }
                while (reader.Read())
                {
                    
                }

                reader.Close();
                cn.close_connection();
            }


            if (selectedYear == "" && mselectedCountryISO == "")
            {
                filter = " ";
            }
            else if (selectedYear == "" && mselectedCountryISO != "")
            {
                filter = "and (f.region_source in (" + mselectedCountryISO + ") or f.region_target in (" + mselectedCountryISO + "))";
            }
            else if (selectedYear != "" && mselectedCountryISO == "")
            {
                filter = "and f.year in(" + selectedYear + ") ";
            }
            else
            {
                filter = "and f.year in(" + selectedYear + ") and (f.region_source in (" + mselectedCountryISO + ") or f.region_target in (" + mselectedCountryISO + ")) ";
            }

            //string query = "select distinct f.system_id SI, f.flow_dataset_number FDN, f.process_id_source PIDS, p.process_name PNS, f.process_id_target PIDT, p.process_name PNT, ";
            //query += "f.region_source CICS, c.country_name CS, f.region_target CICT, c.country_name CT, f.year T, f.age_cohort AC, f.material IE, f.value V, ";
            //query += "f.error_type ET, f.error_value_1 EV1, f.error_value_2 EV2, f.data_quality DQ, f.unit UID, f.comment CM  ";
            //query += "from sankey.flows f inner join sankey.process_list p on f.process_id_source = p.process_id inner join sankey.countries c ";
            //query += "on f.region_source = c.ISO_code where f.process_id_source = " + source_flow_id + " and f.process_id_target = " + target_flow_id + " ";
            //query += " order by f.flow_dataset_number ";

            string query2 = "SELECT distinct f.system_id SI, f.flow_dataset_number FDN, f.process_id_source PIDS, (select p.process_name from sankey.process_list p where p.process_id = "+ source_flow_id + ") as PNS, ";
            query2 += "f.process_id_target PIDT, (select p.process_name from sankey.process_list p where p.process_id = " + target_flow_id + ") as PNT, f.region_source CICS, c.country_name CS, f.region_target CICT, ";
            query2 += "c.country_name CT, f.year T, f.age_cohort AC, f.material IE, f.value V, f.error_type ET, f.error_value_1 EV1, f.error_value_2 EV2, f.data_quality DQ, f.unit UID, f.comment CM ";
            query2 += "FROM sankey.flows f inner join sankey.countries c on (f.region_source = c.ISO_code or f.region_target = c.ISO_code) ";
            query2 += "where f.process_id_source = " + source_flow_id + " and f.process_id_target = " + target_flow_id + " "+ filter + " ";

           

  



            //string query = "select stocks.system_id SI, stocks.stock_dataset_number SDN ";
            //query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
            //query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
            //query += "where stocks.process_id = 12 limit 5 ";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query2, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query2, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }

        public DataTable flowCycleDataTable(string selectedYear, string selectedCountry)
        {
            DataTable table = new DataTable();
            string filter = "";

            //string[] modifiedSelectedCountry = selectedCountry.Split(',');
            //string mselectedCountry = "'" + string.Join("','", modifiedSelectedCountry) + "'";
            //string mselectedCountryISO = "";
            //string query = "select GROUP_CONCAT(c.ISO_code) as ISO_code from sankey.countries c where c.country_name in (" + mselectedCountry + ") ";
            //if (cn.open_connection() == true)
            //{
            //    MySqlCommand cmd = new MySqlCommand(query, cn.connection);
            //    MySqlDataReader reader = cmd.ExecuteReader();
            //    while (reader.Read())
            //    {
            //        mselectedCountryISO = Convert.ToString(reader["ISO_code"]);
            //    }

            //    reader.Close();
            //    cn.close_connection();
            //}


            if (selectedYear == "" && selectedCountry == "")
            {
                filter = " ";
            }
            else if (selectedYear == "" && selectedCountry != "")
            {
                filter = "where (f.region_source in (" + selectedCountry + ") or f.region_target in (" + selectedCountry + "))";
            }
            else if (selectedYear != "" && selectedCountry == "")
            {
                filter = "where f.year in(" + selectedYear + ") ";
            }
            else
            {
                filter = "where f.year in(" + selectedYear + ") and (f.region_source in (" + selectedCountry + ") or f.region_target in (" + selectedCountry + ")) ";
            }

            string query2 = "SELECT distinct f.system_id SI, f.flow_dataset_number FDN, f.process_id_source PIDS, (select p.process_name from sankey.process_list p where p.process_id = PIDS) as PNS, ";
            query2 += "f.process_id_target PIDT, (select p.process_name from sankey.process_list p where p.process_id = PIDT) as PNT, f.region_source CICS, c.country_name CS, f.region_target CICT, ";
            query2 += "c.country_name CT, f.year T, f.age_cohort AC, f.material IE, f.value V, f.error_type ET, f.error_value_1 EV1, f.error_value_2 EV2, f.data_quality DQ, f.unit UID, f.comment CM ";
            query2 += "FROM sankey.flows f inner join sankey.countries c on(f.region_source = c.ISO_code or f.region_target = c.ISO_code) ";
            query2 += "  " + filter + " ";







            //string query = "select stocks.system_id SI, stocks.stock_dataset_number SDN ";
            //query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
            //query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
            //query += "where stocks.process_id = 12 limit 5 ";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query2, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query2, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }

        public DataTable stockProcessList(string datasetId)
        {
            DataTable table = new DataTable();
            string query = "select distinct p.process_id, p.process_name from sankey.process_list p inner join sankey.stocks s where p.process_id=s.process_id and p.system_id = " + datasetId + "";

            //string query = "select stocks.system_id SI, stocks.stock_dataset_number SDN ";
            //query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
            //query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
            //query += "where stocks.process_id = 12 limit 5 ";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }
        
        public DataTable sourceFLowList(string datasetId)
        {
            DataTable table = new DataTable();
            //string query = "select process_id, process_name from sankey.process_list where system_id = " + datasetId + "";
             ;
            string query = "select distinct p.process_id, p.process_name from sankey.process_list p inner join sankey.flows f ";
            query += "where p.process_id = f.process_id_source and p.system_id = " + datasetId + "";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }
        public DataTable targetFLowList(string datasetId, string source_flow)
        {
            DataTable table = new DataTable();

            string query = "select distinct p.process_id, p.process_name from sankey.flows f, sankey.process_list p ";
            query += "where p.process_id = f.process_id_target and process_id_source = " + source_flow + " and p.system_id = " + datasetId + "";


            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }
        public void processListDropDown(DropDownList dp, string datasetId)
        {
            string query = "select * from sankey.process_list where system_id = " + datasetId + "";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);

                dp.DataSource = ds;
                dp.DataTextField = "process_name";
                dp.DataValueField = "process_id";
                dp.DataBind();

                cn.close_connection();
            }
        }

        public void stocksGridView(GridView gv, string processId, string param)
        {
            //string query = "select * from sankey.stocks where process_id = " + processId + "";
                                                 
            string query = "select stocks.system_id SI, stocks.stock_dataset_number SDN, proc.process_name PN, ";
            query += "countries.country_name C, stocks.year T, stocks.indicator_element IE, ";
            query += "stocks.aspect_of_dataset AD, stocks.value V, stocks.unit_id UID  ";
            query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
            query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
            query += "where stocks.process_id = " + processId + " and " + param + "";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);
                gv.DataSource = ds;
                gv.DataBind();

                cn.close_connection();
            }
        }


        public DataSet stocksDataSet(string processId, string param)
        {
            //string query = "select * from sankey.stocks where process_id = " + processId + "";
            string query = "";
            if (param == "")
            {
                query = "select stocks.system_id SI, stocks.stock_dataset_number SDN, proc.process_name PN, ";
                query += "countries.country_name C, stocks.year T, stocks.indicator_element IE, ";
                query += "stocks.aspect_of_dataset AD, stocks.value V, stocks.unit_id UID  ";
                query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
                query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
                query += "where stocks.process_id = " + processId + "";
            }
            else
            {
                query = "select stocks.system_id SI, stocks.stock_dataset_number SDN, proc.process_name PN, ";
                query += "countries.country_name C, stocks.year T, stocks.indicator_element IE, ";
                query += "stocks.aspect_of_dataset AD, stocks.value V, stocks.unit_id UID  ";
                query += "from sankey.stocks stocks  inner join sankey.process_list proc ";
                query += "on stocks.process_id = proc.process_id inner join sankey.countries on stocks.country_iso_code = countries.ISO_code ";
                query += "where stocks.process_id = " + processId + " and " + param + "";
            }

            DataSet ds = new DataSet();
           

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);
           
                adapter.Fill(ds);

                cn.close_connection();
            }

            return ds;
        }

        public void flowsGridView(GridView gv, string processSourceId, string processTargetId)
        {
            string query = "select * from sankey.flows_base where process_id_origin = " + processSourceId + " and process_id_destination = " + processTargetId + " ";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);
                gv.DataSource = ds;
                gv.DataBind();

                cn.close_connection();
            }
        }

        public void getYear(HiddenField hdn)
        {
            string query = "select distinct stocks.year YEAR ";
            query += "from sankey.stocks stocks ";
            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataReader reader = cmd.ExecuteReader();
                string years = "";
                int counter = 0;
                while (reader.Read())
                {
                    if (counter == 0)
                        years += Convert.ToString(reader["YEAR"]);
                    else
                        years += "|||" + Convert.ToString(reader["YEAR"]);

                    counter++;
                    //countries.Add(Convert.ToString(reader["ISO"]));
                    //countries.Add(Convert.ToString(reader["COUNTRY"]));
                    //countries.Add(new string[2] { Convert.ToString(reader["ISO"]), Convert.ToString(reader["COUNTRY"]) });
                }
                hdn.Value =years;

                reader.Close();
                cn.close_connection();
            }
        }


        public DataTable CycleYear(string datasetId)
        {
            DataTable table = new DataTable();

            string query = "select distinct f.year as year, f.year as year from sankey.flows f where f.system_id= "+ datasetId + "";


            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }

        public DataTable CycleCountry(string datasetId, string selected_year)
        {
            DataTable table = new DataTable();

            string query = "select distinct c.ISO_code ISO, c.country_name COUNTRY from sankey.flows f, sankey.countries c ";
            query += "where (f.region_source = c.ISO_code or f.region_target = c.ISO_code) and f.year = " + selected_year + " and f.system_id = " + datasetId + "";


            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            return table;
        }

        public void getCountry(HiddenField hdn)
        {
            //string query = "select GROUP_CONCAT(distinct countries.country_name) COUNTRY ";
            //query += "from sankey.stocks stocks ";
            //query += "inner join sankey.process_list proc on stocks.process_id = proc.process_id inner join sankey.countries countries on stocks.country_iso_code= countries.ISO_code ";
            //query += "where stocks.process_id = 12 ";
            
                                                                
            string query = "select distinct c.ISO_code ISO, c.country_name COUNTRY from sankey.countries c inner ";
            query += "join sankey.stocks s on c.ISO_code = s.country_iso_code ";
            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataReader reader = cmd.ExecuteReader();

                //List<string[]> countries = new List<string[]>();
                //ArrayList countries = new ArrayList();
                string countries = "";
                while (reader.Read())
                {
                    countries += Convert.ToString(reader["ISO"]) + "::" + Convert.ToString(reader["COUNTRY"]) + "|||";
                    //countries.Add(Convert.ToString(reader["ISO"]));
                    //countries.Add(Convert.ToString(reader["COUNTRY"]));
                    //countries.Add(new string[2] { Convert.ToString(reader["ISO"]), Convert.ToString(reader["COUNTRY"]) });
                }

                hdn.Value = countries;

                reader.Close();
                cn.close_connection();
            }
        }
        public DataTable getData()
        {
            //string connection_string = cn.connection_string;
            //string query = "select Id, UnitCode, UnitName from unit ;";
            //SqlDataAdapter adapter = new SqlDataAdapter(query, cn.sqlCn);
            //DataTable dt = new DataTable();
            //adapter.Fill(dt);
            DataTable dt = new DataTable();
            dt.Columns.Add("id", typeof(int));
            dt.Columns.Add("UnitCode", typeof(string));
            dt.Columns.Add("UnitName", typeof(string));

            // Here we add five DataRows.
            dt.Rows.Add(1, "kg", "David");
            dt.Rows.Add(2, "m", "Sam");
            dt.Rows.Add(3, "cm", "Christoff");
            dt.Rows.Add(4, "km", "Janet");
            dt.Rows.Add(5, "p", "Melanie");

            return dt;
        }

        public string SetSearchStr(string oper, string fld, string search)
        {
            string str = "";
            switch (oper)
            {
                case "eq":
                    str = fld + "='" + search + "'";
                    break;
                case "ne":
                    str = fld + "<>'" + search + "'";
                    break;
                case "bw":
                    str = fld + " like '" + search + "%'";
                    break;
                case "bn":
                    str = fld + " NOT like '" + search + "%'";
                    break;
                case "ew":
                    str = fld + " like '%" + search + "'";
                    break;
                case "en":
                    str = fld + " NOT like '%" + search + "'";
                    break;
                case "cn":
                    str = fld + " like '%" + search + "%'";
                    break;
                case "nc":
                    str = fld + " NOT like '%" + search + "%'";
                    break;
                default:
                    str = "";
                    break;
            }
            return str;
        }


        public void showClassificationGrid(GridView gv)
        {
            string query = "SELECT * FROM iedc.classification_definition";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);
                gv.DataSource = ds;
                gv.DataBind();

                cn.close_connection();
            }

        }

        public void showAspectsGrid(GridView gv)
        {
            string query = "SELECT * FROM iedc.aspects";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);
                gv.DataSource = ds;
                gv.DataBind();

                cn.close_connection();
            }

        }

        public void listTables(DropDownList dp)
        {
            string query = "SELECT table_name FROM information_schema.tables where table_schema='iedc';";

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);

                dp.DataSource = ds;
                dp.DataTextField = "table_name";
                dp.DataValueField = "table_name";
                dp.DataBind();

                cn.close_connection();
            }
        }

        public void dataGrid(GridView gv, string query)
        {

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);
                gv.DataSource = ds;
                gv.DataBind();

                cn.close_connection();
            }

        }

        //SELECT id, dataset_name, dataset_version, datagroup_id, data_category, data_type, data_layer, process_scope, process_resolution, product_scope, product_resolution, material_scope,
        //material_resolution, regional_scope, regional_resolution, temporal_scope, temporal_resolution, description, keywords, data_provenance, dataset_size, comment, aspect_1, aspect_1_classification,
        //aspect_2, aspect_2_classification, aspect_3, aspect_3_classification, aspect_4, aspect_4_classification, aspect_5, aspect_5_classification, aspect_6, aspect_6_classification, aspect_7,
        //aspect_7_classification, aspect_8, aspect_8_classification, aspect_9, aspect_9_classification, aspect_10, aspect_10_classification, aspect_11, aspect_11_classification, aspect_12,
        //aspect_12_classification, tupel_notation, semantic_string_example, semantic_string_general, type_of_source, project_license, main_author, dataset_link, dataset_format, project_report,
        //suggested_citation, visible, access_date, submission_date, submitting_user, dataset_conversion_info, review_date, review_user, review_comment, reserve1, reserve2, reserve3, reserve4, reserve5
        // FROM iedc.datasets;

        public DataTable IEDC_DataSet(string selectedItems, string searchText)
        {
            string[] selectedItemsList = new string[6];
            string filter = "";
            string query = "";
            
            if (selectedItems == "")
            {
                selectedItemsList[0] = "dataset_name";
                selectedItemsList[1] = "keywords";
                selectedItemsList[2] = "main_author";
                selectedItemsList[3] = "project_report";
                selectedItemsList[4] = "suggested_citation";
                selectedItemsList[5] = "description";
            }
            else
                selectedItemsList = selectedItems.Split(',');

            if (searchText == "")
            {
                query = "SELECT id, dataset_name DN,  ";
                query += "description DS, keywords KW, ";
                query += "main_author MA, datagroup_id DG, suggested_citation SC  ";
                query += "FROM iedc.datasets";
            }
            else
            {
                for (int i = 0; i < selectedItemsList.Length; i++)
                {
                    //filter += "" + selectedItemsList[i] + " like '%" + searchText + "%' || ";
                    filter += "" + selectedItemsList[i] + " REGEXP '" + searchText + "' || ";
                }
                string mod_filter = filter.Remove(filter.Length - 4);

                query = "SELECT id, dataset_name DN,  ";
                query += "description DS, keywords KW, ";
                query += "main_author MA, datagroup_id DG, suggested_citation SC  ";
                query += "FROM iedc.datasets where " + mod_filter + "";
            }
            DataTable table = new DataTable();          

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }
            //DataTable transposedTable = GenerateTransposedTable(table);
            return table;
        }


        public DataTable IEDC_DataGroupView(string datasetId)
        {
            //string query = "select * from iedc.datasets where id = '" + datasetId + "'";

            //string query = "SELECT distinct dg.* FROM iedc.datagroups dg inner join iedc.datasets ds where ds.datagroup_id=dg.id and ds.id = '" + datasetId + "' ";

            string query = "SELECT distinct dg.id, dg.datagroup_name, dg.datagroup_version, dg.project_id, dg.data_categories, dg.data_types, dg.data_layers, ";
            query += "dg.process_scope, dg.process_resolution, dg.product_scope, dg.product_resolution, dg.material_scope, dg.material_resolution, dg.regional_scope, ";
            query += "dg.regional_resolution, dg.temporal_scope, dg.temporal_resolution, dg.description, dg.keywords, dg.system_definition_picture, dg.comment, st.name as source_name, l.name ";

            query += "as license_name, dg.main_author, dg.project_link, dg.project_report, dg.suggested_citation, dg.submission_date, u.name as submitting_user, dg.reserve1, dg.reserve2, dg.reserve3 ";

            query += "FROM iedc.datagroups dg inner join iedc.datasets ds on dg.id = ds.datagroup_id left join iedc.users u on dg.submitting_user = u.id ";
            query += "left join iedc.source_type st on dg.type_of_source = st.id left join iedc.licences l on dg.project_license = l.id where ds.id = '" + datasetId + "' ";

            DataTable table = new DataTable();

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }
            if ((table == null) || (table.Rows.Count == 0))
            {
                DataRow newBlankRow1 = table.NewRow();
                table.Rows.Add(newBlankRow1);
                return table;
            }
            else
            {
                DataTable transposedTable = GenerateTransposedTable(table);
                return transposedTable;              
            }
               
        }
        public DataTable IEDC_DataSetView(string datasetId)
        {
            //string query = "select * from iedc.datasets where id = '" + datasetId + "'";

            //  string query = "select distinct datasets.id, datasets.dataset_name, datasets.dataset_version, datasets.datagroup_id, categories.name as category, types.name type, layers.name layer, ";
            //query += "datasets.process_scope, datasets.process_resolution, datasets.product_scope, datasets.product_resolution, datasets.material_scope, datasets.material_resolution, ";
            //query += "datasets.regional_scope, datasets.regional_resolution, datasets.temporal_scope, datasets.temporal_resolution, datasets.description, datasets.keywords, provenance.name as provenance, ";
            //query += "datasets.dataset_size, datasets.comment, aspects.aspect as aspect1_name, datasets.aspect_1_classification, datasets.aspect_2, datasets.aspect_2_classification, ";
            //query += "datasets.aspect_3, datasets.aspect_3_classification, datasets.aspect_4, datasets.aspect_4_classification, datasets.aspect_5, datasets.aspect_5_classification, ";
            //query += "datasets.aspect_6, datasets.aspect_6_classification, datasets.aspect_7, datasets.aspect_7_classification, datasets.aspect_8, datasets.aspect_8_classification, ";
            //query += "datasets.aspect_9, datasets.aspect_9_classification,datasets.aspect_10, datasets.aspect_10_classification, datasets.aspect_11, datasets.aspect_11_classification, ";
            //query += "datasets.aspect_12, datasets.aspect_12_classification, datasets.tupel_notation, datasets.semantic_string_example, datasets.semantic_string_general, source_type.name source, ";
            //query += "licences.name license, datasets.main_author, datasets.dataset_link, datasets.dataset_format, datasets.project_report, datasets.suggested_citation, datasets.visible, datasets.access_date, ";
            //query += "datasets.submission_date, users.name as Submitting_User, datasets.dataset_conversion_info, datasets.review_date, users.name as Review_User, datasets.review_comment, ";
            //query += "datasets.reserve1, datasets.reserve2, datasets.reserve3, datasets.reserve4, datasets.reserve5 from datasets inner join categories on datasets.data_category = categories.id ";
            //query += "inner join types on datasets.data_type = types.id inner join layers on datasets.data_layer = layers.id inner join provenance on datasets.data_provenance = provenance.id inner join ";
            //query += "source_type on datasets.type_of_source = source_type.id inner join licences on datasets.project_license = licences.id inner join users on datasets.submitting_user = users.id ";
            //query += "inner join aspects on datasets.aspect_1 = aspects.id ";
            //query += "where datasets.id = '" + datasetId + "'";


            string query = "select distinct d.id, d.dataset_name, d.dataset_version, d.datagroup_id, c.name as category, t.name as type, l.name as layer, d.process_scope, d.process_resolution, ";
            query += "d.product_scope, d.product_resolution, d.material_scope, d.material_resolution, d.regional_scope, d.regional_resolution, d.temporal_scope, d.temporal_resolution, d.description, ";
            query += "d.keywords, p.name as provenance, d.dataset_size, d.comment, a1.aspect as aspect1_name, cd1.classification_name as classification_name1, a2.aspect as aspect2_name, ";
            query += "cd2.classification_name as classification_name2, a3.aspect as aspect3_name, cd3.classification_name as classification_name3, a4.aspect as aspect4_name, ";
            query += "cd4.classification_name as classification_name4, a5.aspect as aspect5_name, cd5.classification_name as classification_name5, a6.aspect as aspect6_name, ";
            query += "cd6.classification_name as classification_name6, a7.aspect as aspect7_name, cd7.classification_name as classification_name7, a8.aspect as aspect8_name, cd8.classification_name ";
            query += "as classification_name8, a9.aspect as aspect9_name, cd9.classification_name as classification_name9, a10.aspect as aspect10_name, cd10.classification_name as classification_name10, ";
            query += "a11.aspect as aspect11_name, cd11.classification_name as classification_name11, a12.aspect as aspect12_name, cd12.classification_name as classification_name12, d.tupel_notation, ";     
            query += "d.semantic_string_example, d.semantic_string_general, st.name source, licences.name license, d.main_author, d.dataset_link, d.dataset_format, d.project_report, d.suggested_citation, ";
            query += "d.visible, d.access_date, d.submission_date, u1.name as Submitting_User, d.dataset_conversion_info, d.review_date, u2.name as Review_User, d.review_comment, d.reserve1, ";
            query += "d.reserve2, d.reserve3, d.reserve4, d.reserve5 from iedc.datasets d left join iedc.categories c on d.data_category = c.id left join iedc.types t on d.data_type = t.id left join ";
            query += "iedc.layers l on d.data_layer = l.id left join iedc.provenance p on d.data_provenance = p.id left join iedc.source_type st on d.type_of_source = st.id left join iedc.licences on ";
            query += "d.project_license = licences.id left join iedc.users u1 on d.submitting_user = u1.id left join iedc.users u2 on d.review_user = u2.id left join iedc.aspects a1 on d.aspect_1 = a1.id ";
            query += "left join iedc.aspects a2 on d.aspect_2 = a2.id left join iedc.aspects a3 on d.aspect_3 = a3.id left join iedc.aspects a4 on d.aspect_4 = a4.id ";
            query += "left join iedc.aspects a5 on d.aspect_5 = a5.id left join iedc.aspects a6 on d.aspect_6 = a6.id left join iedc.aspects a7 on d.aspect_7 = a7.id ";
            query += "left join iedc.aspects a8 on d.aspect_8 = a8.id left join iedc.aspects a9 on d.aspect_9 = a9.id left join iedc.aspects a10 on d.aspect_10 = a10.id ";
            query += "left join iedc.aspects a11 on d.aspect_11 = a11.id left join iedc.aspects a12 on d.aspect_12 = a12.id left join iedc.classification_definition cd1 on d.aspect_1_classification = cd1.id ";
            query += "left join iedc.classification_definition cd2 on d.aspect_2_classification = cd2.id left join iedc.classification_definition cd3 on d.aspect_3_classification = cd3.id ";
            query += "left join iedc.classification_definition cd4 on d.aspect_4_classification = cd4.id left join iedc.classification_definition cd5 on d.aspect_5_classification = cd5.id ";
            query += "left join iedc.classification_definition cd6 on d.aspect_6_classification = cd6.id left join iedc.classification_definition cd7 on d.aspect_7_classification = cd7.id ";
            query += "left join iedc.classification_definition cd8 on d.aspect_8_classification = cd8.id left join iedc.classification_definition cd9 on d.aspect_9_classification = cd9.id ";
            query += "left join iedc.classification_definition cd10 on d.aspect_10_classification = cd10.id left join iedc.classification_definition cd11 on d.aspect_11_classification = cd11.id ";
            query += "left join iedc.classification_definition cd12 on d.aspect_12_classification = cd12.id where d.id = '" + datasetId + "'";


            DataTable table = new DataTable();

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }
            DataTable transposedTable = GenerateTransposedTable(table);
            return transposedTable;
        }
        
        private DataTable GenerateTransposedTable(DataTable inputTable)
        {
            DataTable outputTable = new DataTable();

            // Add columns by looping rows

            // Header row's first column is same as in inputTable
            outputTable.Columns.Add(inputTable.Columns[0].ColumnName.ToString());

            // Header row's second column onwards, 'inputTable's first column taken
            foreach (DataRow inRow in inputTable.Rows)
            {
                string newColName = inRow[0].ToString();
                outputTable.Columns.Add(newColName);
            }

            // Add rows by looping columns        
            for (int rCount = 1; rCount <= inputTable.Columns.Count - 1; rCount++)
            {
                DataRow newRow = outputTable.NewRow();

                // First column is inputTable's Header row's second column
                newRow[0] = inputTable.Columns[rCount].ColumnName.ToString();
                for (int cCount = 0; cCount <= inputTable.Rows.Count - 1; cCount++)
                {
                    string colValue = inputTable.Rows[cCount][rCount].ToString();
                    newRow[cCount + 1] = colValue;
                }
                outputTable.Rows.Add(newRow);
            }

            return outputTable;
        }

        public DataTable IEDC_DataTable(string datasetId)
        {

            //string query = "select * from iedc.data where dataset_id = '" + datasetId + "'";

            ArrayList colNames = AspectNames(datasetId);

            string query = "select d.id, ds.dataset_name, ci1.attribute1_oto as aspect_1, ci2.attribute1_oto as aspect_2, ci3.attribute1_oto as aspect_3, ci4.attribute1_oto as aspect_4, ";
            query += "ci5.attribute1_oto as aspect_5, ci6.attribute1_oto as aspect_6, ci7.attribute1_oto as aspect_7, ci8.attribute1_oto as aspect_8, ci9.attribute1_oto as aspect_9, ci10.attribute1_oto as aspect_10, ";
            query += "ci11.attribute1_oto as aspect_11, ci12.attribute1_oto as aspect_12, d.value, u1.unitcode, u2.unitcode, sa1.name as stats_array_1, d.stats_array_2, d.stats_array_3,";

            query += "d.stats_array_4, d.comment, d.reserve1, d.reserve2, d.reserve3 from iedc.data d ";
            query += "left join iedc.stats_array sa1 on d.stats_array_1 = sa1.id ";
            query += "left join iedc.units u1 on d.unit_nominator = u1.id left join iedc.units u2 on d.unit_denominator = u2.id ";

            query += "left join iedc.classification_items ci1 on d.aspect1 = ci1.id left join iedc.classification_items ci2 on d.aspect2 = ci2.id left join iedc.classification_items ci3 on d.aspect3 = ci3.id ";
            query += "left join iedc.classification_items ci4 on d.aspect4 = ci4.id left join iedc.classification_items ci5 on d.aspect5 = ci5.id left join iedc.classification_items ci6 on d.aspect6 = ci6.id ";
            query += "left join iedc.classification_items ci7 on d.aspect7 = ci7.id left join iedc.classification_items ci8 on d.aspect8 = ci8.id left join iedc.classification_items ci9 on d.aspect9 = ci9.id ";
            query += "left join iedc.classification_items ci10 on d.aspect10 = ci10.id left join iedc.classification_items ci11 on d.aspect11 = ci11.id left join iedc.classification_items ci12 on d.aspect12 = ci12.id ";

            query += " inner join iedc.datasets ds on d.dataset_id = ds.id where d.dataset_id = '" + datasetId + "'";



            DataTable table = new DataTable();

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(table);
                cn.close_connection();
            }

            for (int i = 0; i < colNames.Count; i++)
            {
                table.Columns["aspect_" + (i + 1) + ""].ColumnName = colNames[i].ToString();
            }

            //table.Columns["aspect_1"].ColumnName = colNames[0].ToString();
            //table.Columns["aspect_2"].ColumnName = colNames[1].ToString();
            //table.Columns["aspect_3"].ColumnName = colNames[2].ToString();
            //table.Columns["aspect_4"].ColumnName = colNames[3].ToString();
            //table.Columns["aspect_5"].ColumnName = colNames[4].ToString();
            //table.Columns["aspect_6"].ColumnName = colNames[5].ToString();
            //table.Columns["aspect_7"].ColumnName = colNames[6].ToString();
            //table.Columns["aspect_8"].ColumnName = colNames[7].ToString();
            //table.Columns["aspect_9"].ColumnName = colNames[8].ToString();
            //table.Columns["aspect_10"].ColumnName = colNames[9].ToString();
            //table.Columns["aspect_11"].ColumnName = colNames[10].ToString();
            //table.Columns["aspect_12"].ColumnName = colNames[11].ToString();

            return table;
        }


        public ArrayList AspectNames(string datasetId)
        {

            //string query = "select * from iedc.data where dataset_id = '" + datasetId + "'";

            string query = "SELECT CONCAT('aspect 1 : ', a1.aspect) AS aspect1, CONCAT('aspect 2 : ', a2.aspect) AS aspect2, CONCAT('aspect 3 : ', a3.aspect) AS aspect3, CONCAT('aspect 4 : ', a4.aspect) AS aspect4, ";
            query += "CONCAT('aspect 5 : ', a5.aspect) AS aspect5, CONCAT('aspect 6 : ', a6.aspect) AS aspect6, CONCAT('aspect 7 : ', a7.aspect) AS aspect7, CONCAT('aspect 8 : ', a8.aspect) AS aspect8, ";
            query += "CONCAT('aspect 9 : ', a9.aspect) AS aspect9, CONCAT('aspect 10 : ', a10.aspect) AS aspect10, CONCAT('aspect 11 : ', a11.aspect) AS aspect11, CONCAT('aspect 12 : ', a12.aspect) AS aspect12 ";
            query += "FROM iedc.datasets ds left join iedc.aspects a1 on ds.aspect_1= a1.id left join iedc.aspects a2 on ds.aspect_2= a2.id left join iedc.aspects a3 on ds.aspect_3= a3.id ";
            query += "left join iedc.aspects a4 on ds.aspect_4= a4.id left join iedc.aspects a5 on ds.aspect_5= a5.id left join iedc.aspects a6 on ds.aspect_6= a6.id left join iedc.aspects a7 on ds.aspect_7= a7.id ";
            query += "left join iedc.aspects a8 on ds.aspect_8= a8.id left join iedc.aspects a9 on ds.aspect_9= a9.id left join iedc.aspects a10 on ds.aspect_10= a10.id left join iedc.aspects a11 on ds.aspect_11= a11.id ";
            query += "left join iedc.aspects a12 on ds.aspect_12= a12.id where ds.id = '" + datasetId + "'";

            ArrayList aspectNames = new ArrayList();

            DataTable table = new DataTable();

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    for (int i =0; i<reader.FieldCount;i++)
                    {
                        if (Convert.ToString(reader[i]) == "")
                            aspectNames.Add(Convert.ToString("aspect " + (i+1) + " : "));
                        else
                            aspectNames.Add(Convert.ToString(reader[i]));
                    }                  
                }

                reader.Close();
                cn.close_connection();
            }

            return aspectNames;
        }
        

        public void dropdown(DropDownList dp, string query)
        {

            if (cn.open_connection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, cn.connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(query, cn.connection);

                DataSet ds = new DataSet();
                adapter.Fill(ds);

                dp.DataSource = ds;
                dp.DataTextField = "classification_Name";
                dp.DataValueField = "id";
                dp.DataBind();

                cn.close_connection();
            }
        }
    }
}

<|start_filename|>IEDC_webapp/frmDatabase.aspx.designer.cs<|end_filename|>
﻿//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated. 
// </auto-generated>
//------------------------------------------------------------------------------

namespace IEF_Database {
    
    
    public partial class frmDatabase {
        
        /// <summary>
        /// form1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        
        /// <summary>
        /// drp_stock_process control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drp_stock_process;
        
        /// <summary>
        /// rfv_stock_process control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RequiredFieldValidator rfv_stock_process;
        
        /// <summary>
        /// btnFilter control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnFilter;
        
        /// <summary>
        /// drp_source_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drp_source_flows;
        
        /// <summary>
        /// rfv_drp_source_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RequiredFieldValidator rfv_drp_source_flows;
        
        /// <summary>
        /// drp_target_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drp_target_flows;
        
        /// <summary>
        /// rfv_drp_target_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RequiredFieldValidator rfv_drp_target_flows;
        
        /// <summary>
        /// drpCycleYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drpCycleYear;
        
        /// <summary>
        /// drpCycleCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drpCycleCountry;
        
        /// <summary>
        /// hdnYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnYear;
        
        /// <summary>
        /// hdnCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnCountry;
        
        /// <summary>
        /// stock_hdnSelectedYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField stock_hdnSelectedYear;
        
        /// <summary>
        /// stock_hdnSelectedCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField stock_hdnSelectedCountry;
        
        /// <summary>
        /// flow_hdnSelectedYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField flow_hdnSelectedYear;
        
        /// <summary>
        /// flow_hdnSelectedCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField flow_hdnSelectedCountry;
    }
}


<|start_filename|>IEDC_webapp/frmDatabaseTest.aspx.designer.cs<|end_filename|>
﻿//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated. 
// </auto-generated>
//------------------------------------------------------------------------------

namespace IEF_Database {
    
    
    public partial class frmDatabaseTest {
        
        /// <summary>
        /// form1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        
        /// <summary>
        /// lblUser control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label lblUser;
        
        /// <summary>
        /// btnLogOut control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnLogOut;
        
        /// <summary>
        /// rdoProcessType control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RadioButtonList rdoProcessType;
        
        /// <summary>
        /// drp_stock_process control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drp_stock_process;
        
        /// <summary>
        /// rfv_stock_process control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RequiredFieldValidator rfv_stock_process;
        
        /// <summary>
        /// drp_source_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drp_source_flows;
        
        /// <summary>
        /// rfv_drp_source_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RequiredFieldValidator rfv_drp_source_flows;
        
        /// <summary>
        /// drp_target_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drp_target_flows;
        
        /// <summary>
        /// rfv_drp_target_flows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RequiredFieldValidator rfv_drp_target_flows;
        
        /// <summary>
        /// btnFilter control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnFilter;
        
        /// <summary>
        /// hdnYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnYear;
        
        /// <summary>
        /// hdnCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnCountry;
        
        /// <summary>
        /// hdnSelectedYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnSelectedYear;
        
        /// <summary>
        /// hdnSelectedCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnSelectedCountry;
        
        /// <summary>
        /// btnExport control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnExport;
    }
}


<|start_filename|>IEDC_webapp/aspects.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class aspects : System.Web.UI.Page
    {
        clsDataHandling objDataHandling = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string aspects_query = "select id, aspect, description, dimension, index_letter, index_letter_crib, reserve1, reserve2, reserve3 from iedc.aspects";
                objDataHandling.dataGrid(grdAspect, aspects_query);
                string dimensions_query = "select id, name, description, reserve1, reserve2, reserve3, reserve4, reserve5 from iedc.dimensions";
                objDataHandling.dataGrid(grdDimensions, dimensions_query);

            }

        }
    }
}

<|start_filename|>IEDC_webapp/css/style.css<|end_filename|>
body {
	font-family: Arial, Helvetica, sans-serif;
}

table {
	font-size: 1em;
}

.ui-draggable, .ui-droppable {
	background-position: top;
}
.node rect {
  cursor: move;
  shape-rendering: crispEdges;
}

.node1 rect {
    cursor: default
}

.node text {
  pointer-events: none;
  text-shadow: 1px 1px 2px #fff;
  font-size: 0.8em;
  font-family: sans-serif;
}

#tooltip {
  position: absolute;
  pointer-events: none;
  font-size: 0.7em;
  font-family: sans-serif;
  padding: 3px;
  width: auto;
  height: auto;
  background-color: #F2F2F2;
  -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.4);
  -mox-box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, 0.4);
  box-shadow: 0px 0px 5px rbga(0, 0, 0, 0.4);
  pointer-events: none;
}

.value {
  white-space: pre-line;
  margin: 0;
}


body {font:80% Trebuchet MS, Arial, Helvetica, Sans-Serif;color:#333;line-height:180%;margin:0;padding:0;}

h1, h2, h3, h4, h5{margin: 0 0 15px 0;padding: 0;color: #690;font-weight: normal;}
h1{font-size: 200%;letter-spacing: -2px}
p{margin: 0 0 15px 0;padding: 0;line-height:21px;}
a{color: #690;text-decoration: underline;font-weight: bold;}
a:hover{color: #333;text-decoration: none;font-weight: bold;}
img{border:none;}
pre{margin-top:-16px;display:block;font:12px "Courier New", Courier, monospace;padding:10px;border:1px solid #bae2f0;background:#e3f4f9;width:674px;}	
body {font:80% Trebuchet MS, Arial, Helvetica, Sans-Serif;color:#333;line-height:180%;margin:0;padding:0;}

#container {margin:0 auto;position:relative;text-align:left;width:696px;background:#fff;margin-bottom:2em;
}	

ol {margin:1em 0;padding:0;height:28px;	}
ol li{margin:0 10px 0 0; padding:0;float:left;list-style:none;height:28px;line-height:28px;}
ol li a{float:left;height:28px;line-height:28px;border:1px solid #ccc;background:#DAF3F8;color:#555;padding:0 10px;text-decoration:none;}
ol li.current a{background:#5DC9E1;color:#fff;}
ol li a:focus, .prevBtn a:focus, .nextBtn a:focus{outline:none;}

.graphic, .prevBtn, .nextBtn{margin:0;padding:0;display:block;overflow:hidden;text-indent:-8000px;}

.prevBtn, .nextBtn {display:block;width:30px;height:77px;position:absolute;left:-30px;top:71px;z-index:1000;background:url(../images/btn_prev.gif) no-repeat 0 0;cursor:pointer;}	
.nextBtn{left:696px;}														
.nextBtn {background:url(../images/btn_next.gif) no-repeat 0 0;}	

pre {white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; }

<|start_filename|>IEDC_webapp/cls/ProductJqGridView.cs<|end_filename|>
using System;
using System.Collections.Generic;
using System.Text;

namespace IEF_Database.cls
{
    public class ProductJqGridView : JqGridView
    {
        public IList<Product> Products
        {
            get { return _products; }
            set { _products = value; }
        }

        private IList<Product> _products;
        public ProductJqGridView(int total, int page, IList<Product> products) : base(total, page)
        {
            _products = products;
        }

        public override string ToJson()
        {
            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + SurrondWithQuote(1) + ", ");
            stringBuilder.Append("page: " + SurrondWithQuote(1) + ", ");
            stringBuilder.Append("records: " + SurrondWithQuote(Total) + ", ");
            stringBuilder.Append("  rows : [ ");
            for (int i = 0; i < Products.Count; i++)
            {
                stringBuilder.Append("{");

                stringBuilder.Append("id:" + SurrondWithQuote(i+1) + ", ");
                stringBuilder.Append("cell:[ ");
                stringBuilder.Append(SurrondWithQuote(Products[i].ProductId) + ", ");
                stringBuilder.Append(SurrondWithQuote(Products[i].Name) + ", ");
                stringBuilder.Append(SurrondWithQuote(Products[i].ProductNumber) + ", ");
                stringBuilder.Append(SurrondWithQuote(Products[i].Color) + ", ");
                stringBuilder.Append(SurrondWithQuote(Products[i].Size) + ", ");
                stringBuilder.Append(SurrondWithQuote(Products[i].Style));
                stringBuilder.Append(" ]");
                if (i == Products.Count - 1)
                {
                    stringBuilder.Append(" }");
                }
                else
                {
                    stringBuilder.Append(" },");
                }
            }
            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();
        }
    }
}

<|start_filename|>IEDC_webapp/datatypes.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class datatypes : System.Web.UI.Page
    {
        clsDataHandling objDataHandling = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string categories_query = "select id, name, description, reserve1, reserve2 from iedc.categories";
                objDataHandling.dataGrid(grdCategories, categories_query);
                string types_query = "select id, name, description, reference_data_category, symbol, reserve1, reserve2, reserve3 from iedc.types";
                objDataHandling.dataGrid(grdTypes, types_query);
                string layers_query = "select id, name, description, reserve1, reserve2 from iedc.layers";
                objDataHandling.dataGrid(grdLayers, layers_query);
            }

        }
        
    }
}

<|start_filename|>IEDC_webapp/frmDatabaseHome.aspx.designer.cs<|end_filename|>
﻿//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated. 
// </auto-generated>
//------------------------------------------------------------------------------

namespace IEF_Database {
    
    
    public partial class frmDatabaseHome {
        
        /// <summary>
        /// form1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        
        /// <summary>
        /// lblUser control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label lblUser;
        
        /// <summary>
        /// btnLogOut control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnLogOut;
        
        /// <summary>
        /// grdDataSet control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.GridView grdDataSet;
        
        /// <summary>
        /// grdProcessList control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.GridView grdProcessList;
        
        /// <summary>
        /// rdoProcessType control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.RadioButtonList rdoProcessType;
        
        /// <summary>
        /// drdStocks control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drdStocks;
        
        /// <summary>
        /// drdSourceFlows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drdSourceFlows;
        
        /// <summary>
        /// drdTargetFlows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drdTargetFlows;
        
        /// <summary>
        /// year control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlInputText year;
        
        /// <summary>
        /// lblYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label lblYear;
        
        /// <summary>
        /// country control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlInputText country;
        
        /// <summary>
        /// btnFilter control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnFilter;
        
        /// <summary>
        /// hdnYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnYear;
        
        /// <summary>
        /// hdnCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnCountry;
        
        /// <summary>
        /// hdnSelectedYear control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnSelectedYear;
        
        /// <summary>
        /// hdnSelectedCountry control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnSelectedCountry;
        
        /// <summary>
        /// grdStocks control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.GridView grdStocks;
        
        /// <summary>
        /// btnExport control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnExport;
        
        /// <summary>
        /// grdFlows control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.GridView grdFlows;
    }
}


<|start_filename|>IEDC_webapp/fromTagTest.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class fromTagTest : System.Web.UI.Page
    {
        clsDataHandling objDataHandling = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            objDataHandling.getYear(hdnYear);
            objDataHandling.getCountry(hdnCountry);
        }
    }
}

<|start_filename|>IEDC_webapp/css/GridView.css<|end_filename|>
﻿ .grdContent
        {
            width: 80%;
            border: solid 2px black;
            min-width: 80%;
        }
        .header
        {
            background-color: #646464;
            font-family: Arial;
            color: White;
            border: none 0px transparent;
            height: 25px;
            text-align: center;
            font-size: 16px;
        }
        .rows
        {
            background-color: #fff;
            font-family: Arial;
            font-size: 14px;
            color: #000;
            min-height: 25px;
            text-align: left;
            border: none 0px transparent;
        }
        .rows:hover
        {
            background-color: #ff8000;
            font-family: Arial;
            color: #fff;
            text-align: left;
        }
        .selectedrow
        {
            background-color: #ff8000;
            font-family: Arial;
            color: #fff;
            font-weight: bold;
            text-align: left;
        }
        .mydatagrid a /** FOR THE PAGING ICONS  **/
         {
            background-color: Transparent;
            padding: 5px 5px 5px 5px;
            color: #fff;
            text-decoration: none;
            font-weight: bold;
        }
        .mygrdContent a:hover /** FOR THE PAGING ICONS  HOVER STYLES**/
        {
            background-color: #000;
            color: #fff;
        }
        .mygrdContent span /** FOR THE PAGING ICONS CURRENT PAGE INDICATOR **/
         {
            background-color: #c9c9c9;
            color: #000;
            padding: 5px 5px 5px 5px;
        }
        .pager
        {
            background-color: #646464;
            font-family: Arial;
            color: White;
            height: 30px;
            text-align: left;
        }
        .mygrdContent td
        {
            padding: 5px;
        }
        .mygrdContent th
        {
            padding: 5px;
        }

<|start_filename|>IEDC_webapp/classifications.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class classifications : System.Web.UI.Page
    {
        clsDataHandling objDataHandling = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string classifications_query = "select id, classification_Name, dimension, description, reference, ";
                classifications_query += "meaning_attribute1, meaning_attribute2, meaning_attribute3, meaning_attribute4, meaning_attribute5 ";
                classifications_query += " ";
                classifications_query += " from iedc.classification_definition";
                objDataHandling.dataGrid(grdClassifications, classifications_query);

                string dropClassificaitonsQuery = "SELECT distinct id, classification_Name FROM iedc.classification_definition;";
                objDataHandling.dropdown(drpClassifications, dropClassificaitonsQuery);

            }

        }

        protected void drpClassifications_SelectedIndexChanged(object sender, EventArgs e)
        {
            string id = drpClassifications.SelectedValue;
            string classification_item_query = "select id, classification_id, parent_id, description, reference, attribute1_oto, attribute2_oto, attribute3_oto, attribute4_oto, attribute5_anc ";
            classification_item_query += " from iedc.classification_items where classification_id =" + id + "";
            objDataHandling.dataGrid(grdClassificationItems, classification_item_query);
        }

        protected void grdClassifications_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            string classifications_query = "select id, classification_Name, dimension, description, reference, ";
            classifications_query += "meaning_attribute1, meaning_attribute2, meaning_attribute3, meaning_attribute4, meaning_attribute5 ";
            classifications_query += " ";
            classifications_query += " from iedc.classification_definition";
            grdClassifications.PageIndex = e.NewPageIndex;
            objDataHandling.dataGrid(grdClassifications, classifications_query);
        }

        protected void grdClassificationItems_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            string id = drpClassifications.SelectedValue;
            string classification_item_query = "select id, classification_id, parent_id, description, reference, attribute1_oto, attribute2_oto, attribute3_oto, attribute4_oto, attribute5_anc ";
            classification_item_query += " from iedc.classification_items where classification_id =" + id + "";
            grdClassificationItems.PageIndex = e.NewPageIndex;
            objDataHandling.dataGrid(grdClassificationItems, classification_item_query);
        }
    }
}

<|start_filename|>IEDC_webapp/IEDC_Home.aspx.cs<|end_filename|>
﻿using ClosedXML.Excel;
using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class IEDC_Home : System.Web.UI.Page
    {
        clsDataHandling objDataClass = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {


        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            int download_format = drdDownload.SelectedIndex;
            if (download_format == 1)
            {
                download_as_xls();
            }
        }

        private void download_as_xls()
        {
            string dataset_id = hdnDatasetId.Value;
            DataSet ds = getDataSetExportToExcel(dataset_id);

            string dataset_name = objDataClass.DataSetName(dataset_id) + ".xlsx";
            //exportToExcel(ds);

            using (XLWorkbook wb = new XLWorkbook())
            {

                wb.Worksheets.Add(ds.Tables[0], "Dataset description");
                wb.Worksheets.Add(ds.Tables[1], "Data");
                //foreach (System.Data.DataTable dt in ds.Tables)
                //{
                //    wb.Worksheets.Add(dt, "");
                //    wb.Worksheets.Name = “NewTabName”;
                //}

                //Export the Excel file.
                Response.Clear();
                Response.Buffer = true;
                Response.Charset = "";
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;filename=" + dataset_name + "");
                using (MemoryStream MyMemoryStream = new MemoryStream())
                {
                    wb.SaveAs(MyMemoryStream);
                    MyMemoryStream.WriteTo(Response.OutputStream);
                    Response.Flush();
                    Response.End();
                }
            }
        }

        public DataSet getDataSetExportToExcel(string dataset_id)
        {
            DataSet ds = new DataSet();

            string[] colNamesFlow = { "Source", "Value", "Color", "Flow Style", "Target" };
            string[] colNamesNodes = { "Name", "Color", "Orientation", "Width", "Height", "X_position", "Y_position" };

            //string flow_data = Convert.ToString(input_flow_data.InnerText);
            //string node_data = Convert.ToString(input_node_data.InnerText);

            System.Data.DataTable DataSet = new System.Data.DataTable("Dataset description");
            System.Data.DataTable Data = new System.Data.DataTable("Data");

            //dt_s = sampleData(dt_s);

            DataSet = objDataClass.IEDC_DataSetView(dataset_id);
            Data = objDataClass.IEDC_DataTable(dataset_id);

            ds.Tables.Add(DataSet);
            ds.Tables.Add(Data);

            return ds;
        }

        public System.Data.DataTable parsedData(System.Data.DataTable dt, string node_data, string[] colNames)
        {
            //System.Data.DataTable dt = new System.Data.DataTable(tableName);
            string[] lineData = Regex.Split(node_data, "[\r\n]+");
            string pattern = @"\[([^\]]*)\]";

            for (int i = 0; i < colNames.Length; i++)
            {
                dt.Columns.Add(new DataColumn(colNames[i]));
            }

            for (var f = 0; f < lineData.Length; f++)
            {
                MatchCollection matches = Regex.Matches(lineData[f], pattern);
                var row = dt.Rows.Add();

                for (var c = 0; c < matches.Count; c++)
                {
                    row[colNames[c]] = matches[c].Groups[0].Value.Substring(1, matches[c].Groups[0].Value.Length - 2);

                }
            }

            return dt;
        }
    }
}

<|start_filename|>IEDC_webapp/upload.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class upload : System.Web.UI.Page
    {
        clsDataHandling objDataHandling = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                objDataHandling.listTables(drpTables);
            }
        }

        

        protected void btnCreateTable_Click(object sender, EventArgs e)
        {
            string ExcelContentType = "application/vnd.ms-excel";
            string Excel2010ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            if (FileUpload1.HasFile)
            {
                if (FileUpload1.PostedFile.ContentType == ExcelContentType || FileUpload1.PostedFile.ContentType == Excel2010ContentType)
                {
                    try
                    {
                        //Save file path 
                        string path = string.Concat(Server.MapPath(FileUpload1.FileName));
                        FileUpload1.SaveAs(path);

                        string excelConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", path);

                        // Create Connection to Excel Workbook 
                        using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
                        {
                            OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);

                            connection.Open();
                            OleDbDataAdapter da = new OleDbDataAdapter(command);

                            DataTable dt = new DataTable();
                            da.Fill(dt);

                            dbConnect cn = new dbConnect();

                            string database_name = "iedc";
                            string table_name = database_name + "." + txt_table.Text;
                            string Columns = "";
                            if (cn.open_connection() == true)
                            {
                                MySqlCommand cmd;
                                string[] columnNames = dt.Columns.Cast<DataColumn>()
                                 .Select(x => x.ColumnName)
                                 .ToArray();
                                foreach (DataRow row in dt.Rows)
                                {
                                    if (row[0].ToString().ToLower() == "id")
                                        Columns += row[0] + " " + row[2] + " " + row[3] + " AUTO_INCREMENT" + "," + "\r\n";
                                    else
                                        Columns += row[0] + " " + row[2] + " " + row[3] + "," + "\r\n";
                                    //cmd = new MySqlCommand(query, cn.connection);
                                    //cmd.ExecuteNonQuery();
                                    
                                }
                                string query = "CREATE TABLE " + table_name  + " (" + "\r\n" + Columns + "\r\n"+ "PRIMARY KEY (id)" + "\r\n"+ ");";
                                cmd = new MySqlCommand(query, cn.connection);
                                cmd.ExecuteNonQuery();

                                cn.close_connection();
                            }

                        }
                        File.Delete(path);
                    }

                    catch (Exception ex)
                    {
                        //Label1.Text = ex.Message;
                        
                    }
                }


            }


            
        }

        protected void btnDataUpload_Click(object sender, EventArgs e)
        {
            //fileUploader();
            string ExcelContentType = "application/vnd.ms-excel";
            string Excel2010ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            if (flUpload.HasFile)
            {
                if (flUpload.PostedFile.ContentType == ExcelContentType || flUpload.PostedFile.ContentType == Excel2010ContentType)
                {
                    try
                    {
                        //Save file path 
                        string path = string.Concat(Server.MapPath(flUpload.FileName));
                        flUpload.SaveAs(path);

                        //For Office Excel 2010   http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/0f03c2de-3ee2-475f-b6a2-f4efb97de302/#ae1e6748-297d-4c6e-8f1e-8108f438e62e 
                        string excelConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", path);

                        // Create Connection to Excel Workbook 
                        using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
                        {
                            OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);

                            connection.Open();
                            OleDbDataAdapter da = new OleDbDataAdapter(command);

                            DataTable dt = new DataTable();
                            da.Fill(dt);

                            dbConnect cn = new dbConnect();

                            string database_name = "iedc";
                            string table_name = database_name + "." + drpTables.SelectedValue.ToString();

                            if (cn.open_connection() == true)
                            {
                                MySqlCommand cmd, cmd1,cmd2;
                                string[] columnNames = dt.Columns.Cast<DataColumn>()
                                 .Select(x => x.ColumnName)
                                 .ToArray();
                                string columns = string.Join(", ", columnNames);
                                
                                //string query1 = "delete from " + table_name + "";
                                //string query2 = "ALTER TABLE " + table_name + " AUTO_INCREMENT = 1";
                                //cmd1 = new MySqlCommand(query1, cn.connection);
                                //cmd2 = new MySqlCommand(query2, cn.connection);
                                //cmd1.ExecuteNonQuery();
                                //cmd2.ExecuteNonQuery();
                                foreach (DataRow row in dt.Rows)
                                {
                                    string rows = "";
                                    foreach (DataColumn col in dt.Columns)
                                    {
                                        if (col.ToString().ToLower() != "id")
                                        {
                                            if (row[col].ToString().ToLower() == "true" || row[col].ToString().ToLower() == "false")
                                                rows += row[col] + ", ";
                                            else
                                            {

                                                if (row[col].ToString().Contains("'"))
                                                {
                                                    string formatedRow = row[col].ToString().Replace("'", "\\'");
                                                    rows += "'" + formatedRow + "'" + ", ";
                                                }
                                                else
                                                    rows += "'" + row[col] + "'" + ", ";
                                            }

                                        }

                                    }

                                    string query = "Insert INTO " + table_name + " (" + columns + ") values (" + "default, " + rows.Remove(rows.Length - 2) + ")";
                                    cmd = new MySqlCommand(query, cn.connection);
                                    cmd.ExecuteNonQuery();

                                }
                                cn.close_connection();
                            }

                        }
                    }

                    catch (Exception ex)
                    {
                        //Label1.Text = ex.Message;
                    }
                }


            }
        }

        public void fileUploader()
        {
            string[] Individal_Runs = Directory.GetFiles(@"C:\files");
            foreach (string s in Individal_Runs)
            {
                try
                {
                    //Save file path 
                    string path = string.Concat(Server.MapPath("aspects_data.xlsx"));
                    flUpload.SaveAs(path);

                    //For Office Excel 2010   http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/0f03c2de-3ee2-475f-b6a2-f4efb97de302/#ae1e6748-297d-4c6e-8f1e-8108f438e62e 
                    string excelConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", path);

                    // Create Connection to Excel Workbook 
                    using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
                    {
                        OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);

                        connection.Open();
                        OleDbDataAdapter da = new OleDbDataAdapter(command);

                        DataTable dt = new DataTable();
                        da.Fill(dt);

                        dbConnect cn = new dbConnect();

                        string database_name = "iedc";
                        string table_name = database_name + "." + drpTables.SelectedValue.ToString();
                        //classification_definition
                        //aspects
                        //string query = "Insert INTO "+ table_name + " (id,aspect,description,dimension,index_letter,index_letter_crib,reserve1,reserve2,reserve3) values (" + row[0] + ",'" + row[1] + "','" + row[2] + "','" + row[3] + "','" + row[4] + "','" + row[5] + "','" + row[6] + "','" + row[7] + "','" + row[8] + "')";


                        if (cn.open_connection() == true)
                        {
                            MySqlCommand cmd;
                            string[] columnNames = dt.Columns.Cast<DataColumn>()
                             .Select(x => x.ColumnName)
                             .ToArray();
                            string columns = string.Join(", ", columnNames);

                            foreach (DataRow row in dt.Rows)
                            {
                                string rows = "";
                                foreach (DataColumn col in dt.Columns)
                                {
                                    if (col.ToString().ToLower() != "id")
                                    {
                                        if (row[col].ToString().ToLower() == "true" || row[col].ToString().ToLower() == "false")
                                            rows += row[col] + ", ";
                                        else
                                        {

                                            if (row[col].ToString().Contains("'"))
                                            {
                                                string formatedRow = row[col].ToString().Replace("'", "\\'");
                                                rows += "'" + formatedRow + "'" + ", ";
                                            }
                                            else
                                                rows += "'" + row[col] + "'" + ", ";
                                        }

                                    }

                                }

                                string query = "Insert INTO " + table_name + " (" + columns + ") values (" + "default, " + rows.Remove(rows.Length - 2) + ")";
                                cmd = new MySqlCommand(query, cn.connection);
                                cmd.ExecuteNonQuery();

                            }
                            cn.close_connection();
                        }

                    }


                }
                catch (NullReferenceException ex)
                {
                    Console.Out.WriteLine("No run");
                }
            }
        }
    }
}

<|start_filename|>IEDC_webapp/provenance.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class provenance : System.Web.UI.Page
    {
        clsDataHandling objDataHandling = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string provenance_query = "select id, name, description, reserve1, reserve2 from iedc.provenance";
                objDataHandling.dataGrid(grdProvenance, provenance_query);
                string sources_query = "select id, name, description, reserve1, reserve2 from iedc.source_type";
                objDataHandling.dataGrid(grdSources, sources_query);
                string licences_query = "select id, name, description, link, reserve1, reserve2 from iedc.licences";
                objDataHandling.dataGrid(grdLicences, licences_query);
            }

        }
    }
}

<|start_filename|>IEDC_webapp/DataService.svc.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;

namespace IEF_Database
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class DataService
    {
        // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
        // To create an operation that returns XML,
        //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
        //     and include the following line in the operation body:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";


        [OperationContract]
        [WebInvoke(Method = "POST",
            BodyStyle = WebMessageBodyStyle.WrappedRequest,
            ResponseFormat = WebMessageFormat.Json
            )]
        public string GetProducts()
        {
            //JavaScriptSerializer json = new JavaScriptSerializer();
            IList<Product> personList = ProductRepository.GetProducts();
            int total = 1, page = 10;
            ProductJqGridView productJqGridView = new ProductJqGridView(total, page, personList);
            return productJqGridView.ToJson();
        }



        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string DataSet(string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1)
        {
            clsDataHandling objDataClass = new clsDataHandling();

            DataTable dt = null;

            dt = objDataClass.DataSet();
            int page = page1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());

            string sidx = sortIndex1;// HttpContext.Current.Request.QueryString["sidx"].ToString();
            string sord = sord1;// HttpContext.Current.Request.QueryString["sord"].ToString();
            int totalRows = totalrows1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString());


            string searchField = searchField1;// HttpContext.Current.Request.QueryString["SEARCHFIELD"];
            string searchString = searchString1;// HttpContext.Current.Request.QueryString["SEARCHSTRING"];
            string searchOper = searchOper1;// HttpContext.Current.Request.QueryString["SEARCHOPER"];
            if (page == 0) page = 1;
            string result = "";
            if (String.IsNullOrEmpty(sidx)) sidx = "1";
            int count;
            result = dt.Rows.Count.ToString();
            count = dt.Rows.Count;
            int totalpages;
            Int32 limit = 0;
            if (pageSize1 == "All")
            {
                limit = Convert.ToInt32(result);
            }
            else
            {
                limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString());
            }


            double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit);
            if (int.Parse(result) > 0) totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi));
            else
                totalpages = 0;

            if (Convert.ToInt32(page) > totalpages) page = totalpages;
            int start = limit * page - limit;
            if (start < 0) start = 0;

            string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString);
            string strSort = sidx + " " + sord;
            DataRow[] dr = dt.Select(strFilter, strSort);
            DataTable dtNew;

            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + totalpages + ", ");
            stringBuilder.Append("page: " + page + ", ");
            stringBuilder.Append("records: " + count + ", ");
            stringBuilder.Append("  rows : [ ");
            if (dr.Length > 0)
            {
                dtNew = dr.CopyToDataTable<DataRow>();
                for (int i = start; i < dt.Rows.Count; i++)
                {
                    if (i < dtNew.Rows.Count)
                    {
                        stringBuilder.Append("{");

                        stringBuilder.Append("id:" + i + ", ");
                        stringBuilder.Append("cell:[ ");

                        stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][2] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][3] + "'" + ",");

                        stringBuilder.Append("'" + dtNew.Rows[i][4] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][5] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][6] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][7] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][8] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][9] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][10] + "'" + "");


                        stringBuilder.Append(" ]");
                        if (i == dt.Rows.Count - 1)
                        {
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(" },");
                        }
                    }
                }
            }

            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();

        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string stockProcessList(string system_id)
        {
            clsDataHandling objDataClass = new clsDataHandling();
            DataTable dt = objDataClass.stockProcessList(system_id);
            StringBuilder str = new StringBuilder();

            str.Append("[");
            str.Append("{");
            str.Append("\"code\":\"0\" ,");
            str.Append("\"name\":\"--Select--\"");
            str.Append("},");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str.Append("{");
                str.Append("\"code\":\"" + dt.Rows[i]["process_id"].ToString() + "\" ,");
                str.Append("\"name\":\"" + dt.Rows[i]["process_name"].ToString() + "\" ");
                str.Append("},");
            }
            str = str.Remove(str.Length - 1, 1);
            str.Append("]");
            return str.ToString();
        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string sourceFLowList(string system_id)
        {
            clsDataHandling objDataClass = new clsDataHandling();
            DataTable dt = objDataClass.sourceFLowList(system_id);
            StringBuilder str = new StringBuilder();

            str.Append("[");
            str.Append("{");
            str.Append("\"code\":\"0\" ,");
            str.Append("\"name\":\"--Select--\"");
            str.Append("},");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str.Append("{");
                str.Append("\"code\":\"" + dt.Rows[i]["process_id"].ToString() + "\" ,");
                str.Append("\"name\":\"" + dt.Rows[i]["process_name"].ToString() + "\" ");
                str.Append("},");
            }
            str = str.Remove(str.Length - 1, 1);
            str.Append("]");
            return str.ToString();
        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string targetFLowList(string system_id, string source_flow)
        {
            clsDataHandling objDataClass = new clsDataHandling();
            DataTable dt = objDataClass.targetFLowList(system_id, source_flow);
            StringBuilder str = new StringBuilder();

            str.Append("[");
            str.Append("{");
            str.Append("\"code\":\"0\" ,");
            str.Append("\"name\":\"--Select--\"");
            str.Append("},");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str.Append("{");
                str.Append("\"code\":\"" + dt.Rows[i]["process_id"].ToString() + "\" ,");
                str.Append("\"name\":\"" + dt.Rows[i]["process_name"].ToString() + "\" ");
                str.Append("},");
            }
            str = str.Remove(str.Length - 1, 1);
            str.Append("]");
            return str.ToString();
        }
        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string Stocks(string stock_id, string selectedYear, string selectedCountry, string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1)
        {
            clsDataHandling objDataClass = new clsDataHandling();

            DataTable dt = null;

            dt = objDataClass.stocksDataTable(stock_id, selectedYear, selectedCountry);
            int page = page1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());

            string sidx = sortIndex1;// HttpContext.Current.Request.QueryString["sidx"].ToString();
            string sord = sord1;// HttpContext.Current.Request.QueryString["sord"].ToString();
            int totalRows = totalrows1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString());


            string searchField = searchField1;// HttpContext.Current.Request.QueryString["SEARCHFIELD"];
            string searchString = searchString1;// HttpContext.Current.Request.QueryString["SEARCHSTRING"];
            string searchOper = searchOper1;// HttpContext.Current.Request.QueryString["SEARCHOPER"];
            if (page == 0) page = 1;
            string result = "";
            if (String.IsNullOrEmpty(sidx)) sidx = "1";
            int count;
            result = dt.Rows.Count.ToString();
            count = dt.Rows.Count;
            int totalpages;
            Int32 limit = 0;
            if (pageSize1 == "All")
            {
                limit = Convert.ToInt32(result);
            }
            else
            {
                limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString());
            }


            double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit);
            if (int.Parse(result) > 0) totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi));
            else
                totalpages = 0;

            if (Convert.ToInt32(page) > totalpages) page = totalpages;
            int start = limit * page - limit;
            if (start < 0) start = 0;

            string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString);
            string strSort = sidx + " " + sord;
            DataRow[] dr = dt.Select(strFilter, strSort);
            DataTable dtNew;

            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + totalpages + ", ");
            stringBuilder.Append("page: " + page + ", ");
            stringBuilder.Append("records: " + count + ", ");
            stringBuilder.Append("  rows : [ ");
            if (dr.Length > 0)
            {
                dtNew = dr.CopyToDataTable<DataRow>();
                for (int i = start; i < dt.Rows.Count; i++)
                {
                    if (i < dtNew.Rows.Count)
                    {
                        stringBuilder.Append("{");

                        stringBuilder.Append("id:" + i + ", ");
                        stringBuilder.Append("cell:[ ");

                        stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][2] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][3] + "'" + ",");

                        stringBuilder.Append("'" + dtNew.Rows[i][4] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][5] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][6] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][7] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][8] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][9] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][10] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][11] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][12] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][13] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][14] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][15] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][16] + "'" + "");


                        stringBuilder.Append(" ]");
                        if (i == dt.Rows.Count - 1)
                        {
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(" },");
                        }
                    }
                }
            }

            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();

        }
        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string Flows(string source_flow_id, string target_flow_id, string selectedYear, string selectedCountry, string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1)
        {
            clsDataHandling objDataClass = new clsDataHandling();

            DataTable dt = null;

            dt = objDataClass.flowsDataTable(source_flow_id, target_flow_id, selectedYear, selectedCountry);
            int page = page1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());

            string sidx = sortIndex1;// HttpContext.Current.Request.QueryString["sidx"].ToString();
            string sord = sord1;// HttpContext.Current.Request.QueryString["sord"].ToString();
            int totalRows = totalrows1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString());


            string searchField = searchField1;// HttpContext.Current.Request.QueryString["SEARCHFIELD"];
            string searchString = searchString1;// HttpContext.Current.Request.QueryString["SEARCHSTRING"];
            string searchOper = searchOper1;// HttpContext.Current.Request.QueryString["SEARCHOPER"];
            if (page == 0) page = 1;
            string result = "";
            if (String.IsNullOrEmpty(sidx)) sidx = "1";
            int count;
            result = dt.Rows.Count.ToString();
            count = dt.Rows.Count;
            int totalpages;
            Int32 limit = 0;
            if (pageSize1 == "All")
            {
                limit = Convert.ToInt32(result);
            }
            else
            {
                limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString());
            }


            double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit);
            if (int.Parse(result) > 0) totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi));
            else
                totalpages = 0;

            if (Convert.ToInt32(page) > totalpages) page = totalpages;
            int start = limit * page - limit;
            if (start < 0) start = 0;

            string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString);
            string strSort = sidx + " " + sord;
            DataRow[] dr = dt.Select(strFilter, strSort);
            DataTable dtNew;

            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + totalpages + ", ");
            stringBuilder.Append("page: " + page + ", ");
            stringBuilder.Append("records: " + count + ", ");
            stringBuilder.Append("  rows : [ ");
            if (dr.Length > 0)
            {
                dtNew = dr.CopyToDataTable<DataRow>();
                for (int i = start; i < dt.Rows.Count; i++)
                {
                    if (i < dtNew.Rows.Count)
                    {
                        stringBuilder.Append("{");

                        stringBuilder.Append("id:" + i + ", ");
                        stringBuilder.Append("cell:[ ");

                        stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][2] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][3] + "'" + ",");

                        stringBuilder.Append("'" + dtNew.Rows[i][4] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][5] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][6] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][7] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][8] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][9] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][10] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][11] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][12] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][13] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][14] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][15] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][16] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][17] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][18] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][19] + "'" + "");


                        stringBuilder.Append(" ]");
                        if (i == dt.Rows.Count - 1)
                        {
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(" },");
                        }
                    }
                }
            }

            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();

        }



        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string CycleYear(string system_id)
        {
            clsDataHandling objDataClass = new clsDataHandling();
            DataTable dt = objDataClass.CycleYear(system_id);
            StringBuilder str = new StringBuilder();

            str.Append("[");
            str.Append("{");
            str.Append("\"code\":\"0\" ,");
            str.Append("\"name\":\"--Select--\"");
            str.Append("},");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str.Append("{");
                str.Append("\"code\":\"" + dt.Rows[i]["year"].ToString() + "\" ,");
                str.Append("\"name\":\"" + dt.Rows[i]["year"].ToString() + "\" ");
                str.Append("},");
            }
            str = str.Remove(str.Length - 1, 1);
            str.Append("]");
            return str.ToString();
        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string CycleCountry(string system_id, string selected_year)
        {
            clsDataHandling objDataClass = new clsDataHandling();
            DataTable dt = objDataClass.CycleCountry(system_id, selected_year);
            StringBuilder str = new StringBuilder();

            str.Append("[");
            str.Append("{");
            str.Append("\"code\":\"0\" ,");
            str.Append("\"name\":\"--Select--\"");
            str.Append("},");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str.Append("{");
                str.Append("\"code\":\"" + dt.Rows[i]["ISO"].ToString() + "\" ,");
                str.Append("\"name\":\"" + dt.Rows[i]["COUNTRY"].ToString() + "\" ");
                str.Append("},");
            }
            str = str.Remove(str.Length - 1, 1);
            str.Append("]");
            return str.ToString();
        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string FlowCycle(string selectedYear, string selectedCountry, string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1)
        {
            clsDataHandling objDataClass = new clsDataHandling();

            DataTable dt = null;

            dt = objDataClass.flowCycleDataTable(selectedYear, selectedCountry);
            int page = page1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());

            string sidx = sortIndex1;// HttpContext.Current.Request.QueryString["sidx"].ToString();
            string sord = sord1;// HttpContext.Current.Request.QueryString["sord"].ToString();
            int totalRows = totalrows1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString());


            string searchField = searchField1;// HttpContext.Current.Request.QueryString["SEARCHFIELD"];
            string searchString = searchString1;// HttpContext.Current.Request.QueryString["SEARCHSTRING"];
            string searchOper = searchOper1;// HttpContext.Current.Request.QueryString["SEARCHOPER"];
            if (page == 0) page = 1;
            string result = "";
            if (String.IsNullOrEmpty(sidx)) sidx = "1";
            int count;
            result = dt.Rows.Count.ToString();
            count = dt.Rows.Count;
            int totalpages;
            Int32 limit = 0;
            if (pageSize1 == "All")
            {
                limit = Convert.ToInt32(result);
            }
            else
            {
                limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString());
            }


            double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit);
            if (int.Parse(result) > 0) totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi));
            else
                totalpages = 0;

            if (Convert.ToInt32(page) > totalpages) page = totalpages;
            int start = limit * page - limit;
            if (start < 0) start = 0;

            string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString);
            string strSort = sidx + " " + sord;
            DataRow[] dr = dt.Select(strFilter, strSort);
            DataTable dtNew;

            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + totalpages + ", ");
            stringBuilder.Append("page: " + page + ", ");
            stringBuilder.Append("records: " + count + ", ");
            stringBuilder.Append("  rows : [ ");
            if (dr.Length > 0)
            {
                dtNew = dr.CopyToDataTable<DataRow>();
                for (int i = start; i < dt.Rows.Count; i++)
                {
                    if (i < dtNew.Rows.Count)
                    {
                        stringBuilder.Append("{");

                        stringBuilder.Append("id:" + i + ", ");
                        stringBuilder.Append("cell:[ ");

                        stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][2] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][3] + "'" + ",");

                        stringBuilder.Append("'" + dtNew.Rows[i][4] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][5] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][6] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][7] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][8] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][9] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][10] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][11] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][12] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][13] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][14] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][15] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][16] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][17] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][18] + "'" + ",");
                        stringBuilder.Append("'" + dtNew.Rows[i][19] + "'" + "");


                        stringBuilder.Append(" ]");
                        if (i == dt.Rows.Count - 1)
                        {
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(" },");
                        }
                    }
                }
            }

            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();

        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string IEDC_DataSet(string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1, string selectedItems, string searchText)
        {
            clsDataHandling objDataClass = new clsDataHandling();

            DataTable dt = null;

            dt = objDataClass.IEDC_DataSet(selectedItems, searchText);
            int page = page1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());

            string sidx = sortIndex1;// HttpContext.Current.Request.QueryString["sidx"].ToString();
            string sord = sord1;// HttpContext.Current.Request.QueryString["sord"].ToString();
            int totalRows = totalrows1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString());


            string searchField = searchField1;// HttpContext.Current.Request.QueryString["SEARCHFIELD"];
            string searchString = searchString1;// HttpContext.Current.Request.QueryString["SEARCHSTRING"];
            string searchOper = searchOper1;// HttpContext.Current.Request.QueryString["SEARCHOPER"];
            if (page == 0) page = 1;
            string result = "";
            if (String.IsNullOrEmpty(sidx)) sidx = "1";
            int count;
            result = dt.Rows.Count.ToString();
            count = dt.Rows.Count;
            int totalpages;
            Int32 limit = 0;
            if (pageSize1 == "All")
            {
                limit = Convert.ToInt32(result);
            }
            else
            {
                limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString());
            }


            double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit);
            if (int.Parse(result) > 0) totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi));
            else
                totalpages = 0;

            if (Convert.ToInt32(page) > totalpages) page = totalpages;
            int start = limit * page - limit;
            if (start < 0) start = 0;

            string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString);
            string strSort = sidx + " " + sord;
            DataRow[] dr = dt.Select(strFilter, strSort);
            DataTable dtNew;

            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + totalpages + ", ");
            stringBuilder.Append("page: " + page + ", ");
            stringBuilder.Append("records: " + count + ", ");
            stringBuilder.Append("  rows : [ ");
            if (dr.Length > 0)
            {
                dtNew = dr.CopyToDataTable<DataRow>();
                for (int i = start; i < dt.Rows.Count; i++)
                {
                    if (i < dtNew.Rows.Count)
                    {
                        stringBuilder.Append("{");

                        stringBuilder.Append("id:" + i + ", ");
                        stringBuilder.Append("cell:[ ");
                        stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ",");
                        if (dtNew.Rows[i][1].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][1].ToString().Replace("'", "\\'") + "'" + ",");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + ",");

                        if (dtNew.Rows[i][2].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][2].ToString().Replace("'", "\\'") + "'" + ",");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][2] + "'" + ",");

                        if (dtNew.Rows[i][3].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][3].ToString().Replace("'", "\\'") + "'" + ",");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][3] + "'" + ",");

                        if (dtNew.Rows[i][4].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][4].ToString().Replace("'", "\\'") + "'" + ",");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][4] + "'" + ",");
                        if (dtNew.Rows[i][5].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][5].ToString().Replace("'", "\\'") + "'" + ",");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][5] + "'" + ",");

                        if (dtNew.Rows[i][6].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][6].ToString().Replace("'", "\\'") + "'" + "");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][6] + "'" + "");

                      



                        stringBuilder.Append(" ]");
                        if (i == dt.Rows.Count - 1)
                        {
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(" },");
                        }
                    }
                }
            }

            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();

        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string IEDC_DataSetView(string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1, string datasetId)
        {
            clsDataHandling objDataClass = new clsDataHandling();

            DataTable dt = null;

            dt = objDataClass.IEDC_DataSetView(datasetId);
            int page = page1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());

            string sidx = sortIndex1;// HttpContext.Current.Request.QueryString["sidx"].ToString();
            string sord = sord1;// HttpContext.Current.Request.QueryString["sord"].ToString();
            int totalRows = totalrows1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString());


            string searchField = searchField1;// HttpContext.Current.Request.QueryString["SEARCHFIELD"];
            string searchString = searchString1;// HttpContext.Current.Request.QueryString["SEARCHSTRING"];
            string searchOper = searchOper1;// HttpContext.Current.Request.QueryString["SEARCHOPER"];
            if (page == 0) page = 1;
            string result = "";
            if (String.IsNullOrEmpty(sidx)) sidx = "1";
            int count;
            result = dt.Rows.Count.ToString();
            count = dt.Rows.Count;
            int totalpages;
            Int32 limit = 0;
            if (pageSize1 == "All")
            {
                limit = Convert.ToInt32(result);
            }
            else
            {
                limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString());
            }


            double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit);
            if (int.Parse(result) > 0) totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi));
            else
                totalpages = 0;

            if (Convert.ToInt32(page) > totalpages) page = totalpages;
            int start = limit * page - limit;
            if (start < 0) start = 0;

            string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString);
            string strSort = sidx + " " + sord;
            DataRow[] dr = dt.Select(strFilter, "");
            DataTable dtNew;

            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + totalpages + ", ");
            stringBuilder.Append("page: " + page + ", ");
            stringBuilder.Append("records: " + count + ", ");
            stringBuilder.Append("  rows : [ ");
            if (dr.Length > 0)
            {
                dtNew = dr.CopyToDataTable<DataRow>();
                for (int i = start; i < dt.Rows.Count; i++)
                {
                    if (i < dtNew.Rows.Count)
                    {
                        stringBuilder.Append("{");

                        stringBuilder.Append("id:" + i + ", ");
                        stringBuilder.Append("cell:[ ");

                        if (dtNew.Rows[i][0].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][0].ToString().Replace("'", "\\'") + "'" + ",");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ",");

                        if (dtNew.Rows[i][1].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][1].ToString().Replace("'", "\\'") + "'" + "");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + "");



                        stringBuilder.Append(" ]");
                        if (i == dt.Rows.Count - 1)
                        {
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(" },");
                        }
                    }
                }
            }

            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();

        }

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
        public string IEDC_DataGroupView(string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1, string datasetId)
        {
            clsDataHandling objDataClass = new clsDataHandling();

            DataTable dt = null;

            dt = objDataClass.IEDC_DataGroupView(datasetId);
            int page = page1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString());

            string sidx = sortIndex1;// HttpContext.Current.Request.QueryString["sidx"].ToString();
            string sord = sord1;// HttpContext.Current.Request.QueryString["sord"].ToString();
            int totalRows = totalrows1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString());


            string searchField = searchField1;// HttpContext.Current.Request.QueryString["SEARCHFIELD"];
            string searchString = searchString1;// HttpContext.Current.Request.QueryString["SEARCHSTRING"];
            string searchOper = searchOper1;// HttpContext.Current.Request.QueryString["SEARCHOPER"];
            if (page == 0) page = 1;
            string result = "";
            if (String.IsNullOrEmpty(sidx)) sidx = "1";
            int count;
            result = dt.Rows.Count.ToString();
            count = dt.Rows.Count;
            int totalpages;
            Int32 limit = 0;
            if (pageSize1 == "All")
            {
                limit = Convert.ToInt32(result);
            }
            else
            {
                limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString());
            }


            double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit);
            if (int.Parse(result) > 0) totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi));
            else
                totalpages = 0;

            if (Convert.ToInt32(page) > totalpages) page = totalpages;
            int start = limit * page - limit;
            if (start < 0) start = 0;

            string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString);
            string strSort = sidx + " " + sord;
            DataRow[] dr = dt.Select(strFilter, "");
            DataTable dtNew;

            StringBuilder stringBuilder = new StringBuilder("{");
            stringBuilder.Append("total: " + totalpages + ", ");
            stringBuilder.Append("page: " + page + ", ");
            stringBuilder.Append("records: " + count + ", ");
            stringBuilder.Append("  rows : [ ");
            if (dr.Length > 0)
            {
                dtNew = dr.CopyToDataTable<DataRow>();
                for (int i = start; i < dt.Rows.Count; i++)
                {
                    if (i < dtNew.Rows.Count)
                    {
                        stringBuilder.Append("{");

                        stringBuilder.Append("id:" + i + ", ");
                        stringBuilder.Append("cell:[ ");

                        if (dtNew.Rows[i][0].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][0].ToString().Replace("'", "\\'") + "'" + ",");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ",");

                        if (dtNew.Rows[i][1].ToString().Contains("'"))

                            stringBuilder.Append("'" + dtNew.Rows[i][1].ToString().Replace("'", "\\'") + "'" + "");

                        else
                            stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + "");



                        stringBuilder.Append(" ]");
                        if (i == dt.Rows.Count - 1)
                        {
                            stringBuilder.Append(" }");
                        }
                        else
                        {
                            stringBuilder.Append(" },");
                        }
                    }
                }
            }

            stringBuilder.Append(" ]");
            stringBuilder.Append(" }");
            return stringBuilder.ToString();

        }
        
    }
}


<|start_filename|>IEDC_webapp/uncertainty.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class uncertainty : System.Web.UI.Page
    {
        clsDataHandling objDataHandling = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string stats_array_query = "select id, name, description, loc, scale, shape from iedc.stats_array";
                objDataHandling.dataGrid(grdStatsArray, stats_array_query);
                
            }

        }
    }
}

<|start_filename|>IEDC_webapp/css/styleAng.css<|end_filename|>
﻿.sort-true {
  padding-right: 14px;
  background: no-repeat right center url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAICAYAAAAvOAWIAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAAX0lEQVQoU32NQQrAMAgEBa+CvfX5PYa+pn/oR2w2xLIQibAgOqMSEYe73wh6oVp2Ztb6PhAWEszd5OTJAQknRJ73Hpz4bMZ1RFXfAgQ3ahEIxsUf3AklWAlbkIWrev0BT3ZAxrSn1UcAAAAASUVORK5CYII=')
  /*../Icons/Icon-down-white.png*/
}
.sort-false {
  padding-right: 14px;
  background: no-repeat right center url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAICAYAAAAvOAWIAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAAXklEQVQoU2NgwAT8QKH5QAyi8QKQgvNA/B9K49SArBCkGKcGbAqxasBQyMzM/AhqMoYGmBvBEvz8/Cv///8vDqIxNPDw8CyHCUIVCoCCAKhBAFkDWB1MEFkhLLzQ5QBl6UDG/jPuNgAAAABJRU5ErkJggg==')
  /*../Icons/Icon-up-white.png*/
}
.NoData td.NoData {
  text-align: center;
}
.even {
  background-color: #aaa
}
.odd {
  background-color: #fff;
}
.icon {
  max-height: 20px;
  max-width: 20px;
}
.SelectedRow {
  background-color: #888;
}

<|start_filename|>IEDC_webapp/cls/dbConnect.cs<|end_filename|>
﻿using MySql.Data.MySqlClient;
using System;
using System.Diagnostics;
using System.IO;


namespace IEF_Database.cls
{
    public class dbConnect
    {
        public MySqlConnection connection;
        public string server;
        public string database;
        public string uid;
        public string password;

        //Constructor
        public dbConnect()
        {
            Initialize();
        }

        //Initialize values
        public void Initialize()
        {
            server = "localhost";
            database = "iedc";
            uid = "";
            password = "";
            string connectionString;
            connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

            connection = new MySqlConnection(connectionString);
        }


        //open connection to database
        public bool open_connection()
        {
            try
            {
                connection.Open();
                return true;
            }
            catch (MySqlException ex)
            {
                //When handling errors, you can your application's response based on the error number.
                //The two most common error numbers when connecting are as follows:
                //0: Cannot connect to server.
                //1045: Invalid user name and/or password.
                switch (ex.Number)
                {
                    case 0:
                        //MessageBox.Show("Cannot connect to server.  Contact administrator");
                        break;

                    case 1045:
                        //MessageBox.Show("Invalid username/password, please try again");
                        break;
                }
                return false;
            }
        }

        //Close connection
        public bool close_connection()
        {
            try
            {
                connection.Close();
                return true;
            }
            catch (MySqlException ex)
            {
                //MessageBox.Show(ex.Message);
                return false;
            }
        }

        //Backup
        public void Backup()
        {
            try
            {
                DateTime Time = DateTime.Now;
                int year = Time.Year;
                int month = Time.Month;
                int day = Time.Day;
                int hour = Time.Hour;
                int minute = Time.Minute;
                int second = Time.Second;
                int millisecond = Time.Millisecond;

                //Save file to C:\ with the current date as a filename
                string path;
                path = "C:\\" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql";
                StreamWriter file = new StreamWriter(path);


                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName = "mysqldump";
                psi.RedirectStandardInput = false;
                psi.RedirectStandardOutput = true;
                psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}", uid, password, server, database);
                psi.UseShellExecute = false;

                Process process = Process.Start(psi);

                string output;
                output = process.StandardOutput.ReadToEnd();
                file.WriteLine(output);
                process.WaitForExit();
                file.Close();
                process.Close();
            }
            catch (IOException ex)
            {
                //MessageBox.Show("Error , unable to backup!");
            }
        }

        //Restore
        public void Restore()
        {
            try
            {
                //Read file from C:\
                string path;
                path = "C:\\MySqlBackup.sql";
                StreamReader file = new StreamReader(path);
                string input = file.ReadToEnd();
                file.Close();


                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName = "mysql";
                psi.RedirectStandardInput = true;
                psi.RedirectStandardOutput = false;
                psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}", uid, password, server, database);
                psi.UseShellExecute = false;


                Process process = Process.Start(psi);
                process.StandardInput.WriteLine(input);
                process.StandardInput.Close();
                process.WaitForExit();
                process.Close();
            }
            catch (IOException ex)
            {
                //MessageBox.Show("Error , unable to Restore!");
            }
        }
    }
}


<|start_filename|>IEDC_webapp/cls/ProductRepository.cs<|end_filename|>
using System.Collections.Generic;
namespace IEF_Database.cls
{
    public class ProductRepository
    {


        public static IList<Product> GetProducts()
        {
            IList<Product> products = new List<Product>
                                          {
                                              new Product(1, "Coke", "Abc100","Red","s","Fasion"),
                                              new Product(2, "Pepsi", "Abc200","blue","xl","B"),
                                             
                                          };
            return products;
        }
    }
}

<|start_filename|>IEDC_webapp/IEDC_Home.aspx.designer.cs<|end_filename|>
﻿//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated. 
// </auto-generated>
//------------------------------------------------------------------------------

namespace IEF_Database {
    
    
    public partial class IEDC_Home {
        
        /// <summary>
        /// form1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        
        /// <summary>
        /// txtSearch1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.TextBox txtSearch1;
        
        /// <summary>
        /// txtSearch2 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.TextBox txtSearch2;
        
        /// <summary>
        /// txtSearch3 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.TextBox txtSearch3;
        
        /// <summary>
        /// cbDatasets control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.CheckBoxList cbDatasets;
        
        /// <summary>
        /// drdDownload control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drdDownload;
        
        /// <summary>
        /// btnSave control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnSave;
        
        /// <summary>
        /// hdnDatasetId control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HiddenField hdnDatasetId;
    }
}


<|start_filename|>IEDC_webapp/classifications.aspx.designer.cs<|end_filename|>
﻿//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated. 
// </auto-generated>
//------------------------------------------------------------------------------

namespace IEF_Database {
    
    
    public partial class classifications {
        
        /// <summary>
        /// form1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        
        /// <summary>
        /// scriptmanager1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.ScriptManager scriptmanager1;
        
        /// <summary>
        /// updatepnl control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.UpdatePanel updatepnl;
        
        /// <summary>
        /// grdClassifications control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.GridView grdClassifications;
        
        /// <summary>
        /// drpClassifications control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.DropDownList drpClassifications;
        
        /// <summary>
        /// grdClassificationItems control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.GridView grdClassificationItems;
    }
}


<|start_filename|>IEDC_webapp/frmDatabase.aspx.cs<|end_filename|>
﻿using IEF_Database.cls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IEF_Database
{
    public partial class frmDatabase : System.Web.UI.Page
    {
        clsDataHandling clsD = new clsDataHandling();
        protected void Page_Load(object sender, EventArgs e)
        {


            if (!Page.IsPostBack)
            {
                //clsD.datasetDropDown(drdDataSet);
                clsD.getYear(hdnYear);
                clsD.getCountry(hdnCountry);
                //clsD.datasetGridView(grdDataSet);

            }

        }

        protected void btnDatasetGridSelect_Click(object sender, EventArgs e)
        {
            //rdoProcessType.Enabled = true;
            //System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)sender;
            //GridViewRow gvr = (GridViewRow)btn.NamingContainer;
            //string datasetId = gvr.Cells[1].Text;
            ////clsD.processListGridView(grdProcessList, datasetId);

            //clsD.processListDropDown(drdStocks, datasetId);
            //clsD.processListDropDown(drdSourceFlows, datasetId);
            //clsD.processListDropDown(drdTargetFlows, datasetId);
        }

        protected void btnProcessListGridSelect_Click(object sender, EventArgs e)
        {
            System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)sender;
            GridViewRow gvr = (GridViewRow)btn.NamingContainer;
            string processId = gvr.Cells[2].Text;

            bindGrid(processId);


            //clsD.processListGridView(grdProcessList, datasetId);
        }

        protected void bindGrid(string processId)
        {
            //string type = rdoProcessType.SelectedValue;

            //if (type == "1")
            //{
            //    //clsD.stocksGridView(grdStocks, processId);
            //}

            //else if (type == "2")
            //{
            //    //clsD.flowsGridView(grdFlows, processId);
            //}
        }

        protected void rdoProcessType_SelectedIndexChanged(object sender, EventArgs e)
        {
            //string type = rdoProcessType.SelectedValue;

            //if (type == "1")
            //{
            //    drdStocks.Enabled = true;
            //    drdSourceFlows.Enabled = false;
            //    drdTargetFlows.Enabled = false;
            //}

            //else if (type == "2")
            //{
            //    drdSourceFlows.Enabled = true;
            //    drdTargetFlows.Enabled = true;
            //    drdStocks.Enabled = false;
            //}
        }

        protected void drdStocks_SelectedIndexChanged(object sender, EventArgs e)
        {
            //string param = "stocks.time in (" + hdnYear.Value + ")";
            //clsD.stocksGridView(grdStocks, Convert.ToString(drdStocks.SelectedValue), param);
        }

        protected void drdSourceFlows_SelectedIndexChanged(object sender, EventArgs e)
        {
            //clsD.flowsGridView(grdFlows, Convert.ToString(drdSourceFlows.SelectedValue), Convert.ToString(drdTargetFlows.SelectedValue));
        }

        protected void drdTargetFlows_SelectedIndexChanged(object sender, EventArgs e)
        {
            //clsD.flowsGridView(grdFlows, Convert.ToString(drdSourceFlows.SelectedValue), Convert.ToString(drdTargetFlows.SelectedValue));
        }

        protected void btnLoggOut_Click(object sender, EventArgs e)
        {

        }

        protected void grdDataSet_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //grdDataSet.PageIndex = e.NewPageIndex;
            //clsD.datasetGridView(grdDataSet);
        }

        protected void grdProcessList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void grdStocks_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //string param = "stocks.time in (" + hdnYear.Value + ")";
            //grdStocks.PageIndex = e.NewPageIndex;
            //clsD.stocksGridView(grdStocks, Convert.ToString(drdStocks.SelectedValue), param);
        }

        protected void grdFlows_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //grdFlows.PageIndex = e.NewPageIndex;
            //clsD.flowsGridView(grdFlows, Convert.ToString(drdSourceFlows.SelectedValue), Convert.ToString(drdTargetFlows.SelectedValue));
        }

        protected void btnFilter_Click(object sender, EventArgs e)
        {
            //string type = rdoProcessType.SelectedValue;

            //if (type == "1")
            //{

            //    string param = "stocks.time in (" + hdnSelectedYear.Value + ")";
            //    string paramss = "stocks.time in (" + hdnSelectedCountry.Value + ")";

            //    //clsD.stocksGridView(grdStocks, Convert.ToString(drdStocks.SelectedValue), param);
            //}

            //else if (type == "2")
            //{
            //    drdSourceFlows.Enabled = true;
            //    drdTargetFlows.Enabled = true;
            //    drdStocks.Enabled = false;
            //}
        }

     

    }
}

<|start_filename|>IEDC_webapp/cls/Product.cs<|end_filename|>
namespace IEF_Database.cls
{
    public class Product
    {
        public Product()
        {
        }

        private int productId;
        private string name;
        private string productNumber;
        private string color;
        private string size;
        private string style;


        public virtual int ProductId
        {
            get { return productId; }
            set { productId = value; }
        }

        public virtual string Name
        {
            get { return name; }
            set { name = value; }
        }

        public virtual string ProductNumber
        {
            get { return productNumber; }
            set { productNumber = value; }
        }

        public virtual string Color
        {
            get { return color; }
            set { color = value; }
        }

        public virtual string Size
        {
            get { return size; }
            set { size = value; }
        }

        public virtual string Style
        {
            get { return style; }
            set { style = value; }
        }

        public Product(int productId, string name, string productNumber, string color, string size, string style)
        {
            this.productId = productId;
            this.name = name;
            this.productNumber = productNumber;
            this.color = color;
            this.size = size;
            this.style = style;
        }
    }
}

<|start_filename|>IEDC_webapp/css/inputTags.css<|end_filename|>
* {
  box-sizing: border-box;
}
.color {
  color: #19BC9C !important;
}

div.inputTags-list {
  display: inline-block;
  width: 100%;
  padding: 6px;
  border: 1px solid rgba(25, 188, 156, 0.35);
  background-color: #f9f9f9;
  box-shadow: 1px 2px 2px rgba(221, 221, 221, 0.2);
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  -moz-background-clip: padding;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}
div.inputTags-list span.inputTags-item {
  position: relative;
  display: inline-block;
  margin: 2px;
  padding: 3px 22px 4px 8px;
  background-color: #19BC9C;
  text-align: center;
  color: #fff;
  opacity: 1;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  -moz-background-clip: padding;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}
div.inputTags-list span.inputTags-item.is-edit {
  display: none;
}
div.inputTags-list span.inputTags-item.is-hidden {
  display: none !important;
}
div.inputTags-list span.inputTags-item.is-exists {
  background-color: rgba(231, 76, 60, 0.7);
}
div.inputTags-list span.inputTags-item span.value {
  cursor: pointer;
}
div.inputTags-list span.inputTags-item i {
  position: absolute;
  top: 50%;
  right: 6px;
  font-size: 16px;
  cursor: pointer;
  z-index: 10;
  font-weight: 300;
  font-family: sans-serif;
  line-height: 1;
  font-style: normal;
  -webkit-transition: color 0.2s;
  -khtml-transition: color 0.2s;
  -moz-transition: color 0.2s;
  -ms-transition: color 0.2s;
  -o-transition: color 0.2s;
  -webkit-transform: translateY(-50%);
  -khtml-transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  -o-transform: translateY(-50%);
}
div.inputTags-list span.inputTags-item i:hover {
  color: #e74c3c;
}
div.inputTags-list input.inputTags-field {
  border: none;
  margin-left: 4px;
  background-color: transparent;
}
div.inputTags-list input.inputTags-field:focus,
div.inputTags-list input.inputTags-field:active {
  outline: none;
}
div.inputTags-list input.inputTags-field.is-edit {
  margin: 0 2px;
  padding: 4px 8px 3px 8px;
  border: 1px dashed #c4c4c4;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  -moz-background-clip: padding;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}
div.inputTags-list ul.inputTags-autocomplete-list {
  position: absolute;
  max-height: 192px;
  max-width:200px;
  margin: 0;
  padding: 0;
  list-style-type: none;
  background-color: #fff;
  border: 1px solid #ddd;
  overflow-y: auto;
  z-index: 100;
  opacity: 0;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  -moz-background-clip: padding;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
  -webkit-transform: scaleY(0);
  -khtml-transform: scaleY(0);
  -moz-transform: scaleY(0);
  -ms-transform: scaleY(0);
  -o-transform: scaleY(0);
  -webkit-transform-origin: 50% 0;
  -khtml-transform-origin: 50% 0;
  -moz-transform-origin: 50% 0;
  -ms-transform-origin: 50% 0;
  -o-transform-origin: 50% 0;
  -webkit-transition-duration: 0.2s;
  -khtml-transition-duration: 0.2s;
  -moz-transition-duration: 0.2s;
  -ms-transition-duration: 0.2s;
  -o-transition-duration: 0.2s;
}
div.inputTags-list ul.inputTags-autocomplete-list.is-active {
  opacity: 1;
  -webkit-transform: scaleY(1);
  -khtml-transform: scaleY(1);
  -moz-transform: scaleY(1);
  -ms-transform: scaleY(1);
  -o-transform: scaleY(1);
}
div.inputTags-list ul.inputTags-autocomplete-list li {
  height: 32px;
  line-height: 32px;
  padding: 0 16px;
  cursor: pointer;
  border-bottom: 1px solid #ddd;
  -webkit-transition-duration: 0.3s;
  -khtml-transition-duration: 0.3s;
  -moz-transition-duration: 0.3s;
  -ms-transition-duration: 0.3s;
  -o-transition-duration: 0.3s;
  -webkit-transition-duration: 0.2s;
  -khtml-transition-duration: 0.2s;
  -moz-transition-duration: 0.2s;
  -ms-transition-duration: 0.2s;
  -o-transition-duration: 0.2s;
}
div.inputTags-list ul.inputTags-autocomplete-list li:last-child {
  border: none;
}
div.inputTags-list ul.inputTags-autocomplete-list li:hover {
  background-color: #19BC9C;
  color: #fff;
}
div.inputTags-list ul.inputTags-autocomplete-list li.is-disabled {
  cursor: default;
  background-color: #f7f7f7;
  color: initial;
}
p.inputTags-error {
  position: relative;
  margin: 0;
  padding: 0.5em 1em;
  color: #fff;
  background-color: rgba(231, 76, 60, 0.7);
  cursor: pointer;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  -moz-background-clip: padding;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}
p.inputTags-error:first-of-type {
  margin-top: 8px;
}
p.inputTags-error:after {
  position: absolute;
  content: "\000D7";
  top: 50%;
  right: 0.5em;
  -webkit-transform: translateY(-50%);
  -khtml-transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  -o-transform: translateY(-50%);
  font-size: 28px;
}


<|start_filename|>IEDC_webapp/css/main.css<|end_filename|>
﻿html, #page {
    padding-left: 7%;
}
body {
    color: #535353;
    font: 12px/2em sans-serif;
    margin: 0;
    padding: 0;
    width: 86%;
}
h1, h2, h3, h4, h5, h6 {
    color: darkgreen;
}
#page {
    background: #fff none repeat scroll 0 0;
}
#header, #footer, #top-nav, #content, #content #contentbar, #content #sidebar {
    margin: 0;
    padding: 0;
}
#logo {
    float: left;
    padding: 0;
    width: auto;
}
#logo h1 a, h1 a:hover {
    color: darkgreen;
    text-decoration: none;
}
#logo h1 span {
    color: lightgreen;
}
#header {
    background: #fff none repeat scroll 0 0;
}
#header-inner {
    margin: 0 auto;
    padding: 0;
}
.feature {
    /*background: green none repeat scroll 0 0;*/
    padding-top: 30px;
    padding-bottom: 25px;
}
.feature-inner {
    margin: auto;
}
.feature-inner h1 {
   color: green;
    font-size: 22px;
}
#top-nav {
    float: right;
    height: 37px;
    margin: 0 auto;
    padding: 0;
}
#top-nav ul {
    float: left;
    height: 37px;
    list-style: outside none none;
    padding: 0;
}
#top-nav ul li {
    float: left;
    margin: 0;
}
#top-nav ul li a {
    color: green;
    display: block;
    margin: 0;
    padding: 8px 8px;
    text-decoration: none;
}
#top-nav ul li.active a, #top-nav ul li a:hover {
    color: lightgreen;
}
#content-inner {
    background: #fff none repeat scroll 0 0;
    margin: 0 auto;
    padding: 25px 0;
}
#content #contentbar {
    float: left;
    margin: 0;
    padding: 0;
    width: 55%;
}
#content #contentbar .article {
    margin: 0 0 24px;
}
#content #contentbar .article img {
     max-width:100%; 
  max-height:100%;
  margin:auto;
  display:block;
}
#content #sidebar {
       /*border: 2px solid;*/
    float: right;
    padding: 0;
    width: 35%;
}

#content #sidebar .widget-article {
    line-height: 1.4em;
    margin: 0 0 70px;
    font-size:14px;
}
#content #sidebar .widget-article h3 a {
    text-decoration: none;
    font-size:16px;
}

#content #sidebar .widget-login {
    border: 1px solid;
    border-radius: 2px;
    font-size: 14px;
    line-height: 1.4em;
    margin: 3px 4px 12px;
    padding-left: 5px;
    width: 80%;
}
#content #sidebar .widget-login h3 a {
    text-decoration: none;
    font-size:16px;
}

.table-login{
    width:100%;
}

.table-login td {
    font-size: 14px;
    padding: 5px;
}

#footer {
    background: #fff none repeat scroll 0 0;
    padding-top:20px;
}
#footer-inner {

    text-align: center;
    margin:auto;
    padding-top: 10px;
    padding-bottom: 0px;
    position:fixed;
    bottom:0;
    width:90%;
}
#footer a {
    color: green;
    text-decoration: none;
}
.clr {
    clear: both;
    font-size: 0;
    line-height: 0;
    margin: 0;
    padding: 0;
    width: 100%;
}



      #content-inner-row1{
          width:100%;
      }
      #content-inner-row1Col1{
          background-color:yellow;
          float:left;
          width:33%;
      }
      #content-inner-row1Col2{
          float:right;
          width:67%;
      }
    
      .button-logout {
    background-color: green;
    border: medium none;
    color: white;
    display: inline-block;
    font-size: 12px;
    padding: 4px 12px;
    text-align: center;
    text-decoration: none;
}

      .user-name-label{
    color: green;
    font-size: 14px;
}

      
body {
    background-color: #ffff99;
    font-size: 13px;
}
.smalllabel {
    font-size: 11px;
}
.slider {
    border-radius: 3px;
    cursor: pointer;
    width: 150px

}
.errormessage {
    background-color: pink;
    border: 1px solid red;
    color: #660000;
    margin: -1px;
    padding: 4px;
}
.cautionmessage {
    background-color: #ffff99;
    border: 1px solid darkred;
    color: darkred;
    margin: -1px;
    padding: 4px;
}
.okmessage {
    background-color: #ddeeff;
    border: 1px solid #006699;
    color: #003366;
    margin: -1px;
    padding: 4px;
    text-align: center;
}
.importanttext {
    background-color: inherit;
    color: darkred;
    text-decoration: underline;
}
dfn {
    border-bottom: 1px dotted;
    font-style: normal;
}
.center_basic {
    display: table;
    margin: 0 auto;
    width: 1300px;
}
.center_para {
    display: table;
    margin: 0 auto 4px;
    padding-bottom: 4px;
    padding-top: 4px;
}
.indicator {
    float: right;
}
textarea#flows_in {
    border: 1px solid #006699;
    font-family: sans-serif;
    font-size: small;
    margin: 3px;
    padding: 2px;
}
.form_elements {
    margin: 2px 3px 5px;
}
.form_elements1 {
    background-color: inherit;
    margin: 2px 3px 5px;
    padding: 2px 3px;
}
.form_elements2 {
    background-color: #ddf0ff;
    margin: 2px 3px 5px;
    padding: 2px 3px;
}
.spaced_label {
    margin-left: 12px;
}
.form_chunk {
    background-color: #fbfeff;
    border-color: #9ac;
    border-style: solid;
    border-width: 0 1px 1px;
    color: #002244;
    margin: 0 3px 6px;
    padding: 2px;
}
p#chart {
    background-color: white;
    border: 1px dotted #666666;
    height: 500px;
    margin: 10px auto;
    width: 600px;
}
.node rect {
    cursor: move;
}
.node text {
    pointer-events: none;
}

.node1 rect {
    cursor: default
}
td#grapharea {
    margin: 0;
    padding: 0;
}
th#title {
    background-color: #88bbcc;
    font-size: large;
    padding: 5px 10px;
}
#download_link {
    margin-top: 8px;
}
#download_link a {
    background-color: #acf;
    border: 1px solid #069;
    padding: 5px 8px;
}
#img_tag_hint {
    background-color: white;
    border: 1px dotted #999;
    margin: 3px;
    padding: 3px;
}

.btn_normal {
    background-color: coral;
    border: medium none;
    color: white;
    display: inline-block;
    font-size: 12px;
    padding: 4px 9px;
    text-align: center;
    text-decoration: none;
}

.btn_normal:hover {
  background: #fcb63c linear-gradient(to bottom, #fa9f03, #c77a06);
  text-decoration: none;
}

.btn_preview {
    background-color: chocolate;
    border: medium none;
    border-radius: 6px;
    color: white;
    display: inline-block;
    font-size: 13px;
    padding: 7px 11px;
    text-align: center;
    text-decoration: none;
}

.btn_preview:hover {
  background: #fcb63c linear-gradient(to bottom, #fa9f03, #c77a06);
  text-decoration: none;
}
        
.button-login {
    background-color: green;
    border: medium none;
    border-radius: 5px;
    color: white;
    display: inline-block;
    font-size: 14px;
    padding: 4px 17px;
    text-align: center;
    text-decoration: none;
}


  .textbox { 
    background: white none repeat scroll 0 0;
    border: 1px solid #ffa853;
    border-radius: 2px;
    color: #666;
    font-size: 12px;
    height: 20px;
    outline: medium none;
    width: 200px;
  } 
  
 .PopupDiv
{
    border: solid 1px black;
    position: fixed;
    left: 50%;
    top: 50%;
    background-color: white;
    z-index: 100;
    display:none;
    height: 200px;
    margin-top: -200px;

    width: 200px;
    margin-left: -300px;
}

               .dAngle {
  background-color:#ececec;
  border:1px solid #999999;
  cursor:default;
  display:none;
  margin-top: 15px;
  position:absolute;
  text-align:left;
  width:300px;
  z-index:50;
  padding: 25px 25px 20px;
}

               p#buildlink {
    font-size: larger;
    padding-top: 20px;
}
div#main, p#buildlink, .center {
    display: table;
    margin: 0 auto;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}
td {
    padding: 2px;
    vertical-align: top;
}
#nav {
    font-size: 12px;
}
#footer-content {
    font-size: 14px;
    text-align: center;
}
header a {
    color: white;
}
header td {
    padding: 0.3em 1em;
}
header td.leftmost {
    padding-left: 0.2em;
}
header td.active_tab a {
    color: #036;
}
img.figure_right, table.float_right {
    float: right;
    margin-left: 4px;
}
img.figure_left {
    float: left;
    margin-right: 4px;
}
.center_content {
    text-align: center;
}
.align_right {
    text-align: right;
}
.no_wrap {
    white-space: nowrap;
}
td#flows_entry {
    background-color: #808080;
    padding: 0 2px;
    text-align: left;
    vertical-align: middle;
}
div#size_spacing {
    float: left;
    overflow: hidden;
    width: 20%;
}
div#colors {
    text-align: left;
}
div#labels {
    text-align: left;
}
div#advanced_options {
    text-align: left;
}
.upload_button {
    background-color: #004b96;
    border-color: #002c58;
    color: white;
    height: 21px;
    width: auto;
}
a {
    color: black;
    cursor: pointer;
    text-decoration: underline;
}
#download {
    border: 1px solid silver;
    opacity: 0;
    position: absolute;
}
body {
    background-color: #ffffff;
    margin: 0;
}
header {
    background-color: #423dff;
    border-bottom: 3px solid #55b1aa;
    color: white;
    padding: 7px;
}
.button {
    background-color: #b29400;
    border: 1px solid #464f4f;
    color: #ffffff;
    font-family: Tahoma;
    font-size: 12px;
    height: 20px;
    text-align: center;
    text-decoration: none;
}
header td.deactive_tab {
    background-color: #0400b2;
    color: #ffffff;
    font-family: Tahoma;
    font-size: 13px;
    text-align: center;
}
header td.active_tab {
    background-color: #b29400;
    border-bottom: 4px solid #066c9f;
    color: #ffffff;
    font-size: 13px;
    text-align: center;
}
header td:hover {
    background-color: #0400b2;
    color: #ffffff;
    cursor: pointer;
}
td#other_entry {
    background-color: #ffde44;
    padding: 0 2px;
    width: 1300px;
}
h2.ui_head {
    background-color: #b29400;
    color: white;
    font-size: 13px;
    margin: 1px 0 0;
    padding: 4px 5px 1px;
    text-align: left;
    width: 95%;
}
textarea {
    font-family: Tahoma;
    font-size: 12px;
    width: 96%;
}
div#input_textarea {
    float: left;
    overflow: hidden;
    width: 35%;
}
div#input_textarea_angle {
    float: left;
    overflow: hidden;
    width: 25%;
}
div#input_file {
    float: left;
    overflow: hidden;
    width: 25%;
}
div#input_options {
    text-align: left;
}
div#input_textarea_country {
    float: left;
    overflow: hidden;
    width: 35%;
}
textarea_country {
    font-family: Tahoma;
    font-size: 13px;
    width: 96%;
}

.input-text-area {
    background: #ffffff;
    border: 1px solid #b7b7b7;
    border-radius: 0 / 3px;
    box-sizing: content-box;
    color: rgba(0, 142, 198, 1);
    display: inline-block;
    font: 12px Tahoma,Geneva,sans-serif;
}
