public static bool DataFileToClass(string FileStr, out cKBValue KBValue)//从文件加载KB值到变量 { bool isOk = false; cKBValue mKBValue; string readFile = cMain.ReadFile(FileStr); string[] tempStr; int i = 0; try { mKBValue = new cKBValue(); tempStr = readFile.Split('~'); for (i = 0; i < cMain.DataAll; i++) { mKBValue.valueK[i] = Num.DoubleParse(tempStr[2 * i]); mKBValue.valueB[i] = Num.DoubleParse(tempStr[2 * i + 1]); } isOk = true; } catch (Exception exc) { mKBValue = new cKBValue(); cMain.WriteErrorToLog("FrmKb DataFileToClass is Error " + exc.ToString()); isOk = false; } KBValue = mKBValue; return(isOk); }
public static bool DataFrmToClass(frmJiLiang mfrmKb) { bool isOk = false; string[] tempStr = cMain.DataAllTitleStr[cMain.IndexLanguage].Split(','); try { for (int j = 0; j < mfrmKb.readGrid.Columns.Count; j++) { for (int i = 0; i < cMain.DataAll; i++) { if (tempStr[i] == mfrmKb.readGrid.Columns[j].HeaderText) { for (int k = 0; k < 10; k++) { DataGridViewRow dr = mfrmKb.KBGrid.Rows[k]; mfrmKb.mJiLiang.jiLiangTempClass[i].IsUseData[k] = (dr.Cells[j * 3].Value == null) ? false : (bool)dr.Cells[j * 3].Value; mfrmKb.mJiLiang.jiLiangTempClass[i].ReadData[k] = Num.DoubleParse(dr.Cells[j * 3 + 1].Value); mfrmKb.mJiLiang.jiLiangTempClass[i].CureData[k] = Num.DoubleParse(dr.Cells[j * 3 + 2].Value); } break; } } } isOk = true; } catch (Exception exc) { cMain.WriteErrorToLog("FrmJiLiang DataFrmToClass is Error " + exc.ToString()); isOk = false; } return(isOk); }
private void toolStripButton1_Click(object sender, EventArgs e) { //"A相电压(V),B相电压(V),B相电压(V),A相电流(A),B相电流(A),C相电流(A),A相功率(W),B相功率(W),C相功率(W),"+ //"R22进管温度(℃),R22出管温度(℃),R410进管温度(℃),R410出管温度(℃),吸气温度(℃),排气温度(℃),R22进风温度(℃),"+ //"R22出风温度(℃),R410进风温度(℃),R410出风温度(℃),R22高压压力(Mpa),R22低压压力(Mpa),R410高压压力(Mpa),R410低压压力(Mpa),"+ //"1#进风温度(℃),1#出风温度(℃),2#进风温度(℃),2#出风温度(℃),3#进风温度(℃),3#出风温度(℃),4#进风温度(℃),4#出风温度(℃),"+ //"1#进管压力(Mpa),1#出管压力(Mpa),2#进管压力(Mpa),2#出管压力(Mpa),3#进管压力(Mpa),3#出管压力(Mpa),4#进管压力(Mpa),4#出管压力(Mpa),"+ //"1#进管温度(℃),1#出管温度(℃),2#进管温度(℃),2#出管温度(℃),3#进管温度(℃),3#出管温度(℃),4#进管温度(℃),4#出管温度(℃)" if (File.Exists(".\\Data\\KBValue.mdb")) { OleDbConnection KbData = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\Data\\KBValue.mdb;Persist Security Info=True"); KbData.Open(); string[] title = cMain.DataAllTitleStr[cMain.IndexLanguage].Split(','); Dictionary <string, int> oldKBValueIndex = new Dictionary <string, int>(); for (int i = 0; i < cMain.DataAll; i++) { oldKBValueIndex.Add(title[i], i + 1); } DataSet ds; cJiLiang tmpJiLiang = new cJiLiang(); string error; List <double> x = new List <double>(); List <double> y = new List <double>(); for (int i = 0; i < cMain.DataAll; i++) { x.Clear(); y.Clear(); if (!oldKBValueIndex.ContainsKey(title[i])) { continue; } ds = cData.readData(string.Format("select X,Y From TValue{0}", oldKBValueIndex[title[i]]), KbData); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { tmpJiLiang.jiLiangTempClass[i].IsUseData[j] = true; tmpJiLiang.jiLiangTempClass[i].ReadData[j] = Num.DoubleParse(ds.Tables[0].Rows[j]["X"]); tmpJiLiang.jiLiangTempClass[i].CureData[j] = Num.DoubleParse(ds.Tables[0].Rows[j]["Y"]); x.Add(Num.DoubleParse(ds.Tables[0].Rows[j]["X"])); y.Add(Num.DoubleParse(ds.Tables[0].Rows[j]["Y"])); } frmJiLiang.JiLiangByXianXing(x, y, out cMain.mKBValue.valueK[i], out cMain.mKBValue.valueB[i], out error); } KbData.Close(); KbData.Dispose(); frmJiLiang.DataClassToFile(tmpJiLiang); frmKB.DataClassToFile(cMain.mKBValue); DataClassToFrm(this, cMain.mKBValue); } else { MessageBox.Show("安装目录Data文件夹下不存在KBValue.mdb文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void timer1_Tick(object sender, EventArgs e) { int SumRows = 0; for (int i = 0; i < cMain.DataShow; i++) { MaxValue[i] = -65535;//初始化一个默认值 MinValue[i] = 65535; SumValue[i] = 0; } for (int i = 2; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[0].Value != null && Num.BoolParse(dataGridView1.Rows[i].Cells[0].Value)) { for (int j = 0; j < cMain.DataShow; j++) { double tmpValue = Num.DoubleParse(dataGridView1.Rows[i].Cells[1 + j].Value); SumValue[j] = SumValue[j] + tmpValue; MaxValue[j] = Num.DoubleMax(MaxValue[j], tmpValue); MinValue[j] = Num.DoubleMin(MinValue[j], tmpValue); } SumRows++; } } if (SumRows >= 3)//最少要3行,(最高值,最低值,中间值)最少3行 { for (int i = 0; i < cMain.DataShow; i++) { double tmpValue = Num.DoubleParse(txtData.Text); SumValue[i] = SumValue[i] - MaxValue[i] - MinValue[i]; if (chkData[i].Checked) { dataGridView1.Rows[0].Cells[i + 1].Value = (1 - tmpValue * 0.010) * SumValue[i] / (SumRows - 2.000); dataGridView1.Rows[1].Cells[i + 1].Value = (1 + tmpValue * 0.010) * SumValue[i] / (SumRows - 2.000); } else { dataGridView1.Rows[0].Cells[i + 1].Value = 0; dataGridView1.Rows[1].Cells[i + 1].Value = 0; } } } else { if (dataGridView1.Rows.Count >= 2) { for (int i = 0; i < cMain.DataShow; i++) { dataGridView1.Rows[0].Cells[i + 1].Value = 0; dataGridView1.Rows[1].Cells[i + 1].Value = 0; } } } }
public static bool DataFileToClass(string FileStr, out cSystemSet SystemSet, bool isPath) { bool isOk = false; cSystemSet mSystemSet = new cSystemSet(); string readFile; int index = 0; if (isPath) { readFile = cMain.ReadFile(FileStr); } else { readFile = FileStr; } try { string[] tempStr; tempStr = readFile.Split('~'); int i; mSystemSet.mPrevBar = tempStr[index++]; mSystemSet.mPrevId = tempStr[index++]; mSystemSet.mPLCCOM = tempStr[index++]; mSystemSet.mBarCom = tempStr[index++]; mSystemSet.m485COM = tempStr[index++]; mSystemSet.mSnCom = tempStr[index++]; mSystemSet.mPQCom = tempStr[index++]; mSystemSet.mPassWord = tempStr[index++]; for (i = 0; i < mSystemSet.PressK.Length; i++) { mSystemSet.PressK[i] = Num.DoubleParse(tempStr[index++]); } for (i = 0; i < mSystemSet.PressK.Length; i++) { mSystemSet.PressB[i] = Num.DoubleParse(tempStr[index++]); } mSystemSet.ZYSFArea = tempStr[index++].ToInt(); mSystemSet.ZYSFDoing = tempStr[index++].ToInt(); isOk = true; } catch (Exception exc) { //mSystemSet = new cSystemSet(); cMain.WriteErrorToLog("FrmSys DataFileToClass is Error " + exc.ToString()); isOk = false; } SystemSet = mSystemSet; return(isOk); }
private void btnOk_Click(object sender, EventArgs e)//确定按钮,将KB值赋给变量.并写入文件保存 { string error = ""; KBGrid.EndEdit(); if (DataFrmToClass(this)) { if (DataClassToFile(mJiLiang)) { string[] tempStr = cMain.DataAllTitleStr[cMain.IndexLanguage].Split(','); for (int i = 0; i < readGrid.Columns.Count; i++) { string tempName = readGrid.Columns[i].HeaderText; for (int j = 0; j < cMain.DataAll; j++) { if (tempStr[j] == tempName) { List <double> x = new List <double>(); List <double> y = new List <double>(); for (int k = 0; k < 10; k++) { DataGridViewRow dr = KBGrid.Rows[k]; if ((dr.Cells[i * 3].Value == null) ? false : (bool)dr.Cells[i * 3].Value) { x.Add(Num.DoubleParse(dr.Cells[i * 3 + 1].Value)); y.Add(Num.DoubleParse(dr.Cells[i * 3 + 2].Value)); } } JiLiangByXianXing(x, y, out cMain.mKBValue.valueK[j], out cMain.mKBValue.valueB[j], out error); break; } } } frmKB.DataClassToFile(cMain.mKBValue); MessageBox.Show("Successfully Saved,数据保存成功".Split(',')[cMain.IndexLanguage], "Ok,成功".Split(',')[cMain.IndexLanguage], MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } MessageBox.Show("Fail Saved. Check it,数据保存错误,请检测数据是否正确后重新保存".Split(',')[cMain.IndexLanguage], "Error,错误".Split(',')[cMain.IndexLanguage], MessageBoxButtons.OK, MessageBoxIcon.Error); }
private cNetResult GetNetResult(string McgsSendStr) { cNetResult netResult = new cNetResult(); string[] tempStr = McgsSendStr.Split('~'); //0:"D",1:"OK",2:TestTime,3:ThisNo,4:StepId......... netResult.RunResult.mTestTime = DateTime.Parse(tempStr[2]); // netResult.RunResult.mTestNo = Num.IntParse(tempStr[3]); // netResult.RunResult.mStepId = Num.IntParse(tempStr[4]); netResult.RunResult.mStep = tempStr[5]; netResult.RunResult.mMode = tempStr[6]; // netResult.RunResult.mJiQi = Num.IntParse(tempStr[7]); // netResult.RunResult.mIsPass = bool.Parse(tempStr[8]); // netResult.RunResult.mId = tempStr[9]; // netResult.RunResult.mBar = tempStr[10]; // for (int i = 0; i < cMain.DataShow; i++) { netResult.StepResult.mData[i] = Num.DoubleParse(tempStr[11 + i * 2]); // netResult.StepResult.mIsDataPass[i] = Num.IntParse(tempStr[12 + i * 2]); // } netResult.StepResult.mIsStepPass = Num.IntParse(tempStr[11 + 2 * cMain.DataShow]); return(netResult); }
private void timer1_Tick(object sender, EventArgs e) { int i; int rowCount = 0; rowCount = (int)Math.Ceiling((double)(cMain.DataAll / 2.000)); for (i = 0; i < cMain.DataAll; i++) { DataGridViewRow dr; if (i < rowCount) { dr = KBGrid.Rows[i]; dr.Cells[2].Value = frmMain.dataRead[i]; dr.Cells[5].Value = (frmMain.dataRead[i] * Num.DoubleParse(dr.Cells[3].Value) + Num.DoubleParse(dr.Cells[4].Value)); } else { dr = KBGrid.Rows[i - rowCount]; dr.Cells[8].Value = frmMain.dataRead[i]; dr.Cells[11].Value = (frmMain.dataRead[i] * Num.DoubleParse(dr.Cells[9].Value) + Num.DoubleParse(dr.Cells[10].Value)); } } }
public static bool DataFrmToClass(frmKB mfrmKb, out cKBValue KBValue) { bool isOk = false; cKBValue mKBValue = new cKBValue(); int rowCount = 0; rowCount = (int)Math.Ceiling((double)(cMain.DataAll / 2.000)); int i; try { for (i = 0; i < cMain.DataAll; i++) { DataGridViewRow dr; if (i < rowCount) { dr = mfrmKb.KBGrid.Rows[i]; mKBValue.valueK[i] = Num.DoubleParse(dr.Cells[3].Value); mKBValue.valueB[i] = Num.DoubleParse(dr.Cells[4].Value); } else { dr = mfrmKb.KBGrid.Rows[i - rowCount]; mKBValue.valueK[i] = Num.DoubleParse(dr.Cells[9].Value); mKBValue.valueB[i] = Num.DoubleParse(dr.Cells[10].Value); } } isOk = true; } catch (Exception exc) { cMain.WriteErrorToLog("FrmKb DataFrmToClass is Error " + exc.ToString()); isOk = false; } KBValue = mKBValue; return(isOk); }
public static bool DataFrmToClass(frmSys mFrmSys, out cSystemSet SystemSet) { bool isOk = false; cSystemSet mSystemSet = new cSystemSet(); int i; int index = 0; try { mSystemSet.mPrevBar = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString(); mSystemSet.mPrevId = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString(); mSystemSet.mPLCCOM = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString(); mSystemSet.mBarCom = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString(); mSystemSet.m485COM = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString(); mSystemSet.mSnCom = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString(); mSystemSet.mPQCom = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString(); mSystemSet.mPassWord = Num.StringParse(mFrmSys.GridSys.Rows[index++].Cells[1].Value); for (i = 0; i < mSystemSet.PressK.Length; i++) { mSystemSet.PressK[i] = Num.DoubleParse(mFrmSys.GridSys.Rows[index++].Cells[1].Value); } for (i = 0; i < mSystemSet.PressB.Length; i++) { mSystemSet.PressB[i] = Num.DoubleParse(mFrmSys.GridSys.Rows[index++].Cells[1].Value); } mSystemSet.ZYSFArea = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString().ToInt(); mSystemSet.ZYSFDoing = mFrmSys.GridSys.Rows[index++].Cells[1].Value.ToString().ToInt(); isOk = true; } catch (Exception exc) { cMain.WriteErrorToLog("FrmSys DataFrmToClass is Error " + exc.ToString()); isOk = false; } SystemSet = mSystemSet; return(isOk); }
public bool AiNuo9641Read(out AiNuo9641Data _aiNuo9641Data) { aiNuo9641Data.mAiNuoStatue = TestStatueEnum.None; for (int i = 0; i < aiNuo9641Data.mAiNuo9641Data.Length; i++) { aiNuo9641Data.mAiNuo9641Data[i].mTestData = 0; aiNuo9641Data.mAiNuo9641Data[i].mTestName = TestNameEnum.None; aiNuo9641Data.mAiNuo9641Data[i].mTestResult = TestStepResultEnum.None; } bool returnValue = false; if (!mAiNuo9641Init) { AiNuo9641Init(); _aiNuo9641Data = aiNuo9641Data; return(false); } byte[] WriteBuff = new byte[9]; //发送数据 byte[] ReadBuff = new byte[400]; //接收数据 int ReturnByte = 0; //返回数据 bool IsReturn = false; //是否成功返回 bool IsTimeOut = false; //是否超时 DateTime NowTime = DateTime.Now; //当前时间 TimeSpan ts; //时间差 try { if (!comPort.IsOpen) { comPort.Open(); } WriteBuff[0] = 0x7B; WriteBuff[1] = _AiNuo9641BAddress[0]; WriteBuff[2] = _AiNuo9641BAddress[1]; WriteBuff[3] = _AiNuo9641BAddress[2]; WriteBuff[4] = 0x30; WriteBuff[5] = 0x30; WriteBuff[6] = 0x30; WriteBuff[7] = 0x7D; comPort.DiscardInBuffer(); comPort.Write(WriteBuff, 0, 8); NowTime = DateTime.Now; do { if (comPort.BytesToRead >= 193)//收到数据 { ReturnByte = comPort.BytesToRead; IsReturn = true; } ts = DateTime.Now - NowTime; if (ts.TotalMilliseconds > timeOut)//时间超时 { IsTimeOut = true; } } while (!IsReturn && !IsTimeOut); if (!IsReturn && IsTimeOut)//超时 { if (ErrStr.IndexOf("读数失败,接收数据已超时") < 0) { ErrStr = ErrStr + DateTime.Now.ToString() + mName + ":读数失败,接收数据已超时" + (char)13 + (char)10; } returnValue = false; } else { comPort.Read(ReadBuff, 0, ReturnByte); if ((ReadBuff[0] != WriteBuff[0]) || (ReadBuff[1] != WriteBuff[1]) || (ReadBuff[2] != WriteBuff[2]))//数据检验失败 { //comPort.Close(); if (ErrStr.IndexOf("读数失败,接收数据错误") < 0) { ErrStr = ErrStr + DateTime.Now.ToString() + mName + ":读数失败,接收数据错误" + (char)13 + (char)10; } returnValue = false; } else { switch (ReadBuff[189]) { case 0x30: aiNuo9641Data.mAiNuoStatue = TestStatueEnum.Before; break; case 0x31: aiNuo9641Data.mAiNuoStatue = TestStatueEnum.Run; break; case 0x32: aiNuo9641Data.mAiNuoStatue = TestStatueEnum.Over; break; case 0x37: aiNuo9641Data.mAiNuoStatue = TestStatueEnum.None; break; default: aiNuo9641Data.mAiNuoStatue = TestStatueEnum.None; break; } if (aiNuo9641Data.mAiNuoStatue == TestStatueEnum.Over) { for (int i = 0; i < 7; i++) { int DataStart = 6; switch (ReadBuff[4 + i * 23 + 1]) { case 0x31: aiNuo9641Data.mAiNuo9641Data[i].mTestName = TestNameEnum.JieDi; break; case 0x32: aiNuo9641Data.mAiNuo9641Data[i].mTestName = TestNameEnum.JueYuan; break; case 0x33: aiNuo9641Data.mAiNuo9641Data[i].mTestName = TestNameEnum.NaiYa; break; case 0x34: aiNuo9641Data.mAiNuo9641Data[i].mTestName = TestNameEnum.XieLou; break; case 0: default: aiNuo9641Data.mAiNuo9641Data[i].mTestName = TestNameEnum.None; break; } switch (ReadBuff[4 + i * 23 + 23]) { case 0x30: aiNuo9641Data.mAiNuo9641Data[i].mTestResult = TestStepResultEnum.None; break; case 0x31: aiNuo9641Data.mAiNuo9641Data[i].mTestResult = TestStepResultEnum.OK; break; case 0x32: aiNuo9641Data.mAiNuo9641Data[i].mTestResult = TestStepResultEnum.NG1; break; case 0x33: aiNuo9641Data.mAiNuo9641Data[i].mTestResult = TestStepResultEnum.PT; break; case 0x34: aiNuo9641Data.mAiNuo9641Data[i].mTestResult = TestStepResultEnum.NG2; break; default: aiNuo9641Data.mAiNuo9641Data[i].mTestResult = TestStepResultEnum.None; break; } byte[] tmpByte = new byte[4]; string tmpStr = ""; for (int j = 0; j < 4; j++) { tmpByte[j] = ReadBuff[4 + i * 23 + DataStart + j]; } tmpStr = Encoding.ASCII.GetString(tmpByte).Trim(); if (NumRex.IsMatch(tmpStr)) { aiNuo9641Data.mAiNuo9641Data[i].mTestData = Num.DoubleParse(tmpStr); switch (aiNuo9641Data.mAiNuo9641Data[i].mTestName) { case TestNameEnum.JieDi: case TestNameEnum.JueYuan: aiNuo9641Data.mAiNuo9641Data[i].mTestData /= 10; break; case TestNameEnum.NaiYa: aiNuo9641Data.mAiNuo9641Data[i].mTestData /= 100; break; case TestNameEnum.XieLou: aiNuo9641Data.mAiNuo9641Data[i].mTestData /= 1000; break; default: aiNuo9641Data.mAiNuo9641Data[i].mTestData /= 10; break; } } else { aiNuo9641Data.mAiNuo9641Data[i].mTestData = 9999; } } } returnValue = true; } } } catch (Exception exc) { if (ErrStr.IndexOf(exc.ToString()) < 0) { ErrStr = ErrStr + DateTime.Now.ToString() + mName + ":" + exc.ToString() + (char)13 + (char)10; } } _aiNuo9641Data = aiNuo9641Data; return(returnValue); }
private void btnSave_Click(object sender, EventArgs e) { bool isDelFirst = false;//是否要先删除原有数据 try { double[] SaveValue = new double[cMain.DataShow * 2]; for (int i = 0; i < cMain.DataShow; i++) { SaveValue[i * 2] = Num.DoubleParse(dataGridView1.Rows[0].Cells[i + 1].Value); SaveValue[i * 2 + 1] = Num.DoubleParse(dataGridView1.Rows[1].Cells[i + 1].Value); } DataSet ds = cData.readData(string.Format("select * from initPara where ModeId='{0}' and StepId={1}", cbbId.Text, Num.IntParse(cbbStepId.Text) - 1), cData.ConnMain); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < SaveValue.Length; i++) { ds.Tables[0].Rows[0][string.Format("Data{0}", i + 1)] = SaveValue[i]; } isDelFirst = true; } else { isDelFirst = false; } string sqlCommand = "Insert into initPara Values('"; sqlCommand = sqlCommand + ds.Tables[0].Rows[0]["ModeID"].ToString() + "'"; sqlCommand = sqlCommand + "," + ds.Tables[0].Rows[0]["StepID"].ToString(); sqlCommand = sqlCommand + ",'" + ds.Tables[0].Rows[0]["RunMode"].ToString() + "'"; sqlCommand = sqlCommand + "," + ds.Tables[0].Rows[0]["Times"].ToString(); sqlCommand = sqlCommand + ",'" + ds.Tables[0].Rows[0]["Code"].ToString() + "'"; for (int i = 0; i < cMain.DataKaiGuang; i++) { sqlCommand = sqlCommand + "," + ds.Tables[0].Rows[0][string.Format("KaiGuan{0}", i + 1)].ToString(); } for (int i = 0; i < 40; i++) { sqlCommand = sqlCommand + "," + ds.Tables[0].Rows[0][string.Format("Data{0}", i + 1)].ToString(); } sqlCommand = sqlCommand + ")"; if (isDelFirst) { cData.upData(string.Format("delete from initPara where ModeId='{0}' and StepId={1}", cbbId.Text, Num.IntParse(cbbStepId.Text) - 1), cData.ConnMain); } cData.upData(sqlCommand, cData.ConnMain); sqlCommand = "Insert into initParaSave values('"; sqlCommand = sqlCommand + ds.Tables[0].Rows[0]["ModeID"].ToString() + "'"; sqlCommand = sqlCommand + "," + ds.Tables[0].Rows[0]["StepID"].ToString(); sqlCommand = sqlCommand + ",#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "#"; sqlCommand = sqlCommand + ",'" + txtMode.Text + "'"; sqlCommand = sqlCommand + ",'" + ds.Tables[0].Rows[0]["RunMode"].ToString() + "'"; for (int i = 0; i < 40; i++) { sqlCommand = sqlCommand + "," + ds.Tables[0].Rows[0][string.Format("Data{0}", i + 1)].ToString(); } sqlCommand = sqlCommand + ")"; cData.upData(sqlCommand, cData.ConnMain); MessageBox.Show("数据保存成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(FlushDataGridView.FlushStepData); } catch (Exception exc) { cMain.WriteErrorToLog("frmAutoUpAndDown btnSave_Click is Error:" + exc.ToString()); MessageBox.Show("数据保存失败,请检查后重试", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }