/// <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); } }
// 更新主表关联数据 private void btnUpdateRelData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // 获取主表编号 string mainIds = string.Empty; FuelDataSysClient.Tool.Tool_Mits.MitsUtils mitsUtil = new FuelDataSysClient.Tool.Tool_Mits.MitsUtils(); try { List <string> ctnyList = mitsUtil.GetMainIdFromControl(this.gvCljbxx, (DataTable)this.gcCljbxx.DataSource); foreach (string ctnyId in ctnyList) { mainIds += string.Format(",'{0}'", ctnyId); } if (!string.IsNullOrEmpty(mainIds)) { mainIds = mainIds.Substring(1); } if (string.IsNullOrEmpty(mainIds)) { MessageBox.Show("请选择数据"); return; } ReviewUpdateVinForm reviewVinForm = new ReviewUpdateVinForm(mainIds); reviewVinForm.ShowDialog(); } catch (Exception) { } }
/// <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(); }
// 更新主表关联数据 private void btnUpdateRelData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // 获取主表编号 string mainIds = string.Empty; FuelDataSysClient.Tool.Tool_Mits.MitsUtils mitsUtil = new FuelDataSysClient.Tool.Tool_Mits.MitsUtils(); try { List <string> ctnyList = mitsUtil.GetMainIdFromControl(this.gvCtny, (DataTable)this.dgvCtny.DataSource); //List<string> fcdsList = mitsUtil.GetMainIdFromControl(this.gvFcds, (DataTable)this.dgvFcds.DataSource); //if (ctnyList.Count + fcdsList.Count < 1) //{ // MessageBox.Show("请选择主表信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} foreach (string ctnyId in ctnyList) { mainIds += string.Format(",'{0}'", ctnyId); } //foreach (string fcdsId in fcdsList) //{ // mainIds += string.Format(",'{0}'", fcdsId); //} if (!string.IsNullOrEmpty(mainIds)) { mainIds = mainIds.Substring(1); } if (string.IsNullOrEmpty(mainIds)) { MessageBox.Show("请选择数据"); return; } ReviewUpdateVinForm reviewVinForm = new ReviewUpdateVinForm(mainIds); reviewVinForm.ShowDialog(); } catch (Exception) { } }
/// <summary> /// 导入或修改车型参数 /// </summary> /// <param name="importType"></param> protected void ImportMainData(string importType) { string operateType = string.Empty; if (importType == "IMPORT") { operateType = "导入"; } else if (importType == "UPDATE") { operateType = "修改"; } FuelDataSysClient.Tool.Tool_Mits.MitsUtils utils = new FuelDataSysClient.Tool.Tool_Mits.MitsUtils(); FolderDialog openFolder = new FolderDialog(); try { if (openFolder.DisplayDialog() == DialogResult.OK) { // 获取用户选择的文件夹路径 string folderPath = openFolder.Path.ToString(); // 获取folderPath下以格式为utils.CocFileName的所有文件 List <string> fileNameList = utils.GetFileName(folderPath, utils.MainFileName); if (fileNameList.Count > 0) { string fileNameMsg = string.Empty; string returnMsg = string.Empty; List <string> mainUpdateList = new List <string>(); // 遍历读所有文件fileNameList foreach (string fileName in fileNameList) { fileNameMsg += Path.GetFileName(fileName) + "\r\n"; // 导入filename文件信息 returnMsg += utils.ImportMainData(fileName, folderPath, importType, mainUpdateList); } MessageForm mf = new MessageForm(returnMsg); Utils.SetFormMid(mf); mf.Text = operateType + "结果"; mf.ShowDialog(); if (importType == "IMPORT") { this.ShowMainData(); } else if (importType == "UPDATE") { this.ShowUpdatedMainData(mainUpdateList); } } else { MessageBox.Show("目录" + folderPath + "下没有文件" + utils.MainFileName); } } } catch (Exception ex) { MessageBox.Show(operateType + "失败:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } }