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>
        /// 导入或修改CPOS
        /// </summary>
        /// <param name="importType">操作类型:“IMPORT”表示新导入;“UPDATE”表示修改已导入的轮胎信息/param>
        protected void ImportFuelData(string importType)
        {
            string operateType = string.Empty;

            if (importType == "IMPORT")
            {
                operateType = "导入";
            }
            else if (importType == "UPDATE")
            {
                operateType = "修改";
            }

            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.CposFileName);
                    if (fileNameList.Count > 0)
                    {
                        string fileNameMsg = string.Empty;
                        string returnMsg   = string.Empty;

                        //更新列表,记录更新的数据。存油耗值编号,初始为空
                        List <string> fuelUpdateList = new List <string>();

                        // 遍历读所有文件fileNameList
                        foreach (string fileName in fileNameList)
                        {
                            fileNameMsg += Path.GetFileName(fileName) + "\r\n";

                            // 导入filename文件信息
                            returnMsg += utils.ImportFuelData(fileName, folderPath, importType, fuelUpdateList);
                        }

                        MessageForm mf = new MessageForm(returnMsg);
                        Utils.SetFormMid(mf);
                        mf.Text = operateType + "结果";
                        mf.ShowDialog();

                        // 如果是新导入数据,导入完成后显示所有数据
                        if (importType == "IMPORT")
                        {
                            this.ShowCposFuelData();
                        }
                        else if (importType == "UPDATE")
                        {
                            // 如果是修改数据,界面只显示修改过的数据(为了接下来修改和这些轮胎信心关联的燃料数据)。
                            this.ShowUpdatedCposFuelData(fuelUpdateList);
                        }
                    }
                    else
                    {
                        MessageBox.Show("目录" + folderPath + "下没有文件" + utils.CposFileName);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("导入失败:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }