public FrmSetting() { InitializeComponent(); ConfigBll config = new ConfigBll(); this.textBox1.Text = config.getDir(enumModel.AppCut); this.textBox2.Text = config.getDir(enumModel.AppXls); }
/// <summary> /// 设置切割方案 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { this.panelStep3.Dock = DockStyle.Fill; this.panelStep3.Visible = true; this.panelStep3.BringToFront(); this.toolStripStatusLabel.Text = "切割方案"; ConfigBll config = new ConfigBll(); string strDir = config.getDir(enumModel.AppCut); if (!File.Exists(strDir)) { MessageBox.Show("找不到默认切割方案,请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { initAllCutMothed(strDir); } }
/// <summary> /// 计算结果输出为Excel /// </summary> private void button5_Click(object sender, EventArgs e) { this.toolStripStatusLabel.Text = "导出Excel"; string strFilePath = string.Empty; try { ConfigBll config = new ConfigBll(); string strDir = config.getDir(enumModel.AppXls); if (File.Exists(strDir)) { strFilePath = strDir; } else { if (this.BZH) { MessageBox.Show("找不到默认输出模板,请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "选择输出模版"; openFileDialog.Filter = "原油数据模版文件 (*.xls)|*.xls";//Excel2010与2003不兼容 openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { strFilePath = openFileDialog.FileName; } else { return; } } } int outResult = DataToExcelBll.DataToExcel(null, this._oilB, strFilePath, _cutMotheds, "B"); if (outResult == 1) { MessageBox.Show("数据导出成功!", "提示"); } else if (outResult == -1) { MessageBox.Show("当前系统尚未安装EXCEL软件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (outResult == -2) { MessageBox.Show("不能打开Excel进程,请关闭Excel后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (outResult == -3) { MessageBox.Show("数据导出失败,请检查模版是否正确或者关闭正在运行的Excel重试!", "提示"); } else if (outResult == -11) { MessageBox.Show("切割数据不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (outResult == -99) { MessageBox.Show("数据导出失败,找不到正确模板!", "提示"); } else if (outResult == 0)//取消保存 { //MessageBox.Show("数据导出失败,错误信息:\r\n" + outResult, "提示"); } } catch (Exception ex) { Log.Error("导出原油数据出错:" + ex.ToString()); } }