コード例 #1
0
        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();
        }
コード例 #2
0
        //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
            }
        }
コード例 #3
0
ファイル: frmLogin.cs プロジェクト: FacuMuniz/TPC_Mu-iz
        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
            }
        }
コード例 #4
0
        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
            }
        }
コード例 #5
0
        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
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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();
            }
        }
コード例 #8
0
        //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
            }
        }
コード例 #9
0
        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
            }
        }
コード例 #10
0
        //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
            }
        }
コード例 #11
0
        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
            }
        }
コード例 #12
0
        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
            }
        }
コード例 #13
0
        //BUSCAR EL ID DE LA LOCALIDAD, si no encuentra devuelve -1
        public int buscarIdXLocalidad(string Localidad)
        {
            AccesoDatosManager accesoDatos = new AccesoDatosManager();
            int result = -1;

            try
            {
                accesoDatos.setearSP("SP_BUSCAR_ID_X_LOC");                                                             //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


                while (accesoDatos.Lector.Read())
                {
                    result = accesoDatos.Lector.GetInt32(0);
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                accesoDatos.cerrarConexion();//CIERRO CONEXION
            }
        }