private void BT_ok_Click(object sender, EventArgs e) { Remark = TE_Remark.Text; RecipeName = TE_RecipeName.Text.Trim(); double.TryParse(TE_F1.Text, out frame[0]); double.TryParse(TE_F2.Text, out frame[1]); double.TryParse(TE_F3.Text, out frame[2]); double.TryParse(TE_F4.Text, out frame[3]); double.TryParse(TE_F5.Text, out frame[4]); double.TryParse(TE_F6.Text, out frame[5]); double.TryParse(TE_O1.Text, out offset[0]); double.TryParse(TE_O2.Text, out offset[1]); double.TryParse(TE_O3.Text, out offset[2]); double.TryParse(TE_O4.Text, out offset[3]); double.TryParse(TE_O5.Text, out offset[4]); double.TryParse(TE_O6.Text, out offset[5]); if (CreatRecipe) { if (RecipeName.Trim() == "") { MessageBox.Show("名称为空"); return; } if (db.ExistRecipe(RecipeName)) { MessageBox.Show("产品名称已存在!"); return; } else { if (db.AddRecipe(RecipeName, int.Parse(CBE_Type.EditValue.ToString()), frame, offset, Remark)) { this.Close(); } else { RecipeName = ""; MessageBox.Show("操作错误!"); return; } } } else { if (db.EditRecipe(RecipeName, int.Parse(CBE_Type.EditValue.ToString()), frame, offset, Remark)) { this.Close(); } else { MessageBox.Show("操作错误!"); return; } } }
private void BT_ok_Click(object sender, EventArgs e) { Remark = TE_Remark.Text; RecipeName = TE_RecipeName.Text.Trim(); double.TryParse(TE_F1.Text, out frame[0]); double.TryParse(TE_F2.Text, out frame[1]); double.TryParse(TE_F3.Text, out frame[2]); double.TryParse(TE_F4.Text, out frame[3]); double.TryParse(TE_F5.Text, out frame[4]); double.TryParse(TE_F6.Text, out frame[5]); double.TryParse(TE_O1.Text, out offset[0]); double.TryParse(TE_O2.Text, out offset[1]); double.TryParse(TE_O3.Text, out offset[2]); double.TryParse(TE_O4.Text, out offset[3]); double.TryParse(TE_O5.Text, out offset[4]); double.TryParse(TE_O6.Text, out offset[5]); if (CreatRecipe) { if (RecipeName.Trim() == "") { MessageBox.Show("名称为空"); return; } if (!Regex.IsMatch(RecipeName.Trim(), @"^[a-zA-Z0-9_]+$")) { MessageBox.Show("名称不符合规范"); return; } if (db.ExistRecipe(RecipeName)) { MessageBox.Show("产品名称已存在!"); return; } else { if (db.AddRecipe(RecipeName, int.Parse(CBE_Type.EditValue.ToString()), frame, offset, Remark)) { this.Close(); } else { RecipeName = ""; MessageBox.Show("操作错误!"); return; } } } else { if (TC_Traj.SelectedTabPageIndex == 2) { double.TryParse(FL1.Text, out frame[0]); double.TryParse(FL2.Text, out frame[1]); double.TryParse(FL3.Text, out frame[2]); double.TryParse(FL4.Text, out frame[3]); double.TryParse(FL5.Text, out frame[4]); double.TryParse(FL6.Text, out frame[5]); } if (TC_Traj.SelectedTabPageIndex == 3) { double.TryParse(TL1.Text, out offset[0]); double.TryParse(TL2.Text, out offset[1]); double.TryParse(TL3.Text, out offset[2]); double.TryParse(TL4.Text, out offset[3]); double.TryParse(TL5.Text, out offset[4]); double.TryParse(TL6.Text, out offset[5]); } // if (db.EditRecipe(RecipeName, int.Parse(CBE_Type.EditValue.ToString()), frame, offset, Remark)) { this.Close(); } else { MessageBox.Show("操作错误!"); return; } } }
void PollImport(object target) { DataBaseManage db = new DataBaseManage(); switch (OperIndex) { //导出 case 1: { //2015.02.05 if (db.IsMatlabFile(CBE_RecipeName.EditValue.ToString()) == 0) { TxtData.PublicData.ErrorCode = 34; return; } PolishTxt.MatlabFile = (db.IsMatlabFile(CBE_RecipeName.EditValue.ToString()) == 2); // TxtData.PublicData.ErrorCode = (db.SaveProduct(Application.StartupPath + "\\buff.txt", CBE_RecipeName.EditValue.ToString())) ? 0 : 34; if (TxtData.PublicData.ErrorCode != 0) { return; } PolishTxt.Home = db.GetHome(); TxtData.PublicData.ErrorCode = (PolishTxt.Standard2Polish(Application.StartupPath + "\\buff.txt", FileName)) ? 40 : 49; break; } //删除产品 case 2: { TxtData.PublicData.ErrorCode = (db.DeleteRecipe(CBE_RecipeName.EditValue.ToString())) ? 40 : 32; break; } //导入 case 3: { //TxtData.PublicData.ErrorCode = PublicFunc.IsTool(FileName)? 0 : 41; //if (TxtData.PublicData.ErrorCode != 0) //{ // return; //} //PolishTxt t = new PolishTxt(); // PolishTxt.Home = db.GetHome(); PolishTxt.Home = db.GetHome(); string BuffFileName = ""; if (PolishTxt.IsMatlabFile(FileName)) { //把matlab文件转换为一般的文件 //2015.02.05 BuffFileName = Application.StartupPath + "\\Txt\\buffRecipe.txt"; // PolishTxt.MatlabFile = true; TxtData.PublicData.ErrorCode = PolishTxt.ReadMatlabFile(FileName, true) ? 0 : 71; if (TxtData.PublicData.ErrorCode != 0) { return; } TxtData.PublicData.ErrorCode = db.GetRecipe(CBE_RecipeName.EditValue.ToString(), ref PolishTxt.MatlabTool, ref PolishTxt.MatlabFrame) ? 0 : 72; if (TxtData.PublicData.ErrorCode != 0) { return; } //2015.02.05 //重点函数在这里 TxtData.PublicData.ErrorCode = PublicFunc.MatalData() ? 0 : 73; if (TxtData.PublicData.ErrorCode != 0) { return; } TxtData.PublicData.ErrorCode = PolishTxt.Matlab2Recipe(BuffFileName) ? 0 : 74; if (TxtData.PublicData.ErrorCode != 0) { return; } } else { BuffFileName = FileName; } TxtData.PublicData.ErrorCode = PolishTxt.Polish2Standard(BuffFileName, Application.StartupPath + "\\Txt\\buff.txt") ? 0 : 49; if (TxtData.PublicData.ErrorCode != 0) { return; } TxtData.PublicData.ErrorLine = db.ImportProduct(Application.StartupPath + "\\Txt\\buff.txt", CBE_RecipeName.EditValue.ToString()); TxtData.PublicData.ErrorCode = (TxtData.PublicData.ErrorLine == 0) ? 0 : 20; if (TxtData.PublicData.ErrorCode != 0) { return; } TxtData.PublicData.ErrorCode = (db.EditRecipeOffline(CBE_RecipeName.EditValue.ToString(), PolishTxt.MatlabFile)) ? 40 : 20; // return; break; } //删除路径 case 4: { //2013.11.19 //TxtData.PublicData.ErrorCode = (db.DeleteTraj(TrajName,true)) ? 40 : 32; TxtData.PublicData.ErrorCode = (db.DeleteTraj(CBE_RecipeName.EditValue.ToString(), TxtData.PublicData.DeleteTrajIndex)) ? 40 : 32; break; } //导入速度 case 5: { TxtData.PublicData.ErrorCode = (PolishTxt.ReadMatlabFileCount(FileName) == GV_Cut.RowCount)? 0 : 46; if (TxtData.PublicData.ErrorCode != 0) { return; } double[,] da = PolishTxt.ReadMatlabFile(FileName); TxtData.PublicData.ErrorCode = (da != null) ? 0 : 47; if (TxtData.PublicData.ErrorCode != 0) { return; } //TxtData.PublicData.ErrorLine = db.ImportProduct(FileName, CBE_RecipeName.EditValue.ToString()); //TxtData.PublicData.ErrorCode = (TxtData.PublicData.ErrorLine == 0) ? 40 : 20; // return; TxtData.PublicData.ErrorCode = db.BatchPointSpeed(TrajName, da) ? 40 : 48; break; } case 6: { TxtData.PublicData.ErrorCode = (db.SaveProduct(Application.StartupPath + "\\buff.txt", CBE_RecipeName.EditValue.ToString())) ? 0 : 34; if (TxtData.PublicData.ErrorCode != 0) { return; } TxtData.PublicData.ErrorCode = (PolishTxt.Part2Standard(TxtData.PolishData.PartMatlabFile, Application.StartupPath + "\\buff.txt", Application.StartupPath + "\\partbuff.txt")) ? 0 : 62; if (TxtData.PublicData.ErrorCode != 0) { return; } TxtData.PublicData.ErrorCode = (db.AddRecipe(TxtData.PolishData.PartRecipeName, 1, new double[] { 0, 0, 0, 0, 0, 0 }, new double[] { 0, 0, 0, 0, 0, 0 }, TxtData.PolishData.PartRecipeRemark)) ? 0 : 63; if (TxtData.PublicData.ErrorCode != 0) { return; } TxtData.PublicData.ErrorCode = (db.ImportProduct(Application.StartupPath + "\\partbuff.txt", TxtData.PolishData.PartRecipeName) == 0) ? 40 : 64; break; } } }