private void btnSeleccionar_Click(object sender, EventArgs e) { try { Modelos.UsoLogos uso = (Modelos.UsoLogos) this.cmbUso.SelectedItem; bool resultado; if (this._quitaLogo) { resultado = this._catalogosNegocio.seleccionarLogo(-1, uso); // bitacora this._catalogosNegocio.generaBitacora( "Logo removido para el uso '" + uso.nombre + "'", "ARCHIVO - CONFIGURACION"); MessageBox.Show("Logo removido correctamente", "Configuración", MessageBoxButtons.OK, MessageBoxIcon.Information); this._quitaLogo = false; this.btnSeleccionar.Text = "Seleccionar"; this.cmbUso.SelectedIndex = -1; } else { if (this.cmbUso.SelectedIndex == -1) { throw new Exception("Elija un uso"); } if (this._logo == null) { throw new Exception("Elija un logo"); } resultado = this._catalogosNegocio.seleccionarLogo(this._logo.idLogo, uso); if (resultado) { // bitacora this._catalogosNegocio.generaBitacora( "Logo Seleccionado " + this._logo.idLogo + " para el uso '" + uso.nombre + "'", "ARCHIVO - CONFIGURACION"); MessageBox.Show("Logo cambiado para '" + uso.nombre + "' correctamente", "Configuración", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { throw new Exception("Problemas al seleccionar el logo"); } } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Configuración", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnSubirSubir_Click(object sender, EventArgs e) { try { // validaciones if (string.IsNullOrEmpty(this.tbSubirNombre.Text)) { throw new Exception("Defina un nombre para el logo"); } if (string.IsNullOrEmpty(this.tbSubirDescripcion.Text)) { throw new Exception("Defina una descripción para el logo"); } else { if (this.tbSubirDescripcion.Text.Trim().Length < 10) { this.label4.ForeColor = System.Drawing.Color.Red; this.label4.Text = "Descripción*"; throw new Exception("La longitud miníma permitida para la Descripción es de 10 carácteres"); } else { this.label4.ForeColor = System.Drawing.Color.Black; this.label4.Text = "Descripción"; } } if (!string.IsNullOrEmpty(this.tbSubirObserv.Text)) { if (this.tbSubirObserv.Text.Trim().Length < 10) { this.label5.ForeColor = System.Drawing.Color.Red; this.label5.Text = "Observaciones*"; throw new Exception("La longitud miníma permitida para las Observaciones es de 10 carácteres"); } this.label5.ForeColor = System.Drawing.Color.Black; this.label5.Text = "Observaciones"; } if (this.cmbSubirUso.SelectedIndex == -1) { throw new Exception("Seleccione un uso"); } if (this.pbSubirImagen.Image == null) { throw new Exception("Suba un logo"); } Modelos.UsoLogos uso = (Modelos.UsoLogos) this.cmbSubirUso.SelectedItem; string nombre = this.tbSubirNombre.Text; string descripcion = this.tbSubirDescripcion.Text; string observaciones = this.tbSubirObserv.Text; bool seleccionar = this.cbSubirSelLogo.Checked; byte[] logo = Modelos.Utilerias.ImageToByte(this.pbSubirImagen.Image); bool resultado = this._catalogosNegocio.subirLogo(uso, nombre, descripcion, observaciones, seleccionar, logo); if (resultado) { // bitacora this._catalogosNegocio.generaBitacora( "Logo Subido " + (seleccionar ? "y seleccionado" : string.Empty) + " para el uso '" + uso.nombre + "'", "ARCHIVO - CONFIGURACION"); MessageBox.Show( "Logo subido " + (seleccionar ? "y seleccionado" : string.Empty) + " correctamente", "Configuración", MessageBoxButtons.OK, MessageBoxIcon.Information); this.tbSubirNombre.Text = string.Empty; this.tbSubirDescripcion.Text = string.Empty; this.tbSubirObserv.Text = string.Empty; this.cmbSubirUso.SelectedIndex = -1; this.tbSubirArchivo.Text = string.Empty; this.pbSubirImagen.Image = null; this.cbSubirSelLogo.Checked = false; } else { throw new Exception("Problemas al subir el logo"); } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Configuración", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }