Пример #1
0
        private void BtnImportData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FolderDialog openFolder = new FolderDialog();
            string       strMsg     = string.Empty;

            try
            {
                if (openFolder.DisplayDialog() == DialogResult.OK)
                {
                    // 获取用户选择的文件夹路径
                    string folderPath = openFolder.Path.ToString();

                    // 获取folderPath下以格式为utils.CocFileName的所有文件
                    List <string> fileNameList = mu.GetFileName(folderPath, mu.VinFileName);

                    if (fileNameList.Count > 0)
                    {
                        foreach (string str in fileNameList)
                        {
                            strMsg += mu.ImportVinData(str, folderPath);
                        }
                    }
                    else
                    {
                        strMsg = string.Format("目录{0}下没有文件{1}", folderPath, mu.VinFileName);
                    }
                }
            }
            catch (Exception ex)
            {
                strMsg = ex.Message + "\r\n" + strMsg;
            }
            MessageForm mf = new MessageForm("导入完成\r\n" + strMsg);

            mf.Show();
            searchLocal();
        }
Пример #2
0
        /// <summary>
        /// 导入VIN
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImportVin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            MitsUtils utils = new MitsUtils();
            //this.gvCtny.PostEditor();
            //int[] selectedHandle;
            ////selectedHandle = this.gvCtny.GetSelectedRows();
            //if (selectedHandle.Count() > 0)
            //{
            //    if (selectedHandle[0] < 0)
            //    {
            //        MessageBox.Show("请选择车型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        return;
            //    }
            //}
            //else
            //{
            //    MessageBox.Show("请选择车型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}
            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("系统中不存在车型数据,请首先导入车型数据", "提示", 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, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("导入失败:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        /// <summary>
        /// 导入或修改车型参数
        /// </summary>
        /// <param name="importType"></param>
        protected void ImportMainData(string importType)
        {
            string operateType = string.Empty;

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

            MitsUtils    utils      = new MitsUtils();
            FolderDialog openFolder = new FolderDialog();

            DevExpress.Utils.WaitDialogForm waitDialog = null;
            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>();

                        //弹出加载提示画面
                        new Thread((ThreadStart) delegate
                        {
                            waitDialog = new DevExpress.Utils.WaitDialogForm("loading...", "系统处理中,请等待");
                            Application.Run(waitDialog);
                        }).Start();

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

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

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

                        //关闭登录提示画面
                        waitDialog.Invoke((EventHandler) delegate { waitDialog.Close(); });

                        mf.ShowDialog();

                        if (importType == "IMPORT")
                        {
                            this.ShowMainData();
                        }
                        else if (importType == "UPDATE")
                        {
                            this.ShowUpdatedMainData(mainUpdateList);
                        }
                    }
                    else
                    {
                        MessageBox.Show(String.Format("目录{0}下没有文件{1}", folderPath, utils.MainFileName), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                //关闭登录提示画面
                if (waitDialog != null)
                {
                    waitDialog.Invoke((EventHandler) delegate { waitDialog.Close(); });
                }
                MessageBox.Show(String.Format("{0}失败:{1}", operateType, ex.Message), "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }