using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Reflection; using Mesnac.Compressor.Data; namespace Mesnac.Gui.Edit.Dialog { public partial class FrmStationData : Form { public FrmStationData() { InitializeComponent(); } public delegate void InvokeMethod(); public int page = 1; public string stationid = ""; public FrmStationData(string StationID,string Name) { InitializeComponent(); this.stationid = StationID; this.StationName = Name; } public void RereshData(object sender, EventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new InvokeMethod(display)); return; } } public void display() { if (string.IsNullOrEmpty(stationid)) { return; } GetData(); ShowStationinfo(); } public void ShowStationinfo() { this.lb_stationName.Text = StationName; chart1.Series[0].Points.AddXY("合格",Hege); chart1.Series[0].Points.AddXY("不合格", BuHege); this.txt_hege.Text = Hege.ToString(); this.txt_buhege.Text = BuHege.ToString(); this.txt_zongshu.Text = totall.ToString(); this.txt_lv.Text = ((float)Hege/(float)totall*100).ToString("F2").ToString()+"%"; if (dt != null) { dataGridView1.DataSource = dt; } } private void GetData() { DbHandler db = new DbHandler(); object ob=db.GetStationData(stationid);//获取工位数据 var dset = ob as DataSet; if (dset != null) { dt = dset.Tables[0]; DataTable dt2 = dset.Tables[1]; try { if (dt2 != null && dt2.Rows.Count > 0) { int Count = dt2.Rows.Count; List HegeList = new List(); for (int i = 0; i < Count; i++) { HeGe h = new HeGe(); h.stateName = dt2.Rows[i]["State"].ToString(); h.Qality = Convert.ToInt32(dt2.Rows[i]["qulity"]); if (h.stateName.Trim() == "1") { Hege = h.Qality; } else if(h.stateName.Trim() == "2") { BuHege = h.Qality; } HegeList.Add(h); } totall = Hege + BuHege; } } catch(Exception e) { Console.WriteLine(e.ToString()); } } } private void btn_return_Click(object sender, EventArgs e) { this.Close(); } private void btn_next_Click(object sender, EventArgs e) { //this.page=2; //display(); } private void btn_pre_Click(object sender, EventArgs e) { //this.page = 1; //display(); } private void FrmStation_Load(object sender, EventArgs e) { display(); } #region 显示数据 int Hege = 0; int BuHege = 0; int totall = 0; string StationName = ""; DataTable dt = null; #endregion } public class HeGe { public string stateName; public int Qality = 0; } }