public int Actualizar(OrdenPago oBe) { int res = 0; SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_OrdenPago_ACTUALIZAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = oBe.ID; cmd.Parameters.Add("@sucursal_id", SqlDbType.Int).Value = oBe.sucursal_id; cmd.Parameters.Add("@monto", SqlDbType.Decimal, 18).Value = oBe.monto; cmd.Parameters.Add("@moneda", SqlDbType.VarChar, 10).Value = oBe.moneda; cmd.Parameters.Add("@estado", SqlDbType.VarChar, 20).Value = oBe.estado; cmd.Parameters.Add("@fecha_pago", SqlDbType.DateTime).Value = oBe.fecha_pago; try { oConexion.Open(); res = cmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } return(res); }
private void BtnUbicacion_Click(object sender, EventArgs e) { ConexionSQLServer.Conectar(); //FormatoMiles_Simbolo MessageBox.Show(ConexionSQLServer.Respuesta); // Se crea el OpenFileDialog OpenFileDialog dialog = new OpenFileDialog(); // Se muestra al usuario esperando una acción DialogResult result = dialog.ShowDialog(); // Si seleccionó un archivo (asumiendo que es una imagen lo que seleccionó) // la mostramos en el PictureBox de la inferfaz if (result == DialogResult.OK) { string filename = dialog.FileName; if (Regex.IsMatch(filename.ToLower(), @"^.*\.(txt)$")) { ConexionSQLServer.Guardar_Arcivo(filename, "conexion", "conexion", "txt"); MessageBox.Show(ConexionSQLServer.error); } else { MessageBox.Show("El archivo seleccionado no es valido \n la extención debe ser .tex"); } } }
public BancoRespuesta Actualizar(Banco oBe) { DTOHeader oDTOHeader = new DTOHeader(); BancoRespuesta objResponse = new BancoRespuesta(); SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_Banco_ACTUALIZAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = oBe.ID; cmd.Parameters.Add("@nombre", SqlDbType.VarChar, 50).Value = oBe.nombre; cmd.Parameters.Add("@direccion", SqlDbType.VarChar, 50).Value = oBe.direccion; cmd.Parameters.Add("@fecha_registro", SqlDbType.Date).Value = oBe.fecha_registro; try { oConexion.Open(); oDTOHeader.CodigoOK_BD = cmd.ExecuteNonQuery(); } catch (Exception ex) { oDTOHeader.DescRetorno = ex.Message; } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } objResponse.DTOHeader = oDTOHeader; return(objResponse); }
public BancoRespuesta Eliminar(Int32 ID) { DTOHeader oDTOHeader = new DTOHeader(); BancoRespuesta objResponse = new BancoRespuesta(); SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_Banco_ELIMINAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = ID; try { oConexion.Open(); oDTOHeader.CodigoOK_BD = cmd.ExecuteNonQuery(); } catch (Exception ex) { oDTOHeader.DescRetorno = ex.Message; } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } objResponse.DTOHeader = oDTOHeader; return(objResponse); }
public InformePresupuesto(int idpresupuesto) { InitializeComponent(); conexion = new ConexionSQLServer(); idPresupuesto = idpresupuesto; cargarInforme(); }
public int Actualizar(Sucursales oBe) { int res = 0; SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_Sucursales_ACTUALIZAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = oBe.ID; cmd.Parameters.Add("@banco_id", SqlDbType.Int).Value = oBe.banco_id; cmd.Parameters.Add("@nombre", SqlDbType.VarChar, 50).Value = oBe.nombre; cmd.Parameters.Add("@direccion", SqlDbType.VarChar, 50).Value = oBe.direccion; cmd.Parameters.Add("@fecha_registro", SqlDbType.Date).Value = oBe.fecha_registro; try { oConexion.Open(); res = cmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } return(res); }
public int Eliminar(Int32 ID) { int res = 0; SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_Sucursales_ELIMINAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = ID; try { oConexion.Open(); res = cmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } return(res); }
public NegocioUsuario() { ConexionBD = new ConexionSQLServer(); ConexionBD.Server = ConexionConfig.Server; ConexionBD.Database = ConexionConfig.Database; ConexionBD.Connect(); }
public IUPresupuesto() { InitializeComponent(); DoubleBuffered = true; conexion = new ConexionSQLServer(); funciones = new MetodosComunes(); actualizarDGV(); conexion.rellenacombobox(cmbLocalidad, "select idlocalidad, descripcion from localidades order by descripcion", "--Seleccionar Localidad--"); }
public AnadirPresupuesto(Boolean modificar, int idcliente, int presupuesto) { InitializeComponent(); DoubleBuffered = true; consultas = new ConexionSQLServer(); funciones = new MetodosComunes(); listaEliminar = new List <String>(); idCliente = idcliente; Modificar = modificar; Refpresupuesto = presupuesto; rellenarDatosCliente(); txtCalidades.Text = consultas.selectstring("select descripcion from Presu_Calidades where idcalidad=" + 1); if (Modificar == true) { rellenarDatosPresupuesto(); } }
public void InsertUser(Vehiculo u) { csql = new ConexionSQLServer(); SqlCommand cmd = null; SqlConnection con = csql.Abrir(); string query = "INSERT INTO Vehiculo(NumSerie,Precio, Version_, Color, Tipo, CodigoCat)" + "VALUES(@NumSerie,@Precio, @Version_, @Color, @Tipo, @CodigoCat)"; cmd = new SqlCommand(query, con); //Estamos especificando el tipo de dato del parametro cmd.Parameters.Add("@NumSerie", SqlDbType.VarChar); cmd.Parameters.Add("@Precio", SqlDbType.VarChar); cmd.Parameters.Add("@Version_", SqlDbType.VarChar); cmd.Parameters.Add("@Color", SqlDbType.VarChar); cmd.Parameters.Add("@Tipo", SqlDbType.VarChar); cmd.Parameters.Add("@CodigoCat", SqlDbType.Int); //Asignar valores a los parametros cmd.Parameters["@NumSerie"].Value = u.NumSerie; cmd.Parameters["@Precio"].Value = u.Precio; cmd.Parameters["@Version_"].Value = u.Version; cmd.Parameters["@Color"].Value = u.Color; cmd.Parameters["@Tipo"].Value = u.Tipo; cmd.Parameters["@CodigoCat"].Value = u._Categoria.Codigo; //EjecutarComando int R = cmd.ExecuteNonQuery(); if (R > 0) { MessageBox.Show("Insersion exitosa"); } else { MessageBox.Show("No se logró la insercion"); } csql.Cerrar(); }
public void InsertUser(Cliente u) { csql = new ConexionSQLServer(); SqlCommand cmd = null; SqlConnection con = csql.Abrir(); string query = "INSERT INTO Cliente(Nombre,ApMaterno, ApPaterno, Email, IdUsuario)" + "VALUES(@Nombre, @ApMaterno, @ApPaterno, @Email, @IdUsuario)"; cmd = new SqlCommand(query, con); //Estamos especificando el tipo de dato del parametro cmd.Parameters.Add("@Nombre", SqlDbType.VarChar); cmd.Parameters.Add("@ApMaterno", SqlDbType.VarChar); cmd.Parameters.Add("@ApPaterno", SqlDbType.VarChar); cmd.Parameters.Add("@Email", SqlDbType.VarChar); cmd.Parameters.Add("@IdUsuario", SqlDbType.Int); //Asignar valores a los parametros cmd.Parameters["@Nombre"].Value = u.Nombre; cmd.Parameters["@ApMaterno"].Value = u.ApMaterno; cmd.Parameters["@ApPaterno"].Value = u.ApPaterno; cmd.Parameters["@Email"].Value = u.Email; cmd.Parameters["@IdUsuario"].Value = u.IdUsuario; //EjecutarComando int R = cmd.ExecuteNonQuery(); if (R > 0) { MessageBox.Show("Insersion exitosa"); } else { MessageBox.Show("No se logró la insercion"); } csql.Cerrar(); }
public List <OrdenPago> Listar(OrdenPago oBE) { SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_OrdenPago_LISTAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@sucursal_id", SqlDbType.Int).Value = oBE.sucursal_id; cmd.Parameters.Add("@moneda", SqlDbType.VarChar, 10).Value = oBE.moneda; List <OrdenPago> lista = new List <OrdenPago>(); try { oConexion.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OrdenPago entidad = new OrdenPago(); int iID = reader.GetOrdinal("ID"); if (!reader.IsDBNull(iID)) { entidad.ID = reader.GetInt32(iID); } int isucursal_id = reader.GetOrdinal("sucursal_id"); if (!reader.IsDBNull(isucursal_id)) { entidad.sucursal_id = reader.GetInt32(isucursal_id); } int imonto = reader.GetOrdinal("monto"); if (!reader.IsDBNull(imonto)) { entidad.monto = reader.GetDecimal(imonto); } int imoneda = reader.GetOrdinal("moneda"); if (!reader.IsDBNull(imoneda)) { entidad.moneda = reader.GetString(imoneda); } int iestado = reader.GetOrdinal("estado"); if (!reader.IsDBNull(iestado)) { entidad.estado = reader.GetString(iestado); } int ifecha_pago = reader.GetOrdinal("fecha_pago"); if (!reader.IsDBNull(ifecha_pago)) { entidad.fecha_pago = reader.GetDateTime(ifecha_pago); } lista.Add(entidad); entidad = null; } reader.Close(); } catch (Exception ex) { } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } return(lista); }
private void Button_Click_3(object sender, RoutedEventArgs e) { ConexionSQLServer csql = new ConexionSQLServer(); csql.Abrir(); }
public BancoRespuesta GetReg(Int32 ID) { DTOHeader oDTOHeader = new DTOHeader(); BancoRespuesta objResponse = new BancoRespuesta(); SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_Banco_GETREG", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = ID; Banco entidad = null; try { oConexion.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { entidad = new Banco(); int iID = reader.GetOrdinal("ID"); if (!reader.IsDBNull(iID)) { entidad.ID = reader.GetInt32(iID); } int inombre = reader.GetOrdinal("nombre"); if (!reader.IsDBNull(inombre)) { entidad.nombre = reader.GetString(inombre); } int idireccion = reader.GetOrdinal("direccion"); if (!reader.IsDBNull(idireccion)) { entidad.direccion = reader.GetString(idireccion); } int ifecha_registro = reader.GetOrdinal("fecha_registro"); if (!reader.IsDBNull(ifecha_registro)) { entidad.fecha_registro = reader.GetDateTime(ifecha_registro); } } reader.Close(); } catch (Exception ex) { oDTOHeader.DescRetorno = ex.Message; } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } objResponse.Entidad = entidad; objResponse.DTOHeader = oDTOHeader; return(objResponse); }
public List <Sucursales> Listar(Sucursales oBE) { SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_Sucursales_LISTAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@banco_id", SqlDbType.Int).Value = oBE.banco_id; cmd.Parameters.Add("@nombre", SqlDbType.VarChar, 50).Value = oBE.nombre; List <Sucursales> lista = new List <Sucursales>(); try { oConexion.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Sucursales entidad = new Sucursales(); int iID = reader.GetOrdinal("ID"); if (!reader.IsDBNull(iID)) { entidad.ID = reader.GetInt32(iID); } int ibanco_id = reader.GetOrdinal("banco_id"); if (!reader.IsDBNull(ibanco_id)) { entidad.banco_id = reader.GetInt32(ibanco_id); } int inombre = reader.GetOrdinal("nombre"); if (!reader.IsDBNull(inombre)) { entidad.nombre = reader.GetString(inombre); } int idireccion = reader.GetOrdinal("direccion"); if (!reader.IsDBNull(idireccion)) { entidad.direccion = reader.GetString(idireccion); } int ifecha_registro = reader.GetOrdinal("fecha_registro"); if (!reader.IsDBNull(ifecha_registro)) { entidad.fecha_registro = reader.GetDateTime(ifecha_registro); } lista.Add(entidad); entidad = null; } reader.Close(); } catch (Exception ex) { } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } return(lista); }
public BancoRespuesta Listar(Banco oBE) { DTOHeader oDTOHeader = new DTOHeader(); BancoRespuesta objResponse = new BancoRespuesta(); SqlConnection oConexion = new SqlConnection(ConexionSQLServer.DB_Comercio()); SqlCommand cmd = new SqlCommand("PA_Banco_LISTAR", oConexion); cmd.CommandType = CommandType.StoredProcedure; List <Banco> lista = new List <Banco>(); try { oConexion.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Banco entidad = new Banco(); int iID = reader.GetOrdinal("ID"); if (!reader.IsDBNull(iID)) { entidad.ID = reader.GetInt32(iID); } int inombre = reader.GetOrdinal("nombre"); if (!reader.IsDBNull(inombre)) { entidad.nombre = reader.GetString(inombre); } int idireccion = reader.GetOrdinal("direccion"); if (!reader.IsDBNull(idireccion)) { entidad.direccion = reader.GetString(idireccion); } int ifecha_registro = reader.GetOrdinal("fecha_registro"); if (!reader.IsDBNull(ifecha_registro)) { entidad.fecha_registro = reader.GetDateTime(ifecha_registro); } lista.Add(entidad); entidad = null; } reader.Close(); oDTOHeader.CodigoOK_BD = Constantes.Exito.Ok; } catch (Exception ex) { oDTOHeader.DescRetorno = ex.Message; } finally { if (oConexion.State == ConnectionState.Open) { oConexion.Close(); } cmd.Dispose(); oConexion.Dispose(); } objResponse.Lista = lista; objResponse.DTOHeader = oDTOHeader; return(objResponse); }