Exemple #1
0
        private void AsignarLeyenda(Control Control)
        {
            LeyendaBE leyenda = _leyendas.FirstOrDefault(l => l.NombreControl == Control.Name);

            if (leyenda != null)
            {
                Control.Text = leyenda.Texto;
            }
            if (Control.GetType() == typeof(MenuStrip))
            {
                foreach (ToolStripMenuItem item in ((MenuStrip)Control).Items)
                {
                    AsignarLeyenda(item);
                }
            }
            else if (Control.GetType() == typeof(DataGridView))
            {
                foreach (DataGridViewColumn columna in ((DataGridView)Control).Columns)
                {
                    AsignarLeyenda(columna);
                }
            }
            else
            {
                foreach (Control controlHijo in Control.Controls)
                {
                    AsignarLeyenda(controlHijo);
                }
            }
        }
 public void Guardar(LeyendaBE leyenda)
 {
     DeterminarFormaGuardado();
     if (_formaGuardado == FormaGuardado.Insertar)
     {
         Insertar(leyenda);
     }
     else if (_formaGuardado == FormaGuardado.Actualizar)
     {
         Actualizar(leyenda);
     }
     else if (_formaGuardado == FormaGuardado.Mixto)
     {
         // Como no hay certeza de si existe o no, hacer el chequeo antes de insertar o actualizar
         string         query      = "SELECT idioma_id FROM leyenda WHERE idioma_id = @idiomaId AND nombre_form = @nombreForm AND nombre_control = @nombreControl";
         SqlParameter[] parameters =
         {
             new SqlParameter("@idiomaId",      idiomaId),
             new SqlParameter("@nombreForm",    leyenda.NombreForm),
             new SqlParameter("@nombreControl", leyenda.NombreControl)
         };
         DataTable table = SqlHelper.Obtener(query, parameters);
         if (table.Rows.Count == 0)
         {
             Insertar(leyenda);
         }
         else
         {
             Actualizar(leyenda);
         }
     }
 }
Exemple #3
0
        private void AsignarLeyenda(DataGridViewColumn columna)
        {
            LeyendaBE leyenda = _leyendas.FirstOrDefault(l => l.NombreControl == columna.Name);

            if (leyenda != null)
            {
                columna.HeaderText = leyenda.Texto;
            }
        }
Exemple #4
0
 private void LlenarTextoIdioma(List <LeyendaBE> leyendas)
 {
     foreach (DataGridViewRow row in dgvLeyendas.Rows)
     {
         LeyendaBE le            = (LeyendaBE)row.Tag; // Leyenda en español
         LeyendaBE leyendaIdioma = leyendas.SingleOrDefault(l => l.NombreForm == le.NombreForm && l.NombreControl == le.NombreControl);
         row.Cells[2].Value = leyendaIdioma != null ? leyendaIdioma.Texto : "";
     }
 }
        private void Actualizar(LeyendaBE leyenda)
        {
            string query = "UPDATE leyenda SET texto = @texto WHERE idioma_id = @idiomaId AND nombre_form = @nombreForm AND nombre_control = @nombreControl";

            SqlParameter[] parameters =
            {
                new SqlParameter("@idiomaId",      idiomaId),
                new SqlParameter("@nombreForm",    leyenda.NombreForm),
                new SqlParameter("@nombreControl", leyenda.NombreControl),
                new SqlParameter("@texto",         leyenda.Texto)
            };
            SqlHelper.Ejecutar(query, parameters);
        }
        private void Insertar(LeyendaBE leyenda)
        {
            string query = "INSERT INTO leyenda (idioma_id, nombre_form, nombre_control, texto) VALUES (@idiomaId, @nombreForm, @nombreControl, @texto)";

            SqlParameter[] parameters =
            {
                new SqlParameter("@idiomaId",      idiomaId),
                new SqlParameter("@nombreForm",    leyenda.NombreForm),
                new SqlParameter("@nombreControl", leyenda.NombreControl),
                new SqlParameter("@texto",         leyenda.Texto)
            };
            SqlHelper.Ejecutar(query, parameters);
        }
Exemple #7
0
        private void AsignarLeyenda(ToolStripMenuItem Item)
        {
            LeyendaBE leyenda = _leyendas.FirstOrDefault(l => l.NombreControl == Item.Name);

            if (leyenda != null)
            {
                Item.Text = leyenda.Texto;
            }
            foreach (ToolStripMenuItem item in Item.DropDownItems)
            {
                AsignarLeyenda(item);
            }
        }
Exemple #8
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (ValidarDatos())
            {
                CompletarLeyendasFaltantes();
                IdiomaBE idioma;
                if (lstIdiomasActuales.SelectedItem == null)
                {
                    idioma = new IdiomaBE();
                }
                else
                {
                    idioma = (IdiomaBE)lstIdiomasActuales.SelectedItem;
                }
                idioma.Nombre = txtNombre.Text;

                // Comienzo construyendo las leyendas
                idioma.Leyendas = new List <LeyendaBE>();
                foreach (DataGridViewRow row in dgvLeyendas.Rows)
                {
                    LeyendaBE leyendaEsp = (LeyendaBE)row.Tag;
                    LeyendaBE leyenda    = new LeyendaBE
                    {
                        NombreControl = leyendaEsp.NombreControl,
                        NombreForm    = leyendaEsp.NombreForm,
                        Texto         = row.Cells[2].Value.ToString()
                    };
                    idioma.Leyendas.Add(leyenda);
                }

                try
                {
                    Idioma.Guardar(idioma);

                    MessageBox.Show(ObtenerLeyenda("msgGuardado"), ObtenerLeyenda("msgGuardadoTitulo"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _editando = false;
                    LimpiarForm();

                    List <IdiomaBE> idiomas = Idioma.ListarTodos();
                    lstIdiomasActuales.DataSource   = idiomas;
                    lstIdiomasActuales.SelectedItem = null;
                }
                catch
                {
                    MostrarError();
                }
            }
        }
Exemple #9
0
        public string ObtenerLeyenda(string Clave)
        {
            LeyendaBE leyenda = _leyendas.FirstOrDefault(l => l.NombreControl == Clave);

            return(leyenda != null ? leyenda.Texto : "");
        }