Beispiel #1
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);
            }
        }
Beispiel #2
0
        private void btnUploadOT_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!Utils.CheckUser())
            {
                return;
            }
            try
            {
                //获取补传的数据
                List <string> vinList = new List <string>();
                this.dgvCljbxx.DefaultView.PostEditor();
                DataTable dt = (DataTable)this.dgvCljbxx.DataSource;
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        bool result = false;
                        bool.TryParse(dt.Rows[i]["check"].ToString(), out result);
                        if (result)
                        {
                            string vin = String.Format("'{0}'", dt.Rows[i]["vin"]);
                            vinList.Add(vin);
                        }
                    }
                }
                if (vinList == null || vinList.Count < 1)
                {
                    MessageBox.Show("请选择要补传的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string     delReason = string.Empty;
                ReasonForm rf        = new ReasonForm();
                Utils.SetFormMid(rf);
                rf.Text = "补传原因";
                rf.ShowDialog();

                //Utils.Open("INSERT_O");

                if (rf.DialogResult == DialogResult.OK)
                {
                    pf = new ProcessForm();
                    pf.Show();

                    // 补传
                    List <OperateResult> orList = this.applyOTParamMultiRows(vinList, rf.Reason);

                    // 获取补传结果
                    List <string>               vinsSucc    = new List <string>();
                    List <NameValuePair>        vinsFail    = new List <NameValuePair>();
                    Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>();
                    Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid);

                    string strSucc = "";// "备案号(VIN):返回码(VID)";
                    // 修改本地状态为“4:已申请补传”
                    if (vinsSucc.Count > 0)
                    {
                        string strUpdate = "";
                        for (int i = 0; i < vinsSucc.Count; i++)
                        {
                            strUpdate += String.Format(",'{0}'", vinsSucc[i]);
                            strSucc   += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]);
                        }
                        //Utils.setStatusForUpload(strUpdate.Substring(1), "0");
                        //// 反馈码入库
                        //Utils.setVidForUpload(dSuccVinVid);

                        Utils.setVidStatusForUpload(dSuccVinVid);

                        // 刷新当前页面
                        this.searchLocal();
                    }

                    string strFail = "";
                    if (vinsFail.Count > 0)
                    {
                        for (int i = 0; i < vinsFail.Count; i++)
                        {
                            strFail += String.Format("备案号(VIN):{0},\r反馈码(VID):, \r失败: {1} \r\n", vinsFail[i].Name, vinsFail[i].Value);
                        }
                    }
                    string      summary = string.Format("{0}条补传成功\r\n {1}条补传失败\r\n", vinsSucc.Count, vinsFail.Count);
                    MessageForm mf      = new MessageForm(String.Format("{0}{1} \n{2}", summary, strSucc, strFail));
                    Utils.SetFormMid(mf);
                    mf.Text = "补传结果";
                    mf.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (pf != null)
                {
                    pf.Close();
                }
                //关端口
                //Utils.Close("INSERT_O");
            }
        }
Beispiel #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);
            }
        }