public static Empresa informacionEmpresa(object[] pArgumentos) { Empresa resultado = new Empresa(); SqlDataReader dataReader = null; try { dataReader = SqlServer.Instance.traerDataReader("informacionCompañia", pArgumentos); if (dataReader.HasRows) { dataReader.Read(); resultado.CedulaJuridica = (long)dataReader[0]; resultado.Telefono = (long)dataReader[1]; resultado.Fax = (long)dataReader[2]; resultado.Imagen = (byte[])dataReader[3]; } } catch (Exception ex) { throw new Exception(ex.Message); } finally { SqlServer.Instance.cerrarDataReader(dataReader); SqlServer.Instance.CerrarConexion(); } return resultado; }
public static void introducirTipo(Empresa pempresa, Periodo pperiodo, string ptipo) { try { AccesoEmpresas.introducirTipo(new object[] { pempresa, pperiodo, ptipo }); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static void introducirEmpresa(Empresa pempresa) { try { AccesoEmpresas.introducirEmpresa(new object[] { pempresa.Nombre, pempresa.CedulaJuridica, pempresa.Telefono, pempresa.Fax, pempresa.Imagen, pempresa.MonedaLocal, pempresa.MonedaSistema }); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List<Periodo> obtenerFechaPeriodo(Empresa pempresa) { List<Periodo> fechas = new List<Periodo>(); try { fechas = AccesoEmpresas.obtenerPeriodo(new object[] { pempresa }); } catch (Exception ex) { throw new Exception(ex.Message); } return fechas; }
public static Empresa informacionEmpresa(string pNombreEmpresa) { Empresa empresa = new Empresa(); try { empresa = AccesoEmpresas.informacionEmpresa(new object[] { pNombreEmpresa }); FileStream file = new FileStream("logo.jpg", FileMode.Create); file.Write(empresa.Imagen, 0, empresa.Imagen.Length); file.Close(); file = null; } catch (Exception ex) { throw new Exception(ex.Message); } return empresa; }
public static List<string> obtenerPeriodo(Empresa pempresa) { List<string> fechas = new List<string>(); List<Periodo> periodo = new List<Periodo>(); int contador; try { periodo = obtenerFechaPeriodo(pempresa); } catch (Exception ex) { throw new Exception(ex.Message); } for (contador = 0; contador < fechas.Count; contador++) { string desplegar = ""; desplegar = periodo[contador].FechaInicio.ToString(); desplegar += "-"; desplegar += periodo[contador].FechaFin.ToString(); fechas.Add(desplegar); } return fechas; }
private void buttonCrearEmpresa_Click(object sender, EventArgs e) { // Stream usado como buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Se guarda la imagen en el buffer pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); // Se extraen los bytes del buffer para asignarlos como valor para el // parámetro. Empresa empresaNueva = new Empresa(); empresaNueva.Nombre = textBoxNombreEmpresa.Text; empresaNueva.CedulaJuridica = Convert.ToInt64(textBoxCedulaJuridica.Text); empresaNueva.Telefono = Convert.ToInt64(textBoxTelefono.Text); empresaNueva.Fax = Convert.ToInt64(textBoxFax.Text); empresaNueva.MonedaLocal = comboBoxMonedaLocalEmpresa.SelectedItem.ToString(); empresaNueva.MonedaSistema = comboBoxMonedaSistemaEmpresa.SelectedItem.ToString(); empresaNueva.Imagen = ms.GetBuffer(); LogicaEmpresas.introducirEmpresa(empresaNueva); MessageBox.Show("La empresa ha sido insertada", "Información", MessageBoxButtons.OK); }