// 指定某个Excel导入VIN private void ImportVinFromExcel(string dataType) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); JaguarUtils jaguarUtil = new JaguarUtils(); try { if (openFileDialog1.ShowDialog() == DialogResult.OK) { string returnFile = string.Empty; string folderPath = Path.GetDirectoryName(openFileDialog1.FileName); returnFile += jaguarUtil.ImportVinData(openFileDialog1.FileName, folderPath, dataType); MessageForm mf = new MessageForm(returnFile); Utils.SetFormMid(mf); mf.Text = "VIN导入结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("导入失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 生成(燃料) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barBtnGenerate_ItemClick(object sender, ItemClickEventArgs e) { if (!this.CheckAllDataReady(Utils.FUEL)) { return; } try { //DONE-lyc L43-47 DataSet dsCtny = this.GetReadyDataFromLocalCoc(Utils.CTNY); DataSet dsFcds = this.GetReadyDataFromLocalCoc(Utils.FCDS); JaguarUtils jaguarUtils = new JaguarUtils(); string msg = jaguarUtils.SaveParam(dsCtny, Utils.CTNY); msg += jaguarUtils.SaveParam(dsFcds, Utils.FCDS); if (string.IsNullOrEmpty(msg)) { 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, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// 批量修改进口时间 private void btnUpdateDate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { // 获取对象 List <string> vinList = Utils.GetUpdateVin(this.gvGH, (DataTable)this.gcGH.DataSource); if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } using (UpdateDateForm dateForm = new UpdateDateForm() { Date = "GH" }) { if (dateForm.ShowDialog() == DialogResult.OK) { JaguarUtils jaguarUtil = new JaguarUtils(); if (jaguarUtil.UpdateGHImportDate(vinList, dateForm.Date)) { this.searchLocal(); } } } } catch (Exception) { } }
// 通过excel查询数据 private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { JaguarUtils jaguarUtil = new JaguarUtils(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = jaguarUtil.SearchGHExcel(openFileDialog1.FileName, ""); DataTable dt = ds.Tables[0]; dt.Columns.Add("check", System.Type.GetType("System.Boolean")); gcGH.DataSource = dt; lblSum.Text = string.Format("共{0}条", dt.Rows.Count); Utils.SelectItem(this.gvGH, false); } }
/// <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.GetCocData(Utils.CTNY); DataTable dtFcds = this.GetCocData(Utils.FCDS); JaguarUtils jaguarUtils = new JaguarUtils(); DataTable dtCtnyPam = jaguarUtils.GetRllxData("传统能源"); DataTable dtFcdsPam = jaguarUtils.GetRllxData("非插电式混合动力"); using (OleDbConnection con = new OleDbConnection(strCon)) { con.Open(); try { foreach (string vin in vinList) { DataRow[] drCtny = dtCtny.Select("COC_ID='" + this.dictVinCocId[vin] + "'"); DataRow[] drFcds = dtFcds.Select("COC_ID='" + this.dictVinCocId[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.cocIds); } }
// 修改进口日期 private void btnUpdateImportDate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { JaguarUtils jaguarUtil = new JaguarUtils(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (jaguarUtil.ReadUpdateGHDate(openFileDialog1.FileName, "") == 1) { MessageBox.Show("批量修改时间成功"); } else { MessageBox.Show("批量修改时间失败"); } this.searchLocal(); } }
/// <summary> /// 修改关联数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdateVin_ItemClick(object sender, ItemClickEventArgs e) { // 获取主表编号 string cocIds = string.Empty; JaguarUtils jaguarUtils = new JaguarUtils(); try { List <string> cocList = new List <string>(); List <string> ctnyList = jaguarUtils.GetCocIdFromControl(this.gvCtny, (DataTable)this.dgvCtny.DataSource); cocList.AddRange(ctnyList); List <string> fcdsList = jaguarUtils.GetCocIdFromControl(this.gvFcds, (DataTable)this.dgvFcds.DataSource); cocList.AddRange(fcdsList); if (cocList.Count < 1) { MessageBox.Show("请选择COC信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } foreach (string cocId in cocList) { cocIds += string.Format(",'{0}'", cocId); } if (!string.IsNullOrEmpty(cocIds)) { cocIds = cocIds.Substring(1); } ReviewUpdateVinForm reviewVinForm = new ReviewUpdateVinForm(cocIds); reviewVinForm.ShowDialog(); } catch (Exception ex) { } }
private void btnGenFuelData_Click(object sender, EventArgs e) { try { JaguarUtils jaguarUtils = new JaguarUtils(); string msg = string.Empty; if (this.dataType == Utils.FUEL) { msg += jaguarUtils.SaveParam(dsGenCtny, Utils.CTNY); msg += jaguarUtils.SaveParam(dsGenFcds, Utils.FCDS); } else if (this.dataType == Utils.GH) { msg += jaguarUtils.SaveGHParam(dsGenCtny); msg += jaguarUtils.SaveGHParam(dsGenFcds); } 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, "生成失败"); } }
//指定某个Excel导入COC protected void ImportCOCData(string importType) { JaguarUtils utils = new JaguarUtils(); FolderDialog openFolder = new FolderDialog(); List <string> cocIdList = new List <string>(); string genFileName = string.Empty; string promptMsg = string.Empty; if (importType == "IMPORT") { genFileName = utils.CocFileName; promptMsg = "导入"; } else if (importType == "UPDATE") { genFileName = utils.UpdateCocFileName; promptMsg = "修改"; } try { if (openFolder.DisplayDialog() == DialogResult.OK) { // 获取用户选择的文件夹路径 string folderPath = openFolder.Path.ToString(); // 获取folderPath下以格式为utils.CocFileName的所有文件 List <string> fileNameList = utils.GetFileName(folderPath, genFileName); if (fileNameList.Count > 0) { string returnMsg = string.Empty; // 遍历读所有文件fileNameList foreach (string fileName in fileNameList) { // 导入filename文件信息 returnMsg += utils.ReadCtnyCOCExcel(fileName, folderPath, importType, cocIdList, promptMsg); } MessageForm mf = new MessageForm(returnMsg); Utils.SetFormMid(mf); mf.Text = promptMsg + "结果"; mf.ShowDialog(); if (importType == "IMPORT") { this.SearchAllCocData(); } else if (importType == "UPDATE") { this.SearchUpdatedCocData(cocIdList); } } else { MessageBox.Show("目录" + folderPath + "下没有文件" + genFileName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(promptMsg + "失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }