Esempio 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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 修改车型参数或者油耗值信息后,修改他们关联的油耗数据
        /// </summary>
        /// <param name="updateType">修改类型:“FUEL”表示修改车型参数对应的油耗数据;“CPOS”表示修改轮胎规格对应的油耗数据</param>
        protected void UpdateFuelData(string updateType)
        {
            try
            {
                // 记录修改后的CPOS或者车型参数编号
                string        mainIds      = string.Empty;
                ChryslerUtils chryslerUtil = new ChryslerUtils();
                List <string> ctnyList     = new List <string>();

                // 冲界面获取修改后的车型参数或者cpos信息
                if (updateType == "MAIN")
                {
                    ctnyList = chryslerUtil.GetMainIdFromControl(this.gvCtny, (DataTable)this.gcCtny.DataSource, updateType);
                    if (ctnyList.Count < 1)
                    {
                        MessageBox.Show("请首先选择车型参数数据或者油耗值数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                else if (updateType == "FUEL")
                {
                    ctnyList = chryslerUtil.GetMainIdFromControl(this.gvCpos, (DataTable)this.gcCpos.DataSource, updateType);
                    if (ctnyList.Count < 1)
                    {
                        MessageBox.Show("请首先选择车型参数数据或者油耗值数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                foreach (string ctnyId in ctnyList)
                {
                    if (updateType == "MAIN")
                    {
                        mainIds += string.Format(",{0}", ctnyId);
                    }
                    else if (updateType == "FUEL")
                    {
                        mainIds += string.Format(",{0}", ctnyId);
                    }
                }
                if (!string.IsNullOrEmpty(mainIds))
                {
                    mainIds = mainIds.Substring(1);
                }

                // 查看修改后的CPOS或车型参数关联到的原始油耗数据
                using (ReviewUpdateVinForm reviewVinForm = new ReviewUpdateVinForm(mainIds, updateType))
                {
                    reviewVinForm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        /// <summary>
        /// 删除车型参数或CPOS
        /// </summary>
        /// <param name="deleteType">修改类型:“FUEL”表示修改车型参数对应的油耗数据;“CPOS”表示修改轮胎规格对应的油耗数据</param>
        protected void DeleteMainCpos(string deleteType)
        {
            // 记录修改后的CPOS或者车型参数编号
            string        mainIds      = string.Empty;
            ChryslerUtils chryslerUtil = new ChryslerUtils();

            try
            {
                List <string> ctnyList = new List <string>();

                // 冲界面获取修改后的车型参数或者cpos信息
                if (deleteType == "MAIN")
                {
                    ctnyList = chryslerUtil.GetMainIdFromControl(this.gvCtny, (DataTable)this.gcCtny.DataSource, deleteType);
                }
                else if (deleteType == "FUEL")
                {
                    ctnyList = chryslerUtil.GetMainIdFromControl(this.gvCpos, (DataTable)this.gcCpos.DataSource, deleteType);
                }
                if (ctnyList.Count < 1)
                {
                    MessageBox.Show("请选择要删除的数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                foreach (string ctnyId in ctnyList)
                {
                    if (deleteType == "MAIN")
                    {
                        mainIds += string.Format(",{0}", ctnyId);
                    }
                    else if (deleteType == "FUEL")
                    {
                        mainIds += string.Format(",{0}", ctnyId);
                    }
                }
                if (!string.IsNullOrEmpty(mainIds))
                {
                    mainIds = mainIds.Substring(1);
                }

                string delMsg = string.Empty;
                if (MessageBox.Show("确定要删除吗?", "删除确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    delMsg = chryslerUtil.DeleteMainCpos(deleteType, mainIds);

                    if (deleteType == "MAIN")
                    {
                        this.ShowMainData();
                    }
                    else if (deleteType == "FUEL")
                    {
                        this.ShowCposFuelData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
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);
            }
        }