private void FrmLanguage_Load(object sender, EventArgs e) { try { SessionHelper.RegisterForTranslation(this, Codes.MNU_OP001); SessionHelper.RegisterForTranslation(lblLanguage, Codes.MNU_OP001_LBL_LANGUAGE); SessionHelper.RegisterForTranslation(cmdAccept, Codes.BTN_ACCEPT); SessionHelper.RegisterForTranslation(cmdCancel, Codes.BTN_CLOSE); //Carga los idiomas LanguageBLL languageBll = new LanguageBLL(); ResultBM language = languageBll.GetLanguages(); if (language.IsValid()) { cmbLanguage.DataSource = language.GetValue <List <LanguageBM> >(); cmbLanguage.DisplayMember = "Name"; //Desprolijo - mejorar (BAJA PRIORIDAD) bool found = false; for (int i = 0; i < language.GetValue <List <LanguageBM> >().Count&& !found; ++i) { found = language.GetValue <List <LanguageBM> >()[i].Id == SessionHelper.GetLoggedUser().LanguageId; if (found) { cmbLanguage.SelectedIndex = i; } } } else { MessageBox.Show(language.description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception exception) { MessageBox.Show("Se ha producido el siguiente error: " + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void FrmUser_Load(object sender, EventArgs e) { try { //Traducciones SessionHelper.RegisterForTranslation(this, Codes.MNU_GE003); SessionHelper.RegisterForTranslation(cmdAccept, Codes.BTN_ACCEPT); SessionHelper.RegisterForTranslation(cmdClose, Codes.BTN_CLOSE); SessionHelper.RegisterForTranslation(lblName, Codes.LBL_NAME); SessionHelper.RegisterForTranslation(lblPassword, Codes.LBL_PASSWORD); SessionHelper.RegisterForTranslation(lblPasswordConfirm, Codes.LBL_PASSWORD_CHECK); SessionHelper.RegisterForTranslation(lblLanguage, Codes.LBL_LANGUAGE); SessionHelper.RegisterForTranslation(lblProfile, Codes.LBL_PROFILE); SessionHelper.RegisterForTranslation(chkIsActive, Codes.LBL_ACTIVE); //Idioma LanguageBLL languageBll = new LanguageBLL(); ResultBM language = languageBll.GetLanguages(); //Permisos ProfileBLL profileBll = new ProfileBLL(); ResultBM profile = profileBll.GetProfiles(); if (language.IsValid()) { cmbLanguage.DataSource = language.GetValue <List <LanguageBM> >(); cmbLanguage.DisplayMember = "Name"; } else { MessageBox.Show(language.description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (profile.IsValid()) { cmbProfile.DataSource = profile.GetValue <List <PermissionMDL> >(); cmbProfile.DisplayMember = "Description"; } else { MessageBox.Show(profile.description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //Si se está actualizando, entonces se completan los campos if (isUpdate) { txtName.Text = this.Entity.Name; chkIsActive.Checked = this.Entity.Active; //Desprolijo - mejorar (BAJA PRIORIDAD) bool found = false; for (int i = 0; i < language.GetValue <List <LanguageBM> >().Count&& !found; ++i) { found = language.GetValue <List <LanguageBM> >()[i].Id == entity.LanguageId; if (found) { cmbLanguage.SelectedIndex = i; } } found = false; for (int i = 0; i < profile.GetValue <List <PermissionMDL> >().Count&& !found; ++i) { found = profile.GetValue <List <PermissionMDL> >()[i].Code == entity.PermissionId; if (found) { cmbProfile.SelectedIndex = i; } } } } catch (Exception exception) { MessageBox.Show("Se ha producido el siguiente error: " + exception.Message, "EXCEPCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }