//列表 public static DataTable CreateViewReport(string _selCol, string _strTestNo) { BLL.Bend bllts = new HR_Test.BLL.Bend(); DataSet dst = bllts.GetFinishListReport(_selCol, " testSampleNo in ('" + _strTestNo + ") and isFinish=true "); return(dst.Tables[0]); }
//列表 public static DataTable CreateView_B(string _selCol, string _strTestNo) { BLL.Bend bllts = new HR_Test.BLL.Bend(); string s = _selCol; DataSet dst = bllts.GetFinishList1(_selCol, " testNo = '" + _strTestNo + "' and isFinish=true "); return(dst.Tables[0]); }
private static List <TreeNode> ReadYBT5349Samples(DateTime dtp) { BLL.Bend bllb = new HR_Test.BLL.Bend(); DataSet dsb = bllb.GetNotOverlapList("testDate=#" + dtp.Date + "#"); int count = dsb.Tables[0].Rows.Count; List <TreeNode> ltn = new List <TreeNode>(); for (int j = 0; j < count; j++) { DataSet _dsb = bllb.GetList(" testNo='" + dsb.Tables[0].Rows[j]["testNo"].ToString() + "' and testDate=#" + dtp.Date + "#"); TreeNode tn = new TreeNode(); tn.Text = dsb.Tables[0].Rows[j]["testNo"].ToString(); tn.Name = "YBT5349-2006"; tn.ImageIndex = 0; foreach (DataRow dr in _dsb.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 = "YBT5349-2006_c"; ftn.Tag = dr; tn.Nodes.Add(ftn); } else { //左侧node未完成试验的图标 TreeNode ftn = new TreeNode(); ftn.ImageIndex = 2; ftn.Text = dr["testSampleNo"].ToString(); ftn.Name = "YBT5349-2006_c"; ftn.Tag = dr; tn.Nodes.Add(ftn); } } _dsb.Dispose(); ltn.Add(tn); } dsb.Dispose(); return(ltn); }
//求取平均值 X~,S,V public static DataTable CreateAverageViewReport(StringBuilder _selCol, StringBuilder _selSqlAver, string _strTestNo) { BLL.Bend bllts = new HR_Test.BLL.Bend(); //求平均 DataSet dsaver = bllts.GetFinishSumList1(_selSqlAver.ToString(), " testSampleNo in ('" + _strTestNo + ") and isFinish=true and isEffective=false "); //获取选择试样的数量和试样编号 string _sel = _selCol.ToString(); DataSet dsfinish = bllts.GetFinishListReport(_sel, " testSampleNo in ('" + _strTestNo + ") and isFinish=true and isEffective=false "); int fcount = dsfinish.Tables[0].Rows.Count; //变异系数 = sd/mean StringBuilder strCV = new StringBuilder(); //中间值 StringBuilder strMid = new StringBuilder(); ////添加新列 //DataColumn dc = new DataColumn(); //dc = dsaver.Tables[0].Columns.Add("数量(" + fcount + ")", System.Type.GetType("System.String")); ////设置为第0列 //dsaver.Tables[0].Columns["数量(" + fcount + ")"].SetOrdinal(0); ////平均值已经有一行,不用添加,直接修改其显示名称 //dsaver.Tables[0].Rows[0][0] = "Mean:"; ////S.D.标准偏差行 //if (_isSelSD) { dsaver.Tables[0].Rows.Add("S.D.:"); } ////变异系数行 //if (_isSelCV) { dsaver.Tables[0].Rows.Add("C.V.:"); } ////中间值行 //if (_isSelMid) { dsaver.Tables[0].Rows.Add("Mid.:"); } //创建新的数据计算结果表 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 (!string.IsNullOrEmpty(dsaver.Tables[0].Rows[0][i].ToString())) { if (double.Parse(dsaver.Tables[0].Rows[0][i].ToString()) != 0) { objmean.Add(dsaver.Tables[0].Rows[0][i].ToString()); } else { objmean.Add("-"); } } 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.:"); //计算标准偏差 int averColCount = dsaver.Tables[0].Columns.Count; int finishRowsCount = dsfinish.Tables[0].Rows.Count; for (int i = 0; i < averColCount; i++) { for (int j = 0; j < finishRowsCount; j++) { // 求和 (真实值-平均值)^2 string strtrue = dsfinish.Tables[0].Rows[j][i + 2].ToString(); string straver = dsaver.Tables[0].Rows[0][i].ToString(); ctrue = Convert.ToDouble(strtrue); caver = Convert.ToDouble(straver); 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]); }
//获取 弯曲试验 结果的 DataSource public static void readFinishSample(DataGridView dg, DataGridView dataGridViewSum, string testNo, DateTimePicker dtime, ZedGraph.ZedGraphControl zed) { //try //{ //dg.MultiSelect = true; if (dg != null) { dg.DataSource = null; dg.Columns.Clear(); dg.RowHeadersVisible = false; } BLL.Bend bllTs = new HR_Test.BLL.Bend(); double maxvalue = 0; DataSet dsmax = bllTs.GetFbbMax(" testNo='" + testNo + "' and testDate =#" + dtime.Value.Date + "#"); if (!string.IsNullOrEmpty(dsmax.Tables[0].Rows[0]["Fbb"].ToString())) { maxvalue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Fbb"].ToString()); } if (!string.IsNullOrEmpty(testNo)) { //if (testNo.Contains('-')) // testNo = testNo.Substring(0, testNo.LastIndexOf("-")); //获取不重复的试验编号列表 DataSet ds = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtime.Value.Date + "#"); DataSet ds1 = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtime.Value.Date + "#"); DataTable dt1 = ds1.Tables[0]; string methodName = dt1.Rows[0]["testMethod"].ToString(); if (dt1 != null) { StringBuilder[] tst = strSql_B(methodName, maxvalue); if (!string.IsNullOrEmpty(tst[0].ToString()) && dg != null) { dg.DataSource = CreateView_B(tst[0].ToString(), dt1.Rows[0]["testNo"].ToString()); } if (!string.IsNullOrEmpty(tst[1].ToString())) { dataGridViewSum.DataSource = CreateAverageView_B(tst[0], tst[1], dt1.Rows[0]["testNo"].ToString()); } } } else { DataSet ds = bllTs.GetFinishListDefault(" testNo='" + testNo + "' and testDate=#" + dtime.Value.Date + "#", maxvalue); DataTable _dt = ds.Tables[0]; DataRow dr = _dt.NewRow(); _dt.Rows.Add(dr); if (dg != null) { dg.DataSource = _dt; } ds.Dispose(); } if (dg != null) { DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn(); chkcol.Name = "选择"; chkcol.MinimumWidth = 50; chkcol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; 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 > 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(); } if (zed != null) { //clear all curves foreach (CurveItem ci in zed.GraphPane.CurveList) { ci.Clear(); ci.Label.Text = ""; } zed.AxisChange(); zed.Refresh(); } dsmax.Dispose(); //} //catch (Exception ee) { MessageBox.Show(this, ee.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void gBtnDelC_Click(object sender, EventArgs e) { BLL.Bend bllBend = new HR_Test.BLL.Bend(); bllBend.Delete(_methodName); //TestStandard.MethodControl.ReadMethod(this.treeviewTestMethod); }
private void gBtnDelB_Click(object sender, EventArgs e) { BLL.Bend bllBend = new HR_Test.BLL.Bend(); bllBend.Delete(this._methodName); //Task t = tskReadMethod(); }
//private void b_caculate_Click(object sender, EventArgs e) //{ // //矩形试样 // if (rbtnB1.Checked) // { // if (b_h.Text.Trim().Length > 0 && b_b.Text.Trim().Length > 0) // { // this.b_S0.Text = (double.Parse(b_h.Text.Trim()) * double.Parse(b_b.Text.Trim())).ToString("0.0000"); // } // } //} private void gBtnAddB_Click(object sender, EventArgs e) { string strErr = ""; if (this.b_testNo.Text.Trim().Length == 0) { strErr += "试验编号不能为空!\r\n"; } if (this.b_testSampleNo.Text.Trim().Length == 0) { strErr += "试样编号不能为空!\r\n"; } if (string.IsNullOrEmpty(this._sendCompany)) { strErr += "送检单位不能为空!\r\n"; } if (this.b_stuffCardNo.Text.Trim().Length == 0) { strErr += "材料牌号不能为空!\r\n"; } if (this.b_stuffSpec.Text.Trim().Length == 0) { strErr += "材料规格不能为空!\r\n"; } if (this.b_stuffType.Text.Trim().Length == 0) { strErr += "材料类型不能为空!\r\n"; } if (string.IsNullOrEmpty(this._temperature)) { strErr += "试验温度不能为空!\r\n"; } if (string.IsNullOrEmpty(this._condition)) { strErr += "试验条件不能为空!\r\n"; } if (string.IsNullOrEmpty(this._controlMode)) { strErr += "控制方式不能为空!\r\n"; } if (this.b_testMethod.Text.Trim().Length == 0) { strErr += "试验方法不能为空!\r\n"; } if (string.IsNullOrEmpty(this._sampleCharacter)) { strErr += "试样标识不能为空!\r\n"; } if (this.b_getSample.Text.Trim().Length == 0) { strErr += "试样取样不能为空!\r\n"; } if (this.b_tester.Text.Trim().Length == 0) { strErr += "试验员不能为空!\r\n"; } if (rbtnB1.Checked) { if (this.b_h.Text.Trim().Length == 0) { strErr += "h不能为空!\r\n"; } else { if (double.Parse(this.b_h.Text.Trim()) == 0d) { strErr += "h 不能为0!\r\n"; } } if (this.b_b.Text.Trim().Length == 0) { strErr += "b不能为空!\r\n"; } else { if (double.Parse(this.b_b.Text.Trim()) == 0d) { strErr += "b 不能为0!\r\n"; } } } if (rbtnB2.Checked) { if (this.b_d.Text.Trim().Length == 0) { strErr += "d不能为空!\r\n"; } else { if (double.Parse(this.b_d.Text.Trim()) == 0d) { strErr += "d 不能为0!\r\n"; } } } if (this.b_L.Text.Trim().Length == 0) { strErr += "L 不能为空!\r\n\r\n"; } else { if (double.Parse(this.b_L.Text.Trim()) == 0d) { strErr += "L 不能为0!\r\n\r\n"; } } if (this.b_Ls.Text.Trim().Length == 0) { strErr += "Ls 不能为空!\r\n\r\n"; } else { if (double.Parse(this.b_Ls.Text.Trim()) == 0d) { strErr += "Ls 不能为0!\r\n\r\n"; } } if (this.b_n.Text.Trim().Length == 0) { strErr += "n 不能为空!\r\n\r\n"; } else { if (double.Parse(this.b_n.Text.Trim()) == 0d) { strErr += "n 不能为0!\r\n\r\n"; } } if (this.b_εpb.Text.Trim().Length == 0) { strErr += "εpb 不能为空!\r\n\r\n"; } else { //if (double.Parse(this.b_εpb.Text.Trim()) == 0d) //{ // strErr += "εpb 不能为0!\r\n\r\n"; //} } if (this.b_εrb.Text.Trim().Length == 0) { strErr += "εrb 不能为空!\r\n\r\n"; } else { //if (double.Parse(this.b_εrb.Text.Trim()) == 0d) //{ // strErr += "εrb 不能为0!\r\n\r\n"; //} } if (this.cmbBendType.SelectedIndex == -1) { strErr += "请选择弯曲类型!\r\n;"; } //if (this.b_S0.Text.Trim().Length == 0) //{ // strErr += "S0不能为空!\r\n\r\n"; //} //else //{ // if (double.Parse(this.b_S0.Text.Trim()) == 0d) // { // strErr += "S0不能为0!\r\n\r\n"; // } //} switch (cmbBendType.SelectedIndex) { case 0: //三点弯曲 break; case 1: //四点弯曲 if (this.b_ll.Text.Trim().Length == 0) { strErr += "力臂不能为空!\r\n\r\n"; } else { if (double.Parse(this.b_ll.Text.Trim()) == 0d) { strErr += "力臂不能为0!\r\n\r\n"; } } break; } if (strErr != "") { MessageBox.Show(this, strErr); return; } HR_Test.Model.Bend model = new HR_Test.Model.Bend(); model.testNo = this.b_testNo.Text; model.testSampleNo = this.b_testSampleNo.Text; model.testMethodID = 0; model.sendCompany = this._sendCompany; model.stuffCardNo = this.b_stuffCardNo.Text; model.stuffSpec = b_stuffSpec.Text; model.stuffType = b_stuffType.Text; model.hotStatus = this._hotStatus; model.temperature = double.Parse(this._temperature); model.humidity = double.Parse(this._humidity); model.testStandard = this._testStandard_B.Text; model.testMethod = b_testMethod.Text; model.mathineType = b_mathineType.Text; model.testCondition = "-"; model.sampleCharacter = this._sampleCharacter; model.getSample = b_getSample.Text; model.tester = b_tester.Text; model.assessor = "-"; model.sign = this.b_sign.Text; model.testType = this.cmbBendType.Text; model.d = Convert.ToDouble(!string.IsNullOrEmpty(this.b_d.Text) ? this.b_d.Text : "0"); model.b = Convert.ToDouble(!string.IsNullOrEmpty(this.b_b.Text) ? this.b_b.Text : "0"); model.h = Convert.ToDouble(!string.IsNullOrEmpty(this.b_h.Text) ? this.b_h.Text : "0"); model.L = Convert.ToDouble(!string.IsNullOrEmpty(this.b_L.Text) ? this.b_L.Text : "0"); model.Ds = this._b_Ds; model.Da = this._b_Da; model.R = this._b_R; model.t = 0; model.Ls = Convert.ToDouble(!string.IsNullOrEmpty(this.b_Ls.Text) ? this.b_Ls.Text : "0"); model.Le = Convert.ToDouble(!string.IsNullOrEmpty(this.b_Le.Text) ? this.b_Le.Text : "0"); model.l_l = Convert.ToDouble(!string.IsNullOrEmpty(this.b_ll.Text) ? this.b_ll.Text : "0"); model.lt = 0; model.m = this._b_m; model.n = Convert.ToDouble(!string.IsNullOrEmpty(this.b_n.Text) ? this.b_n.Text : "0"); model.a = this._b_a; model.εpb = Convert.ToDouble(!string.IsNullOrEmpty(this.b_εpb.Text) ? this.b_εpb.Text : "0"); model.εrb = Convert.ToDouble(!string.IsNullOrEmpty(this.b_εrb.Text) ? this.b_εrb.Text : "0"); model.y = 0; //试验结果 if (this.rbtnB1.Checked) { model.sampleType = "矩形"; model.W = (double)Math.Round((decimal)(model.b * model.h * model.h / 6.0), 3); //bh²/6 model.I = (double)Math.Round((decimal)(model.b * model.h * model.h * model.h / 12), 3); //bh³/12 } else if (this.rbtnB2.Checked) { model.sampleType = "圆柱形"; model.W = (double)Math.Round((decimal)(Math.PI * model.d * model.d * model.d / 32), 3); model.I = (double)Math.Round((decimal)(Math.PI * model.d * model.d * model.d * model.d / 64.0), 3); } model.f_bb = 0; model.f_n = 0; model.f_n1 = 0; model.f_rb = 0; model.Fo = 0; model.Fpb = 0; model.Frb = 0; model.Fbb = 0; model.Fn = 0; model.Fn1 = 0; model.Z = 0; model.S = 0; model.Eb = 0; model.σpb = 0; model.σrb = 0; model.σbb = 0; model.U = 0; //----------- model.isFinish = false; model.isConformity = false; model.testDate = this.b_testDate.Value.Date; model.condition = this._condition; model.controlmode = this._controlMode; model.isUseExtensometer = false; model.isEffective = false; BLL.Bend bllc = new HR_Test.BLL.Bend(); if (bllc.GetList("testSampleNo ='" + this.b_testSampleNo.Text + "'").Tables[0].Rows.Count == 0) { bllc.Add(model); this.b_testSampleNo.Items.Remove(this.b_testSampleNo.SelectedItem); this.b_h.Text = "0"; this.b_b.Text = "0"; MessageBox.Show(this, "添加试样信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(this, "已经存在相同的编号,请重新设置!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //TestStandard.MethodControl.ReadMethod(this.treeviewTestMethod); }