コード例 #1
0
        /// <summary>
        /// Initialize all control text following by stored data on database, depend on current user's language.
        /// </summary>
        protected virtual void InitializeControlText()
        {
            if (this.ScreenCode == string.Empty)
            {
                return;
            }

            Map <string, ScreenDetail> mapControlList      = this.GetControlList();
            ScreenDetailLangBIZ        bizScreenDetailLang = new ScreenDetailLangBIZ();

            string langCD = CommonLib.Common.SystemLanguage.StrongValue;

            if (CommonLib.Common.CurrentUserInfomation != null)
            {
                langCD = CommonLib.Common.CurrentUserInfomation.LanguageCD.StrongValue;
            }

            // Load screen detail depend on language.
            List <ScreenDetailLangDTO> listScreenDetailLang = bizScreenDetailLang.LoadScreenDetailByLangCD(this.ScreenCode, langCD);

            for (int i = 0; i < listScreenDetailLang.Count; i++)
            {
                ScreenDetailLangDTO dto = listScreenDetailLang[i];
                MapKeyValue <string, ScreenDetail> mapKeyValue = mapControlList[dto.CONTROL_CD.StrongValue];
                if (mapKeyValue == null)
                {
                    continue;
                }

                ScreenDetail screenDetail = mapKeyValue.Value;
                Control      ctrl         = null;
                switch (screenDetail.Type)
                {
                case ScreenDetail.TYPE_FORM:
                    ctrl = screenDetail.ObjOwner as Control;
                    if (ctrl != null)
                    {
                        ctrl.Text = ScreenAttribute.GetScreenAttribute(screenDetail.ObjOwner.GetType()).ScreenCD + ": " + dto.CONTROL_CAPTION.NVL(string.Empty);
                    }
                    break;

                case ScreenDetail.TYPE_BUTTON:
                case ScreenDetail.TYPE_CHECKBOX:
                case ScreenDetail.TYPE_GROUPBOX:
                case ScreenDetail.TYPE_LABEL:
                case ScreenDetail.TYPE_RADIOBUTTON:
                case ScreenDetail.TYPE_TABPAGE:
                    ctrl = screenDetail.ObjOwner as Control;
                    if (ctrl != null)
                    {
                        ctrl.Text = dto.CONTROL_CAPTION.NVL(string.Empty);
                    }

                    break;

                case ScreenDetail.TYPE_SPREAD_COLUMN:
                    Column column = screenDetail.ObjOwner as Column;
                    if (column != null)
                    {
                        column.Label = dto.CONTROL_CAPTION.NVL(string.Empty);
                    }
                    break;
                }
            }
        }
コード例 #2
0
        private void btnImportScreen_Click(object sender, EventArgs e)
        {
            try
            {
                // show confirm message
                switch (ShowConfirmMessage(Messages.eConfirm.CFM9004))
                {
                case MessageDialogResult.Cancel:
                    return;

                case MessageDialogResult.No:
                    return;

                case MessageDialogResult.Yes:
                    break;
                }
                List <ScreenImportUIDM> UIDMList             = new List <ScreenImportUIDM>();
                ScreenImportController  SIC                  = new ScreenImportController();
                List <ScreenDetailUIDM> UIDMScreenDetailList = new List <ScreenDetailUIDM>();
                int row = shtScreenList.Rows.Count;
                for (int i = 0; i < row; i++)
                {
                    if (shtScreenList.Cells[i, (int)eColView.SEL].Text == "True")
                    {
                        ScreenImportUIDM uidm = new ScreenImportUIDM();
                        uidm.ScreenCD.Value      = shtScreenList.Cells[i, (int)eColView.SCREEN_CD].Text;
                        uidm.ScreenName.Value    = shtScreenList.Cells[i, (int)eColView.SCREEN_NAME].Text;
                        uidm.ScreenType.Value    = (int)Enum.Parse(typeof(eScreenType), shtScreenList.Cells[i, (int)eColView.SCREEN_TYPE].Text, true);
                        uidm.ImportStatus.Value  = shtScreenList.Cells[i, (int)eColView.IMPORT_STATUS].Text;
                        uidm.OriginalTitle.Value = shtScreenList.Cells[i, (int)eColView.SCREEN_NAME].Text;
                        UIDMList.Add(uidm);
                    }
                }

                foreach (ScreenImportUIDM screenUIDM in UIDMList)
                {
                    // get screen detail from screen cd
                    //Hashtable hshScreenDetails = GetScreenDetail(screenUIDM.ScreenCD.StrongValue);

                    Map <string, ScreenDetail> mapControl = GetScreenDetail(screenUIDM.ScreenCD.StrongValue);

                    for (int i = 0; i < mapControl.Count; i++)
                    {
                        ScreenDetail screendetail = mapControl[i].Value;
                        if (SIC.IsScreenDetailAlreadyExist(screenUIDM.ScreenCD.StrongValue, screendetail.Name))
                        {
                            continue;
                        }
                        ScreenDetailUIDM screenDetailUIDM = new ScreenDetailUIDM();
                        screenDetailUIDM.ScreenCD             = screenUIDM.ScreenCD;
                        screenDetailUIDM.ControlType.Value    = screendetail.Type;// control.GetType().Name;
                        screenDetailUIDM.ControlCD.Value      = screendetail.Name;
                        screenDetailUIDM.ControlCaption.Value = screendetail.Text;
                        screenDetailUIDM.OriginalTitle.Value  = screendetail.Text;
                        UIDMScreenDetailList.Add(screenDetailUIDM);
                    }
                }
                SIC.ImportData(UIDMList, UIDMScreenDetailList);
                MessageDialog.ShowInformation(this, "Information", new EVOFramework.Message(Messages.eInformation.INF9001.ToString()).MessageDescription);
                UpdateImportStatus(true);
            }
            catch (ValidateException err)
            {
                for (int i = 0; i < err.ErrorResults.Count; i++)
                {
                    MessageBox.Show(err.ErrorResults[i].Message.MessageDescription);
                    err.ErrorResults[i].FocusOnControl();
                }
                if (CommonLib.Common.CurrentDatabase.DBTransactionState == EVOFramework.Database.TransactionState.PROCESSING)
                {
                    CommonLib.Common.CurrentDatabase.Rollback();
                }
            }
            catch (BusinessException err)
            {
                MessageBox.Show(err.Error.Message.MessageDescription);
                if (CommonLib.Common.CurrentDatabase.DBTransactionState == EVOFramework.Database.TransactionState.PROCESSING)
                {
                    CommonLib.Common.CurrentDatabase.Rollback();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                if (CommonLib.Common.CurrentDatabase.DBTransactionState == EVOFramework.Database.TransactionState.PROCESSING)
                {
                    CommonLib.Common.CurrentDatabase.Rollback();
                }
            }
        }