/// <summary> /// 导入VIN /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnImportVin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FuelDataSysClient.Tool.Tool_Mits.MitsUtils utils = new FuelDataSysClient.Tool.Tool_Mits.MitsUtils(); this.gvCljbxx.PostEditor(); int[] selectedHandle; selectedHandle = this.gvCljbxx.GetSelectedRows(); if (selectedHandle.Count() > 0) { if (selectedHandle[0] < 0) { MessageBox.Show("请选择数据"); return; } } else { MessageBox.Show("请选择数据"); return; } FolderDialog openFolder = new FolderDialog(); try { if (openFolder.DisplayDialog() == DialogResult.OK) { // 获取folderPath下以格式为utils.CocFileName的所有文件 List <string> fileNameList = utils.GetFileName(openFolder.Path, utils.VinFileName); if (fileNameList.Count > 0) { string fileNameMsg = string.Empty; string returnMsg = string.Empty; // 获取全部主表数据,用作合并VIN数据 bool IsMainDataExist = utils.GetMainData(); if (!IsMainDataExist) { MessageBox.Show("系统中不存在车型数据,请首先导入车型数据", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // 遍历读所有文件fileNameList foreach (string fileName in fileNameList) { // 导入filename文件信息 returnMsg += utils.ImportVinData(fileName, openFolder.Path); } MessageForm mf = new MessageForm(returnMsg); Utils.SetFormMid(mf); mf.Text = "导入结果"; mf.ShowDialog(); } else { MessageBox.Show(String.Format("目录{0}下没有文件{1}", openFolder.Path, utils.VinFileName)); } } } catch (Exception ex) { MessageBox.Show("导入失败:" + ex.Message); } }
/// <summary> /// 生成燃料消耗量数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barBtnGenerate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { string message = string.Empty; FuelDataSysClient.Tool.Tool_Mits.MitsUtils utils = new FuelDataSysClient.Tool.Tool_Mits.MitsUtils(); try { DataTable dtVin = utils.GetImportedVinData(""); if (dtVin.Rows.Count > 0) { bool IsMainDataExist = utils.GetMainData(); if (!IsMainDataExist) { MessageBox.Show("系统中不存在车型数据,请首先导入车型数据", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } message = utils.SaveVinInfo(dtVin); } else { MessageBox.Show("系统中不存在VIN数据"); return; } } catch (Exception ex) { message += ex.Message; } MessageForm mf = new MessageForm(message); Utils.SetFormMid(mf); mf.Text = "生成结果"; mf.ShowDialog(); }