Exemplo n.º 1
0
        /// <summary>
        /// 本地导入商品信息线程
        /// </summary>
        private void ImportGoodsTrd()
        {
            int intErrCode = 0;

            bool blnPrevious = false;
            bool blnNext     = false;
            bool blnView     = false;

            this.tbTitle.Dispatcher.Invoke(new Action(() =>
            {
                // 记录操作前按钮的使能状态
                blnPrevious           = btnPrevious.IsEnabled;
                blnNext               = btnDown.IsEnabled;
                blnView               = btnView.IsEnabled;
                btnImport.IsEnabled   = btnCancel.IsEnabled = btnPrevious.IsEnabled =
                    btnDown.IsEnabled = btnView.IsEnabled = btnClearGoods.IsEnabled = btnDelete.IsEnabled = false;
            }));

            try
            {
                intErrCode = PubHelper.ImportMcdInfo("2");
            }
            catch
            {
                intErrCode = 2;// 认为读取导入文件失败
            }

            string strMsgInfo = string.Empty;

            switch (intErrCode)
            {
            case 0:    // 导入成功
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Pub_OperSuc");
                break;

            case 1:    // 没有找到信息导入文件
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_NoFile");
                break;

            case 2:    // 读取信息导入文件失败
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_ReadFileFail");
                break;

            case 3:    // 获取商品导入信息失败
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_GetInfoFail");
                break;

            case 4:    // 没有要导入的商品信息
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Err_Import_NoInfo");
                break;

            default:    // 导入失败
                strMsgInfo = PubHelper.p_LangOper.GetStringBundle("Pub_OperFail");
                break;
            }

            this.tbTitle.Dispatcher.Invoke(new Action(() =>
            {
                if (intErrCode == 0)
                {
                    LoadPage();
                }
                else
                {
                    btnImport.IsEnabled   = btnCancel.IsEnabled = true;
                    btnPrevious.IsEnabled = blnPrevious;
                    btnDown.IsEnabled     = blnNext;
                    btnView.IsEnabled     = blnView;
                    btnDelete.IsEnabled   = false;
                    if (m_GoodsCount > 0)
                    {
                        btnClearGoods.IsEnabled = true;
                    }
                }
                PubHelper.ShowMsgInfo(strMsgInfo, PubHelper.MsgType.Ok);
            }));
        }