Exemplo n.º 1
0
        /// <summary>
        /// 导入VIN
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImportVin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                ChryslerUtils utils      = new ChryslerUtils();
                FolderDialog  openFolder = new FolderDialog();
                if (openFolder.DisplayDialog() == DialogResult.OK)
                {
                    // 获取用户选择的文件夹路径
                    string folderPath = openFolder.Path.ToString();

                    // 获取folderPath下以格式为utils.MainFileName的所有文件
                    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("MAIN_RLLX"); // "MAIN_RLLX"表示燃料数据表(传统,非插电式混合动力等)
                        if (!IsMainDataExist)
                        {
                            MessageBox.Show("系统中不存在车型参数数据,请首先导入车型参数数据", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        bool IsCposDataExist = utils.GetMainData("MAIN_FUEL"); // "MAIN_FUEL"表示油耗值数据
                        if (!IsCposDataExist)
                        {
                            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, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生成燃料消耗量数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barBtnGenerate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string        message      = string.Empty;
            ChryslerUtils chryslerUtil = new ChryslerUtils();

            try
            {
                DataTable dtVin = chryslerUtil.GetImportedVinData("");

                if (dtVin.Rows.Count > 0)
                {
                    // 获取全部车型参数数据,用作合并VIN数据
                    bool IsMainDataExist = chryslerUtil.GetMainData("MAIN_FUEL"); // "MAIN_FUEL"表示燃料数据表(传统,非插电式混合动力等)
                    if (!IsMainDataExist)
                    {
                        MessageBox.Show("系统中不存在车型参数数据,请首先导入车型参数数据", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    bool IsCposDataExist = chryslerUtil.GetMainData("MAIN_CPOS"); // "MAIN_CPOS"表示轮胎信息表
                    if (!IsCposDataExist)
                    {
                        MessageBox.Show("系统中不存在油耗值数据,请首先导入油耗值数据", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    message = chryslerUtil.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();
        }