private static List <TreeNode> ReadGBT228Samples(DateTime dtp) { BLL.TestSample bllTs = new HR_Test.BLL.TestSample(); //查询不重复项 DataSet ds = bllTs.GetNotOverlapList1(" testDate = #" + dtp.Date + "#"); int rCount = ds.Tables[0].Rows.Count; List <TreeNode> ltn = new List <TreeNode>(); for (int i = 0; i < rCount; i++) { DataSet _ds = bllTs.GetList(" testNo='" + ds.Tables[0].Rows[i]["testNo"].ToString() + "' and testMethodName='" + ds.Tables[0].Rows[i]["testMethodName"].ToString() + "' and testDate=#" + dtp.Date + "#"); TreeNode tn = new TreeNode(); tn.Text = ds.Tables[0].Rows[i]["testNo"].ToString(); tn.Name = "GBT228-2010"; tn.ImageIndex = 0; foreach (DataRow dr in _ds.Tables[0].Rows) { if (Convert.ToBoolean(dr["isFinish"].ToString()) == true) { //左侧node完成试验的图标 TreeNode ftn = new TreeNode(); ftn.ImageIndex = 1; ftn.Text = dr["testSampleNo"].ToString(); ftn.Name = "GBT228-2010_c"; ftn.Tag = dr; tn.Nodes.Add(ftn); } else { //左侧node未完成试验的图标 //左侧node完成试验的图标 TreeNode ftn = new TreeNode(); ftn.ImageIndex = 2; ftn.Text = dr["testSampleNo"].ToString(); ftn.Tag = dr; ftn.Name = "GBT228-2010_c"; tn.Nodes.Add(ftn); } } _ds.Dispose(); ltn.Add(tn); } ds.Dispose(); return(ltn); }
public static void readFinishSample(DataGridView dg, DataGridView dgSum, string testNo, DateTimePicker dtp, ZedGraph.ZedGraphControl zed) { //try //{ //dg.MultiSelect = true; if (dg != null) { dg.DataSource = null; dg.Columns.Clear(); dg.RowHeadersVisible = false; } BLL.TestSample bllTs = new HR_Test.BLL.TestSample(); if (!string.IsNullOrEmpty(testNo)) { //if (testNo.Contains('-')) // testNo = testNo.Substring(0, testNo.LastIndexOf("-")); //获取不重复的试验编号列表 DataSet ds = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#"); DataTable dt = ds.Tables[0]; int ab = 0; if (dt != null) { if (dt.Rows[0]["b0"].ToString() != "0") { ab = 1; } if (dt.Rows[0]["d0"].ToString() != "0") { ab = 2; } if (dt.Rows[0]["Do"].ToString() != "0") { ab = 3; } } DataSet ds1 = bllTs.GetNotOverlapList1(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#"); DataTable dt1 = ds1.Tables[0]; DataSet dsmax = bllTs.GetMaxFm(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#"); double maxvalue = 0; if (dsmax != null) { if (!string.IsNullOrEmpty(dsmax.Tables[0].Rows[0]["Fm"].ToString())) { maxvalue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Fm"].ToString()); } } string methodName = dt1.Rows[0]["testMethodName"].ToString(); if (dt1 != null) { StringBuilder[] tst = strSql_T(methodName, maxvalue); if (!string.IsNullOrEmpty(tst[0].ToString()) && dg != null) { dg.DataSource = CreateView_T(tst[0].ToString(), dt1.Rows[0]["testNo"].ToString(), ab); } if (!string.IsNullOrEmpty(tst[1].ToString())) { dgSum.DataSource = CreateAverageView(tst[0], tst[1], dt1.Rows[0]["testNo"].ToString(), ab); } } } else { DataSet ds = bllTs.GetFinishList(" testNo='" + testNo + "' and testDate=#" + dtp.Value.Date + "#", 0); DataTable dt = ds.Tables[0]; DataRow dr = dt.NewRow(); dt.Rows.Add(dr); if (dg != null) { dg.DataSource = dt; } ds.Dispose(); } //DataGridViewDisableCheckBoxColumn chkcol = new DataGridViewDisableCheckBoxColumn(); //DataGridViewCheckBoxColumn chkeffective = new DataGridViewCheckBoxColumn(); //chkeffective.Name = "是否有效"; //chkeffective.MinimumWidth = 60; //chkeffective.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn(); chkcol.Name = "选择"; chkcol.MinimumWidth = 50; chkcol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; if (dg != null) { DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn(); c.Name = ""; dg.Columns.Insert(0, chkcol); dg.Columns.Insert(1, c); dg.Name = "tensile"; //dg.Rows[0].Cells[0].Value = false; //dg.Rows[0].Cells[0].Selected = false; int rCount = dg.Rows.Count; for (int i = 0; i < rCount; i++) { if (!string.IsNullOrEmpty(dg.Rows[i].Cells[2].Value.ToString())) { if (Convert.ToBoolean(dg.Rows[i].Cells[2].Value.ToString()) == true) { dg.Rows[i].DefaultCellStyle.BackColor = Color.IndianRed; } } if (i > 19) { dg.Rows[i].Cells[1].Style.BackColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.ForeColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Value = _Color_Array[i % 20].ToString(); } else { dg.Rows[i].Cells[1].Style.BackColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.ForeColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Value = _Color_Array[i].ToString(); } } foreach (DataGridViewColumn dgvc in dg.Columns) { dgvc.SortMode = DataGridViewColumnSortMode.NotSortable; dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; } if (dg.Columns.Count > 3) { dg.Columns[0].Frozen = true; dg.Columns[1].Frozen = true; dg.Columns[2].Frozen = true; } if (dg.Columns.Count > 2) { dg.Columns[2].Frozen = true; } dg.Refresh(); } if (zed != null) { //clear all curves foreach (CurveItem ci in zed.GraphPane.CurveList) { ci.Clear(); ci.Label.Text = ""; } zed.AxisChange(); zed.Refresh(); } //} //catch (Exception ee) { throw ee; } }