/// <summary> /// 设置页面数据 /// </summary> /// <param name="lstPara"></param> private void SetPageData(List <ParaData> lstPara) { if (lstPara != null && lstPara.Count > 0) { for (int i = 0; i < tabControl1.TabPages.Count; i++) { DataGridView gridResult = new DataGridView(); if (tabControl1.TabPages[i].Controls.Count > 0) { gridResult = (DataGridView)tabControl1.TabPages[i].Controls[0]; } if (gridResult.Rows.Count > 0) { for (int j = 0; j < gridResult.Rows.Count; j++) { foreach (ParaData data in lstPara) { if (data.paraName == gridResult.Rows[j].Cells[0].Value.ToString()) { gridResult.Rows[j].Cells[1].Value = data.paraValue; curWaParas[j].ParaValue = data.paraValue; break; } } } } } XLog.Write("从IDE导入参数值成功"); } }
/// <summary> /// 重量数据2从当前重量设计数据导入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolMemuWeihtData2FormWeightDataImport_Click(object sender, EventArgs e) { if (treeViewSort.Nodes.Count == 0) { XLog.Write("先导入重量数据1数据"); MessageBox.Show("先导入重量数据1数据"); return; } if (mainForm.designProjectData == null) { MessageBox.Show("当前重量设计没有数据"); XLog.Write("当前重量设计没有数据"); return; } else { if ((mainForm.designProjectData.lstWeightArithmetic == null || mainForm.designProjectData.lstWeightArithmetic.Count == 0) && (mainForm.designProjectData.lstAdjustmentResultData == null || mainForm.designProjectData.lstAdjustmentResultData.Count == 0)) { MessageBox.Show("当前重量设计没有数据"); XLog.Write("当前重量设计没有数据"); return; } } strWeightDataType = "data2"; ImportWeightDataListForm form = new ImportWeightDataListForm(this, mainForm.designProjectData, "weightDesign"); form.ShowDialog(); }
private void TryDBConnect() { bool IsConnect = false; string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["strCon"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); XLog.Write("正在连接数据库..."); try { connection.Open(); if (connection.State == ConnectionState.Open) { IsConnect = true; } connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); IsConnect = false; connection.Close(); } if (IsConnect == false) { DialogResult result = MessageBox.Show("无法连接至数据库服务器,请确认配置是否正确,网络是否畅通?", "无法连接至数据库服务器...", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); if (result == DialogResult.Retry) { TryDBConnect(); } } }
/// <summary> /// 删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteNode_Click(object sender, EventArgs e) { if (selNode == null) { XLog.Write("请选择节点"); return; } if (selNode.Level == 0) { lstCorePointData = null; } else { if (lstCorePointData != null && lstCorePointData.Count > 0) { for (int i = 0; i < lstCorePointData.Count; i++) { if (lstCorePointData[i].pointName == selNode.Name) { lstCorePointData.Remove(lstCorePointData[i]); } } } } selNode = null; txtPtName.Text = string.Empty; BindTreeList(lstCorePointData); }
private void memu2CurrentAdjustmentImport_Click(object sender, EventArgs e) { if (treeViewSort.Nodes.Count == 0) { XLog.Write("先导入重量数据1数据"); MessageBox.Show("先导入重量数据1数据"); return; } if (mainForm.designProjectData == null) { MessageBox.Show("重量调整结果没有数据"); XLog.Write("重量调整结果没有数据"); return; } if (mainForm.designProjectData.lstAdjustmentResultData == null || mainForm.designProjectData.lstAdjustmentResultData.Count == 0) { MessageBox.Show("重量调整结果没有数据"); XLog.Write("重量调整结果没有数据"); return; } strWeightDataType = "data2"; ImportWeightDataListForm form = new ImportWeightDataListForm(this, mainForm.designProjectData, "weightAdjust"); form.ShowDialog(); }
/// <summary> /// 上移事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpNode_Click(object sender, EventArgs e) { if (selNode == null || selNode.Level == 0) { XLog.Write("请选择节点"); return; } TreeNode node = selNode.Parent; //判断第一个子节点 if (selNode == node.FirstNode) { return; } for (int j = 0; j < node.Nodes.Count; j++) { if (selNode == node.Nodes[j]) { TreeNode preNode = node.Nodes[j - 1]; node.Nodes.Remove(preNode); node.Nodes.Remove(selNode); node.Nodes.Insert(j - 1, selNode); node.Nodes.Insert(j, preNode); treeViewList.SelectedNode = node.Nodes[j - 1]; return; } } }
static PubSyswareCom() { try { //要获取的类型的 ProgID。 string progID = "Sysware.SyswareSDK.SyswareCom.SyswareComServer"; //与指定 ProgID 关联的类型,即获取相应的Com对象 System.Type comObjectName = System.Type.GetTypeFromProgID(progID); if (comObjectName != null) { //通过类型创建对象实例 SyswareObj = Activator.CreateInstance(comObjectName); ////设置需要设置的参数值 //args[0] = true; ////设置可视属性,显示Word窗体 //comObjectName.InvokeMember("Visible", BindingFlags.SetProperty, null, comObject, args); //object t = SyswareObj.GetType().InvokeMember("IsRuntimeServerStarted", BindingFlags.InvokeMethod, null, SyswareObj, new Object[] { }); } } catch (Exception e) { XLog.Write("Sysware COM组件创建失败." + e.Message); } }
private void OnCurWaChanged() { curExprList = new List <CExpression>(); string errmsg; foreach (WeightFormula wf in curWa.FormulaList) { CExpression expr = CExpression.Parse(wf.Formula, out errmsg); if (expr == null) { string outmsg = "公式\"" + wf.Formula + "\"错误:" + errmsg; XLog.Write(outmsg); MessageBox.Show(outmsg); return; } curExprList.Add(expr); } curWaParas = curWa.GetParaList(); dataGridViewParaInput.Rows.Clear(); foreach (WeightParameter wp in curWaParas) { dataGridViewParaInput.Rows.Add(new object[] { wp.ParaName, wp.ParaValue, wp.ParaUnit, WeightParameter.ParaTypeList[wp.ParaType], wp.ParaRemark }); } btnCompute.Enabled = true; flowLayoutPanelParaImport.Enabled = true; flowLayoutPanelParaExport.Enabled = true; }
/// <summary> /// 编辑事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, EventArgs e) { if (selNode == null || selNode.Level == 0) { XLog.Write("请选择节点"); return; } string strPtName = txtPtName.Text; string strErroInfo = PageVerificationInfo(); if (strErroInfo != string.Empty) { XLog.Write(strErroInfo); return; } else { bool IsExit = false; for (int i = 0; i < lstCorePointData.Count; i++) { if (lstCorePointData[i].pointName == strPtName) { XLog.Write("坐标点名称:" + strPtName + "已存在"); IsExit = true; return; } } if (IsExit == false) { for (int i = 0; i < lstCorePointData.Count; i++) { if (lstCorePointData[i].pointName == selNode.Name) { double XValue = lstCorePointData[i].pointXValue; double YValue = lstCorePointData[i].pointYValue; lstCorePointData[i].pointName = strPtName; break; } } } BindTreeList(lstCorePointData); TreeNode rootNode = treeViewList.Nodes[0]; foreach (TreeNode childNode in rootNode.Nodes) { if (strPtName == childNode.Name) { treeViewList.SelectedNode = childNode; selNode = childNode; break; } } } }
/// <summary> ///xls文件转换成WeightSortData类型 /// </summary> /// <param name="strFilePath">文件路径</param> /// <returns>返回WeightSortData类型</returns> public static WeightSortData GetXlsImportSortData(string strFilePath) { WeightSortData sortData = null; try { if (File.Exists(strFilePath)) { ExcelLib OpExcel = new ExcelLib(); //指定操作的文件 OpExcel.OpenFileName = strFilePath; //打开文件 if (OpExcel.OpenExcelFile() == false) { return(sortData); } //取得所有的工作表名称 string[] strSheetsName = OpExcel.getWorkSheetsName(); //默认操作第一张表 OpExcel.SetActiveWorkSheet(1); System.Data.DataTable table; table = OpExcel.getAllCellsValue(); OpExcel.CloseExcelApplication(); int count = table.Rows.Count; if (count > 0) { sortData = new WeightSortData(); sortData.sortName = table.Rows[0][0].ToString(); List <WeightData> lstWeightData = new List <WeightData>(); for (int i = 0; i < count; i++) { WeightData data = new WeightData(); data.nID = Convert.ToInt32(table.Rows[i][1].ToString()); data.weightName = table.Rows[i][2].ToString(); data.weightValue = Convert.ToDouble(table.Rows[i][4].ToString()); data.strRemark = table.Rows[i][5].ToString(); data.nParentID = Convert.ToInt32(table.Rows[i][6].ToString()); lstWeightData.Add(data); } sortData.lstWeightData = lstWeightData; } } } catch { XLog.Write("导入文件\"" + strFilePath + "\"格式错误"); MessageBox.Show("导入文件\"" + strFilePath + "\"格式错误"); return(null); } return(sortData); }
private void memu2ExportToDataFile_Click(object sender, EventArgs e) { if (importSortData2 == null) { XLog.Write("重量数据2没有数据不能导出"); MessageBox.Show("重量数据2没有数据不能导出"); return; } ExportDataToDataFile(importSortData2); }
private void btnExportToExcel_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"; dialog.OverwritePrompt = true; dialog.RestoreDirectory = true; if (dialog.ShowDialog() != DialogResult.OK) { return; } Excel.Application app = new Excel.ApplicationClass(); try { Object missing = System.Reflection.Missing.Value; app.Visible = false; Excel.Workbook wBook = app.Workbooks.Add(missing); Excel.Worksheet wSheet = wBook.Worksheets[1] as Excel.Worksheet; Excel.Range DataCell = wSheet.get_Range("A1", "A1"); DataCell.Value2 = "参数名称"; DataCell.Next.Value2 = "参数单位"; DataCell.Next.Next.Value2 = "参数数值"; for (int i = 0; i < curWaParas.Count; ++i) { WeightParameter wp = curWaParas[i]; string cellid = "A" + (i + 2).ToString(); DataCell = wSheet.get_Range(cellid, cellid); DataCell.Value2 = wp.ParaName; DataCell.Next.Value2 = wp.ParaUnit; DataCell.Next.Next.Value2 = wp.ParaValue; } //设置禁止弹出保存和覆盖的询问提示框 app.DisplayAlerts = false; app.AlertBeforeOverwriting = false; //保存工作簿 wBook.SaveAs(dialog.FileName, Excel.XlFileFormat.xlWorkbookNormal, missing, missing, missing, missing, Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing); wBook.Close(false, missing, missing); app.Quit(); app = null; XLog.Write("成功导出参数值到文件\"" + dialog.FileName + "\"!"); } catch (Exception err) { MessageBox.Show("导出Excel出错!错误原因:" + err.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 获取参数表数据转换成ListParaData /// </summary> /// <returns></returns> public static List <ParaData> GetListParaData() { List <ParaData> lstPara = null; if (PubSyswareCom.IsRuntimeServerStarted()) { //获取参数的值 object obj = null; PubSyswareCom.GetParameterNames(string.Empty, ref obj); //转换为字符串数组 if (obj is Object[]) { lstPara = new List <ParaData>(); object[] objName = obj as Object[]; for (int i = 0; i < objName.Count(); i++) { Object objValue = null; PubSyswareCom.mGetParameter(string.Empty, objName[i].ToString(), ref objValue); if (objValue != null) { //参数 if (objName[i].ToString() != "weightData" && objName[i].ToString() != "coreEnvelopeData") { ParaData data = new ParaData(); data.paraName = objName[i].ToString(); try { data.paraValue = Convert.ToDouble(objValue.ToString()); } catch (Exception e) { data.paraValue = 0; XLog.Write(e.Message); } lstPara.Add(data); } } } } } else { MessageBox.Show("TDE/IDE 没有启动成功"); } return(lstPara); }
/// <summary> /// 基于新建 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnJYNew_Click(object sender, EventArgs e) { if (selNode == null || selNode.Level != 2) { XLog.Write("请选择参数"); return; } strType = "JYNew"; SettingPageData(); SettingTitle(strType); SetingPageButton(strType); }
/// <summary> /// 全局导入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAllImort_Click(object sender, EventArgs e) { try { if (lstParaData.Count > 0) { DialogResult result = MessageBox.Show("导入会清空当前列表数据,是否继续?", "清空提示", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "PMC文件 (*.PMC)|*.PMC";; fileDialog.RestoreDirectory = true; fileDialog.FilterIndex = 1; if (fileDialog.ShowDialog() == DialogResult.OK) { string strFilePath = fileDialog.FileName; List <ParaData> lstTempParaData = GetParaData(strFilePath); lstAllParaData = lstTempParaData; BindTreeParaData(GetSelParaData()); } XLog.Write("导入成功"); } } else { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "PMC文件 (*.PMC)|*.PMC"; fileDialog.RestoreDirectory = true; fileDialog.FilterIndex = 1; if (fileDialog.ShowDialog() == DialogResult.OK) { string strFilePath = fileDialog.FileName; List <ParaData> lstTempParaData = GetParaData(strFilePath); lstAllParaData = lstTempParaData; BindTreeParaData(GetSelParaData()); } XLog.Write("导入成功"); } } catch { XLog.Write("导入参数文件错误"); MessageBox.Show("导入参数文件错误"); } }
/// <summary> /// 删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { string strFloder = strPath + "weightCategory" + "\\" + selNode.Name; if (!System.IO.Directory.Exists(strFloder)) { MessageBox.Show("目录\"" + strFloder + "\"" + "不存在!"); return; } string[] files = System.IO.Directory.GetFiles(strFloder, "*.WEM"); if (files.Length > 0) { DialogResult result = MessageBox.Show("该分类下有算法文件!如果继续将把分类下的所有算法文件一起删除!是否继续?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result != DialogResult.Yes) { return; } else { Directory.Delete(strFloder, true); } } else { DialogResult result = MessageBox.Show("是否删除" + selNode.Name + "?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Directory.Delete(strFloder, true); } else { return; } } WeightSortData tempSortData = selNode.Tag as WeightSortData; if (tempSortData == null) { return; } lstWeightSort.Remove(tempSortData); treeViewWeightSort.Nodes[0].Nodes.Remove(selNode); XLog.Write("删除" + selNode.Name + "成功"); }
/// <summary> /// 编辑事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, EventArgs e) { if (selNode == null || selNode.Level != 2) { XLog.Write("请选择参数"); return; } if (selNode.Level == 2) { SettingPageData(); SetingPageButton("edit"); SettingTitle("edit"); strType = "edit"; } }
/// <summary> /// 从重量设计数据库导入数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void memu1FromWeightDesignDBImport_Click(object sender, EventArgs e) { BLLWeightDesignData bllWeightDesign = new BLLWeightDesignData(); List <WeightDesignData> lstWeightDesign = bllWeightDesign.GetListModel(); if (lstWeightDesign.Count == 0) { XLog.Write("数据库没有重量设计数据"); MessageBox.Show("数据库没有重量设计数据"); } strWeightDataType = "data1"; ImportWeightDataListForm form = new ImportWeightDataListForm(this, lstWeightDesign, "weightDB"); form.ShowDialog(); }
/// <summary> /// 从型号重量数据库导入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void memu1FromTypeDBImport_Click(object sender, EventArgs e) { BLLTypeWeightData bllTypeWeight = new BLLTypeWeightData(); List <TypeWeightData> lstTypeWeight = bllTypeWeight.GetListModel(); if (lstTypeWeight.Count == 0) { XLog.Write("数据库没有型号重量数据"); MessageBox.Show("数据库没有型号重量数据"); return; } strWeightDataType = "data1"; ImportWeightDataListForm form = new ImportWeightDataListForm(this, lstTypeWeight, "typeDB"); form.ShowDialog(); }
/// <summary> /// 导出WeightSortData类型实例至XML/XLS文件 /// </summary> /// <param name="sortData">WeightSortData类型</param> public static void ExportDataToDataFile(WeightSortData sortData) { if (sortData == null) { XLog.Write("没有数据不能导出"); return; } SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls"; dlg.OverwritePrompt = true; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; dlg.FileName = sortData.sortName; if (dlg.ShowDialog() == DialogResult.OK) { string strFilePath = dlg.FileName; if (strFilePath.EndsWith(".xml")) { List <string> lstContent = MainForm.GetDesignResultFlieContent(sortData); CommonFunction.mWriteListStringToFile(strFilePath, lstContent); } if (strFilePath.EndsWith(".xls")) { DataTable table = MainForm.GetDesignResultTable(sortData); int result = XCommon.FileStatus.FileIsOpen(strFilePath); if (result == 1) { MessageBox.Show("请关闭文件" + strFilePath + ",再导出"); } else { CommonExcel commonExcel = new CommonExcel(); commonExcel.lstColumn = MainForm.GetDesignResultExcleCloumn(); commonExcel.CreateExcel("example", strFilePath, "sheet1", table); } } XLog.Write("导出文件\"" + strFilePath + "\"成功"); } }
/// <summary> /// 导出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { if (lstCalculateRatio == null || lstCalculateRatio.Count == 0) { MessageBox.Show("没有修正因子数据不能导出"); return; } SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "xml文件 (*.xml)|*.xml|Excel文件 (*.xls)|*.xls"; dlg.OverwritePrompt = true; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; dlg.FileName = zedGraphControlPic.GraphPane.Title.Text; if (dlg.ShowDialog() == DialogResult.OK) { string strFilePath = dlg.FileName; if (strFilePath.EndsWith(".xml")) { List <string> lstContent = GetFileContent(lstCalculateRatio); CommonFunction.mWriteListStringToFile(strFilePath, lstContent); } if (strFilePath.EndsWith(".xls")) { DataTable table = GetExcelTable(lstCalculateRatio); int result = XCommon.FileStatus.FileIsOpen(strFilePath); if (result == 1) { MessageBox.Show("请关闭文件" + strFilePath + ",再导出"); } else { CommonExcel commonExcel = new CommonExcel(); commonExcel.lstColumn = GetExcelCloumn(); commonExcel.CreateExcel("example", strFilePath, "sheet1", table); } } XLog.Write("导出文件\"" + strFilePath + "\"成功"); } }
/// <summary> /// 导出事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { if (treeViewParameterList.Nodes.Count == 0) { XLog.Write("没有数据不能导出"); return; } SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "PMC文件 (*.PMC)|*.PMC|xls文件 (*.xls)|*.xls"; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; dlg.FileName = "ParameterCollection"; List <ParaData> lstTempParaDagta = lstParaData; if (dlg.ShowDialog() == DialogResult.OK) { string strFilePath = dlg.FileName; if (strFilePath.EndsWith(".PMC")) { SaveFile(strFilePath, lstTempParaDagta); } if (strFilePath.EndsWith(".xls")) { DataTable table = GetTableData(lstTempParaDagta); int result = XCommon.FileStatus.FileIsOpen(strFilePath); if (result == 1) { MessageBox.Show("请关闭文件" + strFilePath + ",再导出"); } else { CommonExcel commonExcel = new CommonExcel(); commonExcel.lstColumn = GetColumnName(); commonExcel.CreateExcel("example", strFilePath, "sheet1", table); } } XLog.Write("导出成功"); } }
/// <summary> /// 重量数据1从当前重量调整数据导入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolFormAdjustWeightImport_Click(object sender, EventArgs e) { if (mainForm.designProjectData == null) { MessageBox.Show("重量调整结果没有数据"); XLog.Write("重量调整结果没有数据"); return; } if (mainForm.designProjectData.lstAdjustmentResultData == null || mainForm.designProjectData.lstAdjustmentResultData.Count == 0) { MessageBox.Show("重量调整结果没有数据"); XLog.Write("重量调整结果没有数据"); return; } strWeightDataType = "data1"; ImportWeightDataListForm form = new ImportWeightDataListForm(this, mainForm.designProjectData, "weightAdjust"); form.ShowDialog(); }
/// <summary> /// 导入事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnImport_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.RestoreDirectory = true; fileDialog.Filter = "hcc文件 (*.hcc)|*.hcc"; if (fileDialog.ShowDialog() != DialogResult.OK) { return; } WeightSortData sortData = WeightSortData.GetSortData(fileDialog.FileName); if (sortData == null) { MessageBox.Show("错误的分类文件!"); return; } bool boverwrite = treeViewWeightSort.Nodes[0].Nodes.ContainsKey(sortData.sortName); if (!SaveHccFile(sortData, boverwrite)) { XLog.Write("导入失败!"); return; } lstWeightSort.Add(sortData); if (!boverwrite) { RefreshTreeViewData(); } XLog.Write("导入成功"); foreach (TreeNode node in treeViewWeightSort.Nodes[0].Nodes) { if (node.Text == sortData.sortName) { treeViewWeightSort.SelectedNode = node; } } }
/// <summary> /// 导出事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { if (selNode == null || selNode.Level == 0) { XLog.Write("请选择重量分类"); return; } //WeightSortData weightSortData = new WeightSortData(); //foreach (WeightSortData sortData in lstWeightSort) //{ // if (selNode.Text == sortData.sortName) // { // weightSortData = sortData; // } //} WeightSortData weightSortData = selNode.Tag as WeightSortData; if (weightSortData == null) { return; } SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "hcc文件 (*.hcc)|*.hcc"; dlg.OverwritePrompt = false; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; dlg.FileName = weightSortData.sortName;// selNode.Text; if (dlg.ShowDialog() == DialogResult.OK) { string strFilePath = dlg.FileName; if (SaveHccFile(weightSortData, strFilePath, true)) { XLog.Write("导出成功"); } } }
/// <summary> /// 双击节点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void treeViewWeightSort_MouseDoubleClick(object sender, MouseEventArgs e) { weightSort = selNode.Tag as WeightSortData; if (weightSort == null) { return; } string strFolderPath = strPath + "weightCategory" + "\\" + selNode.Name; if (Directory.Exists(strFolderPath)) { string[] files = System.IO.Directory.GetFiles(strFolderPath, "*.WEM"); string strtype = (files.Length > 0) ? "readOnlyEdit" : "edit"; WeightSortEditForm form = new WeightSortEditForm(this, weightSort, strtype); form.ShowDialog(); } else { XLog.Write("文件\"" + strFolderPath + "\"不存在"); } }
/// <summary> /// 确定事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnConfirm_Click(object sender, EventArgs e) { string strErroInfo = PageVerification(); if (strErroInfo != string.Empty) { XLog.Write(strErroInfo); return; } if (strType == "weightDesign") { WeightDesignData weight = GetWeightDesignData(); bool IsAdd = bllWeightDesign.Add(weight); if (IsAdd) { XLog.Write("重量设计结果发布数据库成功"); } } if (strType == "coreEnvelopeDesign" || strType == "coreEnvelopeCut") { CoreEnvelopeDesign core = GetCoreEnvelopeDesignData(); bool IsAdd = bllCoreEnvelopeDesign.Add(core); if (IsAdd) { if (strType == "coreEnvelopeDesign") { XLog.Write("重心包线设计结果发布数据库成功"); } if (strType == "coreEnvelopeCut") { XLog.Write("重心包线剪裁结果发布数据库成功"); } } } this.Close(); }
/// <summary> /// 添加节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddNode_Click(object sender, EventArgs e) { string strPtName = txtPtName.Text; string strErroInfo = PageVerificationInfo(); if (strErroInfo != string.Empty) { XLog.Write(strErroInfo); return; } else { bool IsExit = false; if (lstCorePointData != null && lstCorePointData.Count > 0) { foreach (CorePointData data in lstCorePointData) { if (data.pointName == strPtName) { XLog.Write("坐标点名称:" + strPtName + "已存在"); IsExit = true; return; } } } if (IsExit == false) { if (lstCorePointData == null) { lstCorePointData = new List <CorePointData>(); } CorePointData pt = new CorePointData(); pt.pointName = strPtName; lstCorePointData.Add(pt); } BindTreeList(lstCorePointData); } }
/// <summary> /// 测试连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTestConnect_Click(object sender, EventArgs e) { string strUserName = txtUserName.Text; string strPwd = txtPwd.Text; if (strUserName == string.Empty) { XLog.Write("请输入用户名"); return; } if (strPwd == string.Empty) { XLog.Write("请输入密码"); return; } bool IsConnect = false; string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["strCon"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); try { IsConnect = true; XLog.Write("正在连接..."); } catch (Exception ex) { XLog.Write("连接失败:" + ex.Message); } //连接成功 if (IsConnect) { SaveSerVerInfo(); XLog.Write("测试连接成功"); } }
/// <summary> /// 从当前重量设计数据导入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void memu1FromCurrentWeighDesignImport_Click(object sender, EventArgs e) { if (mainForm.designProjectData == null) { MessageBox.Show("当前重量设计没有数据"); XLog.Write("当前重量设计没有数据"); return; } else { if (mainForm.designProjectData.lstWeightArithmetic == null || mainForm.designProjectData.lstWeightArithmetic.Count == 0) { MessageBox.Show("当前重量设计没有数据"); XLog.Write("当前重量设计没有数据"); return; } } strWeightDataType = "data1"; ImportWeightDataListForm form = new ImportWeightDataListForm(this, mainForm.designProjectData, "weightDesign"); form.ShowDialog(); }