예제 #1
0
 private void load()
 {
     try
     {
         Chart1.Series.Clear();
         lbl3.Text = "";
         lbl4.Text = "";
         Chart1.DataBindCrossTable(GetData().DefaultView, "RBS", "Date", "FRAMESLOST", "");
         loadLoss();
         loadDCH();
         con.Close();
         Chart1.MouseWheel += chart1_MouseWheel;
     }
     catch (Exception ex)
     {
         if (MessageBox.Show("Could not Load data! : " + ex.Message, "Connection Failed", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information) == DialogResult.Retry)
         {
             load();
         }
         else
         {
             this.Close();
         }
     }
 }
예제 #2
0
        private void load()
        {
            Chart1.Series.Clear();
            Chart1.DataBindCrossTable(GetData().DefaultView, "RBS", "Date", "FRAMESLOST", "");
            con.Close();
            dgvTampil.Columns.Clear();
            string query = "SELECT `tbldata_id`,DATE_FORMAT(Date,'%d/%m/%Y') AS Date, `Hour`, `RBS`, `RNC`, `FRAMESLOST`, `DCH_FRAMELOST`, `pmEdchIubLimitingRatio`, `IUB_CAP_HS_LIMIT` FROM `tbldata`";

            data.dgv(query, "", dgvTampil);
        }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        sqlParamS[0].Value = Convert.ToInt32(ddlBranch.SelectedValue);
        sqlParamS[1].Value = Convert.ToInt32(ddlProductDivision.SelectedValue);
        sqlParamS[2].Value = Convert.ToInt32(DDlYear.SelectedValue);;
        sqlParamS[3].Value = Convert.ToInt32(DDLMonth1.SelectedValue);
        sqlParamS[4].Value = Convert.ToInt32(DDLMonth2.SelectedValue);

        //  for default series source
        // Chart1.Series["Series1"].Enabled = false; // hide default series from Legend Imp


        DataSet ds = new DataSet();

        ds = objSqlDataAccessLayer.ExecuteDataset(CommandType.StoredProcedure, "tmpOutBoundq1", sqlParamS);

        Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray;
        Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;

        Chart1.DataBindCrossTable(ds.Tables[0].AsEnumerable(), "MonthName", "scaleanswer_desc", "Percentage", "Label=Percentage");

        foreach (Series sr in Chart1.Series)
        {
            //sr.IsValueShownAsLabel = true;
            sr.LabelBorderColor = System.Drawing.Color.BlueViolet;
        }

        // Chart1.Series[0].LabelFormat  = "{0:0.00}";

        Chart1.Legends.Add("Legend");



        ////   Chart1.Series[rowindex].ChartArea = Chart1.ChartAreas[rowindex].Name;

        //// Set series members names for the X and Y values
        //Chart1.Series[0].XValueMember = "Scaleanswer_desc";
        //Chart1.Series[0].YValueMembers = "Percentage";


        Chart1.ChartAreas[0].AxisY.Title = "Percentage (%)";
        Chart1.ChartAreas[0].AxisX.Title = "Rating by customers (1 for worst , 5 for best)";
    }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Chart1.Series.Clear();
            try
            {
                Chart1.DataBindCrossTable(GetDataSpecific().DefaultView, "RBS", "Hour", "FRAMESLOST", "");
                string query = "SELECT `RBS`,DATE_FORMAT(Date,'%d/%m/%Y') AS Date,`Hour`,FRAMESLOST FROM tbldata where DATE_FORMAT(Date, '" + txtRange1.Text + "') && RBS = '" + txtObject.Text + "' GROUP BY RBS,Hour";
                data.dgv(query, "", dgvTampil);
                Chart1.Series[0].ChartType = SeriesChartType.Spline;
                Chart1.Series[0].Color     = Color.MediumPurple;
                con.Close();
                Chart1.ChartAreas[0].AxisX.ScaleView.ZoomReset();
                Chart1.ChartAreas[0].AxisY.ScaleView.ZoomReset();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select a data : " + ex.Message, "The value is empty!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                con.Close();
            }

            txtObject.Text = "";
            txtRange1.Text = "";
            txtRange2.Text = "";
        }
        protected void populateChartSectionViaFunction(string function, string sectionlist, int questionID)
        {
            try
            {
                MultiView1.Visible = true;
                Chart1.Series.Clear();
                Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray;
                Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
                MultiView1.Visible = true;
                DataTable table = new DataTable();
                table.Columns.Add("SectionGroup");
                table.Columns.Add("AverageGrading");
                table.Columns.Add("Date");
                ArrayList listofdates  = dbmanager.GetListofDatesViaFunction(function);
                string[]  sectionsplit = sectionlist.Split(',');

                ArrayList listofquestion = dbmanager.GetAllQuestion();
                ArrayList listofstaff    = dbmanager.GetAllStaffDetails();

                foreach (DateTime date in listofdates)
                {
                    foreach (string section in sectionsplit)
                    {
                        double result             = 0.0;
                        double staffAverage       = 0.0;
                        double staffAverageResult = 0.0;
                        int    count = 0;

                        foreach (staffinfo staff in listofstaff)
                        {
                            if (staff.Section.Contains(section) && staff.Function.Equals(function))
                            {
                                if (questionID == 0)
                                {
                                    foreach (Question qn in listofquestion)
                                    {
                                        staffAverage += dbmanager.GetAvgRating(staff.Uid, date, qn.QuestionID); // for all question
                                    }
                                    int countquestion = dbmanager.GetTotalCountQuestionInPeriod(staff.Uid, date);
                                    staffAverageResult = Math.Round((staffAverage / countquestion), 1);
                                    count++;
                                }
                                else
                                {
                                    staffAverage += dbmanager.GetAvgRating(staff.Uid, date, questionID); // for per question
                                    int countquestion = dbmanager.GetTotalCountQuestionInPeriod(staff.Uid, date);
                                    staffAverageResult = staffAverage;
                                    count++;
                                }
                            }
                        }

                        try
                        {
                            result = Math.Round((staffAverageResult / count), 1);
                        }
                        catch
                        {
                            result = 0.0;
                        }

                        string monthname = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month);
                        table.Rows.Add(section, result, monthname.Substring(0, 3) + "/" + date.Year.ToString().Substring(2, 2));

                        result             = 0.0;
                        staffAverage       = 0.0;
                        staffAverageResult = 0.0;
                    }
                }

                bool display = false;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (table.Rows[i].ItemArray[1].ToString() == "0")
                    {
                        display = false;
                    }
                    else
                    {
                        display = true;
                        break;
                    }
                }
                if (display == true)
                {
                    Chart1.Visible = true;
                    DataTableReader datareader = table.CreateDataReader();
                    Chart1.ChartAreas[0].AxisX.Title = "Period of evaluation";
                    Chart1.ChartAreas[0].AxisY.Title = "Average grade";
                    Chart1.DataBindCrossTable(datareader, "SectionGroup", "Date", "AverageGrading", "");
                    Chart1.Legends.Add("Legend");
                    Chart1.Legends[0].Enabled   = true;
                    Chart1.Legends[0].BackColor = System.Drawing.Color.Transparent;
                    Chart1.Width  = 1000;
                    Chart1.Height = 600;

                    MultiView1.ActiveViewIndex = 0;
                }
                else
                {
                    Chart1.Visible             = false;
                    MultiView1.ActiveViewIndex = 1;
                    lbDisplay.Text             = "<b>No result found</b>";
                }
            }
            catch (Exception e)
            {
                MultiView1.Visible = false;
                MessageBoxShowWithoutredirect(e.Message);
            }
        }
        protected void populateChartSectionViaFunctionALL()
        {
            try
            {
                MultiView1.Visible = true;
                Chart1.Series.Clear();
                Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray;
                Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
                MultiView1.Visible = true;
                DataTable table = new DataTable();
                table.Columns.Add("AverageGrading");
                table.Columns.Add("Date");
                ArrayList listofdates = dbmanager.GetListofDatesViaAll();

                // decare and get items
                double result = 0.0;
                //double staffAverage = 0.0;
                //double staffAverageResult = 0.0;

                //ArrayList listofstaff = dbmanager.GetAllStaffDetails();
                //ArrayList listofquestion = dbmanager.GetAllQuestion();

                foreach (DateTime date in listofdates)
                {
                    //foreach (staffinfo staff in listofstaff)
                    //{
                    //foreach (Question qn in listofquestion)
                    //{
                    //staffAverage += dbmanager.GetAvgRating(staff.Uid, date, qn.QuestionID);
                    //staffAverage += dbmanager.GetAverageStaffPeriod(staff.Uid, date);
                    //}
                    //int countquestion = dbmanager.GetTotalCountQuestionInPeriod(staff.Uid, date);
                    //staffAverageResult = Math.Round((staffAverage / countquestion), 1);
                    //}
                    //result = Math.Round((staffAverageResult / listofstaff.Count), 1);
                    result = dbmanager.GetAverageAllStaffPeriod(date);
                    string monthname = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month);
                    table.Rows.Add(result, monthname.Substring(0, 3) + "/" + date.Year.ToString().Substring(2, 2));

                    result = 0.0;
                    //staffAverage = 0.0;
                    //staffAverageResult = 0.0;
                }

                bool display = false;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (table.Rows[i].ItemArray[1].ToString() == "0")
                    {
                        display = false;
                    }
                    else
                    {
                        display = true;
                        break;
                    }
                }
                if (display == true)
                {
                    Chart1.Visible = true;
                    DataTableReader datareader = table.CreateDataReader();
                    Chart1.ChartAreas[0].AxisY.Title = "Average grade";
                    Chart1.DataBindCrossTable(datareader, "Date", "", "AverageGrading", "");
                    Chart1.Legends.Add("Legend");
                    Chart1.Legends[0].Enabled   = true;
                    Chart1.Legends[0].BackColor = System.Drawing.Color.Transparent;
                    Chart1.Width  = 1000;
                    Chart1.Height = 600;

                    MultiView1.ActiveViewIndex = 0;
                }
                else
                {
                    Chart1.Visible             = false;
                    MultiView1.ActiveViewIndex = 1;
                    lbDisplay.Text             = "<b>No result found</b>";
                }
            }
            catch (Exception e)
            {
                MultiView1.Visible = false;
                MessageBoxShowWithoutredirect(e.Message);
            }
        }
예제 #7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // resolve the address to the Access database
            string fileNameString = this.MapPath(".");

            fileNameString += "..\\..\\..\\..\\data\\chartdata.mdb";

            // initialize a connection string
            string myConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileNameString;

            // define the database query
            string mySelectQuery = "SELECT * FROM REPSALES;";

            // create a database connection object using the connection string
            OleDbConnection myConnection = new OleDbConnection(myConnectionString);

            // create a database command on the connection using query
            OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);

            // open the connection
            myCommand.Connection.Open();

            // Bind grid to the original data
            OleDbDataAdapter custDA = new OleDbDataAdapter();

            custDA.SelectCommand = myCommand;
            DataSet custDS = new DataSet();

            custDA.Fill(custDS, "Customers");
            this.DataGrid.DataSource = custDS;
            this.DataGrid.DataBind();

            // create a database reader
            OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            // data bind chart to a table where all rows are grouped in series by the "Name" column
            Chart1.DataBindCrossTable(
                myReader,
                (DropDownListGroupBy.SelectedIndex == 0) ? "Name" : "Year",
                (DropDownListGroupBy.SelectedIndex == 0) ? "Year" : "Name",
                "Sales",
                "Label=Commissions{C}");

            // close the reader and the connection
            myReader.Close();
            myConnection.Close();

            // Set series appearance
            MarkerStyle marker = MarkerStyle.Star4;

            foreach (Series ser in Chart1.Series)
            {
                ser.ShadowOffset      = 2;
                ser.BorderWidth       = 3;
                ser.ChartType         = SeriesChartType.Line;
                ser.MarkerSize        = 12;
                ser.MarkerStyle       = marker;
                ser.MarkerBorderColor = Color.FromArgb(64, 64, 64);
                ser.Font = new Font("Trebuchet MS", 8, FontStyle.Bold);
                marker++;
            }
        }