/// <summary> /// 生成燃料消耗量数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barBtnGenerate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!this.CheckAllDataReady()) { return; } try { DataSet ds = this.GetReadyDataFromLocalCoc(); ToyotaUtils toyotaUtils = new ToyotaUtils(); string msg = toyotaUtils.SaveParam(ds); if (string.IsNullOrEmpty(msg)) { this.ShowLocalReadyData(); MessageBox.Show("生成成功", "生成成功"); } else { MessageForm mf = new MessageForm("以下数据已经存在\r\n" + msg); Utils.SetFormMid(mf); mf.Text = "生成结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("燃料消耗量数据生成失败:" + ex.Message, "生成失败"); } }
/// <summary> /// 导入VIN /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnImportVin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ToyotaUtils utils = new ToyotaUtils(); 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.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) { // fileNameMsg += Path.GetFileName(fileName) + "\r\n"; // 导入filename文件信息 returnMsg += utils.ImportVinData(fileName, folderPath); } MessageForm mf = new MessageForm(returnMsg); Utils.SetFormMid(mf); mf.Text = "导入结果"; mf.ShowDialog(); } else { MessageBox.Show("目录" + folderPath + "下没有文件" + utils.VinFileName); } } } catch (Exception ex) { MessageBox.Show("导入失败:" + ex.Message); } }
/// <summary> /// 更新主表关联燃料数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { string message = string.Empty; string strCon = AccessHelper.conn; DataTable dtCtny = this.GetMainData("CTNY"); DataTable dtFcds = this.GetMainData("FCDS"); ToyotaUtils toyotaUtil = new ToyotaUtils(); DataTable dtCtnyPam = toyotaUtil.GetRllxData("传统能源"); DataTable dtFcdsPam = toyotaUtil.GetRllxData("非插电式混合动力"); using (OleDbConnection con = new OleDbConnection(strCon)) { con.Open(); try { foreach (string vin in vinList) { DataRow[] drCtny = dtCtny.Select("MAIN_ID='" + this.dictVinMainId[vin] + "'"); DataRow[] drFcds = dtFcds.Select("MAIN_ID='" + this.dictVinMainId[vin] + "'"); if (drCtny.Length > 0) { message += this.UpdateFuelData(vin, dictStatus[vin], drCtny[0], dtCtnyPam, con); } if (drFcds.Length > 0) { message += this.UpdateFuelData(vin, dictStatus[vin], drFcds[0], dtFcdsPam, con); } } } catch (Exception ex) { MessageBox.Show("更新失败:" + ex.Message + "\r\n"); } if (string.IsNullOrEmpty(message)) { MessageBox.Show("全部更新成功"); } else { MessageForm mf = new MessageForm(message); Utils.SetFormMid(mf); mf.Text = "更新结果"; mf.ShowDialog(); } this.SearchLocal(this.mainIds); } }
// 更新主表关联数据 private void btnUpdateRelData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // 获取主表编号 string mainIds = string.Empty; ToyotaUtils toyotaUtil = new ToyotaUtils(); try { List <string> ctnyList = toyotaUtil.GetMainIdFromControl(this.gvCtny, (DataTable)this.dgvCtny.DataSource); List <string> fcdsList = toyotaUtil.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); } FuelDataSysClient.Form_DBManager.Form_Toyota.ReviewUpdateVinForm reviewVinForm = new FuelDataSysClient.Form_DBManager.Form_Toyota.ReviewUpdateVinForm(mainIds); reviewVinForm.ShowDialog(); } catch (Exception ex) { } }
private void btnGenFuelData_Click(object sender, EventArgs e) { try { ToyotaUtils toyotaUtils = new ToyotaUtils(); string msg = toyotaUtils.SaveParam(ds); if (string.IsNullOrEmpty(msg)) { this.DialogResult = DialogResult.OK; MessageBox.Show("生成成功", "生成成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageForm mf = new MessageForm("以下数据已经存在\r\n" + msg); Utils.SetFormMid(mf); mf.Text = "生成结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("燃料消耗量数据生成失败:" + ex.Message, "生成失败"); } }
protected void ImportMainData(string importType) { string operateType = string.Empty; if (importType == "IMPORT") { operateType = "导入"; } else if (importType == "UPDATE") { operateType = "修改"; } ToyotaUtils utils = new ToyotaUtils(); 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); } if (string.IsNullOrEmpty(returnMsg)) { MessageForm mf = new MessageForm("以下文件" + operateType + "成功:\r\n" + fileNameMsg); Utils.SetFormMid(mf); mf.Text = operateType + "成功"; mf.ShowDialog(); } else { 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); } }