using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Windows.Forms; using Core.StlMes.Client.Lims.Data.PipeAndOutdec.数据管理.钢管实验管理; namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec { public partial class FrmChemDataManageNew : FrmBase { public FrmChemDataManageNew() { InitializeComponent(); } private string[] arrId;//数据权限 private string[] arrId2;//数据权限 private string[] plineCodes = { }; private string deptid = ""; private int aduitCount = 0; private int manageCount = 0; private string updateFlag = "0"; private void FrmChemDataManageNew_Load(object sender, EventArgs e) { arrId2 = new string[] { "002001007010", "002023003001" };//化学 arrId = this.ValidDataPurviewIds; plineCodes = comm.GetPlineCode(ValidDataPurviewIds, ob); //取标钢时默认天管化学实验室 if (this.UserInfo.GetDeptid().Equals("002023003001")) { deptid = "002023003001"; } else { deptid = "002001007010"; } DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(this.ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(this.ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(this.ultraGrid4.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(this.ultraGrid5.DisplayLayout.Bands[0]); initChem(); cmbContent.SelectedIndex = 0; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); ultraGrid3.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; ultraGrid7.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; ultraGrid8.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; ultraGrid9.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; } /// /// 加载基础信息 /// private void initChem() { //加载试验设备 DataTable dt = PublicServer.GetData("com.steering.lims.data.pipe.FrmDataCJBase.initCheckEquipment", new object[] { arrId }, ob); if (dt != null && dt.Rows.Count > 0) { cmbChemDive.DataSource = dt; cmbChemDive.ValueMember = "DEVICE_NO"; } //加载试验方法 DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmDataCJBase.initCheckMethod", new object[] { arrId }, ob); if (ds != null && ds.Rows.Count > 0) { cmbChemMethodName.DataSource = ds; cmbChemMethodName.ValueMember = "CHECK_METHOD_NO"; } //加载钢种分类 DataTable gradeDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryGradeTypeNew", new object[] { }, ob); if (gradeDt != null && gradeDt.Rows.Count > 0) { comGradeType.DataSource = gradeDt; comGradeType.ValueMember = "ASSORTMENT_CODE"; } //加载试验人、审核人 DataTable userDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryUser", new object[] { arrId, arrId2 }, ob); if (userDt != null && userDt.Rows.Count > 0) { txtChemUser.DataSource = userDt; txtChemUser.ValueMember = "USERID"; txtAuditUser.DataSource = userDt; txtAuditUser.ValueMember = "USERID"; txtHandOverName.DataSource = userDt; txtHandOverName.ValueMember = "USERID"; txtTakeOverName.DataSource = userDt; txtTakeOverName.ValueMember = "USERID"; } this.cmbChemOrder.Value = UserInfo.GetUserOrder(); this.cmbChemGroup.Value = UserInfo.GetUserGroup(); this.txtChemUser.Text = UserInfo.GetUserName(); this.txtAuditUser.Text = UserInfo.GetUserName(); //加载设备运行记录受控编号 DataTable lxDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.initMeeting", new Object[] { "10012402%" }, ob); if (lxDt.Rows.Count > 0 && lxDt != null) { ultraLabelYX.Text = "设备运行记录:" + lxDt.Rows[0][0].ToString(); } //加载交接班记录受控编号 DataTable jjDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.initMeeting", new Object[] { "100126%" }, ob); if (jjDt.Rows.Count > 0 && jjDt != null) { ultraLabelJJ.Text = "交接班记录:" + jjDt.Rows[0][0].ToString(); } } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQueryChem(); break; case "CheckStdSteel": checkStdSteelValue(); break; case"DeletePipeOutData": deletePipeOutData(); break; case "Save": saveData(); break; case "Delete": deleteChemValue(); break; case "Audit": auditChemValue(); break; case"CancelAudit": cancelAudit(); break; case "Print": printReport(); break; case "UpFile": UpFile(); break; case "StdSteelNo": doStdSteelNo(); break; case "UpdateFlag0": updateFlag = "0"; break; case "UpdateFlag1": updateFlag = "1"; break; case "Close": close(); break; } } /// /// 标钢信息 /// private void doStdSteelNo() { this.ultraGrid4.UpdateData(); UltraGridRow uRow = this.ultraGrid4.ActiveRow; if (uRow == null) return; FrmChemDataManageNewSon labDateParm = new FrmChemDataManageNewSon(uRow.Cells["CheckNo"].Text.Trim(),"HX", this.ob); labDateParm.ShowDialog(); } /// /// 清除采集数据 /// private void deletePipeOutData() { this.ultraGrid1.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) return; PipeCheckconsignBaseinfoEntity pipeBaseInfoTity = (PipeCheckconsignBaseinfoEntity)uRow.ListObject; string pipeBaseEntity = JSONFormat.Format(pipeBaseInfoTity); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmChemDataManage"; ccp.MethodName = "deletePipeOutData"; ccp.ServerParams = new object[] { pipeBaseEntity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("清除成功!")) { doQueryChem(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 修约值检查 /// private void checkStdSteelValue() { UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) return; string gradeType = this.comGradeType.Text; if (gradeType == "") { MessageUtil.ShowTips("修约检查时请选择钢种分类"); return; } DataTable dsProvt = ultraGrid3.DataSource as DataTable; //取钢种下所有标钢号下元素值 DataTable stdsteelBaseDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteelBaseInfo", new object[] { uRow.Cells["SteelNo"].Text, deptid }, ob); Dictionary stdProcessDtDic = new Dictionary(); //取选择了哪些标钢 DataTable stdsteelDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteel", new object[] { uRow.Cells["SteelNo"].Text, deptid }, ob); DataTable stdsteelDt_ = stdsteelDt.DefaultView.ToTable(); foreach (UltraGridRow row in this.ultraGrid7.Rows) { for (int m = 1; m < dsProvt.Columns.Count; m++) { string bName = "0.0";//标钢标定值 string cName = "0.0";//标钢采集值 string name = ""; if (dsProvt.Columns[m].ColumnName.ToUpper().Equals("ALT")) { name = "ANA_" + "AL"; } else { name = "ANA_" + dsProvt.Columns[m].ColumnName.ToUpper(); } var list = stdsteelDt_.AsEnumerable().Where(p => p[name].ToString2() == "1").ToList();//取出对应元素所用的哪个标钢号 if (list.Count() > 0) { string steelname = list.FirstOrDefault()["SAMPLE_NO"].ToString2();//标钢号 if (list.Any()) { var list2 = stdsteelBaseDt.AsEnumerable().Where(p => p["SAMPLE_NO"].ToString2() == steelname).ToList(); if (list2.Any()) { bName = list2.FirstOrDefault()[name].ToString3();//标钢标定值 if (dsProvt.Columns[m].ColumnName.ToUpper().Equals("SI") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("MN") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("NI") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("CR") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("MO") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("CU") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("V") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("NB") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("TI") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("W") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("CO") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("ZR")) { bName = Math.Round(decimal.Parse(bName), 2).ToString3(); } else if (dsProvt.Columns[m].ColumnName.ToUpper().Equals("P") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("AL") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("ALS")) { bName = Math.Round(decimal.Parse(bName), 3).ToString3(); } else if (dsProvt.Columns[m].ColumnName.ToUpper().Equals("B") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("CA") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("PB") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("SN") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("AS") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("SB") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("BI")) { bName = Math.Round(decimal.Parse(bName), 4).ToString3(); } } } } string boundValue = ""; //row.Cells[m].Value = double.Parse(bName) - double.Parse(cName); DataTable gradeTypeDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryGradeTypeMax", new object[] { dsProvt.Columns[m].ColumnName.ToString(), bName, gradeType }, ob);//获取标钢修约值的界限值 if (gradeTypeDt.Rows.Count > 0) { boundValue = gradeTypeDt.Rows[0]["BOUNDARY_VALUE"].ToString3(); } else { boundValue = ""; } if (boundValue != "") { if (double.Parse(row.Cells[m - 1].Value.ToString3()) > double.Parse(boundValue.ToString3())) { row.Cells[m - 1].Appearance.BackColor = Color.Red; } else { row.Cells[m - 1].Appearance.BackColor = Color.Empty; } } } } } /// /// 打印报告 /// private void printReport() { this.ultraGrid4.UpdateData(); UltraGridRow uRow = this.ultraGrid4.ActiveRow; if (uRow == null) return; string checkNo = uRow.Cells["CheckNo"].Text.Trim(); string strSUPPLY_UNIT = uRow.Cells["SupplyUnit"].Text.Trim(); string flag = ""; DataTable dt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryFlag", new object[] { checkNo }, ob); if (dt.Rows.Count > 0) { flag = dt.Rows[0]["Flag"].ToString3(); } if (flag != "4" && flag != "5") { MessageUtil.ShowTips("未审核数据,不允许打印报告!"); return; } string strurl = ""; if (strSUPPLY_UNIT.Equals("江苏天淮钢管有限公司")) { strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepPipeChemAnalysisReportTH.cpt&op=view&CHECK_NO=" + checkNo; } else { strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepPipeChemAnalysisReport.cpt&op=view&CHECK_NO=" + checkNo; } FrmRepExcel fBug = new FrmRepExcel(ob, strurl); fBug.AutoSize = true; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fBug.WindowState = FormWindowState.Maximized; fBug.Text = "化成成分报告"; fBug.Show(); } //查询上传的PDF文件 /// /// 查询上传的PDF文件 /// private void SelectFile(string filePathNew) { dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathNew); // down.DeleteButton.Visible = false; down.ShowDialog(); } //上传 /// /// 上传 /// private void UpFile() { this.ultraGrid4.UpdateData(); UltraGridRow uRow = this.ultraGrid4.ActiveRow; if (uRow == null) return; string checkNo = uRow.Cells["CheckNo"].Text.Trim(); string strSUPPLY_UNIT = uRow.Cells["SupplyUnit"].Text.Trim(); string cpt = ""; if (strSUPPLY_UNIT.Equals("江苏天淮钢管有限公司")) { cpt = "RepPipeChemAnalysisReportTH.cpt"; } else { cpt = "RepPipeChemAnalysisReport.cpt"; } DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmDataCJBase.doQueryIsAudit", new object[] { checkNo, arrId }, ob); if (int.Parse(ds.Rows[0][0].ToString()) > 0) { MessageUtil.ShowTips("还有未审核试样组,不允许上传报告!"); return; } string filePathNew = ""; if (UpLoadHandle.Upload(checkNo, cpt, "huaxue", out filePathNew)) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmLabDateParm"; ccp.MethodName = "updatePipeReport"; ccp.ServerParams = new object[] { checkNo, "", "", "HUAXUE_PATH", filePathNew }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("上传成功!")) { MessageUtil.ShowTips(ccp.ReturnInfo); SelectFile(filePathNew); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } else { MessageUtil.ShowError("系统生成PDF失败,请稍后再试!"); return; } } //上传 /// /// 上传 /// private void UpFile(string checkNo) { DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmDataCJBase.doQueryIsAuditHx", new object[] { checkNo, arrId }, ob); if (int.Parse(ds.Rows[0][0].ToString()) > 0) { MessageUtil.ShowTips("还有未审核试样组,不允许上传报告!"); return; } string filePathNew = ""; if (UpLoadHandle.Upload(checkNo, "RepPipeChemAnalysisReport.cpt", "huaxue", out filePathNew)) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmLabDateParm"; ccp.MethodName = "updatePipeReport"; ccp.ServerParams = new object[] { checkNo, "", "", "HUAXUE_PATH", filePathNew }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("上传成功!")) { } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } else { MessageUtil.ShowError("系统生成PDF失败,请稍后再试!"); return; } } /// /// 查询 /// private void doQueryChem() { string startTim = ""; string endTim = ""; string checkNo = ""; string judgeNo = ""; string sampleNo = ""; if (this.chkRegTime.Checked) { startTim = this.RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.RegEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } if (this.chkLotNo.Checked && this.txtCheckNo.Text.Trim() != "") { checkNo = this.txtCheckNo.Text.Trim(); } if (this.chkJudgeNo.Checked && this.txtJudgeNo.Text.Trim() != "") { judgeNo = this.txtJudgeNo.Text.Trim(); } if (this.chkSampleNo.Checked && this.txtSampleNo.Text.Trim() != "") { sampleNo = this.txtSampleNo.Text.Trim(); } ArrayList parmList = new ArrayList(); parmList.Add(startTim); parmList.Add(endTim); parmList.Add(checkNo); parmList.Add(judgeNo); parmList.Add(sampleNo); if (ultraTabControl1.SelectedTab.Key == "0") { parmList.Add("2"); } else if (ultraTabControl1.SelectedTab.Key == "1") { parmList.Add("3"); } List listSource = EntityHelper.GetData( "com.steering.lims.data.pipe.FrmChemDataManage.doQueryChem", new object[] { parmList, arrId, plineCodes }, this.ob); if (ultraTabControl1.SelectedTab.Key == "0") { pipeCheckconsignBaseinfoEntityBindingSource1.Clear(); //((DataTable)this.ultraGrid3.DataSource).Clear(); pipeCheckconsignBaseinfoEntityBindingSource.DataSource = listSource; foreach (UltraGridRow row in ultraGrid1.Rows) { if (int.Parse(row.Cells["CheckCount"].Text) > 0) { row.RowSelectorAppearance.BackColor = Color.GreenYellow; ; } } } else if (ultraTabControl1.SelectedTab.Key == "1") { pipeCheckconsignBaseinfoEntityBindingSource3.Clear(); //((DataTable)this.ultraGrid6.DataSource).Clear(); pipeCheckconsignBaseinfoEntityBindingSource2.DataSource = listSource; foreach (UltraGridRow row in ultraGrid4.Rows) { if (row.Cells["Flag"].Text.Equals("已审核") || row.Cells["Flag"].Text.Equals("判定已接收")) { row.RowSelectorAppearance.BackColor = Color.Yellow; } } } } /// /// 删除化学结果 /// private void deleteChemValue() { this.ultraGrid4.UpdateData(); UltraGridRow uRow = this.ultraGrid4.ActiveRow; if (uRow == null) return; PipeCheckconsignBaseinfoEntity pipeBase = (PipeCheckconsignBaseinfoEntity)uRow.ListObject; string pipeBaseInfoEntity = JSONFormat.Format(pipeBase); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmChemDataManage"; ccp.MethodName = "deleteChemValue"; ccp.ServerParams = new object[] { pipeBaseInfoEntity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("删除成功!")) { doQueryChem(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 审核 /// private void auditChemValue() { this.ultraGrid4.UpdateData(); UltraGridRow uRow = this.ultraGrid4.ActiveRow; if (uRow == null) return; if (aduitCount > 0) { if (MessageUtil.ShowYesNoAndQuestion("存在不符合工艺文件数据信息,是否继续审核检验实绩?") == DialogResult.No) { return; } } PipeCheckconsignBaseinfoEntity pipeBase = (PipeCheckconsignBaseinfoEntity)uRow.ListObject; string pipeBaseInfoEntity = JSONFormat.Format(pipeBase); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmChemDataManage"; ccp.MethodName = "auditChemValue"; ccp.ServerParams = new object[] { pipeBaseInfoEntity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("审核成功!")) { string isProducer = uRow.Cells["Isproducer"].Text.ToString(); if (isProducer == "1") { if (MessageUtil.ShowYesNoAndQuestion("有监制,是否打印?") == DialogResult.Yes) { printReport(); } } UpFile(uRow.Cells["CheckNo"].Text); doQueryChem(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 取消审核 /// private void cancelAudit() { this.ultraGrid4.UpdateData(); UltraGridRow uRow = this.ultraGrid4.ActiveRow; if (uRow == null) return; PipeCheckconsignBaseinfoEntity pipeBase = (PipeCheckconsignBaseinfoEntity)uRow.ListObject; string pipeBaseInfoEntity = JSONFormat.Format(pipeBase); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmChemDataManage"; ccp.MethodName = "cancelAudit"; ccp.ServerParams = new object[] { pipeBaseInfoEntity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销成功!")) { doQueryChem(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 保存数据 /// private void saveData() { this.ultraGrid3.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; UltraGridRow stsRow = this.ultraGrid7.ActiveRow; if (uRow == null) return; UltraGrid ug = this.ultraGrid3; if (manageCount > 0) { if (MessageUtil.ShowYesNoAndQuestion("存在不符合工艺文件数据信息,是否继续保存检验实绩?") == DialogResult.No) { return; } } if (!checkBaseInfo()) { return; } string chemDiveCode = this.cmbChemDive.CheckedItems.Select(p => p.DataValue.ToString()).Aggregate((a, b) => a + (a == "" ? "" : ",") + b); string chemDiveName = this.cmbChemDive.CheckedItems.Select(p => p.DisplayText.ToString()).Aggregate((a, b) => a + (a == "" ? "" : ",") + b); string chemMethodCode = this.cmbChemMethodName.CheckedItems.Select(p => p.DataValue.ToString()).Aggregate((a, b) => a + (a == "" ? "" : ",") + b); string chemMethodName = this.cmbChemMethodName.CheckedItems.Select(p => p.DisplayText.ToString()).Aggregate((a, b) => a + (a == "" ? "" : ",") + b); ArrayList baseInfoList = new ArrayList(); baseInfoList.Add(chemDiveCode); baseInfoList.Add(chemDiveName); baseInfoList.Add(chemMethodCode); baseInfoList.Add(chemMethodName); baseInfoList.Add(this.cmbChemOrder.Value.ToString2()); baseInfoList.Add(this.cmbChemGroup.Value.ToString2()); baseInfoList.Add(this.txtChemUser.Text); baseInfoList.Add(this.txtAuditUser.Text); baseInfoList.Add(this.txtREMARK.Text); baseInfoList.Add(this.txtTemp.Text.Trim()); baseInfoList.Add(this.txtHumidity.Text.Trim()); baseInfoList.Add(this.cmbContent.Text); baseInfoList.Add(this.txtHandOverName.Text); baseInfoList.Add(this.txtTakeOverName.Text); baseInfoList.Add(this.txtProductionSituation.Text); if (this.txtChemUser.Text.Equals(this.txtAuditUser.Text)) { MessageUtil.ShowTips("试验人和审核人不能是同一人!"); return; } string diveName = "";//试样采集设备 DataTable dsDiveName = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryDiveName", new object[] { uRow.Cells["CheckNo"].Text }, ob); if (dsDiveName.Rows.Count > 0) { diveName = dsDiveName.Rows[0][0].ToString(); } //取选择了哪些标钢 DataTable stdsteelDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteel", new object[] { uRow.Cells["SteelNo"].Text, deptid }, ob); DataTable stdsteelDt_ = stdsteelDt.DefaultView.ToTable(); //标钢下元素值 DataTable stdsteelBaseDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteelBaseInfo", new object[] { uRow.Cells["SteelNo"].Text, deptid }, ob); ArrayList parmList = new ArrayList(); for (int i = 0; i < ug.Rows.Count; i++) { if (ug.Rows[i].Cells["SAMPLE_NO"].Text != "报出值") { for (int j = 1; j < this.ultraGrid3.DisplayLayout.Bands[0].Columns.Count; j++) { ArrayList chemCode = new ArrayList(); chemCode.Add(ug.Rows[i].Cells["SAMPLE_NO"].Text);//试样号 chemCode.Add(ug.Rows[i].Cells[j].Column.Key);//元素 chemCode.Add(stsRow.Cells[j - 1].Text);//元素修约值 chemCode.Add(ug.Rows[i].Cells[j].Text.ToString3());//元素采集值 chemCode.Add(ug.Rows[i + 1].Cells[j].Text.ToString3().Replace('<', '-'));//报出值 string chemName = "ANA_" + ug.Rows[i].Cells[j].Column.Key; var list = stdsteelDt_.AsEnumerable().Where(p => p[chemName].ToString2() == "1").ToList();//取出对应元素所用的哪个标钢号 if (list.Any()) { chemCode.Add(list.FirstOrDefault()["SAMPLE_NO"].ToString2());//标钢号 var list2 = stdsteelBaseDt.AsEnumerable().Where(p => p["SAMPLE_NO"].ToString2() == list.FirstOrDefault()["SAMPLE_NO"].ToString2()).ToList(); if (list2.Any()) { chemCode.Add(list2.FirstOrDefault()[chemName].ToString3());//标钢标定值 } else { chemCode.Add(""); } DataTable stdSteelD = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteelProcess", new object[] { list.FirstOrDefault()["SAMPLE_NO"].ToString2(), diveName }, ob); var list3 = stdSteelD.AsEnumerable().Where(p => p["SAMPLE_NO"].ToString2() == list2.FirstOrDefault()[chemName].ToString3()).ToList(); if (list3.Any()) { chemCode.Add(list3.FirstOrDefault()[chemName].ToString3());//标钢采集值 } else { chemCode.Add(""); } } else { chemCode.Add(""); chemCode.Add(""); chemCode.Add(""); } parmList.Add(chemCode); } } } PipeCheckconsignBaseinfoEntity pipeBase = (PipeCheckconsignBaseinfoEntity)uRow.ListObject; string pipeBaseInfoEntity = JSONFormat.Format(pipeBase); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.lims.data.pipe.FrmChemDataManage"; ccp.MethodName = "saveChemValue"; ccp.ServerParams = new object[] { pipeBaseInfoEntity, parmList, baseInfoList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("保存成功!")) { doQueryChem(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 检查基础信息是否选择、录入 /// /// private bool checkBaseInfo() { if (this.cmbChemDive.CheckedItems.Count() == 0) { MessageUtil.ShowTips("请选择试验设备!"); return false; } if (this.cmbChemMethodName.CheckedItems.Count() == 0) { MessageUtil.ShowTips("请选择试验方法!"); return false; } if (this.cmbChemOrder.Value.ToString2() == "") { MessageUtil.ShowTips("请选择试验班次!"); return false; } if (this.cmbChemGroup.Value.ToString2() == "") { MessageUtil.ShowTips("请选择试验班组!"); return false; } if (this.txtChemUser.Text.ToString2() == "") { MessageUtil.ShowTips("请输入试验人!"); return false; } if (this.txtAuditUser.Text.ToString2() == "") { MessageUtil.ShowTips("请输入审核人!"); return false; } if (this.txtTemp.Text.Trim() == "") { MessageUtil.ShowTips("请输入环境温度!"); return false; } if (this.txtHumidity.Text.Trim() == "") { MessageUtil.ShowTips("请输入环境湿度!"); return false; } if (this.cmbContent.Text.Trim() == "") { MessageUtil.ShowTips("请选择工作内容!"); return false; } return true; } /// /// 关闭 /// private void close() { this.Close(); } private void chkRegTime_CheckedChanged(object sender, EventArgs e) { this.RegStartTime.Enabled = this.RegEndTime.Enabled = this.chkRegTime.Checked; } private void chkLotNo_CheckedChanged(object sender, EventArgs e) { this.txtCheckNo.Enabled = this.chkLotNo.Checked; } private void chkJudgeNo_CheckedChanged(object sender, EventArgs e) { this.txtJudgeNo.Enabled = this.chkJudgeNo.Checked; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) return; doQueryChemBaseInfo(uRow);//查询委托基础信息 doQueryChemStdSteelValue(uRow);//查询标钢修约值 doQueryChemDetial(uRow);//查询化学检验基础信息 doQueryLgChem(uRow);//查询熔炼成分信息 } private void ultraGrid4_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = this.ultraGrid4.ActiveRow; if (uRow == null) { return; } doQueryChemBaseInfo(uRow);//查询委托基础信息 doQueryChemDetialQuote(uRow); checkChemValue(ultraGrid6, uRow); initCheckInformation(uRow); doQueryLgChem2(uRow);//查询熔炼成分信息 } private void initCheckInformation(UltraGridRow uRow) { DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryCheckTime", new object[] { uRow.Cells["CheckNo"].Text, uRow.Cells["SampleNo"].Text }, ob); if (ds.Rows.Count > 0) { this.txtTemp1.Text = ds.Rows[0]["CHECK_TEMP"].ToString(); this.txtHumidity1.Text = ds.Rows[0]["CHECK_HUMIDITY"].ToString(); this.cmbChemMethodName1.Value = ds.Rows[0]["FORMUAL_NAME"].ToString(); cmbChemDive1.Value = ds.Rows[0]["DEVICE_NAME"].ToString(); cmbChemOrder1.Value = ds.Rows[0]["CHECK_SHIFT"].ToString(); cmbChemGroup1.Value = ds.Rows[0]["CHECK_CLASS"].ToString(); txtChemUser1.Value = ds.Rows[0]["CHECK_NAME"].ToString(); cmbCheckTime.Value = ds.Rows[0]["CHECK_TIME"].ToString(); txtAuditUser1.Value = ds.Rows[0]["AUDIT_NAME"].ToString(); cmbAuditTime.Value = ds.Rows[0]["AUDIT_TIME"].ToString(); cmbContent1.Text = ds.Rows[0]["CONTENT"].ToString(); ultraHandOverName.Value = ds.Rows[0]["HAND_OVER_NAME"].ToString(); //交班人 ultraTakeOverName.Value = ds.Rows[0]["TAKE_OVER_NAME"].ToString(); //接班人 ultraProductionSituation.Value = ds.Rows[0]["PRODUCTION_SITUATION"].ToString(); //生产情况 } } /// /// 查询标钢计算修约值 /// /// private void doQueryChemStdSteelValue(UltraGridRow uRow) { //string steelType = "";//钢种分类 //DataTable steelTypeDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryGradeType", new object[] { uRow.Cells["SteelNo"].Text }, ob); //if (steelTypeDt.Rows.Count > 0) //{ // steelType = steelTypeDt.Rows[0]["ASSORTMENT_NAME"].ToString(); //} DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemDetial", new object[] { uRow.Cells["CheckNo"].Text }, ob); DataTable ss = ds.DefaultView.ToTable(); DataTable dsProvt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemPrivotStdSteel", new object[] { uRow.Cells["CheckNo"].Text }, ob); if (dsProvt.Rows.Count > 0) { for (int i = dsProvt.Columns.Count - 1; i >= 0; i--) { dsProvt.Columns[i].ColumnName = dsProvt.Columns[i].ColumnName.Trim('\''); if ((ss.Select("CHEM_NAME='" + dsProvt.Columns[i].ColumnName + "'").Length == 0)) { dsProvt.Columns.Remove(dsProvt.Columns[i].ColumnName); } } } ultraGrid7.DataSource = dsProvt; string diveName = "";//试样采集设备 DataTable dsDiveName = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryDiveName",new object[]{uRow.Cells["CheckNo"].Text},ob); if (dsDiveName.Rows.Count > 0) { diveName = dsDiveName.Rows[0][0].ToString(); } this.txtSamDiveName.Text = diveName; //取钢种下所有标钢号下元素值 DataTable stdsteelBaseDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteelBaseInfo", new object[] { uRow.Cells["SteelNo"].Text, deptid }, ob); Dictionary stdProcessDtDic = new Dictionary(); //取选择了哪些标钢 DataTable stdsteelDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteel", new object[] { uRow.Cells["SteelNo"].Text, deptid }, ob); DataTable stdsteelDt_ = stdsteelDt.DefaultView.ToTable(); foreach (UltraGridRow row in this.ultraGrid7.Rows) { for (int m = 0; m < dsProvt.Columns.Count; m++) { string bName = "0.0";//标钢标定值 string cName = "0.0";//标钢采集值 string name = ""; if (dsProvt.Columns[m].ColumnName.ToUpper().Equals("ALT")) { name = "ANA_" + "AL" ; } else { name = "ANA_" + dsProvt.Columns[m].ColumnName.ToUpper(); } var list = stdsteelDt_.AsEnumerable().Where(p => p[name].ToString2() == "1").ToList();//取出对应元素所用的哪个标钢号 if (list.Count() > 0) { string steelname = list.FirstOrDefault()["SAMPLE_NO"].ToString2();//标钢号 if (list.Any()) { var list2 = stdsteelBaseDt.AsEnumerable().Where(p => p["SAMPLE_NO"].ToString2() == steelname).ToList(); if (list2.Any()) { bName = list2.FirstOrDefault()[name].ToString3();//标钢标定值 DataTable stdProcessDt; if (stdProcessDtDic.ContainsKey(steelname)) { stdProcessDtDic.TryGetValue(steelname, out stdProcessDt); } else { stdProcessDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteelProcess", new object[] { steelname, diveName }, ob); stdProcessDtDic.Add(steelname, stdProcessDt); } var list3 = stdProcessDt.AsEnumerable().Where(p => p["SAMPLE_NO"].ToString2().ToUpper() == steelname.ToUpper()).ToList(); if (list3.Any()) { cName = list3.FirstOrDefault()[name].ToString3();//标钢采集值 } } } } string boundValue = ""; if (!StringUtil.IsNumber(cName)) { MessageUtil.ShowTips("标钢采集值:" + cName + "不是数字"); return; } row.Cells[m].Value = decimal.Parse(bName) - decimal.Parse(cName); //隐藏C、S //if (dsProvt.Columns[m].ColumnName.ToUpper().Equals("C") || dsProvt.Columns[m].ColumnName.ToUpper().Equals("S")) //{ // row.Cells[m].Column.Hidden = true; //} row.Cells[m].Appearance.FontData.SizeInPoints = 10; //DataTable gradeTypeDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryGradeTypeMax", new object[] { dsProvt.Columns[m].ColumnName.ToString(), bName, steelType }, ob);//获取标钢修约值的界限值 //if (gradeTypeDt.Rows.Count > 0) //{ // boundValue = gradeTypeDt.Rows[0]["BOUNDARY_VALUE"].ToString3(); //} //else //{ // boundValue = ""; //} //if (double.Parse(row.Cells[m].Value.ToString3()) > double.Parse(boundValue.ToString3())) //{ // row.Cells[m].Appearance.BackColor = Color.Red; //} } } //foreach (UltraGridColumn clo in this.ultraGrid7.DisplayLayout.Bands[0].Columns) //{ // clo.Header.Appearance.FontData.SizeInPoints = 12; //} GridHelper.RefreshAndAutoSize(ultraGrid7); //GridHelper.SetAllColumnsActive(ultraGrid7); } /// /// 查询保存结果 /// /// private void doQueryChemDetialQuote(UltraGridRow uRow) { DataTable chemDetialDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemDetialQuote", new object[] { uRow.Cells["CheckNo"].Text }, ob); DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemDetial", new object[] { uRow.Cells["CheckNo"].Text }, ob); DataTable ss = ds.DefaultView.ToTable(); chemDetialDt.Columns["SAMPLE_NO"].Caption = "试样号"; if (chemDetialDt.Rows.Count > 0) { if (chemDetialDt.Columns.Contains("'Al'") && chemDetialDt.Columns.Contains("'N'")) { chemDetialDt.Columns.Add(new DataColumn("ALN") { Caption = "ALN" }); for (int i = 0; i < chemDetialDt.Rows.Count; i++) { if (!string.IsNullOrWhiteSpace(chemDetialDt.Rows[i]["'Al'"].ToString2()) && !string.IsNullOrWhiteSpace(chemDetialDt.Rows[i]["'N'"].ToString2())) { chemDetialDt.Rows[i]["ALN"] = (Double.Parse(chemDetialDt.Rows[i]["'Al'"].ToString2()) / Double.Parse(chemDetialDt.Rows[i]["'N'"].ToString2())).ToString("f3"); } } } for (int i = chemDetialDt.Columns.Count - 1; i >= 0; i--) { chemDetialDt.Columns[i].ColumnName = chemDetialDt.Columns[i].ColumnName.Trim('\''); if (chemDetialDt.Columns[i].ColumnName != "SAMPLE_NO" && (ss.Select("CHEM_NAME='" + chemDetialDt.Columns[i].ColumnName + "'").Length == 0) && chemDetialDt.Columns[i].ColumnName != "ALN") { chemDetialDt.Columns.Remove(chemDetialDt.Columns[i].ColumnName); } } } ultraGrid6.DataSource = chemDetialDt; foreach (UltraGridRow row in ultraGrid6.Rows) { if (double.Parse( row.Cells["ALN"].Text.ToString3()) < 2 ) { row.Cells["ALN"].Appearance.BackColor = Color.Red; } for (int i = 0; i < ultraGrid6.DisplayLayout.Bands[0].Columns.Count; i++) { row.Cells[i].Appearance.FontData.SizeInPoints = 10; } } string diveName = "";//试样采集设备 DataTable dsDiveName = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryDiveName", new object[] { uRow.Cells["CheckNo"].Text }, ob); if (dsDiveName.Rows.Count > 0) { diveName = dsDiveName.Rows[0][0].ToString(); } txtDiveName1.Text = diveName; GridHelper.RefreshAndAutoSize(ultraGrid6); GridHelper.SetAllColumnsActive(ultraGrid6); } /// /// 查询熔炼成分 /// /// private void doQueryLgChem(UltraGridRow uRow) { if (ultraGrid8.DataSource != null) { ((DataTable)ultraGrid8.DataSource).Clear(); } DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryLgChem", new object[] { uRow.Cells["StoveNo"].Text }, ob); DataTable dt = ultraGrid3.DataSource as DataTable; if (ds.Rows.Count > 0) { for (int i = ds.Columns.Count - 1; i >= 0; i--) { if (ds.Columns[i].ColumnName.Equals("SAMPLE_NO")) { ds.Columns[i].Caption = "式样号"; } if (ds.Columns[i].ColumnName.Equals("ASN")) { ds.Columns[i].ColumnName = "As"; } else { if (ds.Columns[i].ColumnName.Length == 2) { ds.Columns[i].ColumnName = ds.Columns[i].ColumnName.Substring(0, 1) + ds.Columns[i].ColumnName.Substring(1, 1).ToLower(); } } if (!dt.Columns.Contains(ds.Columns[i].ColumnName)) { ds.Columns.Remove(ds.Columns[i].ColumnName); } } ultraGrid8.DataSource = ds; GridHelper.RefreshAndAutoSize(ultraGrid8); } else { ultraGrid8.DataSource = null; } } private void doQueryLgChem2(UltraGridRow uRow) { if (ultraGrid9.DataSource != null) { ((DataTable)ultraGrid9.DataSource).Clear(); } DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryLgChem", new object[] { uRow.Cells["StoveNo"].Text }, ob); DataTable dt = ultraGrid6.DataSource as DataTable; if (ds.Rows.Count > 0) { for (int i = ds.Columns.Count - 1; i >= 0; i--) { if (ds.Columns[i].ColumnName.Equals("SAMPLE_NO")) { ds.Columns[i].Caption = "式样号"; } if (ds.Columns[i].ColumnName.Equals("ASN")) { ds.Columns[i].ColumnName = "As"; } else { if (ds.Columns[i].ColumnName.Length == 2) { ds.Columns[i].ColumnName = ds.Columns[i].ColumnName.Substring(0, 1) + ds.Columns[i].ColumnName.Substring(1, 1).ToLower(); } } if (!dt.Columns.Contains(ds.Columns[i].ColumnName)) { ds.Columns.Remove(ds.Columns[i].ColumnName); } } ultraGrid9.DataSource = ds; GridHelper.RefreshAndAutoSize(ultraGrid9); } else { ultraGrid9.DataSource = null; } } /// /// 查询化学详细检验信息 /// /// private void doQueryChemDetial(UltraGridRow uRow) { string steelType = "";//钢种分类 string txtLable = ""; UltraGridRow stsRow = this.ultraGrid7.ActiveRow; DataTable steelTypeDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryGradeType", new object[] { uRow.Cells["SteelNo"].Text }, ob); if (steelTypeDt.Rows.Count > 0) { steelType = steelTypeDt.Rows[0]["ASSORTMENT_NAME"].ToString(); } DataTable ds = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemDetial", new object[] { uRow.Cells["CheckNo"].Text }, ob); DataTable ss = ds.DefaultView.ToTable(); DataTable dsProvt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemPrivot", new object[] { uRow.Cells["CheckNo"].Text }, ob); dsProvt.Columns["SAMPLE_NO"].Caption = "试样号"; if (dsProvt.Rows.Count > 0) { for (int i = dsProvt.Columns.Count - 1; i >= 0; i--) { dsProvt.Columns[i].ColumnName = dsProvt.Columns[i].ColumnName.Trim('\''); if (dsProvt.Columns[i].ColumnName != "SAMPLE_NO" && (ss.Select("CHEM_NAME='" + dsProvt.Columns[i].ColumnName + "'").Length == 0)) { dsProvt.Columns.Remove(dsProvt.Columns[i].ColumnName); } } } //增加修约值行 for (int h = 0; h < dsProvt.Rows.Count; h++) { DataRow drr = dsProvt.NewRow(); drr["SAMPLE_NO"] = "报出值"; dsProvt.Rows.InsertAt(drr, h + 1); h++; } ultraGrid3.DataSource = dsProvt; //取钢种下所有标钢号下元素值 DataTable stdsteelBaseDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryStdsteelBaseInfo", new object[] { uRow.Cells["SteelNo"].Text, deptid }, ob); Dictionary stdProcessDtDic = new Dictionary(); for (int k = 0; k < ultraGrid3.Rows.Count; k++) { if (updateFlag == "0") { ultraGrid3.Rows[k].Cells[0].Activation = Activation.ActivateOnly; } else { ultraGrid3.Rows[k].Cells[0].Activation = Activation.AllowEdit; } if (ultraGrid3.Rows[k].Cells["SAMPLE_NO"].Value.ToString() != "报出值") { //取式样号下采集值 DataTable dsSampleDt = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQuerySampleProcess", new object[] { uRow.Cells["CheckNo"].Text, ultraGrid3.Rows[k].Cells["SAMPLE_NO"].Value.ToString() }, ob); if (dsSampleDt.Rows.Count > 0) { for (int x = 1; x < dsProvt.Columns.Count; x++) { string cc = dsProvt.Columns[x].ColumnName.ToUpper(); decimal bcValue = 0; ultraGrid3.Rows[k].Cells[x].Value = dsSampleDt.Rows[0]["ANA_" + dsProvt.Columns[x].ColumnName.ToUpper()].ToString(); if (!dsProvt.Columns[x].ColumnName.ToUpper().Equals("C") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("S") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("CA") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("BI") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("ALS")) { if (updateFlag == "0") { ultraGrid3.Rows[k].Cells[x].Activation = Activation.ActivateOnly; } else { ultraGrid3.Rows[k].Cells[x].Activation = Activation.AllowEdit; } bcValue = decimal.Parse(dsSampleDt.Rows[0]["ANA_" + dsProvt.Columns[x].ColumnName.ToUpper()].ToString3()) + decimal.Parse(this.ultraGrid7.Rows[0].Cells[x - 1].Value.ToString3()); } else { ultraGrid3.Rows[k].Cells[x].Activation = Activation.AllowEdit; ultraGrid3.Rows[k].Cells[x].Appearance.BackColor = Color.Yellow; //bcValue = decimal.Parse(dsSampleDt.Rows[0]["ANA_" + dsProvt.Columns[x].ColumnName.ToUpper()].ToString3()); bcValue = decimal.Parse(dsSampleDt.Rows[0]["ANA_" + dsProvt.Columns[x].ColumnName.ToUpper()].ToString3()) + decimal.Parse(this.ultraGrid7.Rows[0].Cells[x - 1].Value.ToString3()); } ultraGrid3.Rows[k + 1].Cells[x].Value = bcValue; if (!dsProvt.Columns[x].ColumnName.ToUpper().Equals("PB") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("BI") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("SB")) { if (bcValue <= 0) { txtLable = txtLable + dsProvt.Columns[x].ColumnName + "异常 "; } } if (updateFlag == "0") { ultraGrid3.Rows[k + 1].Cells[x].Activation = Activation.ActivateOnly; } else { ultraGrid3.Rows[k + 1].Cells[x].Activation = Activation.AllowEdit; } ultraGrid3.Rows[k].Cells[x].Appearance.FontData.SizeInPoints = 10; } //ultraLabel11.Text = txtLable; ultraLabel11.ForeColor = Color.Red; } else { for (int x = 1; x < dsProvt.Columns.Count; x++) { ultraGrid3.Rows[k].Cells[x].Value = ""; if (!dsProvt.Columns[x].ColumnName.ToUpper().Equals("C") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("S") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("B") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("CA") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("BI") && !dsProvt.Columns[x].ColumnName.ToUpper().Equals("ALS")) { ultraGrid3.Rows[k + 1].Cells[x].Value = 0.0 - double.Parse(this.ultraGrid7.Rows[0].Cells[x - 1].Value.ToString3()); if (updateFlag == "0") { ultraGrid3.Rows[k].Cells[x].Activation = Activation.ActivateOnly; } else { ultraGrid3.Rows[k].Cells[x].Activation = Activation.AllowEdit; } } else { ultraGrid3.Rows[k + 1].Cells[x].Value = 0.0 - double.Parse(this.ultraGrid7.Rows[0].Cells[x - 1].Value.ToString3()); ultraGrid3.Rows[k].Cells[x].Activation = Activation.AllowEdit; ultraGrid3.Rows[k].Cells[x].Appearance.BackColor = Color.Yellow; } ultraGrid3.Rows[k].Cells[x].Appearance.FontData.SizeInPoints = 10; //ultraGrid3.Rows[k + 1].Cells[x].Value = 0.0 - double.Parse(this.ultraGrid7.Rows[0].Cells[x - 1].Value.ToString3()); //ultraGrid3.Rows[k + 1].Cells[x].Activation = Activation.ActivateOnly; } } } else { for (int x = 1; x < dsProvt.Columns.Count; x++) { ultraGrid3.Rows[k].Cells[x].Appearance.FontData.SizeInPoints = 10; } } } checkUltraGrid(ultraGrid3, uRow); GridHelper.RefreshAndAutoSize(ultraGrid3); //foreach (UltraGridColumn cl in ultraGrid3.DisplayLayout.Bands[0].Columns) //{ // cl.FilterOperandStyle = FilterOperandStyle.Disabled; //} } /// /// 检查保存后数据 /// /// /// private void checkChemValue(UltraGrid ug, UltraGridRow uRow) { DataTable chemDataTable = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemDetial", new object[] { uRow.Cells["CheckNo"].Text }, ob); if (chemDataTable.Rows.Count <= 0) return; for (int i = 0; i < ug.Rows.Count; i++) { string sampleNo = ug.Rows[i].Cells["SAMPLE_NO"].Value.ToString(); for (int j = 1; j < ug.DisplayLayout.Bands[0].Columns.Count; j++) { string columsKey = ug.DisplayLayout.Bands[0].Columns[j].Key; if (!chemDataTable.AsEnumerable().Any(p => p["SAMPLE_NO"].ToString() == sampleNo && p["CHEM_NAME"].ToString() == columsKey)) continue; DataRow list = chemDataTable.AsEnumerable().First(p => p["SAMPLE_NO"].ToString() == sampleNo && p["CHEM_NAME"].ToString() == columsKey); string stdMax = list["STDMAX"].ToString();//元素上限值 string stdMin = list["STDMIN"].ToString();//元素下限值 double quoteValue = double.Parse(ug.Rows[i].Cells[j].Value.ToString3().Replace('<', '-')); //判断报出值是否不合 if (stdMin != "" && stdMax != "") { if (quoteValue < double.Parse(stdMin) || quoteValue > double.Parse(stdMax)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; aduitCount = aduitCount + 1; } } else if (stdMin != "" && stdMax == "") { if (StringUtil.IsNumber(stdMin)) { if (quoteValue < double.Parse(stdMin)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; aduitCount = aduitCount + 1; } } } else if (stdMin == "" && stdMax != "") { if (StringUtil.IsNumber(stdMax)) { if (quoteValue > double.Parse(stdMax)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; aduitCount = aduitCount + 1; } } } } } } /*/// /// 检查数据 /// /// private void checkUltraGrid(UltraGrid ug, UltraGridRow uRow) { manageCount = 0; DataTable chemDataTable = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemDetial", new object[] { uRow.Cells["CheckNo"].Text }, ob); if (chemDataTable.Rows.Count <= 0) return; int quoteIndex = 0;//报出值位数 int stdMinIndex = 0;//下限小数位数 int stdMaxIndex = 0;//上限小数位数 int stdIndex = 0;//报出位数 string txtLable = ""; this.ultraLabel27.Text = ""; for (int i = 0; i < ug.Rows.Count; i++) { if (ug.Rows[i].Cells["SAMPLE_NO"].Text == "报出值") { string sampleNo = ug.Rows[i - 1].Cells["SAMPLE_NO"].Value.ToString(); for (int j = 1; j < ug.DisplayLayout.Bands[0].Columns.Count; j++) { string columsKey = ug.DisplayLayout.Bands[0].Columns[j].Key; if (!chemDataTable.AsEnumerable().Any(p => p["SAMPLE_NO"].ToString() == sampleNo && p["CHEM_NAME"].ToString() == columsKey)) continue; DataRow list = chemDataTable.AsEnumerable().First(p => p["SAMPLE_NO"].ToString() == sampleNo && p["CHEM_NAME"].ToString() == columsKey); string stdMax = list["STDMAX"].ToString();//元素上限值 string stdMin = list["STDMIN"].ToString();//元素下限值 double quoteValue = double.Parse(ug.Rows[i].Cells[j].Value.ToString3().Replace('<', '-'));//报出值 quoteIndex = ug.Rows[i].Cells[j].Value.ToString3().Length - ug.Rows[i].Cells[j].Value.ToString3().IndexOf('.') - 1;//报出值小数位数 stdMinIndex = stdMin.Length - stdMin.IndexOf('.') - 1;//下限值小数位数 stdMaxIndex = stdMax.Length - stdMax.IndexOf('.') - 1;//上限值小数位数 if (stdMax == "" && stdMin == "")//工艺无要求上下限 { if (columsKey == "V" || columsKey == "Nb" || columsKey == "Ti" || columsKey == "Zr" || columsKey == "Mo" || columsKey == "Ni" || columsKey == "Cr" || columsKey == "Mo" || columsKey == "Cu" || columsKey == "W" || columsKey == "Co") { //大于0.006的数据四舍六入后是0.01 if (quoteValue < 0.006) { ug.Rows[i].Cells[j].Value = "<0.01"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 2).ToString("f" + 2); } } else if (columsKey == "Pb" || columsKey == "Bi" || columsKey == "Sn" || columsKey == "As") { if (quoteValue < 0.0010) { ug.Rows[i].Cells[j].Value = "<0.0010"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 4).ToString("f" + 4); } } else if (columsKey == "Sb") { if (quoteValue < 0.0020) { ug.Rows[i].Cells[j].Value = "<0.0020"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 4).ToString("f" + 4); } } else if (columsKey == "B") { if(uRow.Cells["ContractNo"].Text.Contains("EXMPQ-180449E")) { this.ultraLabel27.Text = "B元素需报出实际值!"; this.ultraLabel27.ForeColor = Color.Red; ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 4).ToString("f" + 4); } else { if (quoteValue < 0.0005) { ug.Rows[i].Cells[j].Value = "<0.0005"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 4).ToString("f" + 4); } } } else if (columsKey == "C" || columsKey == "Si" || columsKey == "Mn" || columsKey == "Ni" || columsKey == "Cr" || columsKey == "Mo" || columsKey == "Cu" || columsKey == "W" || columsKey == "Co") { if (columsKey == "C" && uRow.Cells["SteelGrade"].Text.Contains("DNVGL SMLS 13Cr")) { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 3).ToString("f" + 3); } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 2).ToString("f" + 2); } if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。"; } } else if (columsKey == "P" || columsKey == "S" || columsKey == "Al" || columsKey == "Als") { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 3).ToString("f" + 3); if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。"; } } else if (columsKey == "Ca" || columsKey == "Sn" || columsKey == "As") { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 4).ToString("f" + 4); if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。。"; } } } else { //判断报出值是否不合 if (columsKey != "Ca" && columsKey != "S") { if (stdMaxIndex >= stdMinIndex)//按工艺位数修约位数 { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMaxIndex).ToString("f" + stdMaxIndex); } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMinIndex).ToString("f" + stdMinIndex); } } else if (columsKey == "C") { if (stdMaxIndex >= stdMinIndex)//按工艺位数修约位数 { if (quoteIndex != stdMaxIndex) { txtLable = txtLable + columsKey + "元素工艺要求报出" + stdMaxIndex + "位"; } } else { if (quoteIndex != stdMinIndex) { txtLable = txtLable + columsKey + "元素工艺要求报出" + stdMinIndex + "位"; } } } else { if (columsKey == "Ca") { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 4).ToString("f" + 4); } if (columsKey == "S") { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 3).ToString("f" + 3); } } //判断符合工艺文件否 if (stdMin != "" && stdMax != "") { if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) < double.Parse(stdMin) || double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) > double.Parse(stdMax)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; manageCount = manageCount + 1; txtLable = txtLable + columsKey + "元素不合。"; } else { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } else if (stdMin != "" && stdMax == "") { if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) < double.Parse(stdMin)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; manageCount = manageCount + 1; txtLable = txtLable + columsKey + "元素不合。"; } else { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } else if (stdMin == "" && stdMax != "") { if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) > double.Parse(stdMax)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; manageCount = manageCount + 1; txtLable = txtLable + columsKey + "元素不合。"; } else { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } if (columsKey == "V" || columsKey == "Nb" || columsKey == "Ti" || columsKey == "Zr" || columsKey == "Ni" || columsKey == "Cr" || columsKey == "Mo" || columsKey == "Cu" || columsKey == "W" || columsKey == "Co") { //大于0.006的数据四舍六入后是0.01 if (quoteValue < 0.006) { ug.Rows[i].Cells[j].Value = "<0.01"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else if (quoteValue >= 0.006 && quoteValue < 0.01) { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 2).ToString("f" + 2); } //if (quoteValue < 0.01) //{ // ug.Rows[i].Cells[j].Value = "<0.01"; // ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; //} else { if (stdMaxIndex > 2 || stdMinIndex > 2) { if (stdMaxIndex > stdMinIndex) { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMaxIndex).ToString("f" + stdMaxIndex); } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMinIndex).ToString("f" + stdMinIndex); } } } } else if (columsKey == "Pb" || columsKey == "Bi" || columsKey == "Sn" || columsKey == "As") { if (quoteValue < 0.0010) { ug.Rows[i].Cells[j].Value = "<0.0010"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } else if (columsKey == "Sb") { if (quoteValue < 0.0020) { ug.Rows[i].Cells[j].Value = "<0.0020"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } else if (columsKey == "B") { if (uRow.Cells["ContractNo"].Text.Contains("EXMPQ-180449E")) { this.ultraLabel27.Text = "B元素需报出实际值!"; this.ultraLabel27.ForeColor = Color.Red; ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 4).ToString("f" + 4); } else { if (quoteValue < 0.0005) { ug.Rows[i].Cells[j].Value = "<0.0005"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } } else { if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。"; } } } } } } this.ultraLabel11.Text = txtLable; } */ /// /// 检查数据 /// /// private void checkUltraGrid(UltraGrid ug, UltraGridRow uRow) { manageCount = 0; DataTable chemDataTable = PublicServer.GetData("com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemDetial", new object[] { uRow.Cells["CheckNo"].Text }, ob); if (chemDataTable.Rows.Count <= 0) return; // 定义元素精度字典 Dictionary elementPrecision = new Dictionary(StringComparer.OrdinalIgnoreCase) { {"Fe", 2}, {"Co", 2}, {"Ta", 2}, {"Se", 2}, {"C", 2}, {"Si", 2}, {"Mn", 2}, {"P", 3}, {"S", 3}, {"Ni", 2}, {"Cr", 2}, {"Cu", 2}, {"As", 4}, {"Ti", 3}, {"V", 3}, {"Mo", 3}, {"B", 4}, {"W", 3}, {"Al", 3}, {"Zn", 3}, {"Pb", 4}, {"Sn", 4}, {"Ca", 4}, {"Sb", 4}, {"Nb", 3}, {"Bi", 4}, {"N", 4}, {"H", 5}, {"O", 4}, {"Zr", 3}, {"Alt", 3}, {"Als", 3} }; int quoteIndex = 0;//报出值位数 int stdMinIndex = 0;//下限小数位数 int stdMaxIndex = 0;//上限小数位数 int stdIndex = 0;//报出位数 string txtLable = ""; this.ultraLabel27.Text = ""; for (int i = 0; i < ug.Rows.Count; i++) { if (ug.Rows[i].Cells["SAMPLE_NO"].Text == "报出值") { string sampleNo = ug.Rows[i - 1].Cells["SAMPLE_NO"].Value.ToString(); for (int j = 1; j < ug.DisplayLayout.Bands[0].Columns.Count; j++) { string columsKey = ug.DisplayLayout.Bands[0].Columns[j].Key; if (!chemDataTable.AsEnumerable().Any(p => p["SAMPLE_NO"].ToString() == sampleNo && p["CHEM_NAME"].ToString() == columsKey)) continue; DataRow list = chemDataTable.AsEnumerable().First(p => p["SAMPLE_NO"].ToString() == sampleNo && p["CHEM_NAME"].ToString() == columsKey); string stdMax = list["STDMAX"].ToString();//元素上限值 string stdMin = list["STDMIN"].ToString();//元素下限值 double quoteValue = double.Parse(ug.Rows[i].Cells[j].Value.ToString3().Replace('<', '-'));//报出值 quoteIndex = ug.Rows[i].Cells[j].Value.ToString3().Length - ug.Rows[i].Cells[j].Value.ToString3().IndexOf('.') - 1;//报出值小数位数 stdMinIndex = stdMin.Length - stdMin.IndexOf('.') - 1;//下限值小数位数 stdMaxIndex = stdMax.Length - stdMax.IndexOf('.') - 1;//上限值小数位数 // 获取元素的精度,默认为2位 int precision = elementPrecision.ContainsKey(columsKey) ? elementPrecision[columsKey] : 2; if (stdMax == "" && stdMin == "")//工艺无要求上下限 { if (columsKey == "V" || columsKey == "Nb" || columsKey == "Ti" || columsKey == "Zr" || columsKey == "Mo" || columsKey == "Ni" || columsKey == "Cr" || columsKey == "Cu" || columsKey == "W" || columsKey == "Co") { // 使用固定精度修约 if (quoteValue < 0.006) { ug.Rows[i].Cells[j].Value = "<0.01"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } else if (columsKey == "Pb" || columsKey == "Bi" || columsKey == "Sn" || columsKey == "As") { if (quoteValue < 0.0010) { ug.Rows[i].Cells[j].Value = "<0.0010"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } else if (columsKey == "Sb") { if (quoteValue < 0.0020) { ug.Rows[i].Cells[j].Value = "<0.0020"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } else if (columsKey == "B") { if (uRow.Cells["ContractNo"].Text.Contains("EXMPQ-180449E")) { this.ultraLabel27.Text = "B元素需报出实际值!"; this.ultraLabel27.ForeColor = Color.Red; ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } else { if (quoteValue < 0.0005) { ug.Rows[i].Cells[j].Value = "<0.0005"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } } else if (columsKey == "C" || columsKey == "Si" || columsKey == "Mn" || columsKey == "Ni" || columsKey == "Cr" || columsKey == "Mo" || columsKey == "Cu" || columsKey == "W" || columsKey == "Co") { if (columsKey == "C" && uRow.Cells["SteelGrade"].Text.Contains("DNVGL SMLS 13Cr")) { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, 3).ToString("f" + 3); } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。"; } } else if (columsKey == "P" || columsKey == "S" || columsKey == "Al" || columsKey == "Als") { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。"; } } else if (columsKey == "Ca" || columsKey == "Sn" || columsKey == "As") { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。"; } } else { // 默认使用固定精度修约 ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } else { //判断报出值是否不合 if (columsKey != "Ca" && columsKey != "S") { if (stdMaxIndex >= stdMinIndex)//按工艺位数修约位数 { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMaxIndex).ToString("f" + stdMaxIndex); } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMinIndex).ToString("f" + stdMinIndex); } } else if (columsKey == "C") { if (stdMaxIndex >= stdMinIndex)//按工艺位数修约位数 { if (quoteIndex != stdMaxIndex) { txtLable = txtLable + columsKey + "元素工艺要求报出" + stdMaxIndex + "位"; } } else { if (quoteIndex != stdMinIndex) { txtLable = txtLable + columsKey + "元素工艺要求报出" + stdMinIndex + "位"; } } } else { // 使用固定精度修约 ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } //判断符合工艺文件否 if (stdMin != "" && stdMax != "") { if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) < double.Parse(stdMin) || double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) > double.Parse(stdMax)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; manageCount = manageCount + 1; txtLable = txtLable + columsKey + "元素不合。"; } else { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } else if (stdMin != "" && stdMax == "") { if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) < double.Parse(stdMin)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; manageCount = manageCount + 1; txtLable = txtLable + columsKey + "元素不合。"; } else { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } else if (stdMin == "" && stdMax != "") { if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) > double.Parse(stdMax)) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; manageCount = manageCount + 1; txtLable = txtLable + columsKey + "元素不合。"; } else { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } } if (columsKey == "V" || columsKey == "Nb" || columsKey == "Ti" || columsKey == "Zr" || columsKey == "Ni" || columsKey == "Cr" || columsKey == "Mo" || columsKey == "Cu" || columsKey == "W" || columsKey == "Co") { //大于0.006的数据四舍六入后是0.01 if (quoteValue < 0.006) { ug.Rows[i].Cells[j].Value = "<0.01"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else if (quoteValue >= 0.006 && quoteValue < 0.01) { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } else { if (stdMaxIndex > 2 || stdMinIndex > 2) { if (stdMaxIndex > stdMinIndex) { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMaxIndex).ToString("f" + stdMaxIndex); } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, stdMinIndex).ToString("f" + stdMinIndex); } } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } } else if (columsKey == "Pb" || columsKey == "Bi" || columsKey == "Sn" || columsKey == "As") { if (quoteValue < 0.0010) { ug.Rows[i].Cells[j].Value = "<0.0010"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } else if (columsKey == "Sb") { if (quoteValue < 0.0020) { ug.Rows[i].Cells[j].Value = "<0.0020"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } else if (columsKey == "B") { if (uRow.Cells["ContractNo"].Text.Contains("EXMPQ-180449E")) { this.ultraLabel27.Text = "B元素需报出实际值!"; this.ultraLabel27.ForeColor = Color.Red; ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } else { if (quoteValue < 0.0005) { ug.Rows[i].Cells[j].Value = "<0.0005"; ug.Rows[i].Cells[j].Appearance.BackColor = Color.Empty; } else { ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); } } } else { // 使用固定精度修约 ug.Rows[i].Cells[j].Value = Math.Round(quoteValue, precision).ToString("f" + precision); if (double.Parse(ug.Rows[i].Cells[j].Value.ToString3()) <= 0) { ug.Rows[i].Cells[j].Appearance.BackColor = Color.Red; txtLable = txtLable + columsKey + "元素修约后为负数。"; } } } } } } this.ultraLabel11.Text = txtLable; } /// /// 查询委托基础信息 /// /// private void doQueryChemBaseInfo(UltraGridRow uRow) { List listSource = EntityHelper.GetData( "com.steering.lims.data.pipe.FrmChemDataManage.doQueryChemBaseInfo", new object[] { uRow.Cells["CheckNo"].Text, arrId }, this.ob); if (ultraTabControl1.SelectedTab.Key == "0") { pipeCheckconsignBaseinfoEntityBindingSource1.DataSource = listSource; } else if (ultraTabControl1.SelectedTab.Key == "1") { pipeCheckconsignBaseinfoEntityBindingSource3.DataSource = listSource; } } private void FrmChemDataManageNew_Shown(object sender, EventArgs e) { if (toolMenu == null || toolMenu.Toolbars == null) return; if (toolMenu.Toolbars[0].Tools.Exists("Audit")) { toolMenu.Toolbars[0].Tools["Audit"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Print")) { toolMenu.Toolbars[0].Tools["Print"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("CancelAudit")) { toolMenu.Toolbars[0].Tools["CancelAudit"].InstanceProps.Visible = DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("StdSteelNo")) { toolMenu.Toolbars[0].Tools["StdSteelNo"].InstanceProps.Visible = DefaultableBoolean.False; } } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null || toolMenu.Toolbars == null) return; if (toolMenu.Toolbars[0].Tools.Exists("Save")) { toolMenu.Toolbars[0].Tools["Save"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("DeletePipeOutData")) { toolMenu.Toolbars[0].Tools["DeletePipeOutData"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Audit")) { toolMenu.Toolbars[0].Tools["Audit"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 1 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Print")) { toolMenu.Toolbars[0].Tools["Print"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 1 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 1 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("CheckStdSteel")) { toolMenu.Toolbars[0].Tools["CheckStdSteel"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("CancelAudit")) { toolMenu.Toolbars[0].Tools["CancelAudit"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 1 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (toolMenu.Toolbars[0].Tools.Exists("StdSteelNo")) { toolMenu.Toolbars[0].Tools["StdSteelNo"].InstanceProps.Visible = this.ultraTabControl1.SelectedTab.Index == 1 ? DefaultableBoolean.True : DefaultableBoolean.False; } if (ultraTabControl1.SelectedTab.Key == "0") { ultraLabel10.Visible = true; comGradeType.Visible = true; chkRegTime.Text = "收样日期"; } else { ultraLabel10.Visible = false; comGradeType.Visible = false; chkRegTime.Text = "录入日期"; doQueryChem(); } } private void ultraGrid3_CellChange(object sender, CellEventArgs e) { this.ultraGrid3.UpdateData(); UltraGridRow uRow = this.ultraGrid3.ActiveRow; UltraGridRow uRow1 = this.ultraGrid1.ActiveRow; if (uRow == null || uRow1 == null) return; //可以手录全部元素 //if ((e.Cell.Column.Key == "C" || e.Cell.Column.Key == "S" || e.Cell.Column.Key == "B" || e.Cell.Column.Key == "Ca" || e.Cell.Column.Key == "Bi" || e.Cell.Column.Key == "Als") && uRow.Cells["SAMPLE_NO"].Text != "报出值") //{ if (!StringUtil.IsDouble(uRow.Cells[e.Cell.Column.Key].Value.ToString3())) { return; } ultraGrid3.Rows[uRow.Index + 1].Cells[e.Cell.Column.Key].Value = decimal.Parse(uRow.Cells[e.Cell.Column.Key].Value.ToString3()); checkUltraGrid(ultraGrid3, uRow1); //} } private void ultraGrid7_CellChange(object sender, CellEventArgs e) { this.ultraGrid7.UpdateData(); this.ultraGrid1.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; foreach (UltraGridRow row in this.ultraGrid3.Rows) { if (row.Cells["SAMPLE_NO"].Text == "报出值") { if (!StringUtil.IsDouble(ultraGrid7.ActiveRow.Cells[e.Cell.Column.Key].Value.ToString3())) return; row.Cells[e.Cell.Column.Key].Value = decimal.Parse(ultraGrid3.Rows[row.Index - 1].Cells[e.Cell.Column.Key].Value.ToString3()) + decimal.Parse(ultraGrid7.ActiveRow.Cells[e.Cell.Column.Key].Value.ToString3()); if (double.Parse(row.Cells[e.Cell.Column.Key].Value.ToString3()) <= 0) { ultraLabel11.Text = ultraLabel11.Text + e.Cell.Column.Key + "异常 "; } } } checkUltraGrid(ultraGrid3, uRow); } private void chkSampleNo_CheckedChanged(object sender, EventArgs e) { this.txtSampleNo.Enabled = this.chkSampleNo.Checked; } private void ultraTextEditor5_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow uRow = this.ultraGrid2.ActiveRow; if (uRow.Cells["CraftFileNo"].Text.Trim() == "" || uRow.Cells["CraftPath"].Text.Trim() == "") { return; } PublicPipeAndOutdec.ViewCarft_No(uRow.Cells["CraftPath"].Text.Trim()); } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow uRow = this.ultraGrid5.ActiveRow; if (uRow.Cells["CraftFileNo"].Text.Trim() == "" || uRow.Cells["CraftPath"].Text.Trim() == "") { return; } PublicPipeAndOutdec.ViewCarft_No(uRow.Cells["CraftPath"].Text.Trim()); } } }