//列表 public static DataTable CreateViewReport(string _selCol, string _strTestSampleNo, int ab) { BLL.Compress bllts = new HR_Test.BLL.Compress(); DataSet dst = bllts.GetFinishListReport(_selCol, " testSampleNo in ('" + _strTestSampleNo + ") and isFinish=true and isEffective=false ", ab); return(dst.Tables[0]); }
//列表 public static DataTable CreateView(string _selCol, string _strTestNo, int ab) { BLL.Compress bllts = new HR_Test.BLL.Compress(); DataSet dst = bllts.GetFinishList1(_selCol, " testNo = '" + _strTestNo + "' and isFinish=true", ab); return(dst.Tables[0]); }
private static List <TreeNode> ReadGBT7314Samples(DateTime dtp) { BLL.Compress bllC = new HR_Test.BLL.Compress(); DataSet dsc = bllC.GetNotOverlapList(" testDate = #" + dtp.Date + "#"); int count = dsc.Tables[0].Rows.Count; List <TreeNode> ltn = new List <TreeNode>(); for (int j = 0; j < count; j++) { DataSet _dsc = bllC.GetList(" testNo='" + dsc.Tables[0].Rows[j]["testNo"].ToString() + "' and testDate=#" + dtp.Date + "#"); TreeNode tn = new TreeNode(); tn.Text = dsc.Tables[0].Rows[j]["testNo"].ToString(); tn.Name = "GBT7314-2005"; tn.ImageIndex = 0; foreach (DataRow dr in _dsc.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 = "GBT7314-2005_c"; ftn.Tag = dr; tn.Nodes.Add(ftn); } else { //左侧node未完成试验的图标 TreeNode ftn = new TreeNode(); ftn.ImageIndex = 2; ftn.Text = dr["testSampleNo"].ToString(); ftn.Name = "GBT7314-2005_c"; ftn.Tag = dr; tn.Nodes.Add(ftn); } } _dsc.Dispose(); ltn.Add(tn); } dsc.Dispose(); return(ltn); }
private void gBtnAddC_Click(object sender, EventArgs e) { string strErr = ""; if (this.c_testNo.Text.Trim().Length == 0) { strErr += "试验编号不能为空!\r\n\r\n"; } if (this.c_testSampleNo.Text.Trim().Length == 0) { strErr += "试样编号不能为空!\r\n\r\n"; } if (this._sendCompany.Length == 0) { strErr += "送检单位不能为空!\r\n\r\n"; } if (this.c_stuffCardNo.Text.Trim().Length == 0) { strErr += "材料牌号不能为空!\r\n\r\n"; } if (this.c_stuffSpec.Text.Trim().Length == 0) { strErr += "材料规格不能为空!\r\n\r\n"; } if (this.c_stuffType.Text.Trim().Length == 0) { strErr += "试样类型不能为空!\r\n\r\n"; } if (this._temperature.Trim().Length == 0) { strErr += "试验温度不能为空!\r\n\r\n"; } if (this._condition.Trim().Length == 0) { strErr += "试验条件不能为空!\r\n\r\n"; } if (this._controlMode.Trim().Length == 0) { strErr += "控制方式不能为空!\r\n\r\n"; } if (this._testStandard_C.Text.Trim().Length == 0) { strErr += "试验标准不能为空!\r\n\r\n"; } if (this._sampleCharacter.Trim().Length == 0) { strErr += "试样标识不能为空!\r\n\r\n"; } if (this.c_getSample.Text.Trim().Length == 0) { strErr += "试样取样不能为空!\r\n\r\n"; } if (this.c_tester.Text.Trim().Length == 0) { strErr += "试验员不能为空!\r\n\r\n"; } if (rBtnRect.Checked) { if (this.c_a.Text.Trim().Length == 0) { strErr += "a不能为空!\r\n\r\n"; } if (this.c_b.Text.Trim().Length == 0) { strErr += "b不能为空!\r\n\r\n"; } } if (rBtnCircle.Checked) { if (this.c_d.Text.Trim().Length == 0) { strErr += "d不能为空!\r\n\r\n"; } } if (this.c_S0.Text.Trim().Length == 0) { strErr += "S0不能为空!\r\n\r\n"; } else { if (double.Parse(this.c_S0.Text.Trim()) == 0d) { strErr += "S0不能为0!\r\n\r\n"; } } if (this.c_L0.Text.Trim().Length == 0) { strErr += " L0不能为空!\r\n\r\n"; } else { if (double.Parse(this.c_L0.Text.Trim()) == 0d) { strErr += " L0不能为0!\r\n\r\n"; } } if (this.Epc.Text.Trim().Length == 0) { strErr += "εpc 不能为空!\r\n\r\n"; } else { if (double.Parse(this.Epc.Text.Trim()) == 0d) { strErr += " εpc 不能为0!\r\n\r\n"; } } if (this.Etc.Text.Trim().Length == 0) { strErr += "εtc 不能为空!\r\n\r\n"; } else { if (double.Parse(this.Etc.Text.Trim()) == 0d) { strErr += " εtc 不能为0!\r\n\r\n"; } } if (this.txtn.Text.Trim().Length == 0) { strErr += "变形放大倍数 n 不能为空!\r\n\r\n"; } else { if (double.Parse(this.txtn.Text.Trim()) == 0d) { strErr += " 变形放大倍数 n 不能为0!\r\n\r\n"; } } if (this.c_L.Text.Trim().Length == 0) { strErr += " L不能为空!\r\n\r\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } HR_Test.Model.Compress model = new HR_Test.Model.Compress(); model.testMethodName = this.c_testMethod.Text; model.testNo = this.c_testNo.Text; model.testSampleNo = this.c_testSampleNo.Text; model.reportNo = "-"; model.sendCompany = this._sampleCharacter; model.temperature = double.Parse(this._temperature); model.humidity = double.Parse(this._humidity); model.testStandard = this._testStandard_C.Text; model.sampleCharacter = this._sampleCharacter; model.hotStatus = this._hotStatus; model.condition = this._condition; model.controlMode = this._controlMode; model.stuffCardNo = this.c_stuffCardNo.Text; model.stuffSpec = c_stuffSpec.Text; model.stuffType = c_stuffType.Text; model.testMethod = c_testMethod.Text; model.mathineType = c_mathineType.Text; model.testCondition = "-"; model.getSample = c_getSample.Text; model.tester = c_tester.Text; model.assessor = "-"; model.sign = this.c_sign.Text; model.a = Convert.ToDouble(!string.IsNullOrEmpty(this.c_a.Text) ? this.c_a.Text : "0"); model.b = Convert.ToDouble(!string.IsNullOrEmpty(this.c_b.Text) ? this.c_b.Text : "0"); model.d = Convert.ToDouble(!string.IsNullOrEmpty(this.c_d.Text) ? this.c_d.Text : "0"); model.L = Convert.ToDouble(!string.IsNullOrEmpty(this.c_L.Text) ? this.c_L.Text : "0"); model.L0 = Convert.ToDouble(!string.IsNullOrEmpty(this.c_L0.Text) ? this.c_L0.Text : "0"); model.H = Convert.ToDouble(!string.IsNullOrEmpty(this.c_HH.Text) ? this.c_HH.Text : "0"); model.hh = Convert.ToDouble(!string.IsNullOrEmpty(this.c_h.Text) ? this.c_h.Text : "0"); model.S0 = Convert.ToDouble(!string.IsNullOrEmpty(this.c_S0.Text) ? this.c_S0.Text : "0"); model.Ff = Convert.ToDouble(!string.IsNullOrEmpty(this.c_Ff.Text) ? this.c_Ff.Text : "0"); model.εpc = Convert.ToDouble(!string.IsNullOrEmpty(this.Epc.Text) ? this.Epc.Text : "0"); model.εtc = Convert.ToDouble(!string.IsNullOrEmpty(this.Etc.Text) ? this.Etc.Text : "0"); model.n = Convert.ToDouble(!string.IsNullOrEmpty(this.txtn.Text) ? this.txtn.Text : "1"); model.deltaL = 0; model.F0 = 0; model.Fpc = 0; model.Ftc = 0; model.FeHc = 0; model.FeLc = 0; model.Fmc = 0; model.Rpc = 0; model.Rtc = 0; model.ReHc = 0; model.ReLc = 0; model.Rmc = 0; model.Ec = 0; model.Avera = 0; model.Avera1 = 0; model.isFinish = false; model.isEffective = false; model.testDate = this.c_testDate.Value.Date; BLL.Compress bllc = new HR_Test.BLL.Compress(); if (bllc.GetList("testSampleNo ='" + this.c_testSampleNo.Text + "'").Tables[0].Rows.Count == 0) { if (bllc.Add(model)) { this.c_testSampleNo.Items.Remove(this.c_testSampleNo.SelectedItem); //this.c_a.Text = ""; //this.c_b.Text = ""; //this.c_d.Text = ""; //this.c_S0.Text = ""; MessageBox.Show("添加压缩试样信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("添加压缩试样信息失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("已经存在相同的编号,请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //TestStandard.MethodControl.ReadMethod(this.treeviewTestMethod); }
//查询结果 public static void ReadGBT7314(DataGridView dg, string testNo, string testSampleNo, DateTimePicker dtpFrom, DateTimePicker dtpTo, ZedGraph.ZedGraphControl zed) { BLL.Compress bllTs = new HR_Test.BLL.Compress(); string strWhere = string.Empty; if (!string.IsNullOrEmpty(testNo)) { strWhere += " and testNo like '%" + testNo + "%'"; } if (!string.IsNullOrEmpty(testSampleNo)) { strWhere += " and testSampleNo like '%" + testSampleNo + "%'"; } double maxValue = 0; DataSet dsmax = bllTs.GetMaxFmc("isFinish=true and isEffective=false and testDate>=#" + dtpFrom.Value.Date + "# and testDate<=#" + dtpTo.Value.Date + "#" + strWhere); if (dsmax != null) { if (dsmax.Tables[0].Rows.Count > 0) { if (!string.IsNullOrEmpty(dsmax.Tables[0].Rows[0]["Fmc"].ToString())) { maxValue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Fmc"].ToString()); } } } DataSet ds = bllTs.GetFinishList("isFinish=true and isEffective=false and testDate>=#" + dtpFrom.Value.Date + "# and testDate<=#" + dtpTo.Value.Date + "#" + strWhere, maxValue); DataTable dt = ds.Tables[0]; dg.DataSource = dt; DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn(); //DataGridViewDisableCheckBoxColumn chkcol = new DataGridViewDisableCheckBoxColumn(); chkcol.Name = "选择"; DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn(); c.Visible = true; c.Name = " "; dg.Columns.Insert(0, c); dg.Columns.Insert(0, chkcol); dg.Columns[1].Frozen = true; dg.Columns[2].Frozen = true; //dg.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); dg.Columns[0].Width = 50; dg.Columns[1].Width = 50; dg.Columns[2].Width = 100; if (dg.ColumnCount > 0) { foreach (DataGridViewColumn dgvc in dg.Columns) { dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvc.SortMode = DataGridViewColumnSortMode.NotSortable; dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } } dg.Refresh(); for (int i = 0; i < dg.Rows.Count; i++) { 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.SelectionForeColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Value = _Color_Array[i].ToString(); } } foreach (CurveItem ci in zed.GraphPane.CurveList) { ci.Clear(); ci.Label.Text = ""; } zed.AxisChange(); zed.Refresh(); ds.Dispose(); }
//求取平均值 X~,S,V public static DataTable CreateAverageViewReport(StringBuilder _selCol, StringBuilder _selSqlAver, string _strTestSampleNo, int ab) { BLL.Compress bllts = new HR_Test.BLL.Compress(); //求平均 DataSet dsaver = bllts.GetFinishSumList1(_selSqlAver.ToString(), " testSampleNo in ('" + _strTestSampleNo + ") and isFinish=true and isEffective=false "); //获取选择试样的数量和试样编号 string selCol = _selCol.ToString(); DataSet dsfinish = bllts.GetFinishList1(selCol.ToString(), " testSampleNo in ('" + _strTestSampleNo + ") and isFinish=true and isEffective=false ", ab); int fcount = dsfinish.Tables[0].Rows.Count; //变异系数 = sd/mean StringBuilder strCV = new StringBuilder(); //中间值 StringBuilder strMid = new StringBuilder(); //创建新的数据计算结果表 DataSet dsaverto = new DataSet(); dsaverto.Tables.Add(); dsaverto.Tables[0].Columns.Add("数量(" + fcount + ")").SetOrdinal(0); for (int i = 0; i < dsaver.Tables[0].Columns.Count; i++) { dsaverto.Tables[0].Columns.Add(dsaver.Tables[0].Columns[i].Caption).SetOrdinal(i + 1); } //给新数据表添加平均值列 List <object> objmean = new List <object>(); objmean.Add("Mean.:"); for (int i = 0; i < dsaver.Tables[0].Columns.Count; i++) { if (double.Parse(dsaver.Tables[0].Rows[0][i].ToString()) != 0) { objmean.Add(dsaver.Tables[0].Rows[0][i].ToString()); } else { objmean.Add("-"); } } dsaverto.Tables[0].Rows.Add(objmean.ToArray()); double sumsd = 0; double sd = 0; double cv = 0; double ctrue = 0; double caver = 0; double temp = double.MaxValue; double mid = 0; List <object> objsd = new List <object>(); objsd.Add("S.D.:"); List <object> objcv = new List <object>(); objcv.Add("C.V.:"); List <object> objmid = new List <object>(); objmid.Add("Mid.:"); //计算标准偏差 for (int i = 0; i < dsaver.Tables[0].Columns.Count; i++) { for (int j = 0; j < dsfinish.Tables[0].Rows.Count; j++) { // 求和 (真实值-平均值)^2 if (ab == 1) { ctrue = Convert.ToDouble(dsfinish.Tables[0].Rows[j][i + 4].ToString()); } if (ab == 2) { ctrue = Convert.ToDouble(dsfinish.Tables[0].Rows[j][i + 3].ToString()); } caver = Convert.ToDouble(dsaver.Tables[0].Rows[0][i].ToString()); double c1 = (ctrue - caver) * (ctrue - caver); sumsd += c1; //查找中间值,最接近平均值的 double d_value = Math.Abs(ctrue - caver); if (d_value < temp) { temp = d_value; mid = ctrue; } } //标准偏差 if (fcount - 1 != 0) { sd = Math.Sqrt(sumsd / (fcount - 1)); } else { sd = 0; } //变异系数 =( 标准偏差 / 平均值 ) *100 if (caver != 0) { cv = (sd / caver) * 100; } else { cv = 0; } if (sd != 0) { objsd.Add(sd.ToString("f4")); } else { objsd.Add("-"); } if (cv != 0) { objcv.Add(cv.ToString("f4")); } else { objcv.Add("-"); } if (mid != 0) { objmid.Add(mid.ToString("f4")); } else { objmid.Add("-"); } temp = double.MaxValue; sumsd = 0; } //S.D.标准偏差行 if (_isSelSD) { dsaverto.Tables[0].Rows.Add(objsd.ToArray()); } //变异系数行 if (_isSelCV) { dsaverto.Tables[0].Rows.Add(objcv.ToArray()); } //中间值行 if (_isSelMid) { dsaverto.Tables[0].Rows.Add(objmid.ToArray()); } dsfinish.Dispose(); return(dsaverto.Tables[0]); }
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.Compress bllTs = new HR_Test.BLL.Compress(); if (!string.IsNullOrEmpty(testNo)) { //if (testNo.Contains('-')) // testNo = testNo.Substring(0, testNo.LastIndexOf("-")); //获取不重复的试验编号列表 DataSet ds = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#"); DataSet dsMax = bllTs.GetMaxFmc(" testNo='" + testNo + "' and isEffective=false and testDate =#" + dtp.Value.Date + "#"); double maxValue = 0; if (dsMax != null) { if (!string.IsNullOrEmpty(dsMax.Tables[0].Rows[0]["Fmc"].ToString())) { maxValue = Convert.ToDouble(dsMax.Tables[0].Rows[0]["Fmc"].ToString()); } } DataTable dt = ds.Tables[0]; int ab = 0; if (dt != null) { //矩形 if (dt.Rows[0]["a"].ToString() != "0") { ab = 1; } //圆柱形 if (dt.Rows[0]["d"].ToString() != "0") { ab = 2; } } DataSet ds1 = bllTs.GetNotOverlapList1(" testNo='" + testNo + "' and testDate =#" + dtp.Value.Date + "#"); DataTable dt1 = ds1.Tables[0]; 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(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 chkcol = new DataGridViewCheckBoxColumn(); chkcol.Name = "选择"; chkcol.MinimumWidth = 50; chkcol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn(); c.Name = ""; if (dg != null) { 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 > 1) { dg.Columns[0].Frozen = true; dg.Columns[1].Frozen = true; dg.Columns[1].Width = 10; } if (dg.Columns.Count > 2) { dg.Columns[2].Frozen = true; } dg.Refresh(); } //clear all curves if (zed != null) { foreach (CurveItem ci in zed.GraphPane.CurveList) { ci.Clear(); ci.Label.Text = ""; } zed.AxisChange(); zed.Refresh(); } //} //catch (Exception ee) { throw ee; } }