flowMeter/NGToolsPC/frmNgTools.cs

2765 lines
96 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using System.Web.Script.Serialization;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Diagnostics;
using System.Security.Policy;
using System.Threading;
using Aladdin.HASP;
using System.Runtime.CompilerServices;
namespace NGToolsPC
{
public partial class frmNgTools : Form
{
public static frmNgTools frmNG;
public frmNgTools()
{
MySqlCon = new System.Data.OleDb.OleDbConnection(mldPublic.strConCNG);
frmNG = this;
InitializeComponent();
}
public static bool blReg = false;
string strZf;
DataSet myDwDS = new DataSet();
string Jsrq = "";
NG_Tools.NG_Cal.FlowParStruct flPar1 = new NG_Tools.NG_Cal.FlowParStruct();
NG_Tools.NG_Cal.GasPropsSTRUCT gasPar1 = new NG_Tools.NG_Cal.GasPropsSTRUCT();
public System.Data.OleDb.OleDbConnection MySqlCon; // VBConversions Note: Initial value cannot be assigned here since it is non-static. Assignment has been moved to the class constructors.
DataTable dtJld = new DataTable();
DataTable dtKh;
OleDbCommandBuilder KhCb;
System.Data.OleDb.OleDbDataAdapter KhDap;
public const string localScope = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> " +
"<haspscope> " +
" <license_manager hostname =\"localhost\" /> " +
"</haspscope>";
public const string defaultScope = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> " +
"<haspscope/> ";
private string scope;
#region
private void DwDsInistial()
{
myDwDS = new DataSet();
myDwDS.Tables.Add("压力类型");
myDwDS.Tables["压力类型"].Columns.Add("序号");
myDwDS.Tables["压力类型"].Columns.Add("压力类型");
myDwDS.Tables["压力类型"].Rows.Add(0, "表压");
myDwDS.Tables["压力类型"].Rows.Add(1, "绝压");
ComboBox5.DisplayMember = "压力类型";
ComboBox5.ValueMember = "序号";
ComboBox5.DataSource = myDwDS.Tables["压力类型"].Copy();
myDwDS.Tables.Add("取压方式");
myDwDS.Tables["取压方式"].Columns.Add("序号");
myDwDS.Tables["取压方式"].Columns.Add("取压方式");
myDwDS.Tables["取压方式"].Rows.Add(0, "法兰取压");
myDwDS.Tables["取压方式"].Rows.Add(1, "角接取压");
myDwDS.Tables["取压方式"].Rows.Add(2, "D和D/2取压");
ComboBox7.DisplayMember = "取压方式";
ComboBox7.ValueMember = "序号";
ComboBox7.DataSource = myDwDS.Tables["取压方式"].Copy();
myDwDS.Tables.Add("标准参比条件");
myDwDS.Tables["标准参比条件"].Columns.Add("序号");
myDwDS.Tables["标准参比条件"].Columns.Add("标准参比条件");
myDwDS.Tables["标准参比条件"].Rows.Add(0, "101.325kPa,20℃");
myDwDS.Tables["标准参比条件"].Rows.Add(1, "101.325kPa,15℃");
myDwDS.Tables["标准参比条件"].Rows.Add(2, "101.325kPa,0℃");
ComboBox3.DisplayMember = "标准参比条件";
ComboBox3.ValueMember = "序号";
ComboBox3.DataSource = myDwDS.Tables["标准参比条件"];
ComboBox3.SelectedIndex = 0;
myDwDS.Tables.Add("燃烧参比条件");
myDwDS.Tables["燃烧参比条件"].Columns.Add("序号");
myDwDS.Tables["燃烧参比条件"].Columns.Add("燃烧参比条件");
myDwDS.Tables["燃烧参比条件"].Rows.Add(0, "101.325kPa,0℃");
myDwDS.Tables["燃烧参比条件"].Rows.Add(1, "101.325kPa,15℃");
myDwDS.Tables["燃烧参比条件"].Rows.Add(2, "101.325kPa,20℃");
myDwDS.Tables["燃烧参比条件"].Rows.Add(3, "101.325kPa,25℃");
ComboBox4.DisplayMember = "燃烧参比条件";
ComboBox4.ValueMember = "序号";
ComboBox4.DataSource = myDwDS.Tables["燃烧参比条件"];
ComboBox4.SelectedIndex = 2;
myDwDS.Tables.Add("节流装置类型");
myDwDS.Tables["节流装置类型"].Columns.Add("序号");
myDwDS.Tables["节流装置类型"].Columns.Add("节流装置类型");
myDwDS.Tables["节流装置类型"].Rows.Add(0, "标准孔板");
myDwDS.Tables["节流装置类型"].Rows.Add(1, "ISA1932喷嘴");
//myDwDS.Tables["节流装置类型"].Rows.Add(2, "长径喷嘴");
//myDwDS.Tables["节流装置类型"].Rows.Add(3, "文丘里喷嘴");
//myDwDS.Tables["节流装置类型"].Rows.Add(4, "粗铸收缩段经典文丘里管");
//myDwDS.Tables["节流装置类型"].Rows.Add(5, "机械加工收缩段经典文丘里管");
//myDwDS.Tables["节流装置类型"].Rows.Add(5, "粗焊铁板收缩段经典文丘里管");
myDwDS.Tables.Add("差压式流量计算标准");
myDwDS.Tables["差压式流量计算标准"].Columns.Add("序号");
myDwDS.Tables["差压式流量计算标准"].Columns.Add("标准名称");
myDwDS.Tables["差压式流量计算标准"].Columns.Add("标准编号");
myDwDS.Tables["差压式流量计算标准"].Rows.Add(0, "GB/T 21446-2008", 1);
ComboBox1.DisplayMember = "标准名称";
ComboBox1.ValueMember = "序号";
ComboBox1.DataSource = myDwDS.Tables["差压式流量计算标准"];
ComboBox1.SelectedIndex = 0;
myDwDS.Tables.Add("压缩因子计算标准");
myDwDS.Tables["压缩因子计算标准"].Columns.Add("序号");
myDwDS.Tables["压缩因子计算标准"].Columns.Add("标准名称");
myDwDS.Tables["压缩因子计算标准"].Columns.Add("标准编号");
myDwDS.Tables["压缩因子计算标准"].Rows.Add(0, "GB/T 17747-2011.2", 1);
ComboBox2.DisplayMember = "标准名称";
ComboBox2.ValueMember = "序号";
ComboBox2.DataSource = myDwDS.Tables["压缩因子计算标准"];
ComboBox2.SelectedIndex = 0;
myDwDS.Tables.Add("流量计类型");
myDwDS.Tables["流量计类型"].Columns.Add("序号");
myDwDS.Tables["流量计类型"].Columns.Add("流量计类型");
myDwDS.Tables["流量计类型"].Rows.Add(0, "差压式流量计");
myDwDS.Tables["流量计类型"].Rows.Add(1, "速度式流量计");
ComboBox6.DisplayMember = "流量计类型";
ComboBox6.ValueMember = "序号";
ComboBox6.DataSource = myDwDS.Tables["流量计类型"];
}
#endregion
private double getMcs(string strMcs)
{
double tempMcs = 0;
tempMcs = double.Parse(strMcs);
return tempMcs;
}
private double getTf(string strT)
{
double tempT = 0;
tempT = double.Parse(strT) + 273.15;
return tempT;
}
private double getDP(string strDP)
{
double tempT = 0;
tempT = double.Parse(strDP);
NG_Tools.UnitConvert myConverter = new NG_Tools.UnitConvert();
tempT = myConverter.Converter("yl", tempT, 1, 0, 7);
return tempT;
}
private double getPf(string strP)
{
double tempP = double.Parse(strP); ;
NG_Tools.UnitConvert myConverter = new NG_Tools.UnitConvert();
double tempDatm = 0;
double tempPa = 0;
try
{
switch (ComboBox5.SelectedIndex)
{
case 0: //表压
if (textBox1.Text == "" || textBox1.Text == "0")
{
MessageBox.Show("压力为表压时大气压不能为零!");
textBox1.Focus();
return 0;
}
else
{
tempDatm = double.Parse(textBox1.Text);
}
tempPa = myConverter.Converter("yl", tempP + tempDatm, 2, 0, 7);
break;
case 1: //绝压
tempPa = myConverter.Converter("yl", tempP, 2, 0, 7);
break;
}
}
catch (Exception)
{
}
return tempPa;
}
private double flowCal(TextBox dPf_jyPa, TextBox dTfK, TextBox dDPPa, TextBox dMCS, TextBox flow, CheckBox checkbox)
{
double dPf = 0; double dTf = 0;
double dDPa = 0; double dMcs = 0;
if (checkbox.Checked)
{
if (dPf_jyPa.Text == "" || dPf_jyPa.Text == "0")
{
//MessageBox.Show("瞬时流量第一个补偿信号压力为零,请重新输入!");
dPf_jyPa.Focus();
checkbox.ForeColor = Color.Red;
checkbox.Checked = false;
checkbox.Text = "未检定";
return 0;
}
if (dTfK.Text == "")
{
//MessageBox.Show("瞬时流量第一个补偿信号温度为空,请重新输入!");
dTfK.Focus();
checkbox.ForeColor = Color.Red;
checkbox.Checked = false;
checkbox.Text = "未检定";
flow.Text = "0";
return 0;
}
if (textBox1.Text == "")
{
//MessageBox.Show("大气压力为空,请重新输入!");
textBox1.Focus();
checkbox.ForeColor = Color.Red;
checkbox.Checked = false;
checkbox.Text = "未检定";
flow.Text = "0";
return 0;
}
if (dDPPa.Text == "" || dDPPa.Text == "0")
{
if (ComboBox6.SelectedIndex == 0)
{
dDPPa.Text = "0";
flow.Text = "0";
checkbox.Checked = true;
checkbox.ForeColor = Color.Green;
checkbox.Text = "已检定";
return 0;
}
}
dPf = getPf(dPf_jyPa.Text);
dTf = getTf(dTfK.Text);
switch (ComboBox6.SelectedIndex)
{
case 0:
dDPa = getDP(dDPPa.Text);
break;
case 1:
dMcs = getMcs(dMCS.Text);
break;
}
//textBox34.Text = flowCal(dPf, dTf, dDp, dMcs, checkBox2).ToString();
}
else
{
flow.Text = "";
checkBox2.ForeColor = Color.Red;
checkBox2.Checked = false;
checkbox.Text = "未检定";
}
double[] tempPar = new double[110];
double[] ngCom = new double[21];
if (textBox61.Text == "")
{
MessageBox.Show("请输入组分数据!");
textBox61.Focus();
checkbox.Checked = false;
checkbox.ForeColor = Color.Red;
checkbox.Text = "未检定";
return 0;
}
double sumZf = 0;
for (int j = 0; j < 21; j++)
{
ngCom[j] = double.Parse(textBox61.Text.Split('_')[j]) / 100;
sumZf += ngCom[j];
}
if (sumZf - 100 > 0.001)
{
MessageBox.Show("输入组分数据和不为100%,请重新输入!");
textBox61.Focus();
checkbox.Checked = false;
checkbox.ForeColor = Color.Red;
checkbox.Text = "未检定";
return 0;
}
if (ComboBox6.SelectedIndex == 0)
{
if (textBox25.Text == "")
{
MessageBox.Show("差压式流量计检定需输入管道内径!");
textBox25.Focus();
checkbox.Checked = false;
checkbox.ForeColor = Color.Red;
checkbox.Text = "未检定";
return 0;
}
if (textBox26.Text == "")
{
MessageBox.Show("差压式流量计检定需输入节流件内径!");
textBox26.Focus();
checkbox.Checked = false;
checkbox.ForeColor = Color.Red;
checkbox.Text = "未检定";
return 0;
}
}
NG_Tools.FlowCal NGFLOW = new NG_Tools.FlowCal();
NG_Tools.NG_Cal.FlowParStruct flPar = new NG_Tools.NG_Cal.FlowParStruct();
NG_Tools.NG_Cal.GasPropsSTRUCT gasPar = new NG_Tools.NG_Cal.GasPropsSTRUCT();
NG_Tools.UnitConvert MyConvert = new NG_Tools.UnitConvert();
gasPar.adMixture = ngCom;
flPar.dCoreType = 0;// ComboBox5.SelectedIndex; //节流装置类型
flPar.dFlowCalbz = 0;// ComboBox9.SelectedIndex; //流量计算标准
flPar.dZcalbz = 0;// ComboBox20.SelectedIndex; //压缩因子计算标准
flPar.dCbtj =( ComboBox3.SelectedIndex==-1)? 0: ComboBox3.SelectedIndex; //'计量参比条件
gasPar.dCbtj_E = ComboBox4.SelectedIndex==-1?0: ComboBox4.SelectedIndex; //'计量参比条件
flPar.dPatmUnit = 2;// ComboBox27.SelectedIndex; //当地大气压单位
flPar.dPatm = MyConvert.Converter("yl", double.Parse(textBox1.Text), flPar.dPatmUnit, 0, 5); ; //当地大气压
flPar.dNG_Compents = gasPar.adMixture; //天然气组分
flPar.dPtmode = ComboBox7.SelectedIndex; //取压方式
flPar.dPipeType = 0;// ComboBox4.SelectedIndex; //管道类型
flPar.dLenUnit = 3;// ComboBox1.SelectedIndex; //长度单位 mm
flPar.dPipeD = double.Parse(textBox25.Text); //管道内径 mm
flPar.dPipeDtemp = 20;// double.Parse(TextBox2.Text); //管道内径参考温度
flPar.dPileDtempUint = 0;// ComboBox2.SelectedIndex; //温度单位
flPar.dPipeMaterial = 2;// ComboBox3.SelectedIndex; //管道材料 20号钢
flPar.dOrificeUnit = 3;// ComboBox6.SelectedIndex; //长度单位
flPar.dOrificeD = double.Parse(textBox26.Text); //孔板孔径
flPar.dOrificeDtemp = 20;// double.Parse(TextBox6.Text); //孔板内径参考温度
flPar.dOrificeDtempUnit = 0;// ComboBox7.SelectedIndex; //温度单位
flPar.dOrificeMaterial = 10;// ComboBox8.SelectedIndex; //孔板材料
flPar.dOrificeSharpness = 0;// (CheckBox1.Checked ? 1 : 0); //锐利度系数计算方法
flPar.dOrificeRk = 0;// double.Parse(TextBox35.Text); //孔板入口圆弧半径
flPar.dOrificeRkLenUint = 3;// ComboBox21.SelectedIndex; //长度单位
flPar.dPfUnit = 2;// ComboBox11.SelectedIndex; //压力单位MPa
flPar.dPf = dPf; //输入压力
flPar.dPfType = ComboBox5.SelectedIndex; //压力类型
flPar.dTfUnit = 0;// ComboBox12.SelectedIndex; //温度单位
flPar.dTf = dTf; //输入温度
flPar.dDpUnit = 1;// ComboBox10.SelectedIndex; //压力单位MPa
flPar.dDp = dDPa; //输入压力; //输入差压
flPar.dVFlowUnit = 0;// ComboBox14.SelectedIndex; //体积流量单位
flPar.dMFlowUnit = 0;// ComboBox15.SelectedIndex; //质量流量单位
flPar.dEFlowUnit = 0;// ComboBox16.SelectedIndex; //能量流量单位
if (ComboBox6.SelectedIndex == 1)
{
if ((textBox27.Text == "0" || textBox27.Text == ""))
{
MessageBox.Show("检定速度式流量计仪表系数不能为零!");
textBox27.Focus();
checkbox.Checked = false;
checkbox.ForeColor = Color.Red;
checkbox.Text = "未检定";
return 0;
}
flPar.dMeterFactor = double.Parse(textBox27.Text); //仪表系数
}
flPar.dPulseNum = dMcs;
gasPar.dCbtj = flPar.dCbtj;
gasPar.dPf = flPar.dPf;
gasPar.dTf = flPar.dTf;
switch (gasPar.dCbtj)
{
case 2:
gasPar.dPb = 101325;
gasPar.dTb = 273.15;
break;
case 1:
gasPar.dPb = 101325;
gasPar.dTb = 288.15;
break;
case 0:
gasPar.dPb = 101325;
gasPar.dTb = 293.15;
break;
}
NG_Tools.NG_Cal NG_Cal = new NG_Tools.NG_Cal();
NG_Cal.Crit(ref gasPar, 0.0);
switch (ComboBox6.SelectedIndex)
{
case 0:
NGFLOW.OFlowCal(ref gasPar, ref flPar);
break;
case 1:
NGFLOW.SdFlowCal(ref gasPar, ref flPar);
break;
}
flPar1 = flPar;
gasPar1 = gasPar;
checkbox.Checked = true;
checkbox.ForeColor = Color.Green;
checkbox.Text = "已检定";
flow.Text = (flPar.dVFlowb * 3600).ToString("0.##");
if (checkbox.Name == "checkBox6")
{
textBox68.Text = flPar.dEFlowb.ToString("0.###");
}
return flPar.dVFlowb;
}
private void frmNgTools_Activated(object sender, EventArgs e)
{
//Login();
}
public void setZf(string str)
{
textBox61.Text = str;
}
public void Login(string jdyxm)
{
setEnable(blReg);
if (jdyxm == "")
{
ToolStripStatusLabel3.Text = "还没有用户登录!";
ToolStripStatusLabel3.BackColor = Color.Red;
MToolStripMenuItem.Enabled = false;
Button2.Enabled = false;
//button5.Enabled = false;
}
else
{
ToolStripStatusLabel3.Text = jdyxm;
ToolStripStatusLabel3.BackColor = Color.Blue;
ToolStripStatusLabel3.ForeColor = Color.White;
MToolStripMenuItem.Enabled = true;
Button2.Enabled = true;
//button5.Enabled = true;
}
}
protected Hasp LoginHasp()
{
HaspFeature feature = new HaspFeature(HaspFeature.FromFeature(1).Feature);
scope = localScope;
Hasp hasp = new Hasp(feature);
HaspStatus status = hasp.Login(VendorCode.Code, scope);
return hasp.IsLoggedIn() ? hasp : null;
}
public void setEnable(bool flag)
{
checkBox1.Enabled = flag;
checkBox3.Enabled = flag;
checkBox5.Enabled = flag;
checkBox7.Enabled = flag;
checkBox9.Enabled = flag;
}
private void frmNgTools_Load(object sender, EventArgs e)
{
this.Show();
MachineInfo info = new MachineInfo();
string strCpu = info.GetCPUSerialNumber();
string strDisk = info.GetHardDiskSerialNumber();
//this.Text = "天然气流量计算软件系统" + "没有检测到USB软件狗系统为试用版";
if ((strCpu == "BFEBFBFF000906E9" & strDisk == "WD-WCC6Y2ZJE760") || (strCpu == "BFEBFBFF000A0655" & strDisk == "WD-WCC6Y4APXKK7"))
{
blReg = true;
setEnable(blReg);
}
else
{
Hasp hasp = LoginHasp();
HaspFile file = null;
if (hasp == null)
{
blReg = false;
setEnable(blReg);
this.Text = "流量积算仪检定系统(天然气)" + "没有检测到USB软件狗系统为受限版";
}
else
{
file = hasp.GetFile(HaspFileId.ReadWrite);
int size = 28;
byte[] data = new byte[size];
HaspStatus status = file.Read(data, 0, data.Length);
if (HaspStatus.StatusOk != status)
{
blReg = false;
setEnable(blReg);
this.Text = "流量积算仪检定系统(天然气)" + "没有检测到USB软件狗系统为受限版";
}
string strData = System.Text.Encoding.UTF8.GetString(data);
if (strData != "hhysbyjypgcwrsqdhxyylcfbdymg")
{
blReg = false;
setEnable(blReg);
this.Text = "流量积算仪检定系统(天然气)" + "USB软件狗不正确系统为受限版";
}
blReg = true;
setEnable(blReg);
this.Text = "流量积算仪检定系统(天然气)";
}
}
if (mldPublic.strJdyXm == "")
{
ToolStripStatusLabel3.Text = "还没有用户登录!";
ToolStripStatusLabel3.BackColor = Color.Red;
MToolStripMenuItem.Enabled = false;
Button2.Enabled = false;
//button5.Enabled = false;
}
else
{
ToolStripStatusLabel3.Text = mldPublic.strJdyXm;
ToolStripStatusLabel3.BackColor = Color.Blue;
ToolStripStatusLabel3.ForeColor = Color.White;
MToolStripMenuItem.Enabled = true;
Button2.Enabled = true;
//button5.Enabled = true;
}
bindKh();
BindListbox1();
myDwDS = new DataSet();
DwDsInistial(); //Combobox 初始化
ComboBox1.SelectedIndex = 0;
ComboBox2.SelectedIndex = 0;
ComboBox3.SelectedIndex = 0;
ComboBox4.SelectedIndex = 2;
frmLogin fl = new frmLogin();
fl.ShowDialog();
}
private void bindKh()
{
dtKh = new DataTable();
dtKh.Clear();
string strSQL = "select * from 客户资料 order by ID";
KhDap = new System.Data.OleDb.OleDbDataAdapter();
KhDap.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
KhCb = new OleDbCommandBuilder(KhDap);
KhDap.UpdateCommand = KhCb.GetUpdateCommand();
KhDap.InsertCommand = KhCb.GetInsertCommand();
KhDap.DeleteCommand = KhCb.GetDeleteCommand();
KhDap.Fill(dtKh);
DataRow dr = dtKh.NewRow();
dr["ID"] = "-1";
dr["客户名称"] = "请选择或输入客户";
dtKh.Rows.InsertAt(dr, 0);
comboBox12.ValueMember = "ID";
comboBox12.DisplayMember = "客户名称";
comboBox12.DataSource = dtKh;
listBox3.ValueMember = "ID";
listBox3.DisplayMember = "客户名称";
listBox3.DataSource = dtKh;
listBox3.SelectedIndex = 0;
}
private void BindListbox1()
{
DataTable dtZhan = new DataTable();
OleDbDataAdapter ZhanDap = new OleDbDataAdapter();
string strSQL = "";
if (listBox3.SelectedIndex == 0)
{
ListBox1.DataSource = null;
ListBox2.DataSource = null;
return;
}
try
{
strSQL = "select * from 生产厂家 where 客户ID=" + listBox3.SelectedValue + " order by ID";
dtZhan = new DataTable();
ZhanDap = new System.Data.OleDb.OleDbDataAdapter();
ZhanDap.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
ZhanDap.Fill(dtZhan);
ListBox1.DisplayMember = "厂家名称";
ListBox1.ValueMember = "ID";
ListBox1.DataSource = dtZhan;
}
catch (Exception)
{
}
try
{
ListBox1.SelectedIndex = 0;
}
catch (Exception)
{
}
}
private void comboBox12_SelectedIndexChanged(object sender, EventArgs e)
{
Jsrq = "";
BindListbox1();
}
public void ListBox1_SelectedIndexChanged(System.Object sender, System.EventArgs e)
{
//ListBox2.Items.Clear()
//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
try
{
OleDbDataAdapter jldDap = new OleDbDataAdapter();
string strSQL = "";
strSQL = "select * from 仪表信息 where 厂家ID=" + ListBox1.SelectedValue;
dtJld = new DataTable();
jldDap = new System.Data.OleDb.OleDbDataAdapter();
jldDap.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
jldDap.Fill(dtJld);
ListBox2.DisplayMember = "仪表编号";
ListBox2.ValueMember = "ID";
ListBox2.DataSource = dtJld;
if (dtJld.Rows.Count > 0)
{
//ListBox2.SelectedIndex = 0;
}
else
{
var textBoxes = LoopControls.AllControl<TextBox>(this);
foreach (TextBox c in textBoxes)
{
c.Text = "";
}
}
textBox80.Text = ListBox2.Text;
textBox70.Text = ListBox1.Text;
}
catch (Exception ex)
{
}
}
private void checkTextBox()
{
var textBoxes = LoopControls.AllControl<TextBox>(this);
foreach (TextBox c in textBoxes)
{
if (c.Text == "")
{
c.BackColor = Color.Red;
}
}
}
public void ListBox2_SelectedIndexChanged(System.Object sender, System.EventArgs e)
{
try
{
checkBox1.Checked = false;
DataRow[] dataRowJldPar;
//dataRowJldPar = dtJld.Select("ID=" + System.Convert.ToString(index));
dataRowJldPar = dtJld.Select("ID=" + System.Convert.ToString(ListBox2.SelectedValue));
DataRow JldParRow = dataRowJldPar[0];
string strJldpar = System.Convert.ToString(JldParRow["仪表参数信息"]);
string[] strPar = strJldpar.Split('~');
Dictionary<String, String> ControlDictionary = new Dictionary<string, string>();
for (int i = 0; i < strPar.Length; i++)
{
try
{
string[] strTemp = strPar[i].Split(':');
ControlDictionary.Add(strTemp[0], strTemp[1]);
}
catch (Exception)
{
}
}
var textBoxes = LoopControls.AllControl<TextBox>(tabPage1);
foreach (TextBox c in textBoxes)
{
try
{
c.Text = "";
c.Text = ControlDictionary[c.Name];
}
catch (Exception)
{
}
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage2);
foreach (TextBox c in textBoxes)
{
try
{
c.Text = "";
c.Text = ControlDictionary[c.Name];
}
catch (Exception)
{
}
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage3);
foreach (TextBox c in textBoxes)
{
try
{
c.Text = "";
c.Text = ControlDictionary[c.Name];
}
catch (Exception)
{
}
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage10);
foreach (TextBox c in textBoxes)
{
try
{
c.Text = "";
c.Text = ControlDictionary[c.Name];
}
catch (Exception)
{
}
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage12);
foreach (TextBox c in textBoxes)
{
try
{
c.Text = "";
c.Text = ControlDictionary[c.Name];
}
catch (Exception)
{
}
}
var comboBoxes = LoopControls.AllControl<ComboBox>(tabPage1);
foreach (ComboBox c in comboBoxes)
{
try
{
if (c.Name != "comboBox12")
{
c.SelectedIndex =0;
c.SelectedIndex = int.Parse(ControlDictionary[c.Name]);
}
}
catch (Exception)
{
}
}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage2);
foreach (ComboBox c in comboBoxes)
{
try
{
if (c.Name != "comboBox12")
{
c.SelectedIndex = 0;
c.SelectedIndex = int.Parse(ControlDictionary[c.Name]);
}
}
catch (Exception)
{
}
}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage10);
foreach (ComboBox c in comboBoxes)
{
try
{
if (c.Name != "comboBox12")
{
c.SelectedIndex = 0;
c.SelectedIndex = int.Parse(ControlDictionary[c.Name]);
}
}
catch (Exception)
{
}
}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage12);
foreach (ComboBox c in comboBoxes)
{
try
{
if (c.Name != "comboBox12")
{
c.SelectedIndex = 0;
c.SelectedIndex = int.Parse(ControlDictionary[c.Name]);
}
}
catch (Exception)
{
}
}
textBox80.Text = ListBox2.Text;
textBox70.Text = ListBox1.Text;
textBox10_TextChanged(sender, e);
textBox17_TextChanged(sender, e);
checkBox1.Checked = false;
}
catch (Exception ex)
{
}
}
private void setCalFalse()
{
checkBox2.Checked = false;
checkBox3.Checked = false;
checkBox4.Checked = false;
checkBox5.Checked = false;
checkBox6.Checked = false;
checkBox7.Checked = false;
checkBox8.Checked = false;
checkBox9.Checked = false;
checkBox10.Checked = false;
}
private void getFlowPar()
{
Jsrq = "";
Single flowMin = 0;
Single flow25 = 0;
Single flow5 = 0;
Single flow75 = 0;
Single flowMax = 0;
try
{
if (textBox8.Text == "")
{
textBox8.Text = "0";
}
flowMin = Single.Parse(textBox8.Text);
flowMax = Single.Parse(textBox9.Text);
flow25 = flowMin + (flowMax - flowMin) / 4;
flow5 = flowMin + (flowMax - flowMin) / 2;
flow75 = flowMin + (flowMax - flowMin) * 3 / 4;
if (textBox5.Text == "")
{
textBox5.Text = "0";
}
if (textBox6.Text == "")
{
textBox6.Text = "0";
}
if (textBox8.Text == "")
{
textBox8.Text = "0";
}
if (textBox9.Text == "")
{
textBox9.Text = "0";
}
Single Lcmin = Single.Parse(textBox5.Text);
Single LcMax = Single.Parse(textBox6.Text);
Single Amin = Single.Parse(textBox8.Text);
Single Amax = Single.Parse(textBox9.Text);
Single DpCurr0 = Lcmin + (LcMax - Lcmin) * (flowMin - Amin) / (Amax - Amin);
Single DpCurr25 = Lcmin + (LcMax - Lcmin) * (flow25 - Amin) / (Amax - Amin);
Single DpCurr5 = Lcmin + (LcMax - Lcmin) * (flow5 - Amin) / (Amax - Amin);
Single DpCurr75 = Lcmin + (LcMax - Lcmin) * (flow75 - Amin) / (Amax - Amin);
Single DpCurr100 = Lcmin + (LcMax - Lcmin) * (flowMax - Amin) / (Amax - Amin);
if (ComboBox6.SelectedIndex == 0)
{
label113.Text = "(kPa)";
label114.Text = DpCurr0.ToString("0.###");
label115.Text = DpCurr25.ToString("0.###");
label116.Text = DpCurr5.ToString("0.###");
label117.Text = DpCurr75.ToString("0.###");
label118.Text = DpCurr100.ToString("0.###");
label119.Text = DpCurr100.ToString("0.###");
label120.Text = DpCurr100.ToString("0.###");
}
else
{
label113.Text = "";
label114.Text = "";
label115.Text = "";
label116.Text = "";
label117.Text = "";
label118.Text = "";
label119.Text = "";
label120.Text = "";
}
textBox95.Text = DpCurr0.ToString("0.###");
textBox96.Text = DpCurr25.ToString("0.###");
textBox97.Text = DpCurr5.ToString("0.###");
textBox98.Text = DpCurr75.ToString("0.###");
textBox99.Text = DpCurr100.ToString("0.###");
if (Lcmin > LcMax)
{
//MessageBox.Show("差压量程输入错误,请重新输入!");
textBox5.BackColor = Color.Red;
textBox6.BackColor = Color.Red;
label113.Text = "";
label114.Text = "";
label115.Text = "";
label116.Text = "";
label117.Text = "";
label118.Text = "";
label119.Text = "";
label120.Text = "";
textBox95.Text = "";
textBox96.Text = "";
textBox97.Text = "";
textBox98.Text = "";
textBox99.Text = "";
//textBox5.Focus();
return;
}
else
{
textBox5.BackColor = SystemColors.Window;
textBox6.BackColor = SystemColors.Window;
}
if (Amin >= Amax)
{
//MessageBox.Show("输出liang范围输入错误请重新输入");
textBox8.BackColor = Color.Red;
textBox9.BackColor = Color.Red;
label113.Text = "";
label114.Text = "";
label115.Text = "";
label116.Text = "";
label117.Text = "";
label118.Text = "";
label119.Text = "";
label120.Text = "";
textBox95.Text = "";
textBox96.Text = "";
textBox97.Text = "";
textBox98.Text = "";
textBox99.Text = "";
//textBox8.Focus();
return;
}
else
{
textBox8.BackColor = SystemColors.Window;
textBox9.BackColor = SystemColors.Window;
}
}
catch (Exception)
{
}
textBox31.Text = textBox8.Text;
textBox37.Text = flow25.ToString("0.###");
textBox43.Text = flow5.ToString("0.###");
textBox49.Text = flow75.ToString("0.###");
textBox55.Text = textBox9.Text;
textBox62.Text = textBox9.Text;
textBox74.Text = textBox9.Text;
}
private void ComboBox6_SelectedIndexChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
switch (ComboBox6.SelectedIndex)
{
case 0:
label21.Text = "(mA)";
label31.Text = "(mA)";
label66.Text = "(mA)";
label36.Text = "差压(kPa)";
textBox25.Enabled = true;
textBox26.Enabled = true;
ComboBox7.Enabled = true;
textBox27.Enabled = false;
textBox4.Text = "差压变送器";
textBox11.Text = "压力变送器";
textBox18.Text = "温度变送器";
textBox7.Text = "电流mA";
textBox14.Text = "电流mA";
comboBox8.SelectedIndex = 0;
textBox8.Text = "4";
textBox9.Text = "20";
textBox15.Text = "4";
textBox16.Text = "20";
break;
case 1:
label21.Text = "(Hz)";
label31.Text = "(Hz)";
label66.Text = "(Hz)";
label36.Text = "脉冲频率(Hz)";
textBox25.Enabled = false;
textBox26.Enabled = false;
ComboBox7.Enabled = false;
textBox27.Enabled = true;
textBox4.Text = "脉冲发生器";
textBox11.Text = "压力变送器";
textBox18.Text = "温度变送器";
textBox7.Text = "脉冲频率Hz";
textBox14.Text = "电流mA";
comboBox8.SelectedIndex = 0;
textBox8.Text = "4";
textBox9.Text = "20";
textBox15.Text = "4";
textBox16.Text = "20";
break;
}
getFlowPar();
setCalFalse();
}
catch (Exception)
{
}
}
private void textBox10_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
textBox33.Text = textBox10.Text;
textBox39.Text = textBox10.Text;
textBox45.Text = textBox10.Text;
textBox51.Text = textBox10.Text;
textBox57.Text = textBox10.Text;
textBox64.Text = textBox10.Text;
checkBox1.Checked = false;
checkBox1.Checked = blReg;
//textBox76.Text = textBox10.Text;
//textBox82.Text = textBox10.Text;
}
private void textBox17_TextChanged(object sender, EventArgs e)
{
textBox32.Text = textBox17.Text;
textBox38.Text = textBox17.Text;
textBox44.Text = textBox17.Text;
textBox50.Text = textBox17.Text;
textBox56.Text = textBox17.Text;
textBox75.Text = textBox17.Text;
checkBox1.Checked = false;
checkBox1.Checked = blReg;
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getFlowPar();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label114.Text;
if (checkBox2.Checked)
{
flowCal(textBox33, textBox32, textDp, textBox31, textBox34, checkBox2).ToString();
}
else
{
checkBox2.ForeColor = Color.Red;
checkBox2.Checked = false;
checkBox2.Text = "未检定";
textBox34.Text = "";
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
string str = "textBox61:88.36_0.68_1.57_6.25_2.4_0_0_0.04_0_0_0.15_0.35_0.1_0.05_0.01_0_0_0_0_0.04_0~textBox24:7200~textBox185:0.2~textBox27:2000~textBox26:150.25~textBox25:259.38~textBox17:30~textBox10:0.4~textBox1:0.0981~textBox85:~textBox84:~textBox83:~textBox82:0.6~textBox79:~textBox78:~textBox77:~textBox76:0.2~textBox73:~textBox72:~textBox71:~textBox69:35~textBox67:~textBox66:~textBox65:~textBox63:25~textBox37:8~textBox36:~textBox35:~textBox34:~textBox33:0.4~textBox32:30~textBox31:4~textBox60:~textBox59:~textBox58:~textBox57:0.4~textBox56:30~textBox55:20~textBox54:~textBox53:~textBox52:~textBox51:0.4~textBox50:30~textBox49:16~textBox48:~textBox47:~textBox46:~textBox45:0.4~textBox44:30~textBox43:12~textBox42:~textBox41:~textBox40:~textBox39:0.4~textBox62:20~textBox74:20~textBox75:30~textBox64:0.4~textBox38:30~textBox23:20~textBox22:4~textBox20:30~textBox19:0~textBox18:温度变送器~textBox16:20~textBox15:4~textBox14:电流mA~textBox13:1~textBox12:0~textBox11:压力变送器~textBox9:20~textBox8:4~textBox7:电流mA~textBox6:60~textBox5:0~textBox4:差压变送器~textBox30:~textBox29:~textBox28:~ComboBox5:0~ComboBox7:0~ComboBox6:0~comboBox8:0~comboBox9:2~comboBox10:2~comboBox11:2~";
//string str = "textBox61:98.73_0.98_0.28_0.01_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0~textBox24:~textBox27:2000~textBox26:41.886~textBox25:150~textBox17:20~textBox10:0.4~textBox85:~textBox84:~textBox83:~textBox82:~textBox79:~textBox78:~textBox77:~textBox76:~textBox73:~textBox72:~textBox71:~textBox69:~textBox67:~textBox66:~textBox65:~textBox63:~textBox37:8~textBox36:~textBox35:~textBox34:~textBox33:0.4~textBox32:20~textBox31:4~textBox30:~textBox29:~textBox28:~textBox60:~textBox59:~textBox58:~textBox57:0.4~textBox56:20~textBox55:20~textBox54:~textBox53:~textBox52:~textBox51:0.4~textBox50:20~textBox49:16~textBox48:~textBox47:~textBox46:~textBox45:0.4~textBox44:20~textBox43:12~textBox42:~textBox41:~textBox40:~textBox39:0.4~textBox62:20~textBox74:20~textBox75:20~textBox64:0.4~textBox38:20~textBox23:20~textBox22:4~textBox20:30~textBox19:0~textBox18:温度变送器~textBox16:20~textBox15:4~textBox14:电流mA~textBox13:1~textBox12:0~textBox11:压力变送器~textBox9:20~textBox8:4~textBox7:电流mA~textBox6:60~textBox5:0~textBox4:差压变送器~ComboBox7:0~ComboBox6:0~comboBox8:0~comboBox9:-1~comboBox10:-1~comboBox11:-1~";
//string str = "textBox2:25~textBox1:0.101325~textBox3:65~textBox85:-0.01~textBox84:3239.6~textBox83:3240.05971~textBox82:0.6~textBox79:-0.01~textBox78:2047.6~textBox77:2047.8013~textBox76:0.2~textBox73:0.02~textBox72:2685.4~textBox71:2684.8219~textBox69:25~textBox67:-0.02~textBox66:2731.8~textBox65:2732.21827~textBox63:15~textBox37:8~textBox36:0~textBox35:0~textBox34:0~textBox33:0.4~textBox32:20~textBox31:4~textBox30:~textBox29:~textBox28:~textBox60:0.05~textBox59:2709.5~textBox58:2708.21935~textBox57:0.4~textBox56:20~textBox55:20~textBox54:0.02~textBox53:2365.9~textBox52:2365.50311~textBox51:0.4~textBox50:20~textBox49:16~textBox48:0.01~textBox47:1948.1~textBox46:1947.82579~textBox45:0.4~textBox44:20~textBox43:12~textBox42:0.03~textBox41:1389.4~textBox40:1389.03992~textBox39:0.4~textBox62:20~textBox74:20~textBox75:20~textBox64:0.4~textBox38:20~textBox94:0.03~textBox88:20~textBox89:601.2~textBox90:452.27~textBox91:1.5~textBox92:453.9~textBox93:452.4~textBox87:~textBox129:30~textBox124:0~textBox123:0~textBox122:0~textBox121:0~textBox120:0~textBox119:1~textBox118:0.75~textBox117:0.5~textBox116:0.25~textBox115:0.001~textBox114:1~textBox113:0.75~textBox112:0.5~textBox111:0.25~textBox110:0~textBox109:0.02~textBox108:0.02~textBox107:0.03~textBox106:0.07~textBox105:0~textBox104:60.01~textBox103:45.01~textBox102:30.01~textBox99:60~textBox98:45~textBox97:30~textBox96:15~textBox95:0~textBox101:15.01~textBox100:0.02~textBox128:22.5~textBox127:15~textBox126:7.5~textBox125:0~textBox130:0~textBox131:7.5~textBox132:15.1~textBox133:22.6~textBox134:30~textBox135:0~textBox136:0~textBox137:0.67~textBox138:0.44~textBox139:0~textBox140:20~textBox142:~textBox148:0~textBox147:16575.8~textBox146:16675.8~textBox145:100~textBox144:16575.08~textBox143:601.2~textBox141:~textBox68:27.57~textBox151:4~textBox152:8~textBox153:12~textBox154:16~textBox155:20~textBox156:4.01~textBox157:8.01~textBox158:12.01~textBox159:16.01~textBox160:20.01~textBox161:4.01~textBox162:8.01~textBox163:12.01~textBox164:16.01~textBox165:20.01~textBox166:0.25~textBox167:0.13~textBox168:0.08~textBox169:0.06~textBox170:0.05~textBox171:4~textBox172:12~textBox173:16~textBox176:4.01~textBox177:12.01~textBox178:16.01~textBox181:4.01~textBox182:12.01~textBox183:16.01~textBox186:0.25~textBox187:0.08~textBox188:0.06~textBox174:162.~textBox61:98.73_0.98_0.28_0.01_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0~textBox24:2750~textBox185:0.2~textBox27:2000~textBox26:41.886~textBox25:150~textBox17:20~textBox10:0.4~textBox23:20~textBox22:4~textBox20:30~textBox19:0~textBox18:温度变送器~textBox16:20~textBox15:4~textBox14:电流mA~textBox13:1~textBox12:0~textBox11:压力变送器~textBox9:20~textBox8:4~textBox7:电流mA~textBox6:60~textBox5:0~textBox4:差压变送器~textBox184:3000~textBox180:12.5~textBox179:15~textBox175:1.48~ComboBox3:0~ComboBox4:2~ComboBox2:-1~ComboBox1:-1~ComboBox5:0~ComboBox7:0~ComboBox6:0~comboBox8:0~comboBox9:-1~comboBox10:-1~comboBox11:-1~radioButton5:False~radioButton7:False~radioButton8:False~radioButton9:False~radioButton10:False~radioButton11:False~radioButton12:False~radioButton14:False~radioButton13:False~radioButton15:True~radioButton1:False~radioButton3:False~radioButton2:False~radioButton4:False~radioButton6:False~Label41:生产厂家~Label42:出厂编号~label13:环境相对湿度(%)~label3:环境温度(℃)~Label49:燃烧标准参比条件~Label51:大气压(MPa)~label2:压力类型~Label50:标准参比条件~Label45:压缩因子计算标准~Label44:流量计算标准~label14:流量信号~label17:补偿信号1~label16:补偿信号2~label18:标准值~label15:仪表显示值~label19:误差~label21:(mA)~label22:(℃)~label23:MPa~label97:~label113:(kPa)~label114:0~label115:15~label116:30~label117:45~label118:60~label119:60~label120:60~label24:输入信号~label28:计算时间~label26:积算标准值~label25:仪表显示值( ~label29:误差~label31:(mA)~label30:S~label27:初始值~label32:终止值~label33:差值~label34:%~label123:(m³)~label59:误差(%~label48:理论计算值~label43:Amax~label35:实验点~label37:零点~label38:0.25Amax~label39:0.5Amax~label40:0.75Amax~label36:差压(kPa)~label52:实测值~label53:误差(%FS~label54:理论计算值~label55:实测值~label56:误差(%FS~label57:理论计算值~label58:实测值~label77:压力MPa~label46:温度(℃)~label47:最大的能量流量MJ/s~label61:输入信号~label62:温度1~label63:温度2~label64:积算时间~label66:(mA)~label67:(℃)~label68:s~label69:MJ~label70:初始值~label71:终止值~label72: ~label73:积算标准值~label65:仪表显示值MJ~label74:差值~label75:误差~label76:%~label79:实验点~label80:理论值~label85:0.2qmax~label82:0.6qmax~label81:0.4qmax~label83:0.8qmax~label84:1.0qmax~label87:1~label88:2~label86:输出量~label90:误差(%~label93:0.2qmax~label94:0.6qmax~label95:0.4qmax~label98:1~label99:2~label102:误差(%~label92:实验点~label101:理论值~label96:实测值~label91:(仅适用于带模拟输出功能的积算仪)~label60:小信号切除~label112:最大流量(m³/h~label111:工作温度(℃)~label20:仪表外观检查~label110:工作压力(MPa)~label122:级~label121:准确度等级~label11:仪表系数~label10:流量计类型~Label12:节流装置内径(mm)~Label9:差压取压方式~Label1:计量管内径(mm)~label4:仪表名称~label5:量程范围~label6:输出信号类型~label7:输出信号范围~label8:准确度等级~label107:kPa~label108:MPa~label109:℃~label106:测试脉冲~label105:测试差压~label104:测试温度~label103:测试压力~";
string[] strPar = str.Split('~');
var comboBoxes = LoopControls.AllControl<ComboBox>(this);
foreach (ComboBox c in comboBoxes)
{
for (int i = 0; i < strPar.Length; i++)
{
try
{
string[] strTemp = strPar[i].Split(':');
if (c.Name == strTemp[0])
{
if (strTemp[1] == "")
{
strTemp[1] = "0";
}
c.SelectedIndex = int.Parse(strTemp[1]);
}
}
catch (Exception)
{
}
}
}
var textBoxes = LoopControls.AllControl<TextBox>(this);
foreach (TextBox c in textBoxes)
{
for (int i = 0; i < strPar.Length; i++)
{
try
{
string[] strTemp = strPar[i].Split(':');
if (c.Name == strTemp[0])
{
c.Text = strTemp[1];
}
}
catch (Exception)
{
}
}
}
//textBox8_TextChanged(sender, e);
//textBox15_TextChanged(sender, e);
//textBox22_TextChanged(sender, e);
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label115.Text;
if (checkBox3.Checked)
{
flowCal(textBox39, textBox38, textDp, textBox37, textBox40, checkBox3).ToString();
}
else
{
checkBox3.ForeColor = Color.Red;
checkBox3.Checked = false;
checkBox3.Text = "未检定";
textBox40.Text = "";
}
}
private void getAcurrDp(TextBox textAcurr, Label labDp)
{
try
{
if (textBox5.Text == "")
{
textBox5.Text = "0";
}
if (textBox6.Text == "")
{
textBox6.Text = "0";
}
if (textBox8.Text == "")
{
textBox8.Text = "0";
}
if (textBox9.Text == "")
{
textBox9.Text = "0";
}
Single Lcmin = Single.Parse(textBox5.Text);
Single LcMax = Single.Parse(textBox6.Text);
Single Amin = Single.Parse(textBox8.Text);
Single Amax = Single.Parse(textBox9.Text);
Single Acurr = Single.Parse(textAcurr.Text);
Single DpCurr = (LcMax - Lcmin) * (Acurr - Amin) / (Amax - Amin);
if (Lcmin > LcMax)
{
//MessageBox.Show("差压量程输入错误,请重新输入!");
//textBox5.Focus();
return;
}
if (Amin >= Amax)
{
//MessageBox.Show("输出信号范围输入错误,请重新输入!");
//textBox8.Focus();
return;
}
if (ComboBox6.SelectedIndex == 0) labDp.Text = DpCurr.ToString();
}
catch (Exception)
{
}
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label116.Text;
if (checkBox4.Checked)
{
flowCal(textBox45, textBox44, textDp, textBox43, textBox46, checkBox4).ToString();
}
else
{
checkBox4.ForeColor = Color.Red;
checkBox4.Checked = false;
checkBox4.Text = "未检定";
textBox46.Text = "";
}
}
private void checkBox5_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label117.Text;
if (checkBox5.Checked)
{
flowCal(textBox51, textBox50, textDp, textBox49, textBox52, checkBox5).ToString();
}
else
{
checkBox5.ForeColor = Color.Red;
checkBox5.Checked = false;
checkBox5.Text = "未检定";
textBox52.Text = "";
}
}
private void checkBox6_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label118.Text;
if (checkBox6.Checked)
{
flowCal(textBox57, textBox56, textDp, textBox55, textBox58, checkBox6).ToString();
textBox88.Text = textBox55.Text;
textBox140.Text = textBox55.Text;
}
else
{
checkBox6.ForeColor = Color.Red;
checkBox6.Checked = false;
checkBox6.Text = "未检定";
textBox58.Text = "";
}
}
private void checkBox7_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label119.Text;
if (checkBox7.Checked)
{
flowCal(textBox64, textBox63, textDp, textBox62, textBox65, checkBox7).ToString();
}
else
{
checkBox7.ForeColor = Color.Red;
checkBox7.Checked = false;
checkBox7.Text = "未检定";
textBox65.Text = "";
}
}
private void checkBox8_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label119.Text;
if (checkBox8.Checked)
{
flowCal(textBox64, textBox69, textDp, textBox62, textBox71, checkBox8).ToString();
}
else
{
checkBox8.ForeColor = Color.Red;
checkBox8.Checked = false;
checkBox8.Text = "未检定";
textBox71.Text = "";
}
}
private void checkBox9_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label120.Text;
if (checkBox9.Checked)
{
flowCal(textBox76, textBox75, textDp, textBox74, textBox77, checkBox9).ToString();
}
else
{
checkBox9.ForeColor = Color.Red;
checkBox9.Checked = false;
checkBox9.Text = "未检定";
textBox77.Text = "";
}
}
private void checkBox10_CheckedChanged(object sender, EventArgs e)
{
TextBox textDp = new TextBox();
textDp.Text = label120.Text;
if (checkBox10.Checked)
{
flowCal(textBox82, textBox75, textDp, textBox74, textBox83, checkBox10).ToString();
}
else
{
checkBox10.ForeColor = Color.Red;
checkBox10.Checked = false;
checkBox10.Text = "未检定";
textBox83.Text = "";
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox61.Text == "" || textBox10.Text == "" || textBox17.Text == "" || textBox25.Text == "" || textBox26.Text == "" || textBox27.Text == "")
{
//MessageBox.Show("有参数未输入,请检查!");
return;
}
if (checkBox1.Checked)
{
checkBox2.Checked = true;
checkBox3.Checked = true;
checkBox4.Checked = true;
checkBox5.Checked = true;
checkBox6.Checked = true;
checkBox7.Checked = true;
checkBox8.Checked = true;
checkBox9.Checked = true;
checkBox10.Checked = true;
checkBox1.Text = "已计算";
checkBox1.ForeColor = Color.Green;
}
else
{
checkBox2.Checked = false;
checkBox3.Checked = false;
checkBox4.Checked = false;
checkBox5.Checked = false;
checkBox6.Checked = false;
checkBox7.Checked = false;
checkBox8.Checked = false;
checkBox9.Checked = false;
checkBox10.Checked = false;
checkBox1.Text = "全部计算";
checkBox1.ForeColor = Color.Red;
}
}
private void textBox31_TextChanged(object sender, EventArgs e)
{
getAcurrDp(textBox31, label114);
checkBox2_CheckedChanged(sender, e);
}
private void textBox37_TextChanged(object sender, EventArgs e)
{
if (!blReg)
{
return;
}
getAcurrDp(textBox37, label115);
checkBox3_CheckedChanged(sender, e);
}
private void textBox43_TextChanged(object sender, EventArgs e)
{
getAcurrDp(textBox43, label116);
checkBox4_CheckedChanged(sender, e);
}
private void textBox49_TextChanged(object sender, EventArgs e)
{
if (!blReg)
{
return;
}
getAcurrDp(textBox49, label117);
checkBox5_CheckedChanged(sender, e);
}
private void textBox55_TextChanged(object sender, EventArgs e)
{
if (!blReg)
{
return;
}
getAcurrDp(textBox55, label118);
checkBox6_CheckedChanged(sender, e);
}
private void textBox62_TextChanged(object sender, EventArgs e)
{
getAcurrDp(textBox55, label118);
checkBox7_CheckedChanged(sender, e);
checkBox8_CheckedChanged(sender, e);
}
private void textBox74_TextChanged(object sender, EventArgs e)
{
getAcurrDp(textBox55, label118);
checkBox9_CheckedChanged(sender, e);
checkBox10_CheckedChanged(sender, e);
}
private void textBox35_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox34, textBox35, textBox36);
}
private void textBox41_TextChanged(object sender, EventArgs e)
{
getErr(textBox40, textBox41, textBox42);
}
private void textBox47_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox46, textBox47, textBox48);
}
private void textBox53_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox52, textBox53, textBox54);
}
private void textBox59_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox58, textBox59, textBox60);
}
private void textBox66_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox65, textBox66, textBox67);
}
private void textBox72_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox71, textBox72, textBox73);
}
private void textBox78_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox77, textBox78, textBox79);
}
private void textBox84_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox83, textBox84, textBox85);
}
private void getErr(TextBox T1, TextBox T2, TextBox T3)
{
Jsrq = "";
Single D1 = 0;
Single D2 = 0;
Single D3 = 0;
if (T1.Text == "")
{
T1.Text = "0";
}
if (T2.Text == "")
{
T2.Text = "0";
}
try
{
D1 = Single.Parse(T1.Text);
D2 = Single.Parse(T2.Text);
D3 = 0;
if (D1 == 0)
{
D3 = 0;
}
else
{
D3 = (D2 - D1) / D1;
}
}
catch (Exception)
{
}
if (textBox185.Text == "" || textBox185.Text == "0")
{
//MessageBox.Show("准确度等级未输入,请重新输入!");
textBox185.Focus();
return;
}
Single ErrMax = Single.Parse(textBox185.Text);
if (Math.Abs(D3 * 100) > ErrMax)
{
T3.BackColor = Color.OrangeRed;
}
else
{
T3.BackColor = SystemColors.Window;
}
T3.Text = (D3 * 100).ToString("0.##");
}
private void getErr2(TextBox T1, TextBox T21, TextBox T22, TextBox T3)
{
Jsrq = "";
Single D1 = 0;
Single D2 = 0;
Single D21 = 0;
Single D22 = 0;
Single D3 = 0;
if (T1.Text == "")
{
T1.Text = "0";
}
if (T21.Text == "")
{
T21.Text = "0";
}
if (T22.Text == "")
{
T22.Text = "0";
}
try
{
D1 = Single.Parse(T1.Text);
D21 = Single.Parse(T21.Text);
D22 = Single.Parse(T22.Text);
D2 = (D21 + D22) / 2;
D3 = 0;
if (D1 == 0)
{
D3 = 0;
}
else
{
D3 = (D2 - D1) / D1;
}
}
catch (Exception)
{
}
T3.Text = (D3 * 100).ToString("0.##");
}
private void textBox89_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single fflow = Single.Parse(textBox58.Text);
Single ftime = Single.Parse(textBox89.Text);
textBox90.Text = (fflow * ftime / 3600).ToString("0.##");
}
catch (Exception)
{
}
}
private void textBox90_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single BZ = Single.Parse(textBox90.Text);
Single CS = Single.Parse(textBox91.Text);
Single ZZ = Single.Parse(textBox92.Text);
Single CZ = ZZ - CS;
textBox93.Text = CZ.ToString("0.##");
getErr(textBox90, textBox93, textBox94);
}
catch (Exception)
{
}
}
private void textBox93_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single BZ = Single.Parse(textBox90.Text);
Single CS = Single.Parse(textBox91.Text);
Single ZZ = Single.Parse(textBox92.Text);
Single CZ = ZZ - CS;
textBox93.Text = CZ.ToString("0.##");
getErr(textBox90, textBox93, textBox94);
}
catch (Exception)
{
}
}
private void textBox92_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single BZ = Single.Parse(textBox90.Text);
Single CS = Single.Parse(textBox91.Text);
Single ZZ = Single.Parse(textBox92.Text);
Single CZ = ZZ - CS;
textBox93.Text = CZ.ToString("0.##");
getErr(textBox90, textBox93, textBox94);
}
catch (Exception)
{
}
}
private void textBox91_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single BZ = Single.Parse(textBox90.Text);
Single CS = Single.Parse(textBox91.Text);
Single ZZ = Single.Parse(textBox92.Text);
Single CZ = ZZ - CS;
textBox93.Text = CZ.ToString("0.##");
getErr(textBox90, textBox93, textBox94);
}
catch (Exception)
{
}
}
private void textBox12_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
Single parMin = 0;
Single par25 = 0;
Single par5 = 0;
Single par75 = 0;
Single parMax = 0;
try
{
if (textBox15.Text == "")
{
textBox15.Text = "0";
}
parMin = Single.Parse(textBox15.Text);
parMax = Single.Parse(textBox16.Text);
par25 = parMin + (parMax - parMin) / 4;
par5 = parMin + (parMax - parMin) / 2;
par75 = parMin + (parMax - parMin) * 3 / 4;
if (textBox12.Text == "")
{
textBox12.Text = "0";
}
if (textBox13.Text == "")
{
textBox13.Text = "0";
}
if (textBox15.Text == "")
{
textBox15.Text = "0";
}
if (textBox16.Text == "")
{
textBox16.Text = "0";
}
Single Lcmin = Single.Parse(textBox12.Text);
Single LcMax = Single.Parse(textBox13.Text);
Single Amin = Single.Parse(textBox15.Text);
Single Amax = Single.Parse(textBox16.Text);
if (Lcmin > LcMax)
{
//MessageBox.Show("差压量程输入错误,请重新输入!");
textBox12.BackColor = Color.Red;
textBox13.BackColor = Color.Red;
textBox12.Focus();
return;
}
else
{
textBox12.BackColor = SystemColors.Window;
textBox13.BackColor = SystemColors.Window;
}
if (Amin >= Amax)
{
//MessageBox.Show("差压量程输入错误,请重新输入!");
textBox15.BackColor = Color.Red;
textBox16.BackColor = Color.Red;
textBox15.Focus();
return;
}
else
{
textBox15.BackColor = SystemColors.Window;
textBox16.BackColor = SystemColors.Window;
}
Single DpCurr0 = Lcmin + (LcMax - Lcmin) * (parMin - Amin) / (Amax - Amin);
Single DpCurr25 = Lcmin + (LcMax - Lcmin) * (par25 - Amin) / (Amax - Amin);
Single DpCurr5 = Lcmin + (LcMax - Lcmin) * (par5 - Amin) / (Amax - Amin);
Single DpCurr75 = Lcmin + (LcMax - Lcmin) * (par75 - Amin) / (Amax - Amin);
Single DpCurr100 = Lcmin + (LcMax - Lcmin) * (parMax - Amin) / (Amax - Amin);
textBox110.Text = DpCurr0.ToString("0.##");
textBox111.Text = DpCurr25.ToString("0.##");
textBox112.Text = DpCurr5.ToString("0.##");
textBox113.Text = DpCurr75.ToString("0.##");
textBox114.Text = DpCurr100.ToString("0.##");
}
catch(Exception)
{
}
}
private void textBox19_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
Single parMin = 0;
Single par25 = 0;
Single par5 = 0;
Single par75 = 0;
Single parMax = 0;
try
{
if (textBox15.Text == "")
{
textBox15.Text = "0";
}
parMin = Single.Parse(textBox22.Text);
parMax = Single.Parse(textBox23.Text);
par25 = parMin + (parMax - parMin) / 4;
par5 = parMin + (parMax - parMin) / 2;
par75 = parMin + (parMax - parMin) * 3 / 4;
if (textBox19.Text == "")
{
textBox19.Text = "0";
}
if (textBox20.Text == "")
{
textBox20.Text = "0";
}
if (textBox22.Text == "")
{
textBox22.Text = "0";
}
if (textBox23.Text == "")
{
textBox23.Text = "0";
}
Single Lcmin = Single.Parse(textBox19.Text);
Single LcMax = Single.Parse(textBox20.Text);
Single Amin = Single.Parse(textBox22.Text);
Single Amax = Single.Parse(textBox23.Text);
if (Lcmin > LcMax)
{
//MessageBox.Show("差压量程输入错误,请重新输入!");
textBox19.BackColor = Color.Red;
textBox20.BackColor = Color.Red;
//textBox19.Focus();
return;
}
else
{
textBox19.BackColor = SystemColors.Window;
textBox20.BackColor = SystemColors.Window;
}
if (Amin >= Amax)
{
//MessageBox.Show("差压量程输入错误,请重新输入!");
textBox22.BackColor = Color.Red;
textBox23.BackColor = Color.Red;
//textBox22.Focus();
return;
}
else
{
textBox22.BackColor = SystemColors.Window;
textBox23.BackColor = SystemColors.Window;
}
Single DpCurr0 = Lcmin + (LcMax - Lcmin) * (parMin - Amin) / (Amax - Amin);
Single DpCurr25 = Lcmin + (LcMax - Lcmin) * (par25 - Amin) / (Amax - Amin);
Single DpCurr5 = Lcmin + (LcMax - Lcmin) * (par5 - Amin) / (Amax - Amin);
Single DpCurr75 = Lcmin + (LcMax - Lcmin) * (par75 - Amin) / (Amax - Amin);
Single DpCurr100 = Lcmin + (LcMax - Lcmin) * (parMax - Amin) / (Amax - Amin);
textBox125.Text = DpCurr0.ToString("0.##");
textBox126.Text = DpCurr25.ToString("0.##");
textBox127.Text = DpCurr5.ToString("0.##");
textBox128.Text = DpCurr75.ToString("0.##");
textBox129.Text = DpCurr100.ToString("0.##");
}
catch (Exception)
{ }
}
private void Button1_Click(object sender, EventArgs e)
{
if (textBox61.Text == "")
{
strZf = "0~0~0~0~0~0~0~0~0~0~0~0~0~0~0~0~0~0~0~0~0";
}
else
{
strZf = textBox61.Text.Replace("_", "~");
}
frmInputNGCom frmZf = new frmInputNGCom();
frmZf.ngzf1.zfCopy = strZf;
frmZf.ShowDialog();
}
private void textBox100_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox95, textBox100, textBox105);
}
private void textBox101_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
getErr(textBox96, textBox101, textBox106);
}
private void textBox102_TextChanged(object sender, EventArgs e)
{
getErr(textBox97, textBox102, textBox107);
}
private void textBox103_TextChanged(object sender, EventArgs e)
{
getErr(textBox98, textBox103, textBox108);
}
private void textBox104_TextChanged(object sender, EventArgs e)
{
getErr(textBox99, textBox104, textBox109);
}
private void textBox115_TextChanged(object sender, EventArgs e)
{
getErr(textBox110, textBox115, textBox120);
}
private void textBox116_TextChanged(object sender, EventArgs e)
{
getErr(textBox111, textBox116, textBox121);
}
private void textBox117_TextChanged(object sender, EventArgs e)
{
getErr(textBox112, textBox117, textBox122);
}
private void textBox118_TextChanged(object sender, EventArgs e)
{
getErr(textBox113, textBox118, textBox123);
}
private void textBox119_TextChanged(object sender, EventArgs e)
{
getErr(textBox114, textBox119, textBox124);
}
private void textBox130_TextChanged(object sender, EventArgs e)
{
getErr(textBox125, textBox130, textBox135);
}
private void textBox131_TextChanged(object sender, EventArgs e)
{
getErr(textBox126, textBox131, textBox136);
}
private void textBox132_TextChanged(object sender, EventArgs e)
{
getErr(textBox127, textBox132, textBox137);
}
private void textBox133_TextChanged(object sender, EventArgs e)
{
getErr(textBox128, textBox133, textBox138);
}
private void textBox134_TextChanged(object sender, EventArgs e)
{
getErr(textBox129, textBox134, textBox139);
}
private void textBox143_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single fflow = Single.Parse(textBox68.Text);
Single ftime = Single.Parse(textBox143.Text);
textBox144.Text = (fflow * ftime).ToString("0.##");
}
catch (Exception)
{ }
}
private void textBox144_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single BZ = Single.Parse(textBox144.Text);
Single CS = Single.Parse(textBox145.Text);
Single ZZ = Single.Parse(textBox146.Text);
Single CZ = ZZ - CS;
textBox147.Text = CZ.ToString("0.##");
getErr(textBox144, textBox147, textBox148);
}
catch (Exception)
{ }
}
private void textBox145_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single BZ = Single.Parse(textBox144.Text);
Single CS = Single.Parse(textBox145.Text);
Single ZZ = Single.Parse(textBox146.Text);
Single CZ = ZZ - CS;
textBox147.Text = CZ.ToString("0.##");
getErr(textBox144, textBox147, textBox148);
}
catch (Exception)
{
}
}
private void textBox146_TextChanged(object sender, EventArgs e)
{
Jsrq = "";
try
{
Single BZ = Single.Parse(textBox144.Text);
Single CS = Single.Parse(textBox145.Text);
Single ZZ = Single.Parse(textBox146.Text);
Single CZ = ZZ - CS;
textBox147.Text = CZ.ToString("0.##");
getErr(textBox144, textBox147, textBox148);
}
catch (Exception)
{
}
}
private void textBox147_TextChanged(object sender, EventArgs e)
{
}
private void textBox151_TextChanged(object sender, EventArgs e)
{
getErr2(textBox151, textBox156, textBox161, textBox166);
}
private void textBox152_TextChanged(object sender, EventArgs e)
{
getErr2(textBox152, textBox157, textBox162, textBox167);
}
private void textBox153_TextChanged(object sender, EventArgs e)
{
getErr2(textBox153, textBox158, textBox163, textBox168);
}
private void textBox154_TextChanged(object sender, EventArgs e)
{
getErr2(textBox154, textBox159, textBox164, textBox169);
}
private void textBox155_TextChanged(object sender, EventArgs e)
{
getErr2(textBox155, textBox160, textBox165, textBox170);
}
private void textBox171_TextChanged(object sender, EventArgs e)
{
getErr2(textBox171, textBox176, textBox181, textBox186);
}
private void textBox172_TextChanged(object sender, EventArgs e)
{
getErr2(textBox172, textBox177, textBox182, textBox187);
}
private void textBox173_TextChanged(object sender, EventArgs e)
{
getErr2(textBox173, textBox178, textBox183, textBox188);
}
private void ComboBox7_SelectedIndexChanged(object sender, EventArgs e) { }
private void button4_Click(object sender, EventArgs e)
{
//保存计量点信息
//1 保存客户名称
//if (listBox3.SelectedIndex == 0)
//{
// MessageBox.Show("请重新输入或选择客户名称!");
// listBox3.Focus();
// return;
//}
string strSQL = "";
strSQL = "select * from 客户资料 where 客户名称='" + listBox3.Text + "' order by ID";
DataTable dtKhtemp = new DataTable();
OleDbDataAdapter KhDaptemp = new System.Data.OleDb.OleDbDataAdapter();
OleDbCommandBuilder KhCb = new OleDbCommandBuilder(KhDaptemp);
KhDaptemp.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
KhDaptemp.UpdateCommand = KhCb.GetUpdateCommand();
KhDaptemp.InsertCommand = KhCb.GetInsertCommand();
KhDaptemp.DeleteCommand = KhCb.GetDeleteCommand();
KhDaptemp.Fill(dtKhtemp);
if (dtKhtemp.Rows.Count < 1)
{
DataRow dr = dtKhtemp.NewRow();
dr["客户名称"] = listBox3.Text;
dr["客户联系人"] = textBox86.Text;
dr["客户联系电话"] = textBox149.Text;
dtKhtemp.Rows.Add(dr);
KhDaptemp.Update(dtKhtemp);
dtKhtemp.Clear();
KhDaptemp.Fill(dtKhtemp);
}
strSQL = "select * from 生产厂家 where 客户ID=" + dtKhtemp.Rows[0]["ID"] + " and 厂家名称='" + textBox70.Text + "' order by ID";
DataTable dtCjtemp = new DataTable();
OleDbDataAdapter CjDaptemp = new System.Data.OleDb.OleDbDataAdapter();
OleDbCommandBuilder CjCb = new OleDbCommandBuilder(CjDaptemp);
CjDaptemp.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
CjDaptemp.UpdateCommand = CjCb.GetUpdateCommand();
CjDaptemp.InsertCommand = CjCb.GetInsertCommand();
CjDaptemp.DeleteCommand = CjCb.GetDeleteCommand();
CjDaptemp.Fill(dtCjtemp);
if (dtCjtemp.Rows.Count < 1)
{
DataRow dr = dtCjtemp.NewRow();
dr["厂家名称"] = textBox70.Text;
dr["客户ID"] = dtKhtemp.Rows[0]["ID"];
dtCjtemp.Rows.Add(dr);
CjDaptemp.Update(dtCjtemp);
dtCjtemp.Clear();
CjDaptemp.Fill(dtCjtemp);
}
string strPar = "";
var textBoxes = LoopControls.AllControl<TextBox>(tabPage1);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage2);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage3);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage10);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage12);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
var comboBoxes = LoopControls.AllControl<ComboBox>(tabPage1);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.SelectedIndex + "~";
}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage2);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.SelectedIndex + "~";
}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage12);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.SelectedIndex + "~";
}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage10);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.SelectedIndex + "~";
}
strSQL = "select * from 仪表信息 where 厂家ID=" + dtCjtemp.Rows[0]["ID"] + " and 仪表编号='" + textBox80.Text + "' order by ID";
DataTable dtYbtemp = new DataTable();
OleDbDataAdapter YbDaptemp = new System.Data.OleDb.OleDbDataAdapter();
OleDbCommandBuilder YbCb = new OleDbCommandBuilder(YbDaptemp);
YbDaptemp.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
YbDaptemp.UpdateCommand = YbCb.GetUpdateCommand();
YbDaptemp.InsertCommand = YbCb.GetInsertCommand();
YbDaptemp.DeleteCommand = YbCb.GetDeleteCommand();
YbDaptemp.Fill(dtYbtemp);
if (dtYbtemp.Rows.Count < 1)
{
DataRow dr = dtYbtemp.NewRow();
dr["厂家名称"] = textBox70.Text;
dr["厂家ID"] = dtCjtemp.Rows[0]["ID"];
dr["仪表编号"] = textBox80.Text;
dr["仪表参数信息"] = strPar;
dtYbtemp.Rows.Add(dr);
YbDaptemp.Update(dtYbtemp);
}
else
{
dtYbtemp.Rows[0]["仪表参数信息"] = strPar;
YbDaptemp.Update(dtYbtemp);
}
int cuid = ListBox2.SelectedIndex;
ListBox1_SelectedIndexChanged(sender, e);
ListBox2.SelectedIndex = cuid;
//bindKh();
}
private void Button3_Click(object sender, EventArgs e)
{
if (ListBox2.SelectedValue is null || ListBox2.Items.Count < 1)
{
MessageBox.Show("请重选择流量计编号!");
ListBox2.Focus();
return;
}
string strPar = "";
var textBoxes = LoopControls.AllControl<TextBox>(tabPage1);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
//textBoxes = LoopControls.AllControl<TextBox>(tabPage2);
//foreach (TextBox c in textBoxes)
//{
// strPar += c.Name + ":" + c.Text + "~";
//}
textBoxes = LoopControls.AllControl<TextBox>(tabPage3);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage10);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
textBoxes = LoopControls.AllControl<TextBox>(tabPage12);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
var comboBoxes = LoopControls.AllControl<ComboBox>(tabPage1);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.SelectedIndex + "~";
}
//comboBoxes = LoopControls.AllControl<ComboBox>(tabPage2);
//foreach (ComboBox c in comboBoxes)
//{
// strPar += c.Name + ":" + c.SelectedIndex + "~";
//}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage12);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.SelectedIndex + "~";
}
comboBoxes = LoopControls.AllControl<ComboBox>(tabPage10);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.SelectedIndex + "~";
}
int intJldID = System.Convert.ToInt32(ListBox2.SelectedValue);
string strSQL = "";
strSQL = "select * from 仪表信息 where ID=" + intJldID.ToString();
DataTable dtSaveJld = new DataTable();
OleDbDataAdapter jldDap = new OleDbDataAdapter();
jldDap = new System.Data.OleDb.OleDbDataAdapter();
jldDap.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
OleDbCommandBuilder cb = new OleDbCommandBuilder(jldDap);
jldDap.UpdateCommand = cb.GetUpdateCommand();
jldDap.Fill(dtSaveJld);
dtSaveJld.Rows[0]["仪表参数信息"] = strPar;
jldDap.Update(dtSaveJld);
strSQL = "select * from 仪表信息 where 厂家ID=" + ListBox1.SelectedValue.ToString();
dtJld = new DataTable();
jldDap = new System.Data.OleDb.OleDbDataAdapter();
jldDap.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
jldDap.Fill(dtJld);
}
private void Button2_Click(object sender, EventArgs e)
{
if (textBox35.Text == "" || textBox41.Text == "" || textBox47.Text == "" || textBox53.Text == "" || textBox59.Text == "" || textBox66.Text == "")
{
if (MessageBox.Show("还未检定完成,确定要保存结果?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)//如果点击“确定”按钮
{
return;
}
}
if (textBox2.Text == "" || textBox3.Text == "" || textBox150.Text == "" || textBox189.Text == "")
{
MessageBox.Show("环境条件还没录入", "提示", MessageBoxButtons.OKCancel);//如果点击“确定”按钮
return;
}
string strPar = "";
var textBoxes = LoopControls.AllControl<TextBox>(this);
foreach (TextBox c in textBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
var comboBoxes = LoopControls.AllControl<ComboBox>(this);
foreach (ComboBox c in comboBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
var radioButtons = LoopControls.AllControl<RadioButton>(this);
foreach (RadioButton c in radioButtons)
{
if (c.Checked)
{
strPar += c.Name + ":●" + c.Text + "~";
}
else
{
strPar += c.Name + ":○" + c.Text + "~";
}
}
var labels = LoopControls.AllControl<Label>(this);
foreach (Label c in labels)
{
strPar += c.Name + ":" + c.Text + "~";
}
var listBoxes = LoopControls.AllControl<ListBox>(this);
foreach (ListBox c in listBoxes)
{
strPar += c.Name + ":" + c.Text + "~";
}
MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
DialogResult dr = MessageBox.Show("点确定将检定结果保存?", "保存", messButton);
if (dr == DialogResult.OK)//如果点击“确定”按钮
{
int intJldID = System.Convert.ToInt32(ListBox2.SelectedValue);
string strSQL = "";
strSQL = "select * from 计算历史记录 where 计量点ID=" + intJldID.ToString();
DataTable dtSaveJld = new DataTable();
OleDbDataAdapter jldDap = new OleDbDataAdapter();
jldDap = new System.Data.OleDb.OleDbDataAdapter();
jldDap.SelectCommand = new OleDbCommand(strSQL, MySqlCon);
OleDbCommandBuilder cb = new OleDbCommandBuilder(jldDap);
jldDap.UpdateCommand = cb.GetUpdateCommand();
jldDap.InsertCommand = cb.GetInsertCommand();
jldDap.Fill(dtSaveJld);
Jsrq = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
DataRow dataRow = dtSaveJld.NewRow();
dataRow["计算日期"] = Jsrq;
dataRow["计量点ID"] = intJldID;
dataRow["计量点资料"] = strPar;
dataRow["计算结果"] = strPar;
dtSaveJld.Rows.Add(dataRow);
jldDap.Update(dtSaveJld);
}
}
private void button5_Click(object sender, EventArgs e)
{
frmPrint frmP = new frmPrint();
if (Jsrq == "")
{
}
else
{
frmP.Jsrq = Jsrq;
}
frmP.ShowDialog();
}
private void button6_Click(object sender, EventArgs e)
{
TextBox t1 = new TextBox();
CheckBox chk1 = new CheckBox();
chk1.Checked = true;
gasPar1 = new NG_Tools.NG_Cal.GasPropsSTRUCT();
flPar1 = new NG_Tools.NG_Cal.FlowParStruct();
flowCal(textBox175, textBox179, textBox180, textBox184, t1, chk1);
frmZjcs fzjcs = new frmZjcs();
fzjcs.gasPar = gasPar1;
fzjcs.flPar = flPar1;
fzjcs.ShowDialog();
}
private void textBox27_TextChanged(object sender, EventArgs e)
{
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
ToolStripMenuItem_Click(sender, e);
tabPage11.Visible = true;
tabControl1.SelectTab(2);
}
private void AToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutBox1 ab1 = new AboutBox1();
ab1.ShowDialog();
}
private void HToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void LToolStripMenuItem_Click(object sender, EventArgs e)
{
frmLogin fl = new frmLogin();
fl.ShowDialog();
}
private void MToolStripMenuItem_Click(object sender, EventArgs e)
{
frmJdygl fjdy = new frmJdygl();
fjdy.ShowDialog();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
frmAddJld frmAdd = new frmAddJld();
frmAdd.ShowDialog();
}
private void 退ToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel3.Enabled = true;
}
private void radioButton6_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel3.Enabled = false;
}
private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel7.Enabled = true;
}
private void radioButton7_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel7.Enabled = false;
}
private void radioButton8_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel8.Enabled = true;
}
private void radioButton9_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel8.Enabled = false;
}
private void radioButton10_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel9.Enabled = true;
}
private void radioButton11_CheckedChanged(object sender, EventArgs e)
{
tableLayoutPanel9.Enabled = false;
}
private void radioButton14_CheckedChanged(object sender, EventArgs e)
{
textBox174.Enabled = false;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox25_TextChanged(object sender, EventArgs e)
{
}
}
public static class LoopControls
{
public static IEnumerable<T> AllControl<T>(this Control startingPoint) where T : Control
{
bool hit = startingPoint is T;
if (hit)
{
yield return startingPoint as T;
}
foreach (var child in startingPoint.Controls.Cast<Control>())
{
foreach (var item in AllControl<T>(child))
{
yield return item;
}
}
}
}
}