public void modificarCliente(int dni, string nombre, string apellido, int nroCalle, string calle, int idLocalidad, int telefono, string email) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("SP_MODIFICAR_CLIENTE"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[8]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@DNI", System.Data.SqlDbType.Int, dni); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 1, "@NOMBRE", System.Data.SqlDbType.VarChar, nombre); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 2, "@APELLIDO", System.Data.SqlDbType.VarChar, apellido); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 3, "@NROCALLE", System.Data.SqlDbType.SmallInt, nroCalle); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 4, "@CALLE", System.Data.SqlDbType.VarChar, calle); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 5, "@IDLOCALIDAD", System.Data.SqlDbType.Int, idLocalidad); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 6, "@TELEFONO", System.Data.SqlDbType.Int, telefono); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 7, "@EMAIL", System.Data.SqlDbType.VarChar, email); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
public void cargarLocalidad(string localidad) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("SP_AGREGAR_LOCALIDAD"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[1]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@LOCALIDAD", System.Data.SqlDbType.VarChar, localidad); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void agregarCliente(Clientes nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("SP_AGREGARCLIENTE"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@DNI", nuevo.DNI); accesoDatos.Comando.Parameters.AddWithValue("@Nombre", nuevo.Nombre); accesoDatos.Comando.Parameters.AddWithValue("@Apellido", nuevo.Apellido); accesoDatos.Comando.Parameters.AddWithValue("@Email", nuevo.Email); accesoDatos.Comando.Parameters.AddWithValue("@Direccion", nuevo.Direccion); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void agregarIngrediente(Ingrediente nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("AgregarIngrediente"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@NombreIngrediente", nuevo.Nombre); accesoDatos.Comando.Parameters.AddWithValue("@StockIngrediente", nuevo.Precio); accesoDatos.Comando.Parameters.AddWithValue("@UnidadMedida", nuevo.UM.IdUnidad); accesoDatos.Comando.Parameters.AddWithValue("@MasterPack", nuevo.Master); accesoDatos.Comando.Parameters.AddWithValue("@PrecioIngrediente", nuevo.Precio); accesoDatos.Comando.Parameters.AddWithValue("@FechaCreacion", nuevo.F_Add); accesoDatos.Comando.Parameters.AddWithValue("@UsuarioCreacion", nuevo.UserAdd.IdUsuario); accesoDatos.Comando.Parameters.AddWithValue("@FechaModificacion", nuevo.F_Mod); accesoDatos.Comando.Parameters.AddWithValue("@UsuarioModificacion", nuevo.UserMod.IdUsuario); accesoDatos.Comando.Parameters.AddWithValue("@Estado", nuevo.estado); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void modificarMedico(Medicos modificar) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { // accesoDatos.setearConsulta("Exec Modificarmedico set Nombre = @Nombre, Apellido = @Apellido Where Idmedico = @id"); accesoDatos.setearSP("modificarmedico"); //accesoDatos.setearConsulta("update MEDICOS Set Nombre= '"+modificar.Nombre+"', Apellido='"+modificar.Apellido+"', Idespecialidad="+modificar.Especialidad.idespecialidad.ToString()+" Where Id=" + modificar.IdMedico.ToString()); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@Nombre", modificar.Nombre); accesoDatos.Comando.Parameters.AddWithValue("@Apellido", modificar.Apellido); accesoDatos.Comando.Parameters.AddWithValue("@DNI", modificar.DNI); accesoDatos.Comando.Parameters.AddWithValue("@Email", modificar.Email); accesoDatos.Comando.Parameters.AddWithValue("@telefono", modificar.Telephone); accesoDatos.Comando.Parameters.AddWithValue("@TipoTel", modificar.TipoTel); accesoDatos.Comando.Parameters.AddWithValue("@id", modificar.IdMedico); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void agregarIngredientePorComida(IngreditePorComida nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("AgregarIngredientePorComida"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@IdComidas", nuevo.Comida.Id); accesoDatos.Comando.Parameters.AddWithValue("@IdIngredientes", nuevo.Ingrediente.Id); accesoDatos.Comando.Parameters.AddWithValue("@Cantidad", nuevo.Cantidad); accesoDatos.Comando.Parameters.AddWithValue("@FechaCreacion", nuevo.FechaCreacion); accesoDatos.Comando.Parameters.AddWithValue("@UsuarioCreacion", nuevo.UsuarioCreacion.IdUsuario); accesoDatos.Comando.Parameters.AddWithValue("@FechaModificacion", nuevo.FechaModificacion); accesoDatos.Comando.Parameters.AddWithValue("@UsuarioModificacion", nuevo.UsuarioModificacion.IdUsuario); accesoDatos.Comando.Parameters.AddWithValue("@Estado", nuevo.Estado); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void ModificarProducto(Producto nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_MODIFICAR_PRODUCTO"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@MARCA", nuevo.marca.Id); accesoDatos.Comando.Parameters.AddWithValue("@CATEGORIA", nuevo.categoria.Id); accesoDatos.Comando.Parameters.AddWithValue("@DESCRIPCION", nuevo.Descripcion); accesoDatos.Comando.Parameters.AddWithValue("@STOCK_ACTUAL", nuevo.StockActual); accesoDatos.Comando.Parameters.AddWithValue("@ID", nuevo.Id); accesoDatos.Comando.Parameters.AddWithValue("@STOCK_MINIMO", nuevo.StockMinimo); accesoDatos.Comando.Parameters.AddWithValue("@PRECIO", nuevo.PrecioVenta); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void ModificarCiente(Cliente nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_MODIFICAR_CLIENTE"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@DNI", nuevo.DNI); accesoDatos.Comando.Parameters.AddWithValue("@APELLIDO", nuevo.Apellido); accesoDatos.Comando.Parameters.AddWithValue("@NOMBRE", nuevo.Nombre); accesoDatos.Comando.Parameters.AddWithValue("@MAIL", nuevo.Mail); accesoDatos.Comando.Parameters.AddWithValue("@NUMERO", nuevo.telefono.Numero); accesoDatos.Comando.Parameters.AddWithValue("@TIPOTEL", nuevo.telefono.TipoDeTelefono); accesoDatos.Comando.Parameters.AddWithValue("@CALLE", nuevo.domicilio.Calle); accesoDatos.Comando.Parameters.AddWithValue("@ALTURA", nuevo.domicilio.Altura); accesoDatos.Comando.Parameters.AddWithValue("@CODPOS", nuevo.domicilio.CodigoPostal); accesoDatos.Comando.Parameters.AddWithValue("@LOCALIDAD", nuevo.domicilio.Localidad); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void ModificarVenta(Venta nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_MODIFICAR_VENTA"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@ID", nuevo.Id); accesoDatos.Comando.Parameters.AddWithValue("@COSTOTOTAL", nuevo.CostoTotal); accesoDatos.Comando.Parameters.AddWithValue("@METODOPAGO", nuevo.MetodoPago); accesoDatos.Comando.Parameters.AddWithValue("@TARJETA", nuevo.Tarjeta); accesoDatos.Comando.Parameters.AddWithValue("@CODIGO", nuevo.Codigo); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void agregarComida(Comida nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("AgregarComida"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@NombreComida", nuevo.Nombre); accesoDatos.Comando.Parameters.AddWithValue("@PrecioComida", nuevo.Precio); accesoDatos.Comando.Parameters.AddWithValue("@FechaCreacion", nuevo.F_Add); accesoDatos.Comando.Parameters.AddWithValue("@UsuarioCreacion", nuevo.UserAdd.IdUsuario); accesoDatos.Comando.Parameters.AddWithValue("@FechaModificacion", nuevo.F_Mod); accesoDatos.Comando.Parameters.AddWithValue("@UsuarioModificacion", nuevo.UserMod.IdUsuario); accesoDatos.Comando.Parameters.AddWithValue("@Estado", nuevo.Estado); accesoDatos.Comando.Parameters.AddWithValue("@TC", nuevo.TC.Id); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void AgregarFactura(Factura nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_AGREGAR_FACTURAXVENTA"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@ID", nuevo.Producto); accesoDatos.Comando.Parameters.AddWithValue("@IDPRODUCTO", nuevo.Producto); accesoDatos.Comando.Parameters.AddWithValue("@COSTO", nuevo.Costo); accesoDatos.Comando.Parameters.AddWithValue("@CANTIDAD", nuevo.Cantidad); accesoDatos.Comando.Parameters.AddWithValue("@SUBTOTAL", nuevo.SubTotal); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public int agregarCliente(Cliente nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("agregarCliente"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@DNI", nuevo.DNI); accesoDatos.Comando.Parameters.AddWithValue("@Nombre", nuevo.Nombre); accesoDatos.Comando.Parameters.AddWithValue("@Apellido", nuevo.Apellido); accesoDatos.Comando.Parameters.AddWithValue("@Email", nuevo.Email); accesoDatos.Comando.Parameters.AddWithValue("@Direccion", nuevo.Direccion); accesoDatos.Comando.Parameters.AddWithValue("@Ciudad", nuevo.Ciudad); accesoDatos.Comando.Parameters.AddWithValue("@CodigoPostal", nuevo.CodigoPostal); accesoDatos.Comando.Parameters.AddWithValue("@Fecha", nuevo.FechaRegistro); accesoDatos.abrirConexion(); return(accesoDatos.ejecutarAccionReturn()); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void pruebapro(prueba nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("pruebaagregar"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@id", nuevo.prod); accesoDatos.Comando.Parameters.AddWithValue("@cant", nuevo.cant); accesoDatos.Comando.Parameters.AddWithValue("@Tota", nuevo.total); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
private void btnCerrar_Click(object sender, EventArgs e) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("Cerrarmesa"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[2]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@id", System.Data.SqlDbType.Int, int.Parse(lblid.Text)); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 1, "@monto", System.Data.SqlDbType.Float, float.Parse(lbltotal.Text)); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } this.Close(); }
//INSERTA EL ID DEL PRODUCTO SELECCIONADO EN EL VOUCHER GANADOR USADO Y DA DE BAJA EL VOUCHER public void bajaVoucher(string idVoucher, int idProd) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("SP_BAJA_VOUCHER"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[2]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@ID_VOUCHER", System.Data.SqlDbType.VarChar, idVoucher); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 1, "@ID_PROD", System.Data.SqlDbType.Int, idProd); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
public void agregarProveedor(Proveedor nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_AGREGAR_PROVEEDOR"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@CUIT", nuevo.CUIT); accesoDatos.Comando.Parameters.AddWithValue("@RAZON_SOCIAL", nuevo.RazonSocial); accesoDatos.Comando.Parameters.AddWithValue("@CONTACTO", nuevo.NombreContacto); accesoDatos.Comando.Parameters.AddWithValue("@NUMERO", nuevo.telefono.Numero); accesoDatos.Comando.Parameters.AddWithValue("@TIPOTEL", nuevo.telefono.TipoDeTelefono); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
private void btnSalir_Click(object sender, EventArgs e) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("Cerrardia"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[1]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@id", System.Data.SqlDbType.Int, int.Parse(lblID.Text)); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } Environment.Exit(0); }
private void btnLogin_Click(object sender, EventArgs e) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("auth_login"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[2]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@usuario", System.Data.SqlDbType.VarChar, txtboxUsuario.Text); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 1, "@contrasenia", System.Data.SqlDbType.VarChar, txtboxContrasenia.Text); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP while (accesoDatos.Lector.Read()) { if (accesoDatos.Lector.GetString(0) == "OK") { if (accesoDatos.Lector.GetInt32(1) == 1) { frmMenuPrincipal MenuPrincipal = new frmMenuPrincipal(accesoDatos.Lector.GetInt32(2)); MenuPrincipal.Show(); this.Hide(); } else { frmCargarPedido frmCargarPedido = new frmCargarPedido(accesoDatos.Lector.GetInt32(2), accesoDatos.Lector.GetString(3)); frmCargarPedido.Show(); this.Hide(); } } else { lblLoginFail.Text = accesoDatos.Lector.GetString(0); } } } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
protected void btnLogin_ServerClick(object sender, EventArgs e) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("auth_login"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[2]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@usuario", System.Data.SqlDbType.VarChar, user.Value); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.agregarParametroSP(VectorParam, 1, "@contrasenia", System.Data.SqlDbType.VarChar, password.Value); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP while (accesoDatos.Lector.Read()) { if (accesoDatos.Lector.GetString(0) == "OK") { if (accesoDatos.Lector.GetInt32(1) == 1) { var cookie = new HttpCookie("session"); cookie.Values.Add("user", user.Value); cookie.Values.Add("type", accesoDatos.Lector.GetInt32(1).ToString()); cookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(cookie); Response.Redirect("BandejaMesas.aspx", false); } } else { } } } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
//BUSCA EL VOUCHER EN LA DB, SI NO ES VALIDO DEVUELVE UN ID="INVALIDO" //si el id es igual al de db, esta activo,fue comprado, no fue utilizado antes y esta en el sorteo actual, EN RESUMEN, VERIFICA SI ES VALIDO //PERO NO SI TIENE PREMIO public voucher buscarXID(string id) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); voucher voucher = new voucher("INVALIDO", DateTime.Now, false, 0, 0); try { accesoDatos.setearSP("SP_BUSCAR_VOUCHER_X_ID"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[1]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@ID_VOUCHER", System.Data.SqlDbType.VarChar, id); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP while (accesoDatos.Lector.Read()) { voucher voucherNew = new voucher(accesoDatos.Lector.GetString(0), accesoDatos.Lector.GetDateTime(1), accesoDatos.Lector.GetBoolean(2), accesoDatos.Lector.GetInt32(3), 0); voucher = voucherNew; } if (voucher.Id == id && voucher.Activo == true) { return(voucher); } else { voucher.Id = "INVALIDO"; return(voucher); } } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
public List <producto> listarPremiosXVoucher(string id) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); List <producto> ListProductos = new List <producto>(); try { accesoDatos.setearSP("SP_LISTAR_PROD_WIN_X_VOUCHER"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[1]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@ID_VOUCHER", System.Data.SqlDbType.VarChar, id); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP while (accesoDatos.Lector.Read()) { producto producto = new producto(); producto.Id = accesoDatos.Lector.GetInt32(0); producto.Nombre = accesoDatos.Lector.GetString(1); //producto.Url =accesoDatos.Lector.GetString(2); ListProductos.Add(producto); } return(ListProductos); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
//VERIFICA SI EL VOUCHER EXISTE EN LA DB CON CIERTAS CONDICIONES //si el id es igual al de db, esta activo,fue comprado, no fue utilizado antes y esta en el sorteo actual Y TIENE PREMIOS public bool isWin(string id) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); voucher voucher = this.buscarXID(id); bool result = false; try { //si lo encuentra revisa si tiene premios if (voucher.Id == id) { accesoDatos.setearSP("SP_IS_WIN"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[1]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@ID_VOUCHER", System.Data.SqlDbType.VarChar, voucher.Id); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP while (accesoDatos.Lector.Read()) { result = accesoDatos.Lector.GetBoolean(0); } } return(result); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
public void AgregarCompra(long id, long proveedor) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_AGREGAR_COMPRA"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@ID", id); accesoDatos.Comando.Parameters.AddWithValue("@IDPROVEEDOR", proveedor); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void ModificarStock(Producto nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_MODIFICAR_STOCK"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@STOCK_ACTUAL", nuevo.StockActual); accesoDatos.Comando.Parameters.AddWithValue("@ID", nuevo.Id); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void agregarProductoXProveedor(Proveedor nuevo, Producto producto, int precio) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_ACTUALIZAR_PRODUCTOSXPROVEEDORES"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@IDPROD", producto.Id); accesoDatos.Comando.Parameters.AddWithValue("@IDPROV", nuevo.CUIT); accesoDatos.Comando.Parameters.AddWithValue("@PRECIO", precio); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public int ContarErrores(int ticket) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); int resultado; try { accesoDatos.setearSP("sp_contar_errores"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@NTicket", ticket); accesoDatos.abrirConexion(); resultado = accesoDatos.ejecutarAccionReturn(); return(resultado); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public void AgregarVenta(long id, int dniEmpleado, int dniCliente) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("sp_AGREGAR_VENTA"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@ID", id); accesoDatos.Comando.Parameters.AddWithValue("@IDEMPLEADO", dniEmpleado); accesoDatos.Comando.Parameters.AddWithValue("@DNICLIENTE", dniCliente); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }
public cliente buscarXDni(int dni) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); cliente c = new cliente(); try { accesoDatos.setearSP("SP_BUSCAR_CLIENTE_X_DNI"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[1]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@DNI", System.Data.SqlDbType.Int, dni); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP while (accesoDatos.Lector.Read()) { string localidad = buscarLocalidadXId(accesoDatos.Lector.GetInt32(5)); c = new cliente(accesoDatos.Lector.GetInt32(0), accesoDatos.Lector.GetString(1), accesoDatos.Lector.GetString(2), accesoDatos.Lector.GetInt16(3), accesoDatos.Lector.GetString(4), localidad, accesoDatos.Lector.GetInt32(6), accesoDatos.Lector.GetString(7)); } return(c); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
public bool verificarCliente(int dni) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("SP_VERIFICAR_CLIENTE"); //SETEO EL SP SqlParameter[] VectorParam = new SqlParameter[1]; //no funciona con lista, aqui se debe agregar la cantidad de parametros totales accesoDatos.agregarParametroSP(VectorParam, 0, "@DNI", System.Data.SqlDbType.Int, dni); // AGREGO UN PARAMETRO AL VECTOR EN ESA POSICION accesoDatos.Comando.Parameters.AddRange(VectorParam); //AGREGO LA MATRIZ DE PARAMETROS A LOS PARAMETROS DEL COMANDO accesoDatos.abrirConexion(); // abro conexion accesoDatos.ejecutarConsulta(); //EJECUTO EL SP bool validar = false; while (accesoDatos.Lector.Read()) { validar = accesoDatos.Lector.GetBoolean(0); } return(validar); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion();//CIERRO CONEXION } }
public void agregarVoucher(Voucher nuevo) { AccesoDatosManager accesoDatos = new AccesoDatosManager(); try { accesoDatos.setearSP("agregarVoucher"); accesoDatos.Comando.Parameters.Clear(); accesoDatos.Comando.Parameters.AddWithValue("@Codigo", nuevo.CodigoVoucher); accesoDatos.Comando.Parameters.AddWithValue("@Cliente", nuevo.Cliente.ID); accesoDatos.Comando.Parameters.AddWithValue("@Producto", nuevo.Producto.ID); accesoDatos.Comando.Parameters.AddWithValue("@Fecha", nuevo.FechaRegistro); accesoDatos.abrirConexion(); accesoDatos.ejecutarAccion(); } catch (Exception ex) { throw ex; } finally { accesoDatos.cerrarConexion(); } }