// - - - - - - - - - - - - - - - - - - - - CREATE & SET OBJECT private void settheobject(int nid) { ExposicionIdioma theobj = getliteralsobject(nid); bool IsNew = false; if (theobj == null) { theobj = new ExposicionIdioma(nid); IsNew = true; } theobj.StartEnterId = textBoxStartEnterId.Text; theobj.StartPlayButton = textBoxStartPlayButton.Text; theobj.StartExposition = textBoxStartExposition.Text; theobj.StartExpoTitle = textBoxStartExpoTitle.Text; theobj.StartExpoIntro = textBoxStartExpoIntro.Text; theobj.StartExpoDateFrom = textBoxStartExpoDateFrom.Text; theobj.StartExpoDateTo = textBoxStartExpoDateTo.Text; theobj.StartExpoURL = textBoxStartExpoURL.Text; theobj.Question = textBoxQuestion.Text; theobj.Hits = textBoxHits.Text; theobj.QstnTXT1 = textBoxQstnTXT1.Text; theobj.QstnTXT2 = textBoxQstnTXT2.Text; theobj.AnswerOK = textBoxAnswerOK.Text; theobj.AnswerKO = textBoxAnswerKO.Text; theobj.NextButton = textBoxNextButton.Text; theobj.SummCongrats = textBoxSummCongrats.Text; theobj.SummGameText = textBoxSummGameText.Text; theobj.SummComment = textBoxSummComment.Text; theobj.SummBye = textBoxSummBye.Text; theobj.SummURLText = textBoxSummURLText.Text; theobj.SummURL = textBoxSummURL.Text; if (IsNew) { literales.Add(theobj); } }
// - - - - - - - - - - - - - - - - - - - - ASIGNA DATOS Y LLAMA GRABAR JSON private void buttonGuardar_Click(object sender, EventArgs e) { ExposicionIdioma theobj = getliteralsobject(((Idioma)comboBoxIdiomas.SelectedItem).Id); settheobject(((Idioma)comboBoxIdiomas.SelectedItem).Id); // crea objeto desde datos form savedata(); // graba list de literales }
// - - - - - - - - - - - - - - - - - - - - carga datos de objeto a elementos formulario private void setliteraldata(ExposicionIdioma theobj) { setmessagelabel("indice seleccionado " + theobj.LangId); textBoxLangId.Text = theobj.LangId.ToString(); textBoxStartEnterId.Text = theobj.StartEnterId; textBoxStartPlayButton.Text = theobj.StartPlayButton; textBoxStartExposition.Text = theobj.StartExposition; textBoxStartExpoTitle.Text = theobj.StartExpoTitle; textBoxStartExpoIntro.Text = theobj.StartExpoIntro; textBoxStartExpoDateFrom.Text = theobj.StartExpoDateFrom; textBoxStartExpoDateTo.Text = theobj.StartExpoDateTo; textBoxStartExpoURL.Text = theobj.StartExpoURL; textBoxQuestion.Text = theobj.Question; textBoxHits.Text = theobj.Hits; textBoxQstnTXT1.Text = theobj.QstnTXT1; textBoxQstnTXT2.Text = theobj.QstnTXT2; textBoxAnswerOK.Text = theobj.AnswerOK; textBoxAnswerKO.Text = theobj.AnswerKO; textBoxNextButton.Text = theobj.NextButton; textBoxSummCongrats.Text = theobj.SummCongrats; textBoxSummGameText.Text = theobj.SummGameText; textBoxSummComment.Text = theobj.SummComment; textBoxSummBye.Text = theobj.SummBye; textBoxSummURLText.Text = theobj.SummURLText; textBoxSummURL.Text = theobj.SummURL; setmessagelabel("ExposicionIdioma seleccionado " + theobj.LangId); }
// - - - - - - - - - - - - - - - - - - - - - - - SELECCIONA IDIOMA Y BUSCA LITERALES X IDIOMA private void comboBoxIdiomas_SelectedIndexChanged(object sender, EventArgs e) { ExposicionIdioma theobj = getliteralsobject(((Idioma)comboBoxIdiomas.SelectedItem).Id); if (theobj != null) { setliteraldata(theobj); } }
// - - - - - - - - - - - - - - - - - - - - retorn el objeto ExposicionIdioma a partir del ID seleccionado de IDIOMA private ExposicionIdioma getliteralsobject(int nid) { ExposicionIdioma theobj = null; for (int i = 0; (i < literales.Count && theobj == null); i++) { if (literales[i].LangId.Equals(nid)) { theobj = literales[i]; } } return(theobj); }
private void FormExposicionIdioma_Load(object sender, EventArgs e) { ExposicionIdioma lite = null; if (File.Exists(fullpath + FILEPATH + LANGFILNAM + "E" + nExpoId + JSONEXTNSN)) { JArray ajsonlangs = JArray.Parse(File.ReadAllText(fullpath + FILEPATH + LANGFILNAM + "E" + nExpoId + JSONEXTNSN)); idiomas = ajsonlangs.ToObject <List <Idioma> >(); comboBoxIdiomas.DataSource = null; // elimina contenido anterior comboBoxIdiomas.DataSource = idiomas; // carga contenido anterior comboBoxIdiomas.DisplayMember = "Nombre"; } else { MessageBox.Show("No existen idiomas !!", "ALERTA", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } if (File.Exists(fullpath + FILEPATH + LITSFILNAM + "E" + nExpoId + JSONEXTNSN)) { JArray ajsonlites = JArray.Parse(File.ReadAllText(fullpath + FILEPATH + LITSFILNAM + "E" + nExpoId + JSONEXTNSN)); literales = ajsonlites.ToObject <List <ExposicionIdioma> >(); } else { foreach (Idioma theobj in idiomas) { lite = new ExposicionIdioma(theobj.Id); literales.Add(lite); } } if (comboBoxIdiomas.Items.Count > 0) { if (comboBoxIdiomas.SelectedIndex < 0) { comboBoxIdiomas.SelectedIndex = 0; } lite = getliteralsobject(((Idioma)comboBoxIdiomas.SelectedItem).Id); } if (lite != null) { setliteraldata(lite); } }