private void DoUpgrade()
        {
            if (this.ucLabelEditRCard.Value.Trim().Length == 0)
            {
                this.ucLabelEditRCard.TextFocus(true, true);
                return;
            }

            if (this.ucLabelEditSoftVersion.Value.Trim().Length == 0)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$CS_PleaseChooseSoftVersion"));
                this.ucLabelEditSoftVersion.TextFocus(false, true);
                return;
            }

            if (this.m_MaterialList.Rows.Count == 0)
            {
                this.ucLabelEditRCard.Value = "";
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$CS_PleaseInputFGRcard"));
                this.ucLabelEditRCardFG.TextFocus(false, true);
                return;
            }

            DataView dv = this.m_MaterialList.Copy().DefaultView;

            dv.RowFilter = "Checked='True'";
            if (dv.Count == 0)
            {
                this.ucLabelEditRCard.Value = "";
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$CS_MustChooseOneMItem"));
                return;
            }

            string newVersion = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.ucLabelEditSoftVersion.Value));
            string mItemCode  = dv[0].Row["ItemCode"].ToString();
            string rcard      = FormatHelper.PKCapitalFormat(this.ucLabelEditRCard.Value.Trim());

            Messages messages = new Messages();

            ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();

            try
            {
                DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
                string            sourceRCard       = dataCollectFacade.GetSourceCard(rcard.Trim().ToUpper(), string.Empty);

                // Get Product Info
                messages = this.GetProduct(sourceRCard);
                if (!messages.IsSuccess() || product == null || product.LastSimulation == null)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$NoProductInfo"));
                    this.ucLabelEditRCard.TextFocus(false, true);
                    return;
                }
                DataCollectFacade    dcf        = new DataCollectFacade(this.DataProvider);
                OnWipSoftVer4Upgrade oldVersion = dcf.GetOnWipSoftVersion2Upgrade(sourceRCard, mItemCode);
                if (oldVersion == null)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CanNotFindItemSoftVer"));
                    this.ucLabelEditRCard.TextFocus(false, true);
                    return;
                }

                if (string.Compare(oldVersion.SoftwareVersion, newVersion, true) == 0)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$CS_AlreadyUpgraded"));
                    this.ucLabelEditRCard.TextFocus(false, true);
                    return;
                }

                BaseModelFacade bmf      = new BaseModelFacade(this.DataProvider);
                Resource        resource = (Domain.BaseSetting.Resource)bmf.GetResource(ApplicationService.Current().ResourceCode);

                messages.AddMessages(dcf.UpgradeNewSoftVer(oldVersion, resource, ApplicationService.Current().UserCode, newVersion));
                if (!messages.IsSuccess())
                {
                    ApplicationRun.GetInfoForm().Add(messages);
                    this.ucLabelEditRCard.TextFocus(false, true);
                    return;
                }

                DataRow rowNew = this.m_UpgradeLog.NewRow();
                rowNew["RCard"]           = rcard;
                rowNew["ItemDescription"] = oldVersion.ItemDescription;
                rowNew["SemiGoodRCard"]   = oldVersion.RunningCard;
                rowNew["OldVersion"]      = oldVersion.SoftwareVersion;
                rowNew["NewVersion"]      = newVersion;
                this.m_UpgradeLog.Rows.Add(rowNew);
                this.m_UpgradeLog.AcceptChanges();
                this.ucLabelEditCount.Value = this.m_UpgradeLog.Rows.Count.ToString();

                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_UpgradeSuccess"));
                this.ucLabelEditRCard.TextFocus(false, true);
            }
            catch (Exception ex)
            {
                ApplicationRun.GetInfoForm().Add(ex.Message);
                this.ucLabelEditRCard.TextFocus(false, true);
            }
            finally
            {
                ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }