public int Guardar_Datos_Generales(CEDatosGenerales objDG) { int resultado; try { SqlCommand cmd = new SqlCommand("Sp_Guardar_Datos_Generales", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Id_Dato", SqlDbType.Int).Value = objDG.Id_Dato; cmd.Parameters.Add("@Nombre_Parroquia", SqlDbType.NVarChar, 100).Value = objDG.Nombre_Parroquia; cmd.Parameters.Add("@Direccion", SqlDbType.NVarChar, 300).Value = objDG.Direccion; cmd.Parameters.Add("@Telefono", SqlDbType.Char, 9).Value = objDG.Telefono; cmd.Parameters.Add("@Id_Usuario", SqlDbType.Int).Value = objDG.Id_Usuario; cmd.Parameters.Add("@Logo", SqlDbType.Image).Value = objDG.Logo; cmd.Parameters.Add("@Usa_Logo", SqlDbType.Bit).Value = objDG.Usa_Logo; ConectarBD(); resultado = cmd.ExecuteNonQuery(); cmd.Dispose(); } catch (Exception ex) { throw new Exception("Error al almacenar los datos.", ex); } finally { CerrarBD(); } return(resultado); }
private void CargarDatosGenerales() { CNDatosGenerales objDatos = new CNDatosGenerales(); CEDatosGenerales objDatosG = new CEDatosGenerales(); objDatosG = objDatos.Mostrar_Datos(); lblNombreParroquia.Text = "Parroquia " + objDatosG.Nombre_Parroquia; Funciones.Funciones.nombreParroquia = "Parroquia " + objDatosG.Nombre_Parroquia; this.Text = objDatosG.Nombre_Parroquia; MemoryStream ms = new MemoryStream((byte[])objDatosG.Logo); pELogo.Image = Image.FromStream(ms); Funciones.Funciones.logo = objDatosG.Logo; usa_logo = objDatosG.Usa_Logo; }
private void CargarDatosGenerales() { CNDatosGenerales objDatos = new CNDatosGenerales(); CEDatosGenerales objDatosG = new CEDatosGenerales(); objDatosG = objDatos.Mostrar_Datos(); txtNombre.EditValue = objDatosG.Nombre_Parroquia; meDireccion.EditValue = objDatosG.Direccion; txtTelefono.EditValue = objDatosG.Telefono; this.Text = objDatosG.Nombre_Parroquia; MemoryStream ms = new MemoryStream((byte[])objDatosG.Logo); pELogo.Image = Image.FromStream(ms); cEUsarLogo.Checked = objDatosG.Usa_Logo; }
private void btnGuardar_Click(object sender, EventArgs e) { MemoryStream ms = new MemoryStream(); if (pELogo.Image != null) { pELogo.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } else { pELogo.Image = Properties.Resources.general; pELogo.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); } this.Validate(); if (Validar()) { CNDatosGenerales objNegocioDatos = new CNDatosGenerales(); CEDatosGenerales objDatosG = new CEDatosGenerales() { Id_Dato = Convert.ToInt32(1), Nombre_Parroquia = txtNombre.Text.Trim(), Direccion = meDireccion.Text.Trim(), Telefono = txtTelefono.Text.Trim(), Id_Usuario = Convert.ToInt32(6), Logo = ms.GetBuffer(), Usa_Logo = cEUsarLogo.Checked }; if (objNegocioDatos.Guardar_Datos_Generales(objDatosG) > 0) { Limpiar(); XtraMessageBox.Show("Registro almacenado satisfactoriamente", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { XtraMessageBox.Show("Error al almacenar los datos.", "Parroquia", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public CEDatosGenerales MostrarDatosGenerales() { SqlCommand cmd; SqlDataReader dr; CEDatosGenerales objD = new CEDatosGenerales(); try { ConectarBD(); cmd = new SqlCommand("Sp_Mostrar_Datos_Generales", cn); cmd.CommandType = CommandType.StoredProcedure; dr = cmd.ExecuteReader(); if (dr.Read()) { objD.Id_Dato = int.Parse(dr["Id_Dato"].ToString()); objD.Nombre_Parroquia = dr["Nombre_Parroquia"].ToString(); objD.Direccion = dr["Direccion"].ToString(); objD.Telefono = dr["Telefono"].ToString(); objD.Telefono = dr["Telefono"].ToString(); objD.Logo = (byte[])dr["Logo"]; objD.Usa_Logo = Boolean.Parse(dr["Usa_Logo"].ToString()); } return(objD); } catch (Exception ex) { throw new Exception("Error al solicitar los datos. ", ex); } finally { CerrarBD(); } }
public int Guardar_Datos_Generales(CEDatosGenerales objDG) { return(objD.Guardar_Datos_Generales(objDG)); }