private void Load_DanhSachHoSo(string Ids = ",26,") { string str = txtSearch.Value.Trim(); DateTime TuNgay = DateTime.Now, DenNgay = DateTime.Now; if (txtTuNgay.Value.Trim() == "") { TuNgay = new DateTime(1900, 1, 1); } TuNgay = Convert.ToDateTime(txtTuNgay.Value, new CultureInfo("vi-VN")); if (txtDenNgay.Value.Trim() == "") { DenNgay = new DateTime(9999, 1, 1); } DenNgay = Convert.ToDateTime(txtDenNgay.Value, new CultureInfo("vi-VN")); List <BieuDoHinhCotBHTN> lstBieuDo = new List <BieuDoHinhCotBHTN>(); DataTable tblNoiNhan = new DanhMuc().getList(13); for (int i = 0; i < tblNoiNhan.Rows.Count; i++) { BieuDoHinhCotBHTN item = new BieuDoHinhCotBHTN(); DataTable tblBHTN = new BaoCao().BieuDoBHTNTTheoDonVi(TuNgay, DenNgay, (int)tblNoiNhan.Rows[i]["IdDanhMuc"]); if (tblBHTN.Rows.Count > 0) { item.Ngay = tblNoiNhan.Rows[i]["NameDanhMuc"].ToString().Trim(); item.SoHoSo = tblBHTN.Rows.Count; lstBieuDo.Add(item); } } // truong hop khong ho so khong ro dia chi nhan do can bo khong chon Chart1.DataSource = lstBieuDo; Chart1.Series["Category"].XValueMember = "Ngay"; Chart1.Series["Category"].YValueMembers = "SoHoSo"; Chart1.DataBind(); //name x,y //Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Các ngày nộp hồ sơ"; //Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Số hồ sơ nộp"; }
private void loadChartData() { try { DataTable tb = new DataTable(); using (SqlConnection sqlcon = new SqlConnection(sqlconstr)) { using (SqlCommand sqlcmd = sqlcon.CreateCommand()) { DataSet ds = new DataSet(); sqlcon.Open(); sqlcmd.CommandType = System.Data.CommandType.StoredProcedure; sqlcmd.CommandText = "projection_chart_stp"; sqlcmd.Parameters.AddWithValue("@command", "chart"); sqlcmd.Parameters.AddWithValue("@year1", tboxYear.Text); using (SqlDataAdapter da = new SqlDataAdapter()) { da.SelectCommand = sqlcmd; da.Fill(ds); Chart1.DataSource = ds; Chart1.DataBind(); //DataView dv = ds.Tables[0].DefaultView; //Chart1.DataBindTable(dv, "MM"); Chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1; Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "N0"; Chart1.ChartAreas[0].AxisY2.LabelStyle.Format = "N0"; } } } } catch (Exception ex) { errorrmessage(ex.Message); } }
/// <summary> /// 建立統計 /// </summary> private void CreatePic() { using (SqlConnection conn = new SqlConnection(DBTools.ConnectionString)) { string sqlstr = string.Format(@"SELECT b.itemname as 品名,SUM(Quantity) as 數量 FROM OrderDetails a INNER JOIN ShopDetails b on a.ItemID=b.ItemID WHERE OrderID=@OrderID AND a.IsCancel=0 GROUP BY b.itemname,a.ItemID"); conn.Open(); using (SqlCommand cmd = new SqlCommand(sqlstr, conn)) { cmd.Parameters.Add("@OrderID", SqlDbType.UniqueIdentifier); cmd.Parameters[0].Value = ViewState["OrderID"]; using (SqlDataReader dr = cmd.ExecuteReader()) { Chart1.DataSource = dr; Chart1.DataBind(); } } } }
protected void Page_Load(object sender, EventArgs e) { // istatikler için çartların sonuçlarının toplanması. Chart1.DataSource = getdata1(); Chart1.DataBind(); Repeater1.DataSource = getdata(); Repeater1.DataBind(); Chart1.ChartAreas[0].AxisX.Title = "gender"; Chart1.ChartAreas[0].AxisY.Title = "picture2"; Chart2.DataSource = getdata2(); Chart2.DataBind(); Chart2.ChartAreas[0].AxisX.Title = "gender"; Chart2.ChartAreas[0].AxisY.Title = "picture1"; basligiAl(); Chart3.DataSource = getdata3(); Chart3.DataBind(); Chart3.ChartAreas[0].AxisX.Title = "age_group"; Chart3.ChartAreas[0].AxisY.Title = "picture1"; Chart4.DataSource = getdata4(); Chart3.DataBind(); Chart4.ChartAreas[0].AxisX.Title = "age_group"; Chart4.ChartAreas[0].AxisY.Title = "picture2"; }
public void LoadChart() { Chart1.DataSource = statistic.GetListUser(txt_month.Text); Chart1.DataBind(); Chart1.Series["Series1"].IsValueShownAsLabel = true; Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular); Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.Font = new System.Drawing.Font("Tahoma", 7F, System.Drawing.FontStyle.Regular); DataTable tb = statistic.GetListUser(txt_month.Text); for (int x = 0; x < tb.Rows.Count; x++) { // Add each point and set its Label DataPoint pt = Chart1.Series["Series1"].Points[x]; if (pt.AxisLabel == Session["FullName"].ToString()) { pt.Color = Color.Red; } } }
//Chart Control private void GetChartTypes(DataTable dt) { // string sql = @"select pbl.aLine, // cast(round(cast(sum(pbl.aHrTotal) as decimal)/ cast((select SUM(LDayTgt) from Smt_LineDetail where LDate between '2016-12-03' and '2016-12-08' and LLineID=pbl.aLineID and LMo is not null group by LLineID) as decimal) * 100,2) as numeric(36,2)) as Achievement // from Hrs_ProductionByLine pbl left join // Smt_LineDetail sld on pbl.aDate=sld.LDate and pbl.aLineID=sld.LLineID left join // Smt_LcSupervisor slc on pbl.aLine=slc.aLine // where aStage='SEWING QC OUT' and aDate between '2016-12-03' and '2016-12-08' and aCompanyID=6 // group by pbl.aLine,pbl.aLineID,slc.LCSV"; // SqlCommand adapter = new SqlCommand(sql, cn); // cn.Open(); // SqlDataReader rdr = adapter.ExecuteReader(); //DataTable dt = new DataTable(); //adapter.Fill(dt); //Chart1.DataBindTable(rdr, "aLine"); //cn.Close(); Chart1.Series["Series1"].XValueMember = "aLine"; Chart1.Series["Series1"].YValueMembers = "Achievement"; //Chart1.Series["Series1"].Label = "#PERCENT{P0}"; Chart1.DataSource = dt; Chart1.DataBind(); }
void InitChart_AppRunsWithoutVersion(DbConnection conn, DBWorker worker) { DbCommand cmd = conn.CreateCommand(); InitQueryForUsageReportTable("select s.AppName, count(s.ID) as NumSessions, avg(" + worker.GetDateDiffExpression("s.StartTime", "s.EndTime", "s") + ") as Dur from " + svc.UsageReportTableName + " as s ", cmd, "group by s.AppName order by count(s.ID) DESC"); DataTable dt = LoadDataTableFromCommand(cmd); AddDurationColumnFromSeconds(dt, "Duration", 2); Chart1.DataSource = dt; Chart1.Series["Series1"].XValueMember = "AppName"; Chart1.Series["Series1"].YValueMembers = "NumSessions"; Chart1.Series["Series1"].Label = "#VALY\n(#PERCENT)"; SetAxisProperties(Chart1.ChartAreas[0].AxisX, "Number Of Runs"); ChartArea ca = Chart1.ChartAreas.Add("duration"); Series s = Chart1.Series.Add("duration"); s.ChartArea = "duration"; s.XValueMember = "AppName"; s.YValueMembers = "Duration"; s.YValueType = ChartValueType.DateTime; s.IsValueShownAsLabel = true; s.LabelFormat = "HH:mm"; ca.AxisY.Minimum = 0; ca.AxisY.LabelStyle.Format = "HH:mm"; ca.AxisY.LabelStyle.Enabled = true; SetAxisProperties(ca.AxisX, "Avg Duration"); AlignChartAreaTo(ca, Chart1.ChartAreas[0].Name); Chart1.DataBind(); }
private void chart_bind() { string ss; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString); SqlCommand cmd = new SqlCommand("disp_net_avg_speed", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("m_ip", SqlDbType.VarChar, 50).Value = DropDownList4.SelectedValue; if ((DropDownList5.SelectedValue != "-1") && (DropDownList6.SelectedValue != "-1")) { cmd.Parameters.Add("d_from", SqlDbType.VarChar, 11).Value = ss = DropDownList5.SelectedValue; cmd.Parameters.Add("d_to", SqlDbType.VarChar, 11).Value = ss = DropDownList6.SelectedValue; } else { cmd.Parameters.Add("d_from", SqlDbType.VarChar, 11).Value = DBNull.Value; cmd.Parameters.Add("d_to", SqlDbType.VarChar, 11).Value = DBNull.Value; } if (DropDownList7.SelectedValue == "-1") { cmd.Parameters.Add("day", SqlDbType.VarChar, 20).Value = DBNull.Value; } else { cmd.Parameters.Add("day", SqlDbType.VarChar, 20).Value = ss = DropDownList7.SelectedValue; } if (con.State == ConnectionState.Closed) { con.Open(); } Chart1.DataSource = cmd.ExecuteReader(); Chart1.DataBind(); con.Close(); cmd.Dispose(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { cn = serv.Con(); if (cn.State != ConnectionState.Open) { cn.Open(); } MySqlCommand cmd = new MySqlCommand("SELECT * FROM tempdb.solarpanel where Local_Time like '%" + DropDownList1.SelectedValue + "%';", cn); MySqlDataAdapter adp = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); adp.Fill(dt); Chart1.DataSource = dt; Chart1.DataBind(); string[] x = new string[dt.Rows.Count]; int[] y = new int[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { x[i] = dt.Rows[i][0].ToString(); y[i] = Convert.ToInt32(dt.Rows[i][1]); } Chart1.Series[0].Points.DataBindXY(x, y); Chart1.Series[0].ChartType = SeriesChartType.Line; }
protected void FillCharts() { DataTable dt = GetData("select * from dbo.top10_Origin"); Chart1.Series[0].ChartType = SeriesChartType.Pie; Chart1.DataSource = dt; Chart1.Series.First().XValueMember = "Origin"; Chart1.Series.First().YValueMembers = "Count"; Chart1.DataBind(); Chart1.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.Transparent; dt.Clear(); dt = GetData("select * from dbo.flightCount"); Chart2.Series[0].ChartType = SeriesChartType.Pie; Chart2.DataSource = dt; Chart2.Series.First().XValueMember = "Code"; Chart2.Series.First().YValueMembers = "Flight Count"; Chart2.DataBind(); Chart2.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.Transparent; dt.Clear(); dt = GetData("select * from dbo.avgDelay"); Chart3.Series[0].ChartType = SeriesChartType.Column; Chart3.DataSource = dt; Chart3.Series.First().XValueMember = "Code"; Chart3.Series.First().YValueMembers = "Average Delay"; Chart3.DataBind(); Chart3.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.Transparent; }
private void drawGraph(DataSet dsGrph) { DundasCharts.DundasChartBase(Chart1, ChartImageType.Flash, 800, 300 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); Series series1 = DundasCharts.CreateSeries(Chart1, "Series1", "Default", "1차", null, SeriesChartType.Column, 1, Color.FromArgb(0x5A, 0x7D, 0xDE), Color.FromArgb(0x4A, 0x58, 0x7E), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Series series2 = DundasCharts.CreateSeries(Chart1, "Series2", "Default", "2차", null, SeriesChartType.Column, 1, Color.FromArgb(0xFF, 0x8A, 0x00), Color.FromArgb(0xD7, 0x41, 0x01), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Chart1.DataSource = dsGrph.Tables[0].DefaultView; series1.ValueMembersY = "1차"; series2.ValueMembersY = "2차"; series1.ValueMemberX = "SEC_NM"; Chart1.DataBind(); Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#,##0.#0"; DundasAnimations.DundasChartBase(Chart1, AnimationTheme.None, -1, -1, false, 1); DundasAnimations.GrowingAnimation(Chart1, series1, 0.0, 2.0, true); DundasAnimations.GrowingAnimation(Chart1, series2, 2.0, 3.0, true); }
public void GetChartData() { // BAL Cust = new BAL() ; // DataSet dstObj = Cust.ToArray<Enum>(); //Series series = Chart1.Series["Series1"]; BAL Cust = new BAL(); DataSet dstObj = Cust.View(); Chart1.DataSource = dstObj; dstObj.CreateDataReader(); //Chart1.Series["Series1"]. Chart1.Series["Series1"].ChartType = SeriesChartType.Line; Chart1.Series["Series1"].XValueMember = "Year_Ref"; Chart1.Series["Series1"].YValueMembers = "Rain_Full_Year"; Chart1.DataBind(); //chartPlaceHolder.Controls.Add(chart1); }
public void TableUserControl(ItemSet itemSet, List <AssociationRule> rules) { GridView ItemSetsDataGrid = new GridView(); GridView RulesDataGrid = new GridView(); Chart ItemsetChart = new Chart(); Label ItemSet = new Label(); Label RuleSet = new Label(); ItemSet.Text = itemSet.Label; flowLayoutPanel2.Controls.Add(ItemSet); flowLayoutPanel2.Controls.Add(ItemSetsDataGrid); flowLayoutPanel3.Controls.Add(RuleSet); flowLayoutPanel3.Controls.Add(RulesDataGrid); ItemsetChart.Visible = true; //ItemSetsDataGrid.AllowPaging = true; //ItemSetsDataGrid.PageSize = PageSize; //RulesDataGrid.AllowPaging = true; //RulesDataGrid.PageSize = PageSize; // ItemSetLabel.Text = itemSet.Label; DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); if (dt.Columns.Count == 0) { dt.Columns.Add("itemSet", typeof(string)); dt.Columns.Add("Count", typeof(string)); dt1.Columns.Add("itemSet", typeof(string)); dt1.Columns.Add("Count", typeof(int)); } DataTable dt2 = new DataTable(); if (dt2.Columns.Count == 0) { dt2.Columns.Add("item", typeof(string)); dt2.Columns.Add("Confidance", typeof(string)); dt2.Columns.Add("Support", typeof(string)); } foreach (var item in itemSet) { dt.Rows.Add(item.Key.ToDisplay(), item.Value); dt1.Rows.Add(item.Key.ToDisplay(), int.Parse(item.Value.ToString())); } if (rules.Count == 0) { ItemSetsDataGrid.Height = 342; //RulesDataGrid.Visible = false; } else { RuleSet.Text = "Rules"; foreach (var item in rules) { dt2.Rows.Add(item.Label, item.Confidance.ToPercentString(), item.Support.ToPercentString()); } } ItemSetsDataGrid.Height = 500; RulesDataGrid.Height = 500; ItemSetsDataGrid.DataSource = dt; ItemSetsDataGrid.DataBind(); RulesDataGrid.DataSource = dt2; RulesDataGrid.DataBind(); foreach (var item in itemSet) { if (item.Value < itemSet.Support) { ItemSetsDataGrid.Rows[ItemSetsDataGrid.Rows.Count - 1].BackColor = System.Drawing.Color.LightGray; } } //var enumerableTable = (dt1 as System.ComponentModel.IListSource).GetList(); //Chart1.DataBindTable(enumerableTable, "Itemset"); Chart1.Series["Series1"].XValueMember = "Itemset"; Chart1.Series["Series1"].YValueMembers = "Count"; Chart1.DataSource = dt1; Chart1.DataBind(); }
protected void ddlChart_SelectedIndexChanged(object sender, EventArgs e) { try { if (ddlChart.SelectedValue == "Chart1") { Chart1.Visible = true; DataTable _dt = _objChartMasterManager.LeaveChart().Tables[0]; Chart1.DataSource = _dt; Chart1.Series[0].YValueMembers = "LeaveAllowed"; Chart1.Series[0].IsValueShownAsLabel = true; Chart1.Series[1].YValueMembers = "LeaveTypeId"; Chart1.Series[0].XValueMember = "LeaveTypeId"; Chart1.ChartAreas["ChartArea1"].AxisY.Interval = 2; Chart1.DataBind(); } else if (ddlChart.SelectedValue == "Chart2") { Chart2.Visible = true; DataTable _dt2 = _objChartMasterManager.DesignationChart().Tables[0]; Chart2.DataSource = _dt2; Chart2.Series[0].YValueMembers = "EmployeeId"; Chart2.Series[0].XValueMember = "Designation"; Chart2.ChartAreas["ChartArea2"].AxisY.Interval = 1; Chart2.DataBind(); } else if (ddlChart.SelectedValue == "Chart3") { Chart3.Visible = true; DataTable _dt3 = _objChartMasterManager.DepartmentChart().Tables[0]; Chart3.DataSource = _dt3; Chart3.Series[0].YValueMembers = "EmployeeId"; Chart3.Series[0].XValueMember = "Department"; Chart3.ChartAreas["ChartArea3"].AxisY.Interval = 1; Chart3.DataBind(); } else if (ddlChart.SelectedValue == "Chart4") { //Chart4.Visible = true; //DataTable _dt4 = _objChartMasterManager.YearlyJoinChart().Tables[0]; //Chart4.DataSource = _dt4; //Chart4.Series[0].YValueMembers = "EmployeeId"; //Chart4.Series[0].IsValueShownAsLabel = true; //Chart4.Series[0].XValueMember = "JoiningDate"; //Chart4.ChartAreas["ChartArea4"].AxisY.Interval = 1; //Chart4.DataBind(); Chart4.Visible = true; DataTable _dt4 = _objChartMasterManager.YearlyJoinChart().Tables[0]; Chart4.DataSource = _dt4; Chart4.Series[0].YValueMembers = "EmployeeId"; // Chart4.Series[0].IsValueShownAsLabel = true; Chart4.Legends.IsUniqueName("ABC..............."); Chart4.Series[0].XValueMember = "JoiningDate"; Chart4.ChartAreas["ChartArea4"].AxisY.Interval = 2; Chart4.DataBind(); } } catch (Exception ex) { lblMsg.Text = "" + ex.Message.ToString(); } }
private void PopulateReport() { Chart1.DataSource = cn.fill("select b.Bok_Name,count(a.Book_ID) as count from Book_Data b,Add_Cart a where a.Book_ID=b.Book_ID AND b.Reg_ID='" + Session["Reg_ID"].ToString() + "' group by b.Bok_Name order by count(a.Book_ID) DESC"); Chart1.DataBind(); }
protected void ListarGrafico() { string IDE_OBJETIVO = string.Empty; if (ddlObejtivos.SelectedIndex == 0) { IDE_OBJETIVO = string.Empty; } else { IDE_OBJETIVO = ddlObejtivos.SelectedValue.ToString(); } BL_RRHH_DESEMPENIO_OBJETIVOS obj = new BL_RRHH_DESEMPENIO_OBJETIVOS(); DataTable dtResultado = new DataTable(); dtResultado.Clear(); dtResultado = obj.uspSEL_RRHH_DESEMPENIO_GRAFICO(lblPersonal.Text, Convert.ToInt32(Session["ANIO"]), IDE_OBJETIVO); DataTable dt = dtResultado; /* * string[] x = new string[dt.Rows.Count]; * int[] y = new int[dt.Rows.Count]; * * for (int i = 0; i < dt.Rows.Count; i++) * { * x[i] = dt.Rows[i]["OBJ"].ToString(); * y[i] = Convert.ToInt32(dt.Rows[i]["AVANCE"]); * } * Chart1.Series["Series1"].Points.DataBindXY(x, y); * * Chart1.Series[0].ChartType = SeriesChartType.Column; * Chart1.Series["Series1"].Label = "#PERCENT"; * Chart1.Series[0].LegendText = "#VALX"; * Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; * Chart1.Legends["Series1"].Enabled = true; * * * string[] x2 = new string[dt.Rows.Count]; * int[] y2 = new int[dt.Rows.Count]; * string[] l2 = new string[dt.Rows.Count]; * for (int i = 0; i < dt.Rows.Count; i++) * { * x2[i] = dt.Rows[i]["obj2"].ToString(); * y2[i] = Convert.ToInt32(dt.Rows[i]["TOTAL_TRANSCURRIDOS"]); * l2[i] = dt.Rows[i]["LEYENDA_TRANSCURRIDOS"].ToString(); * * } * Chart2.Series[0].Points.DataBindXY(x2, y2); * Chart2.Series[0].ToolTip = l2.ToString(); * Chart2.Series[0].IsValueShownAsLabel = true; * Chart2.Series[0].ChartType = SeriesChartType.Column; */ //Chart1.ResetAutoValues(); Chart1.Series[0].Points.Clear(); Chart1.Series["Series1"].Points.Clear(); Chart1.ResetAutoValues(); Chart1.DataSource = dtResultado; Chart1.DataBind(); Chart1.Series[0].IsValueShownAsLabel = true; //Chart1.Series["Series1"].Label = "#PERCENT"; Chart2.DataSource = dtResultado; Chart2.DataBind(); Chart2.Series[0].IsValueShownAsLabel = true; Chart2.Series[1].IsValueShownAsLabel = true; Chart2.Series[0].LegendText = "Días transcurridos"; Chart2.Series[1].LegendText = "Total de días"; }
public void data() { templist = analyticsBusiness.data(); foreach (var newitem in templist) { float amt = Convert.ToInt32(newitem.Amount); int expid = Convert.ToInt16(newitem.ExpenseTypeId); string expname = newitem.ExpenseTypeName; float newamt = addition(amt, expid, expname); } float totalamount = sum(); Session["Total"] = totalamount; List <TempEntity> temp = new List <TempEntity>(); temp = analyticsBusiness.ExpensetypeId(); foreach (var it in temp) { if (it.ExpenseTypeId == 1) { Session["aname"] = it.ExpenseTypeName; } else if (it.ExpenseTypeId == 2) { Session["cname"] = it.ExpenseTypeName; } else if (it.ExpenseTypeId == 3) { Session["dname"] = it.ExpenseTypeName; } else if (it.ExpenseTypeId == 4) { Session["ename"] = it.ExpenseTypeName; } else if (it.ExpenseTypeId == 5) { Session["fname"] = it.ExpenseTypeName; } else if (it.ExpenseTypeId == 6) { Session["gname"] = it.ExpenseTypeName; } else { Session["hname"] = it.ExpenseTypeName; } } foreach (var it in temp) { if (Convert.ToInt16(it.ExpenseTypeId) == 1) { float pera = Convert.ToInt32(Session["a"]) * 100; pera = pera / Convert.ToInt32(Session["Total"]); enty.ExpName = Session["aname"].ToString(); enty.percentage = pera; } else if (Convert.ToInt16(it.ExpenseTypeId) == 2) { float pera = Convert.ToInt32(Session["c"]) * 100; pera = pera / Convert.ToInt32(Session["Total"]); enty.ExpName = Session["cname"].ToString(); enty.percentage = pera; } else if (Convert.ToInt16(it.ExpenseTypeId) == 3) { float pera = Convert.ToInt32(Session["d"]) * 100; pera = pera / Convert.ToInt32(Session["Total"]); enty.ExpName = Session["dname"].ToString(); enty.percentage = pera; } else if (Convert.ToInt16(it.ExpenseTypeId) == 4) { float pera = Convert.ToInt32(Session["e"]) * 100; pera = pera / Convert.ToInt32(Session["Total"]); enty.ExpName = Session["ename"].ToString(); enty.percentage = pera; } else if (Convert.ToInt16(it.ExpenseTypeId) == 5) { float pera = Convert.ToInt32(Session["f"]) * 100; pera = pera / Convert.ToInt32(Session["Total"]); enty.ExpName = Session["fname"].ToString(); enty.percentage = pera; } else if (Convert.ToInt16(it.ExpenseTypeId) == 6) { float pera = Convert.ToInt32(Session["g"]) * 100; pera = pera / Convert.ToInt32(Session["Total"]); enty.ExpName = Session["gname"].ToString(); enty.percentage = pera; } else { float pera = Convert.ToInt32(Session["h"]) * 100; pera = pera / Convert.ToInt32(Session["Total"]); enty.ExpName = Session["hname"].ToString(); enty.percentage = pera; } entys.Add(new AnalyticsEntity { ExpName = enty.ExpName, percentage = enty.percentage }); } Session["entity"] = entys; Chart1.DataSource = analyticsBusiness.GetPieChartData(entys); // List<ChartData> data = SamplesBrowser.Models.ChartData.GetPieChartData(entys); Chart1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { SqlCommand cmd_1 = new SqlCommand("select 'Students' stud_id , COUNT(stud_id) as Total from student Union select 'Finance Staffs' staff_id, COUNT(staff_id) as Total from staff where staff_type = 'finance' Union select 'Teachers' staff_id, COUNT(staff_id) as Total from staff where staff_type = 'teacher' Union select 'Admin Staffs' staff_id, COUNT(staff_id) as Total from staff where staff_type = 'admin' union select 'Parents' parent_id, COUNT(parent_id) as Total from parent", con); SqlCommand cmd_2 = new SqlCommand("select 'Accepted' id ,COUNT(id) as Total from admissionapply where admisionstatus = 'accepted' union select 'Rejected' id ,COUNT(id) as Total from admissionapply where admisionstatus = 'rejected'", con); con.Open(); SqlDataReader myReader = cmd_1.ExecuteReader(); Chart1.Series[0].XValueMember = "stud_id"; Chart1.Series[0].YValueMembers = "Total"; Chart1.Series[0].Label = "#VAL"; Chart1.Series[0].LegendText = "#VALX"; Chart1.DataSource = myReader; Chart1.DataBind(); myReader.Close(); myReader = null; myReader = cmd_2.ExecuteReader(); cht_Cat.Series[0].XValueMember = "id"; cht_Cat.Series[0].YValueMembers = "Total"; cht_Cat.Series[0].Label = "#VAL"; //cht_Cat.Series[0].LegendText = "#VALX"; cht_Cat.DataSource = myReader; cht_Cat.DataBind(); myReader.Close(); List <String> myNotice = new List <String>(); int staff = int.Parse(Session["staffid"].ToString()); //con.Open(); SqlCommand cmd = new SqlCommand("SELECT TOP 6 * FROM staff_notice where staffid=" + staff + " ORDER BY id DESC", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr.HasRows) { myNotice.Add(dr[1].ToString()); count++; } } if (count >= 1) { notices1.Text = myNotice[0].ToString(); } if (count >= 2) { notices1.Text = myNotice[0].ToString(); notices2.Text = myNotice[1].ToString(); } if (count >= 3) { notices1.Text = myNotice[0].ToString(); notices2.Text = myNotice[1].ToString(); notices3.Text = myNotice[2].ToString(); } if (count >= 4) { notices1.Text = myNotice[0].ToString(); notices2.Text = myNotice[1].ToString(); notices3.Text = myNotice[2].ToString(); notices4.Text = myNotice[3].ToString(); } if (count >= 5) { notices1.Text = myNotice[0].ToString(); notices2.Text = myNotice[1].ToString(); notices3.Text = myNotice[2].ToString(); notices4.Text = myNotice[3].ToString(); notices5.Text = myNotice[4].ToString(); } if (count >= 6) { notices1.Text = myNotice[0].ToString(); notices2.Text = myNotice[1].ToString(); notices3.Text = myNotice[2].ToString(); notices4.Text = myNotice[3].ToString(); notices5.Text = myNotice[4].ToString(); notices6.Text = myNotice[5].ToString(); } con.Close(); }
protected void CreateTable(object sender, EventArgs e) { using (LastADEntities b = new LastADEntities()) { string selecteditem = DropDownList2.SelectedItem.Text.ToString(); ItemList idd = new ItemList(); //To get item id idd = b.ItemLists.Where(p => p.Description.Equals(selecteditem)).First(); String idddd = idd.ItemId; int NumOfDepts = 0; ArrayList DeptSelected = new ArrayList(); //To get all the departments chosen by user for (int i = 0; i < DeptList.Items.Count; i++) { if (DeptList.Items[i].Selected) { String temp = DeptList.Items[i].Value.ToString(); Department dd = b.Departments.Where(p => p.DepartmentName.Contains(temp)).First(); String temp2 = dd.DepartmentCode; DeptSelected.Add(temp2); NumOfDepts++; } } Chart1.ChartAreas.Add("ChartArea2"); var sd = yearrange[0]; var ed = yearrange[1]; //Setting up the Chart properties Chart1.ChartAreas[0].AxisX.Title = "Year"; Chart1.ChartAreas[0].AxisY.Title = "Quantity Ordered"; Chart1.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid; Chart1.Legends.Add("QuantityOrdered"); Title title = new Title(); title.Font = new Font("Arial", 14, FontStyle.Bold); title.Text = "Trend Analysis of Quantity of " + idd.Description + " Ordered"; Chart1.ChartAreas[0].AxisX.Minimum = sd; Chart1.ChartAreas[0].AxisX.Maximum = ed; Chart1.Titles.Add(title); int z = 0; //To get all the datapoints that match the conditions chosen by user foreach (string ddept in DeptSelected) { var xy = b.Transactions.Where(p => p.ItemId.Contains(idddd) && p.EntryDate.Value.Year >= sd && p.EntryDate.Value.Year <= ed) .Join(b.Requisitions, m => m.Requid, f => f.RequId, (m, f) => new { Requid = m.Requid, EmployeeId = f.EmployeeId, m.EntryDate, m.Quantity }) .Join(b.Employees.Where(p => p.DepartmentCode.Equals(ddept)), q => q.EmployeeId, p => p.UserId, (q, p) => new { q.EntryDate, p.DepartmentCode, q.Quantity }) .GroupBy(n => n.EntryDate.Value.Year) .Select(g => new { b = g.Key, a = g.Sum(a => a.Quantity) }).ToList(); List <int> xcoor = new List <int>(); List <int> ycoor = new List <int>(); //Converting datapoints into coordinates for the chart for (int q = sd; q <= ed; q++) { for (int p = 0; p < xy.Count; p++) { if (q == xy[p].b) { xcoor.Add(q); ycoor.Add((int)(xy[p].a)); } //else //{ // xcoor.Add(q); // ycoor.Add(0); //} } } Chart1.Series.Add(ddept.ToString()); Chart1.Series[z].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line; Chart1.Series[z].Points.DataBindXY(xcoor, ycoor); Chart1.Series[z].IsVisibleInLegend = true; Chart1.Series[z].IsValueShownAsLabel = true; Chart1.Series[z].BorderWidth = 3; Chart1.Series[z].ToolTip = "Quantity Ordered: #VALY"; Chart1.Series[z].Font = new System.Drawing.Font("Arial", 12); Chart1.Series[z]["LabelStyle"] = "Top"; Chart1.Series[z].LabelBackColor = Color.LightCyan; z++; Chart1.DataBind(); } } }
private void _setGraph(DataSet dsGrph) { DundasCharts.DundasChartBase(Chart1, ChartImageType.Flash, 800, 280 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); if (rdoGbn.SelectedValue == "HS") // 시간대별 누적공급량현황 { DataTable dtSply = dsGrph.Tables[0].Clone(); DataRow drSply; string strMM = ""; double dblCQtn = 0.00; double dblPQtn = 0.00; for (int i = 0; i < dsGrph.Tables[0].Rows.Count; i++) { drSply = dtSply.NewRow(); strMM = dsGrph.Tables[0].Rows[i][0].ToString(); dblCQtn += Convert.ToDouble(dsGrph.Tables[0].Rows[i]["CD_QTN"].ToString()); dblPQtn += Convert.ToDouble(dsGrph.Tables[0].Rows[i]["PD_QTN"].ToString()); drSply[0] = strMM; drSply[1] = dblCQtn; drSply[2] = dblPQtn; dtSply.Rows.Add(drSply); } Chart1.DataSource = dtSply.DefaultView; Series series1 = DundasCharts.CreateSeries(Chart1, "Series1", "Default", "금일", null, SeriesChartType.Column, 1, Color.FromArgb(0x5A, 0x7D, 0xDE), Color.FromArgb(0x4A, 0x58, 0x7E), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Series series2 = DundasCharts.CreateSeries(Chart1, "Series2", "Default", "전일", null, SeriesChartType.Column, 1, Color.FromArgb(0xFF, 0x8A, 0x00), Color.FromArgb(0xD7, 0x41, 0x01), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); series1.ValueMembersY = "CD_QTN"; series2.ValueMembersY = "PD_QTN"; series1.ValueMemberX = "HH"; Chart1.ChartAreas[Chart1.Series[series1.Name].ChartArea].AxisX.Interval = 2; Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#,###"; Chart1.ChartAreas[0].AxisY2.Enabled = AxisEnabled.False; DundasAnimations.DundasChartBase(Chart1, AnimationTheme.None, -1, -1, false, 1); DundasAnimations.GrowingAnimation(Chart1, series1, 0.0, 3.0, true); DundasAnimations.GrowingAnimation(Chart1, series2, 3.0, 4.0, true); Chart1.DataBind(); } else // 일자별 공급량 { Chart1.DataSource = dsGrph.Tables[0].DefaultView; Series series1 = DundasCharts.CreateSeries(Chart1, "Series1", "Default", "계획", null, SeriesChartType.Column, 1, Color.FromArgb(0x5A, 0x7D, 0xDE), Color.FromArgb(0x4A, 0x58, 0x7E), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Series series2 = DundasCharts.CreateSeries(Chart1, "Series2", "Default", "실적", null, SeriesChartType.Column, 1, Color.FromArgb(0xFF, 0x8A, 0x00), Color.FromArgb(0xD7, 0x41, 0x01), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Series series3 = DundasCharts.CreateSeries(Chart1, "Series3", "Default", "달성율", null, SeriesChartType.Line, 3, Color.FromArgb(0x00, 0xC4, 0xCB), Color.FromArgb(0x00, 0xC4, 0xCB), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); series1.ValueMembersY = "QTN_PLAN"; series2.ValueMembersY = "QTN_ACTL"; series3.ValueMembersY = "QTN_RATE"; series1.ValueMemberX = "GUBUN"; string strChartArea = Chart1.Series[series3.Name].ChartArea; series3.YAxisType = AxisType.Secondary; Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#,###"; Chart1.ChartAreas[strChartArea].AxisY2.LabelStyle.Format = "P0"; Chart1.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True; Chart1.ChartAreas[Chart1.Series[series1.Name].ChartArea].AxisX.Interval = 1; DundasAnimations.DundasChartBase(Chart1, AnimationTheme.None, -1, -1, false, 1); DundasAnimations.GrowingAnimation(Chart1, series1, 0.0, 3.0, true); DundasAnimations.GrowingAnimation(Chart1, series2, 3.0, 4.0, true); DundasAnimations.GrowingAnimation(Chart1, series3, 4.0, 6.0, true); Chart1.DataBind(); } }
private void _setGraph(DataSet dsLine, DataSet dsPie) { string strCYY = cboYY.SelectedValue; string strFYY = (int.Parse(strCYY) - 2).ToString(); string strPYY = (int.Parse(strCYY) - 1).ToString(); string strCMM = cboMM.SelectedValue; //strCYY = strCYY + "년"; // 년도별 매출량 그래프 DundasCharts.DundasChartBase(Chart1, ChartImageType.Flash, 800, 250 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); // 전년매출비중 파이그래프 DundasCharts.DundasChartBase(Chart2, ChartImageType.Flash, 265, 200 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); // 당년매출비중 파이그래프 DundasCharts.DundasChartBase(Chart3, ChartImageType.Flash, 265, 200 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); // 익년매출비중 파이그래프 DundasCharts.DundasChartBase(Chart4, ChartImageType.Flash, 265, 200 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); //================================================================== LINE GRAPH Series[] oasrType = new Series[dsLine.Tables[0].Rows.Count]; int intLP = 0; foreach (DataRow row in dsLine.Tables[0].Rows) { oasrType[intLP] = DundasCharts.CreateSeries(Chart1, "Series" + intLP.ToString(), Chart1.ChartAreas[0].Name, row["YY"].ToString(), null, SeriesChartType.Line, 3, GetChartColor(intLP), GetChartColor(intLP), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); for (int colIndex = 1; colIndex < dsLine.Tables[0].Columns.Count; colIndex++) { // For each column (column 1 and onward) add the value as a point string columnName = dsLine.Tables[0].Columns[colIndex].ColumnName; double YVal = double.Parse(row[columnName].ToString()); Chart1.Series[oasrType[intLP].Name].Points.AddXY(columnName, YVal); } intLP += 1; } DundasAnimations.DundasChartBase(Chart1, AnimationTheme.None, -1, -1, false, 1); for (int i = 0; i < oasrType.Length; i++) { oasrType[i].MarkerStyle = GetMarkerStyle(i); oasrType[i].MarkerColor = GetChartColor(i); oasrType[i].MarkerBorderColor = GetMarkerBorderColor(i); if (i == 0) { DundasAnimations.GrowingAnimation(Chart1, oasrType[i], 0.5, 1.0, false); } else { DundasAnimations.GrowingAnimation(Chart1, oasrType[i], i + 0.1, 1.0, true); } } Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#,###"; Chart1.DataSource = dsLine.Tables[0].DefaultView; Chart1.DataBind(); //=================================================================== PIE GRAPH Series series2 = DundasCharts.CreateSeries(Chart2, "Series2", "Default", "매출비중", null, SeriesChartType.Pie, 1, Color.FromArgb(0x5A, 0x7D, 0xDE), Color.FromArgb(0x4A, 0x58, 0x7E), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Series series3 = DundasCharts.CreateSeries(Chart3, "Series3", "Default", "매출비중", null, SeriesChartType.Pie, 1, Color.FromArgb(0x5A, 0x7D, 0xDE), Color.FromArgb(0x4A, 0x58, 0x7E), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Series series4 = DundasCharts.CreateSeries(Chart4, "Series4", "Default", "매출비중", null, SeriesChartType.Pie, 1, Color.FromArgb(0x5A, 0x7D, 0xDE), Color.FromArgb(0x4A, 0x58, 0x7E), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); series2.FontColor = Color.White; series3.FontColor = Color.White; series4.FontColor = Color.White; double dblPTAmt = 0.00; double dblCTAmt = 0.00; double dblNTAmt = 0.00; double dblPRate = 0.00; double dblCRate = 0.00; double dblNRate = 0.00; double dblEtcRate = 0.00; DataRow[] drPPie = dsPie.Tables[0].Select("YY='" + strFYY + "'", "S_RSLT DESC"); DataRow[] drCPie = dsPie.Tables[0].Select("YY='" + strPYY + "'", "S_RSLT DESC"); DataRow[] drNPie = dsPie.Tables[0].Select("YY='" + strCYY + "'", "S_RSLT DESC"); for (int i = 0; i < drPPie.Length; i++) { dblPTAmt += double.Parse(drPPie[i]["S_RSLT"].ToString()); } for (int i = 0; i < drCPie.Length; i++) { dblCTAmt += double.Parse(drCPie[i]["S_RSLT"].ToString()); } for (int i = 0; i < drNPie.Length; i++) { dblNTAmt += double.Parse(drNPie[i]["S_RSLT"].ToString()); } dblEtcRate = 0.00; int intLoop = 0; string strLabel = ""; for (intLoop = 0; intLoop < drPPie.Length; intLoop++) { dblPRate = (dblPTAmt == 0) ? 0 : (double.Parse(drPPie[intLoop]["S_RSLT"].ToString()) / dblPTAmt) * 100; if (intLoop < 3) { strLabel = drPPie[intLoop]["SGBUN_NM"].ToString() + "(" + Math.Round(dblPRate, 1).ToString() + "%)"; Chart2.Series[series2.Name].Points.AddXY(strLabel, dblPRate); } else { dblEtcRate += dblPRate; } } if (drPPie.Length > 3) { Chart2.Series[series2.Name].Points.AddXY("기타", dblEtcRate); } dblEtcRate = 0.00; for (intLoop = 0; intLoop < drCPie.Length; intLoop++) { dblCRate = (dblCTAmt == 0) ? 0 : (double.Parse(drCPie[intLoop]["S_RSLT"].ToString()) / dblCTAmt) * 100; if (intLoop < 3) { strLabel = drCPie[intLoop]["SGBUN_NM"].ToString() + "(" + Math.Round(dblCRate, 1).ToString() + "%)"; Chart3.Series[series3.Name].Points.AddXY(strLabel, dblCRate); } else { dblEtcRate += dblCRate; } } if (drCPie.Length > 3) { Chart3.Series[series3.Name].Points.AddXY("기타", dblEtcRate); } dblEtcRate = 0.00; for (intLoop = 0; intLoop < drNPie.Length; intLoop++) { dblNRate = (dblNTAmt == 0) ? 0 :(double.Parse(drNPie[intLoop]["S_RSLT"].ToString()) / dblNTAmt) * 100; if (intLoop < 3) { strLabel = drNPie[intLoop]["SGBUN_NM"].ToString() + "(" + Math.Round(dblNRate, 1).ToString() + "%)"; Chart4.Series[series4.Name].Points.AddXY(strLabel, dblNRate); } else { dblEtcRate += dblNRate; } } if (drNPie.Length > 3) { Chart4.Series[series4.Name].Points.AddXY("기타", dblEtcRate); } Chart2.Titles.Add(strFYY); Chart3.Titles.Add(strPYY); Chart4.Titles.Add(strCYY); Chart2.Titles[0].Text = (strFYY + "년"); Chart3.Titles[0].Text = (strPYY + "년"); Chart4.Titles[0].Text = (strCYY + "년"); }
protected void Page_Load(object sender, EventArgs e) { Chart.Series["Series1"].YValueMembers = "# of Activities"; Chart.Series["Series1"].XValueMember = "# of Weeks"; Chart1.Series["Series1"].YValueMembers = "# of Activities"; Chart1.Series["Series1"].XValueMember = "# of Weeks"; Chart2.Series["Series1"].YValueMembers = "# of Activities"; Chart2.Series["Series1"].XValueMember = "# of Weeks"; Chart3.Series["Series1"].YValueMembers = "# of Activities"; Chart3.Series["Series1"].XValueMember = "# of Weeks"; try { Chart.DataSource = dbObject.GetActivityData(((SessionData)Session["User_Data"])._loginID, 1, "strength"); Chart1.DataSource = dbObject.GetActivityData(((SessionData)Session["User_Data"])._loginID, 1, "cardio"); Chart2.DataSource = dbObject.GetActivityData(((SessionData)Session["User_Data"])._loginID, 1, "health"); Chart3.DataSource = dbObject.GetActivityData(((SessionData)Session["User_Data"])._loginID, 1, "sleep"); } catch (NullReferenceException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); Response.Redirect("Login.aspx"); } Chart.DataBind(); Chart1.DataBind(); Chart2.DataBind(); Chart3.DataBind(); showInjuries(); showWorkout(); if (!IsPostBack) { dictInjury.Add("Head", 0); dictInjury.Add("Right Shoulder", 0); dictInjury.Add("Right Elbow", 0); dictInjury.Add("Right Hand", 0); dictInjury.Add("Right Knee", 0); dictInjury.Add("Right Foot", 0); dictInjury.Add("Abdomen", 0); dictInjury.Add("Left Shoulder", 0); dictInjury.Add("Left Elbow", 0); dictInjury.Add("Left Knee", 0); dictInjury.Add("Left Foot", 0); dictInjury.Add("Neck", 0); dictInjury.Add("Left Shoulder Blade", 0); dictInjury.Add("Left Forearm", 0); dictInjury.Add("Lumbar", 0); dictInjury.Add("Thoracic", 0); dictInjury.Add("Left Heel", 0); dictInjury.Add("Right Heel", 0); dictInjury.Add("Right Shoulder Blade", 0); dictInjury.Add("Right Forearm", 0); dictInjury.Add("Left Hand", 0); } foreach (string name in HealthInputSessionVariables.Activity.Keys) { foreach (float value in HealthInputSessionVariables.Activity.Values) { Label myLabel = new Label(); myLabel.ID = "lbl" + name; myLabel.Text = value.ToString(); } } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlCommand cmd; string del = "delete from tfuel"; cmd = new SqlCommand(del, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); string dy = System.DateTime.Now.ToString("yyyy"); string dm = System.DateTime.Now.ToString("MM"); string dd = System.DateTime.Now.ToString("dd"); int dd1 = Convert.ToInt32(dd); dd1 = Convert.ToInt32("0"); int year = Convert.ToInt32(dy); int month = Convert.ToInt32(dm); int end = System.DateTime.DaysInMonth(year, month); for (int j = 1; j <= end; j++) { int dd2 = dd1 + j; string start = dy + "-" + dm + "-" + dd2.ToString("00"); Label8.Text = start; string sel = "select amt,date,vehicleno from fueldetails where vehicleno='" + DropDownList1.SelectedItem.Text + "' AND Date = '" + start + "'"; SqlDataAdapter da1 = new SqlDataAdapter(sel, con); DataSet ds1 = new DataSet(); da1.Fill(ds1); if (ds1.Tables[0].Rows.Count > 0) { string veh = ds1.Tables[0].Rows[0][2].ToString(); string dr = "select name from driverdetails where vehicleno='" + veh + "'"; SqlDataAdapter dat = new SqlDataAdapter(dr, con); DataSet dst = new DataSet(); dat.Fill(dst); if (dst.Tables[0].Rows.Count > 0) { string dri = dst.Tables[0].Rows[0][0].ToString(); string ins1 = "insert into tempfuel values('" + dri + "','" + ds1.Tables[0].Rows[0][2].ToString() + "','" + ds1.Tables[0].Rows[0][0].ToString() + "','" + ds1.Tables[0].Rows[0][1].ToString() + "')"; cmd = new SqlCommand(ins1, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } string ins = "insert into tfuel values('" + start + "','" + ds1.Tables[0].Rows[0][0].ToString() + "')"; cmd = new SqlCommand(ins, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } else { string ins = "insert into tfuel values('" + start + "','0')"; cmd = new SqlCommand(ins, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } SqlDataAdapter da; DataSet ds = new DataSet(); string ol = "select drivername,VehicleNo,sum(Amt) as Amt,date from tempfuel where vehicleno='" + DropDownList1.SelectedItem.Text + "' group by drivername,VehicleNo,Amt,date"; da = new SqlDataAdapter(ol, con); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { DropDownList2.Items.Clear(); DropDownList2.Items.Add("--Select--"); DropDownList2.Items.Add("Date"); Panel1.Visible = true; Panel2.Visible = false; DropDownList1.BorderColor = System.Drawing.Color.Empty; Panel3.Visible = true; GridView1.DataSource = ds; GridView1.DataBind(); int i = ds.Tables[0].Rows.Count; int tot = 0; while (i > 0) { tot += (Convert.ToInt32(ds.Tables[0].Rows[i - 1][2].ToString())); i--; } LabelTotal.Text = tot.ToString(); Label4.Visible = true; LabelTotal.Visible = true; string sel1 = "select dates,amount from tfuel"; da = new SqlDataAdapter(sel1, con); da.Fill(ds); Chart1.DataSource = ds; Chart1.Series["Series1"].XValueMember = "dates"; Chart1.Series["Series1"].YValueMembers = "amount"; Chart1.DataBind(); } else if (DropDownList1.Text == "--Select Vehicle--") { DropDownList2.Items.Clear(); DropDownList2.Items.Add("--Select--"); DropDownList2.Items.Add("Date"); DropDownList1.BorderColor = System.Drawing.Color.Red; DropDownList2.BorderColor = System.Drawing.Color.Empty; Panel3.Visible = false; Label4.Visible = false; LabelTotal.Text = ""; LabelTotal.Visible = false; Panel1.Visible = false; Panel2.Visible = false; } else { DropDownList2.Items.Clear(); DropDownList2.Items.Add("--Select--"); DropDownList2.Items.Add("Date"); Panel1.Visible = false; Panel2.Visible = false; Panel3.Visible = false; Label4.Visible = false; LabelTotal.Text = ""; LabelTotal.Visible = false; DropDownList1.BorderColor = System.Drawing.Color.Empty; Page.ClientScript.RegisterStartupScript(GetType(), "msgtype()", "alert('No Data Available !!!')", true); } }
private void displayGraph() { try { DateTime tdate1 = DateTime.Now; string tdate2 = tdate1.ToString("yyyy-MM-dd"); DateTime fdate1 = tdate1.AddYears(-1); string fdate2 = fdate1.ToString("yyyy-MM-dd"); DataTable dtdisp = new DataTable(); int custid = Convert.ToInt32(Session["Customer_ID"]); // DataTable dtsch = g.ReturnData("Select (DATENAME(YY, last_calibration_date)+'-'+ Left(DATENAME(MM, last_calibration_date),3) )as Month, (Select Count(calibration_schedule_id) from calibration_schedule_TB where last_calibration_date >='" + fdate1 + "' and last_calibration_date <='" + tdate1 + "' and DATENAME(MONTH, last_calibration_date)=DATENAME(MONTH, cas.last_calibration_date) and DATENAME(YY, last_calibration_date)=DATENAME(YY,cas.last_calibration_date) and customer_id='" + custid + "')as Scount from calibration_schedule_TB as cas where cas.last_calibration_date >='" + fdate1 + "' and cas.last_calibration_date <='" + tdate1 + "' and cas.customer_id='" + custid + "' order by last_calibration_date"); DataTable dtsch = g.ReturnData("Select concat_WS('-',EXTRACT(YEAR FROM cas.last_calibration_date), DATE_FORMAT(cas.last_calibration_date,'%b') ) as Month, (Select Count(calibration_schedule_id) from calibration_schedule_TB where DATE_FORMAT(last_calibration_date, '%Y-%m-%d') >='" + fdate2 + "' and DATE_FORMAT(last_calibration_date, '%Y-%m-%d') <='" + tdate2 + "' and MONTHNAME(last_calibration_date) =MONTHNAME(cas.last_calibration_date) and EXTRACT(YEAR FROM last_calibration_date)=EXTRACT(YEAR FROM cas.last_calibration_date) and customer_id='" + custid + "') as Scount from calibration_schedule_TB as cas where DATE_FORMAT(cas.last_calibration_date, '%Y-%m-%d') >='" + fdate2 + "' and DATE_FORMAT(cas.last_calibration_date, '%Y-%m-%d') <='" + tdate2 + "' and cas.customer_id='" + custid + "' order by last_calibration_date"); for (int i = 0; i < dtsch.Rows.Count; i++) { int cnt = 0; if (ViewState["dtdisp"] != null) { dtdisp = (DataTable)ViewState["dtdisp"]; } else { DataColumn Month = dtdisp.Columns.Add("Month"); DataColumn Scount = dtdisp.Columns.Add("Scount"); DataColumn Tcount = dtdisp.Columns.Add("Tcount"); } DataRow dr = dtdisp.NewRow(); dr[0] = dtsch.Rows[i]["Month"].ToString(); dr[1] = dtsch.Rows[i]["Scount"].ToString(); dr[2] = 0; for (int j = 0; j < dtdisp.Rows.Count; j++) { if (dtdisp.Rows[j]["Month"].ToString() == dtsch.Rows[i]["Month"].ToString()) { cnt++; } } if (cnt == 0) { dtdisp.Rows.Add(dr); } ViewState["dtdisp"] = dtdisp; } // DataTable dttch = g.ReturnData("Select (DATENAME(YY, calibration_date)+'-'+ Left(DATENAME(MM, calibration_date),3) )as Month, (Select Count(calibration_transaction_id) from calibration_transaction_TB where calibration_date >= '" + fdate1 + "' and calibration_date <='" + tdate1 + "' and DATENAME(MONTH, calibration_date)=DATENAME(MONTH,cts.calibration_date) and DATENAME(YY, calibration_date)=DATENAME(YY,cts.calibration_date) and customer_id='" + custid + "')as Tcount from calibration_transaction_TB cts where cts.calibration_date >='" + fdate1 + "' and cts.calibration_date <='" + tdate1 + "' and cts.customer_id='" + custid + "' order by calibration_date"); DataTable dttch = g.ReturnData("Select concat_WS('-',EXTRACT(YEAR FROM cts.calibration_date), DATE_FORMAT(cts.calibration_date,'%b') ) as Month, (Select Count(calibration_transaction_id) from calibration_transaction_TB where DATE_FORMAT(calibration_date, '%Y-%m-%d') >= '" + fdate2 + "' and DATE_FORMAT(calibration_date, '%Y-%m-%d') <='" + tdate2 + "' and MONTHNAME(calibration_date)= MONTHNAME(cts.calibration_date) and EXTRACT(YEAR FROM calibration_date)=EXTRACT(YEAR FROM cts.calibration_date) and customer_id=" + custid + ") as Tcount from calibration_transaction_TB cts where DATE_FORMAT(cts.calibration_date, '%Y-%m-%d') >='" + fdate2 + "' and DATE_FORMAT(cts.calibration_date, '%Y-%m-%d') <='" + tdate2 + "' and cts.customer_id=" + custid + " order by calibration_date"); for (int j = 0; j < dttch.Rows.Count; j++) { int cnt = 0; int cnt1 = 0; if (ViewState["dtdisp"] != null) { dtdisp = (DataTable)ViewState["dtdisp"]; } for (int k = 0; k < dtdisp.Rows.Count; k++) { if (dtdisp.Rows[k]["Month"].ToString() == dttch.Rows[j]["Month"].ToString()) { dtdisp.Rows[k]["Tcount"] = dttch.Rows[j]["Tcount"]; cnt++; } } if (cnt == 0) { if (ViewState["dtdisp"] != null) { dtdisp = (DataTable)ViewState["dtdisp"]; } else { DataColumn Month = dtdisp.Columns.Add("Month"); DataColumn Scount = dtdisp.Columns.Add("Scount"); DataColumn Tcount = dtdisp.Columns.Add("Tcount"); } DataRow dr = dtdisp.NewRow(); dr[0] = dttch.Rows[j]["Month"].ToString(); dr[1] = 0; dr[2] = dttch.Rows[j]["Tcount"].ToString(); for (int l = 0; l < dtdisp.Rows.Count; l++) { if (dtdisp.Rows[l]["Month"].ToString() == dttch.Rows[j]["Month"].ToString()) { cnt1++; } } if (cnt1 == 0) { dtdisp.Rows.Add(dr); } ViewState["dtdisp"] = dtdisp; } } if (dtdisp.Rows.Count > 0) { Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column; Chart1.Series["Series1"].XValueMember = "Month"; Chart1.Series["Series1"].YValueMembers = "SCount"; Chart1.Series["Series2"].XValueMember = "Month"; Chart1.Series["Series2"].YValueMembers = "TCount"; Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = true; Chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = true; //Chart1.Series["Series1"].ToolTip = #VALX; Chart1.Series["Series1"].IsValueShownAsLabel = true; // Chart1.ChartAreas[0].AxisX.IntervalAutoMode = System.Windows.Charting.IntervalAutoMode.VariableCount; Chart1.DataSource = dtdisp; Chart1.DataBind(); } Session["dtdisp1"] = dtdisp; dtdisp = null; ViewState["dtdisp"] = null; } catch (Exception ex) { Logger.Error(ex.Message); // g.ShowMessage(this.Page, ex.Message); } }
public void acceptchartid() { if (ViewState["chartId"] != null) { string a = "SELECT * FROM [dvs_Chart] WHERE [ChartId] = " + chartId; DataTable t = DatabaseClass.ExecuteQuery(a); //sets the chart title Chart1.Titles["ucFinalTitle"].Text = t.Rows[0][3].ToString(); //for enalbling the legend Chart1.Legends["ChartLegend"].Enabled = true; // enablelegend; Chart1.Series["Series1"].LegendText = "LegendTitle"; #region datasource //Set the datasource try { Chart1.DataSource = DatabaseClass.getTableDatafromTable(t.Rows[0][1].ToString()); Chart1.DataBind(); } catch (Exception) { //Do what to do with the error } #endregion //set axis interval Chart1.ChartAreas["Chart1Area"].AxisX.Interval = 1; //Type Of Chart #region chartType Region if (t.Rows[0][4].ToString() == "Column") { Chart1.Series["Series1"].ChartType = SeriesChartType.Column; } if (t.Rows[0][4].ToString() == "Bar") { Chart1.Series["Series1"].ChartType = SeriesChartType.Bar; } if (t.Rows[0][4].ToString() == "Stacked") { Chart1.Series["Series1"].ChartType = SeriesChartType.StackedBar; } if (t.Rows[0][4].ToString() == "Pie") { Chart1.Series["Series1"].ChartType = SeriesChartType.Pie; } if (t.Rows[0][4].ToString() == "Area") { Chart1.Series["Series1"].ChartType = SeriesChartType.Area; } if (t.Rows[0][4].ToString() == "BoxPlot") { Chart1.Series["Series1"].ChartType = SeriesChartType.BoxPlot; } if (t.Rows[0][4].ToString() == "Line") { Chart1.Series["Series1"].ChartType = SeriesChartType.Line; } if (t.Rows[0][4].ToString() == "Point") { Chart1.Series["Series1"].ChartType = SeriesChartType.Point; } if (t.Rows[0][4].ToString() == "Spline") { Chart1.Series["Series1"].ChartType = SeriesChartType.Spline; } #endregion #region DataBound To Axises //xvaluemember Chart1.Series["Series1"].XValueMember = t.Rows[0][5].ToString(); //yvaluemember Chart1.Series["Series1"].YValueMembers = t.Rows[0][7].ToString(); #endregion #region Axis Titles //value shown as label Chart1.Series["Series1"].IsValueShownAsLabel = true; //xaxis title Chart1.ChartAreas["Chart1Area"].Axes[0].Title = t.Rows[0][6].ToString(); //yaxis title Chart1.ChartAreas["Chart1Area"].Axes[1].Title = t.Rows[0][8].ToString(); #endregion #region legend text //Legend Text Chart1.Series["Series1"].LegendText = t.Rows[0][5].ToString(); #endregion #region chart BackGround color if (t.Rows[0][9].ToString() == "Black") { Chart1.BackColor = System.Drawing.Color.Black; } if (t.Rows[0][9].ToString() == "Blue") { Chart1.BackColor = System.Drawing.Color.Blue; } if (t.Rows[0][9].ToString() == "Green") { Chart1.BackColor = System.Drawing.Color.Green; } if (t.Rows[0][9].ToString() == "Red") { Chart1.BackColor = System.Drawing.Color.Red; } if (t.Rows[0][9].ToString() == "Yellow") { Chart1.BackColor = System.Drawing.Color.Yellow; } if (t.Rows[0][9].ToString() == "Pink") { Chart1.BackColor = System.Drawing.Color.Pink; } if (t.Rows[0][9].ToString() == "AliceBlue") { Chart1.BackColor = System.Drawing.Color.AliceBlue; } if (t.Rows[0][9].ToString() == "Aqua") { Chart1.BackColor = System.Drawing.Color.Aqua; } if (t.Rows[0][9].ToString() == "Aquamarine") { Chart1.BackColor = System.Drawing.Color.Aquamarine; } if (t.Rows[0][9].ToString() == "Brown") { Chart1.BackColor = System.Drawing.Color.Brown; } if (t.Rows[0][9].ToString() == "Chocolate") { Chart1.BackColor = System.Drawing.Color.Chocolate; } if (t.Rows[0][9].ToString() == "DarkBlue") { Chart1.BackColor = System.Drawing.Color.DarkBlue; } if (t.Rows[0][9].ToString() == "DarkCyan") { Chart1.BackColor = System.Drawing.Color.DarkCyan; } if (t.Rows[0][9].ToString() == "Darkviolet") { Chart1.BackColor = System.Drawing.Color.DarkViolet; } if (t.Rows[0][9].ToString() == "Ivory") { Chart1.BackColor = System.Drawing.Color.Ivory; } if (t.Rows[0][9].ToString() == "Azure") { Chart1.BackColor = System.Drawing.Color.Azure; } if (t.Rows[0][9].ToString() == "DimGray") { Chart1.BackColor = System.Drawing.Color.DimGray; } #endregion #region chart Series Color if (t.Rows[0][10].ToString() == "Black") { Chart1.Series["Series1"].Color = System.Drawing.Color.Black; } if (t.Rows[0][10].ToString() == "Blue") { Chart1.Series["Series1"].Color = System.Drawing.Color.Blue; } if (t.Rows[0][10].ToString() == "Green") { Chart1.Series["Series1"].Color = System.Drawing.Color.Green; } if (t.Rows[0][10].ToString() == "Red") { Chart1.Series["Series1"].Color = System.Drawing.Color.Red; } if (t.Rows[0][10].ToString() == "Yellow") { Chart1.Series["Series1"].Color = System.Drawing.Color.Yellow; } if (t.Rows[0][10].ToString() == "Pink") { Chart1.Series["Series1"].Color = System.Drawing.Color.Pink; } if (t.Rows[0][10].ToString() == "AliceBlue") { Chart1.Series["Series1"].Color = System.Drawing.Color.AliceBlue; } if (t.Rows[0][10].ToString() == "Aqua") { Chart1.Series["Series1"].Color = System.Drawing.Color.Aqua; } if (t.Rows[0][10].ToString() == "Aquamarine") { Chart1.Series["Series1"].Color = System.Drawing.Color.Aquamarine; } if (t.Rows[0][10].ToString() == "Brown") { Chart1.Series["Series1"].Color = System.Drawing.Color.Brown; } if (t.Rows[0][10].ToString() == "Chocolate") { Chart1.Series["Series1"].Color = System.Drawing.Color.Chocolate; } if (t.Rows[0][10].ToString() == "DarkBlue") { Chart1.Series["Series1"].Color = System.Drawing.Color.DarkBlue; } if (t.Rows[0][10].ToString() == "DarkCyan") { Chart1.Series["Series1"].Color = System.Drawing.Color.DarkCyan; } if (t.Rows[0][10].ToString() == "Darkviolet") { Chart1.Series["Series1"].Color = System.Drawing.Color.DarkViolet; } if (t.Rows[0][10].ToString() == "Ivory") { Chart1.Series["Series1"].Color = System.Drawing.Color.Ivory; } if (t.Rows[0][10].ToString() == "Azure") { Chart1.Series["Series1"].Color = System.Drawing.Color.Azure; } if (t.Rows[0][10].ToString() == "DimGray") { Chart1.Series["Series1"].Color = System.Drawing.Color.DimGray; } #endregion #region Enable 3D Chart1.ChartAreas["Chart1Area"].Area3DStyle.Enable3D = true; #endregion #region enableLegend Chart1.Legends["ChartLegend"].Enabled = true; #endregion ///Enable viewing Chart1.EnableViewState = true; Chart1.Visible = true; } }
protected void btnAnaliz_Click(object sender, EventArgs e) { DataTable table = new DataTable(); DataTable table2 = new DataTable(); table = miner.Analiz(miner.VeriTabanindaAra(txtSearch.Text, int.Parse(Session["kullanici_id"].ToString()), CheckBox1.Checked), int.Parse(Session["kullanici_id"].ToString())); if (table.Rows.Count > 1) { table2.Columns.Add("CreatedDate"); table2.Columns.Add("İyi"); table2.Columns.Add("Kötü"); table2.Columns.Add("Veri/Gün"); table.Columns.Remove("SearchId"); table.Columns.Remove("GeoCode"); table.Columns.Remove("UserId"); table.Columns.Remove("USerProfileText"); table.Columns.Remove("HasPhoto"); table.Columns.Remove("UserFollowerCount"); table.Columns.Remove("UserFollowingCount"); table.Columns.Remove("UserScreenName"); table.Columns.Remove("IsReweet"); table.Columns.Remove("Text2"); DateTime t1; DateTime t2; t1 = DateTime.Parse(table.Rows[1]["CreatedDate"].ToString()); t2 = DateTime.Parse(table.Rows[1]["CreatedDate"].ToString()); for (int t = 1; t < table.Rows.Count; t++) { if (t1 > DateTime.Parse(table.Rows[t]["CreatedDate"].ToString())) { t1 = DateTime.Parse(table.Rows[t]["CreatedDate"].ToString()); } if (t2 < DateTime.Parse(table.Rows[t]["CreatedDate"].ToString())) { t2 = DateTime.Parse(table.Rows[t]["CreatedDate"].ToString()); } } table.DefaultView.Sort = "Fark desc"; int gun = t2.DayOfYear - t1.DayOfYear; int derece, derece1 = 0, derece2 = 0, sayi1 = 0, sayi2 = 0; for (int i = 0; i <= gun; i++) { for (int j = 1; j < table.Rows.Count; j++) { string a = t1.AddDays(i).ToShortDateString(); string b = DateTime.Parse(table.Rows[1]["CreatedDate"].ToString()).ToShortDateString(); if (DateTime.Parse(table.Rows[j]["CreatedDate"].ToString()).ToShortDateString() == t1.AddDays(i).ToShortDateString() && table.Rows[j]["Fark"].ToString() != "0") { if (int.Parse(table.Rows[j]["Fark"].ToString()) > 0) { sayi1++; //derece1 += int.Parse(table.Rows[j]["İyi"].ToString()); } else if (int.Parse(table.Rows[j]["Fark"].ToString()) < 0) { sayi2++; //derece2 += int.Parse(table.Rows[j]["Kötü"].ToString()); } } } if (sayi1 != 0 && sayi2 != 0) { table2.Rows.Add(t1.AddDays(i).ToShortDateString(), sayi1 * 100 / (sayi1 + sayi2), sayi2 * 100 / (sayi1 + sayi2)); } derece1 += sayi1; derece2 += sayi2; sayi1 = 0; sayi2 = 0; } Chart1.DataSource = table2; Chart1.Series[0].XValueMember = "CreatedDate"; Chart1.Series[0].YValueMembers = "İyi"; Chart1.Series[0].Color = Color.FromArgb(141, 198, 48); Chart1.Series.Add("1"); Chart1.Series[1].XValueMember = "CreatedDate"; Chart1.Series[1].YValueMembers = "Kötü"; Chart1.Series[1].Color = Color.FromArgb(228, 81, 54); Chart1.DataBind(); GridView1.DataSource = table; GridView1.DataBind(); try { for (int i = 0; i < GridView1.Rows.Count - 1; i++) { if (int.Parse(GridView1.Rows[i].Cells[9].Text) < 0) { GridView1.Rows[i].BackColor = Color.FromArgb(228, 81, 54); } else if (int.Parse(GridView1.Rows[i].Cells[9].Text) > 0) { GridView1.Rows[i].BackColor = Color.FromArgb(141, 198, 48); } } } catch { } lblDurum.Text = "Toplam veri sayısı : " + GridView1.Rows.Count.ToString() + " Olumlu veri sayısı : " + derece1.ToString() + " Olumsuz veri sayısı : " + derece2.ToString() + " Toplam : " + (derece1 + derece2).ToString(); } else { lblDurum.Text = "Aranılan kritere uygun veri bulunamadı."; } }
protected void Chart1_Load(object sender, EventArgs e) { //设置图表的数据源 DataSet ds = lpp.Query_SunMasterTypeMonthTrends(); //Chart1.DataSource= ds.Tables[0].Select("年份="+DateTime.Now.Year); //ChartArea ca=new ChartArea(); //Series mySeries= new Series(); //Chart1.ChartAreas.Add(ca); //Chart1.Series.Add(mySeries) ; //设置图表Y轴对应项 //Chart1.Series[0].YValueMembers ="出站数"; //Chart1.Series[2].YValueMembers = "合格率"; ////设置图表X轴对应项 //Chart1.Series[0].XValueMember = "月份"; //Chart1.Series[2].XValueMember = "月份"; //Chart1.DataSource = ds.Tables[0].Select("年份=" + (DateTime.Now.Year-1)); //ChartArea ca=new ChartArea(); //Series mySeries= new Series(); //Chart1.ChartAreas.Add(ca); //Chart1.Series.Add(mySeries) ; //设置图表Y轴对应项 DataTable dt = new DataTable(); if (ds.Tables[0].Select("类型='塑封桥' and 年份=" + (DropDownList1.SelectedValue)).Any()) { dt = ds.Tables[0].Select("类型='塑封桥' and 年份=" + (DropDownList1.SelectedValue)).CopyToDataTable(); foreach (DataRow dr in dt.AsEnumerable()) { Chart1.Series[0].Points.AddXY(dr["月份"], dr["出站数"]); Chart1.Series[3].Points.AddXY(dr["月份"], dr["合格率"]); } } if (ds.Tables[0].Select("类型='浇灌桥' and 年份=" + (DropDownList1.SelectedValue)).Any()) { dt = ds.Tables[0].Select("类型='浇灌桥' and 年份=" + (DropDownList1.SelectedValue)).CopyToDataTable(); foreach (DataRow dr in dt.AsEnumerable()) { Chart1.Series[1].Points.AddXY(dr["月份"], dr["出站数"]); Chart1.Series[4].Points.AddXY(dr["月份"], dr["合格率"]); } } if (ds.Tables[0].Select("类型='模块事业部产品' and 年份=" + (DropDownList1.SelectedValue)).Any()) { dt = ds.Tables[0].Select("类型='模块事业部产品' and 年份=" + (DropDownList1.SelectedValue)).CopyToDataTable(); foreach (DataRow dr in dt.AsEnumerable()) { Chart1.Series[2].Points.AddXY(dr["月份"], dr["出站数"]); Chart1.Series[5].Points.AddXY(dr["月份"], dr["合格率"]); } } Chart1.Titles[0].Text = DropDownList1.SelectedValue + "年塑封桥、浇灌桥和模块事业部产品产量和合格率趋势图"; //设置图表X轴对应项 //绑定数据 Chart1.DataBind(); }
protected void BtnCompare_Click(object sender, EventArgs e) { CPUPerformance service = new CPUPerformance(); string first = processors.SelectedRow.Cells[0].Text; string second = processors2.SelectedRow.Cells[0].Text; if (first != null && second != null) { DataSet ds = new DataSet(); ds = service.Compare(first, second); Chart1.DataSource = ds; Chart1.Series["Score"].XValueMember = "Name"; Chart1.Series["Score"].YValueMembers = "Score"; Chart1.DataBind(); Chart1.Visible = true; name1.Text = ds.Tables[0].Rows[0][0].ToString(); name2.Text = ds.Tables[0].Rows[1][0].ToString(); cores1.Text = ds.Tables[0].Rows[0][1].ToString(); cores2.Text = ds.Tables[0].Rows[1][1].ToString(); if (int.Parse(cores1.Text) < int.Parse(cores2.Text)) { cores2.ForeColor = Color.Green; cores1.ForeColor = Color.Red; } else if (int.Parse(cores1.Text) > int.Parse(cores2.Text)) { cores2.ForeColor = Color.Red; cores1.ForeColor = Color.Green; } else { cores1.ForeColor = Color.Yellow; cores2.ForeColor = Color.Yellow; } threads1.Text = ds.Tables[0].Rows[0][2].ToString(); threads2.Text = ds.Tables[0].Rows[1][2].ToString(); if (int.Parse(threads1.Text) < int.Parse(threads2.Text)) { threads2.ForeColor = Color.Green; threads1.ForeColor = Color.Red; } else if (int.Parse(threads1.Text) > int.Parse(threads2.Text)) { threads2.ForeColor = Color.Red; threads1.ForeColor = Color.Green; } else { threads1.ForeColor = Color.Yellow; threads2.ForeColor = Color.Yellow; } clock1.Text = ds.Tables[0].Rows[0][3].ToString(); clock2.Text = ds.Tables[0].Rows[1][3].ToString(); String clc1, clc2; if (clock1.Text.Length >= 4) { clc1 = clock1.Text.Remove(3); } else { clc1 = clock1.Text.Remove(1); } if (clock2.Text.Length > 4) { clc2 = clock2.Text.Remove(3); } else { clc2 = clock2.Text.Remove(1); } float f1 = float.Parse(clc1); float f2 = float.Parse(clc2); if (f1 > f2) { clock1.ForeColor = Color.Green; clock2.ForeColor = Color.Red; } else if (f1 < f2) { clock2.ForeColor = Color.Green; clock1.ForeColor = Color.Red; } else { clock1.ForeColor = Color.Yellow; clock2.ForeColor = Color.Yellow; } cache1.Text = ds.Tables[0].Rows[0][4].ToString(); cache2.Text = ds.Tables[0].Rows[1][4].ToString(); String cac1, cac2; if (cache1.Text.Length > 3) { cac1 = cache1.Text.Remove(2); } else { cac1 = cache1.Text.Remove(1); } if (cache2.Text.Length > 3) { cac2 = cache2.Text.Remove(2); } else { cac2 = cache2.Text.Remove(1); } int cace1 = int.Parse(cac1); int cace2 = int.Parse(cac2); if (cace1 > cace2) { cache1.ForeColor = Color.Green; cache2.ForeColor = Color.Red; } else if (cace1 < cace2) { cache2.ForeColor = Color.Green; cache1.ForeColor = Color.Red; } else { cache2.ForeColor = Color.Yellow; cache1.ForeColor = Color.Yellow; } score1.Text = ds.Tables[0].Rows[0][5].ToString(); score2.Text = ds.Tables[0].Rows[1][5].ToString(); if (int.Parse(score1.Text) < int.Parse(score2.Text)) { score2.BackColor = Color.Green; score1.BackColor = Color.Red; } else if (int.Parse(score1.Text) > int.Parse(score2.Text)) { score2.BackColor = Color.Red; score1.BackColor = Color.Green; } else { score1.BackColor = Color.Yellow; score2.BackColor = Color.Yellow; } Table1.Visible = true; } }
protected void btn_Click(object sender, EventArgs e) { string date1 = null; if (d1.SelectedIndex == 0) { date1 = "'2014-01-01' and '2014-01-31'"; } if (d1.SelectedIndex == 1) { date1 = "'2014-02-01' and '2014-03-01'"; } if (d1.SelectedIndex == 2) { date1 = "'2014-03-01' and '2014-04-01'"; } if (d1.SelectedIndex == 3) { date1 = "'2014-04-01' and '2014-05-01'"; } if (d1.SelectedIndex == 4) { date1 = "'2014-05-01' and '2014-05-01'"; } if (d1.SelectedIndex == 5) { date1 = "'2014-06-01' and '2014-07-01'"; } if (d1.SelectedIndex == 6) { date1 = "'2014-07-01' and '2014-08-01'"; } if (d1.SelectedIndex == 7) { date1 = "'2014-08-01' and '2014-09-01'"; } if (d1.SelectedIndex == 8) { date1 = "'2014-09-01' and '2014-10-01'"; } if (d1.SelectedIndex == 9) { date1 = "'2014-10-01' and '2014-11-01'"; } if (d1.SelectedIndex == 10) { date1 = "'2014-11-01' and '2014-12-01'"; } if (d1.SelectedIndex == 11) { date1 = "'2014-12-01' and '2015-01-01'"; } string date2 = null; if (d2.SelectedIndex == 0) { date2 = "'2014-01-01' and '2014-01-31'"; } if (d2.SelectedIndex == 1) { date2 = "'2014-02-01' and '2014-03-01'"; } if (d2.SelectedIndex == 2) { date2 = "'2014-03-01' and '2014-04-01'"; } if (d2.SelectedIndex == 3) { date2 = "'2014-04-01' and '2014-05-01'"; } if (d2.SelectedIndex == 4) { date2 = "'2014-05-01' and '2014-05-01'"; } if (d2.SelectedIndex == 5) { date2 = "'2014-06-01' and '2014-07-01'"; } if (d2.SelectedIndex == 6) { date2 = "'2014-07-01' and '2014-08-01'"; } if (d2.SelectedIndex == 7) { date2 = "'2014-08-01' and '2014-09-01'"; } if (d2.SelectedIndex == 8) { date2 = "'2014-09-01' and '2014-10-01'"; } if (d2.SelectedIndex == 9) { date2 = "'2014-10-01' and '2014-11-01'"; } if (d2.SelectedIndex == 10) { date2 = "'2014-11-01' and '2014-12-01'"; } if (d2.SelectedIndex == 11) { date2 = "'2014-12-01' and '2015-01-01'"; } //lbl3.Text = d1.SelectedIndex.ToString(); string sql = "select sum(Balance) a from Payment where DebitDate Between " + date1 + " union select sum(Balance) a from Payment where DebitDate between " + date2; string sql2 = "select sum(Balance) a from Payment where DebitDate Between " + date1 + " union select sum(Balance) a from Payment where DebitDate between " + date2; SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ims"].ToString()); SqlCommand cmd = new SqlCommand(sql, con); SqlCommand cmd2 = new SqlCommand(sql2, con); // SqlCommand cmd2 = new SqlCommand(sql2, con); SqlDataReader read1; // SqlDataReader read2;// SqlDataAdapter data = new SqlDataAdapter(cmd); // //DateTime dt = new DateTime(); //SqlDataAdapter data1 = new SqlDataAdapter(cmd2); DataTable ds = new DataTable(); // DataTable ds2 = new DataTable(); Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false; Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false; Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 1; Chart1.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(1.0, 1.5, d1.SelectedValue); Chart1.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(2.0, 2.5, d2.SelectedValue); //Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 4; Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Months"; Chart1.ChartAreas["ChartArea1"].AxisY.Minimum = 0; Chart1.ChartAreas["ChartArea1"].AxisY.Maximum = 10000; Chart1.ChartAreas["ChartArea1"].AxisY.Title = "%"; Chart1.ChartAreas["ChartArea1"].AxisY.TextOrientation = TextOrientation.Horizontal; //SqlDataReader read1; try { con.Open(); data.Fill(ds); if (ds.Rows.Count > 0) { Chart1.DataSource = ds; Chart1.Series["Series1"].YValueMembers = "a"; Chart1.DataBind(); } //data1.Fill(ds2); //if (ds2.Rows.Count > 0) //{ // Chart1.DataSource = ds2; // Chart1.Series["Series1"].YValueMembers = "a"; // Chart1.DataBind(); //} //read1 = cmd.ExecuteReader(); //while (read1.Read()) //{ // balance[num] = read1["a"].ToString(); // str[num] = read1["DebitDate"].ToString(); // int.TryParse(read1["a"].ToString(), out num ); // Chart1.Series["Series1"].YValuesPerPoint = num; // Chart1.Series["Series1"].AxisLabel = str[num]; // num++; //} //Chart1.Series["Series1"].YValueMembers = balance; //Chart1.Series["Series1"].Points.DataBindXY(str, balance); //read1.Close(); //Chart1.Series["Series1"].YValueMembers = "a"; //Chart1.DataBind(); } catch (Exception err) { lbl1.Text = err.Message; } finally { con.Close(); } }
private void _setGraph(DataSet dsPie, DataSet dsLine) { // Line GRAPH DundasCharts.DundasChartBase(Chart2, ChartImageType.Flash, 550, 300 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); Series[] oasrType = new Series[dsLine.Tables[0].Rows.Count]; int intLP = 0; foreach (DataRow row in dsLine.Tables[0].Rows) { oasrType[intLP] = DundasCharts.CreateSeries(Chart2, "Series" + intLP.ToString(), Chart2.ChartAreas[0].Name, row["GBN_NM"].ToString(), null, SeriesChartType.Line, 3, GetChartColor(intLP), GetChartColor(intLP), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); for (int colIndex = 1; colIndex < dsLine.Tables[0].Columns.Count; colIndex++) { string columnName = dsLine.Tables[0].Columns[colIndex].ColumnName; double YVal = double.Parse(row[columnName].ToString()); Chart2.Series[oasrType[intLP].Name].Points.AddXY(columnName, YVal); } intLP += 1; } DundasAnimations.DundasChartBase(Chart2, AnimationTheme.None, -1, -1, false, 1); for (int i = 0; i < oasrType.Length; i++) { if (i == 0) { DundasAnimations.GrowingAnimation(Chart2, oasrType[i], 0.5, 1.0, true); } else { DundasAnimations.GrowingAnimation(Chart2, oasrType[i], i + 0.1, 1.0, true); } oasrType[i].MarkerStyle = GetMarkerStyle(i); oasrType[i].MarkerColor = GetChartColor(i); oasrType[i].MarkerBorderColor = GetChartColor(i); } Chart2.ChartAreas[0].AxisY.LabelStyle.Format = "#,###"; Chart2.DataSource = dsLine.Tables[0].DefaultView; Chart2.DataBind(); // PIE GRAPH DundasCharts.DundasChartBase(Chart1, ChartImageType.Flash, 250, 300 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); Series serPie = DundasCharts.CreateSeries(Chart1, "Series1", "Default", "고객상태별점유율", null, SeriesChartType.Pie, 1, Color.FromArgb(0x5A, 0x7D, 0xDE), Color.FromArgb(0x4A, 0x58, 0x7E), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); Chart1.Series[serPie.Name].ValueMemberX = "GBN_NM"; Chart1.Series[serPie.Name].ValueMembersY = "FNL_QNT"; serPie.FontColor = Color.White; Chart1.DataSource = dsPie; Chart1.DataBind(); }