Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    int id = int.Parse(Request.QueryString["id"]);

                    BO.User user = UserBLL.getUser(id);

                    name.Value     = user.name.ToString();
                    type.Value     = user.type.ToString();
                    email.Value    = user.email.ToString();
                    password.Value = user.password.ToString();
                    phone.Value    = user.phone.ToString();


                    btnAccept.CommandName     = "Edit";
                    btnAccept.CommandArgument = Request.QueryString["id"];
                    btnDelete.CommandArgument = Request.QueryString["id"];


                    lblTitle.Text = "<h3>Sửa người dùng " + user.id.ToString() + "</h3>";
                }
                else
                {
                    btnAccept.CommandName = "Add";
                    lblTitle.Text         = "<h3>Thêm người dùng</h3>";
                }
            }
        }
Esempio n. 2
0
 public OrdenCompra(ArrayList items, int numero, User cliente, string estado)
 {
     _items = items;
     _numero = numero;
     _Cliente = cliente;
     _estado = estado;
     foreach (Item I in items)
     {
         _subtotal += I.Total;
     }
 }
Esempio n. 3
0
 public void UpdateUser(BO.User user)
 {
     try
     {
         dl.UpdateUser(UserBoDoAdapter(user));
     }
     catch (DO.BadUserNameException ex)
     {
         throw new BO.BadUserNameException(ex.Message, ex);
     }
 }
        public int GenerarOrden(Carrito carrito,User usuario)
        {
            try
            {
                if (carrito.DameFuego().Count > 0)
                {
                    //throw new Exception("The method or operation is not implemented.");
                    _orden = new OrdenCompra(carrito, usuario);

                }
                return miDAO.grabarCompra(_orden);
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error Generando orden",ex);
            }
        }
Esempio n. 5
0
        public void AgregarUsuario(BO.User usuario)
        {
            try
            {
                connServ.Abrir();

                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = "INSERT INTO Usuarios (categoria,apellido,nombre,pass,domicilio,email,nickname)VALUES(" + usuario.Categoria + ", '" + usuario.Apellido + "', '" + usuario.Nombre + "', '" + usuario.Pass + "', '" + usuario.Domicilio + "', '" + usuario.Email + "', '" + usuario.NickName + "')";
                    command.Connection  = connServ.Conexion();

                    command.ExecuteNonQuery();
                }
                connServ.Cerrar();
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error Agregando Categoria", ex);
            }
        }
Esempio n. 6
0
        public User Logueo(string Nick, string Pass)
        {
            User result = null;
            ///hago un select y si me lo devuelve es que esta logeado
            try
            {

                connServ.Abrir();

                using (SqlCommand command = new SqlCommand())
                {   //                                 0          1         2       3     4      5        6       7
                    command.CommandText = "SELECT id_usuario,categoria,apellido,nombre,pass,domicilio,email,nickname FROM Usuarios where nickname='"+Nick+"' and pass='******'";
                    command.Connection = connServ.Conexion();

                    SqlDataReader rdr = command.ExecuteReader();

                    while (rdr.Read())
                    {
                        result = new User(rdr.GetString(3), rdr.GetString(2), rdr.GetString(6), rdr.GetString(7), rdr.GetString(4), rdr.GetString(5), rdr.GetInt32(0), rdr.GetInt32(1));

                    }
                }
                connServ.Cerrar();

            }

            catch (Exception e)
            {
                throw new ArgumentException("Error Cargando LEYENDO USUARIOS", e);
            }
            if (result == null)
            {
                throw new Exception("ERROR DE LOGIN");
            }
            return result;
        }
Esempio n. 7
0
        protected void Accept_Add(object sender, EventArgs e)
        {
            BO.User user = new BO.User();

            if (name.Value != "")
            {
                user.name = name.Value;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Tên người dùng không được bỏ trống')</script>");
                name.Focus();
                return;
            }

            if (email.Value != "")
            {
                user.email = email.Value;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Email không được bỏ trống')</script>");
                email.Focus();
                return;
            }

            if (password.Value != "")
            {
                user.password = password.Value;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Mật khẩu không được bỏ trống')</script>");
                password.Focus();
                return;
            }

            if (phone.Value != "")
            {
                user.phone = phone.Value;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Điện thoại không được bỏ trống')</script>");
                phone.Focus();
                return;
            }

            user.type = int.Parse(type.Value);

            if (UserBLL.addUser(user))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                    "alert('Thêm người dùng thành công'); window.location='" +
                                                    Request.ApplicationPath + "Admin/User.aspx';", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                    "alert('Xảy ra lỗi'); window.location='" +
                                                    Request.ApplicationPath + "Admin/UserForm.aspx';", true);
            }
        }
        public ArrayList LeerOrdenes(string estado)
        {
            try
            {
                ListaOrdenes.Clear();
                connServ.Abrir();

                using (SqlCommand command = new SqlCommand())
                {   //                                0        1         2         3          4         5        6
                    command.CommandText = "SELECT id_orden,pendiente,total_iva,subtotal,total_envio,id_cliente,fecha from OrdenesCompra WHERE pendiente='"+estado+"'";
                    command.Connection = connServ.Conexion();

                    SqlDataReader rdr = command.ExecuteReader();

                    while (rdr.Read())
                    {
                        //int StockComprometido = Convert.ToInt32(rdr.GetValue(7));
                        OrdenCompra Orden = new OrdenCompra();
                        Orden.Envio = Convert.ToDouble(rdr.GetValue(4));
                        Orden.Estado = rdr.GetValue(1).ToString();
                        Orden.Iva = Convert.ToDouble(rdr.GetValue(2));
                        Orden.Numero = (int)rdr.GetValue(0);
                        Orden.Items = new ArrayList();

                        User Usuario = new User();
                        Usuario.Id = (int)rdr.GetValue(5);
                        Orden.Cliente = Usuario;

                        ListaOrdenes.Add(Orden);
                    }
                    rdr.Close();
                }
                connServ.Cerrar();
                CompletarListaOrdenes();
                return ListaOrdenes;
            }
            catch
            {
                throw new ArgumentException("Error Leyendo Ordenes de Compra");
            }
        }
Esempio n. 9
0
        public ArrayList TodosLosUsuarios()
        {
            ArrayList ListaUsuarios=new ArrayList();
            connServ.Abrir();

            using (SqlCommand command3 = new SqlCommand())
            {   //                                 0          1         2       3     4      5        6       7
                command3.CommandText = "SELECT id_usuario,categoria,apellido,nombre,pass,domicilio,email,nickname FROM Usuarios";
                command3.Connection = connServ.Conexion();

                SqlDataReader rdr3 = command3.ExecuteReader();

                while (rdr3.Read())
                {
                    User Usuario  = new User(rdr3.GetString(3), rdr3.GetString(2), rdr3.GetString(6), rdr3.GetString(7), rdr3.GetString(4), rdr3.GetString(5), rdr3.GetInt32(0), rdr3.GetInt32(1));
                    ListaUsuarios.Add(Usuario);
                }
            }
            connServ.Cerrar();

            return ListaUsuarios;
        }
Esempio n. 10
0
 DO.User UserBoDoAdapter(BO.User userBO)
 {
     DO.User userDO = new DO.User();
     userBO.CopyPropertiesTo(userDO);
     return(userDO);
 }
Esempio n. 11
0
 public void AgregarNuevoUsuario(string Nombre, string Apellido, string Mail, string Nick, string Pass, string Domicilio, int Id, short Categoria)
 {
     BO.User Nuevo = new BO.User(Nombre, Apellido, Mail, Nick, Pass, Domicilio, Id, Categoria);
     this.miDao.AgregarUsuario(Nuevo);
 }
Esempio n. 12
0
 public OrdenCompra(Carrito carr,User client)
 {
     this._items = carr.DameFuego();
     this._Cliente = client;
     this._estado = "PENDIENTE";
 }
Esempio n. 13
0
 public OrdenCompra(Carrito carr, User client,double iva)
     : this(carr,client)
 {
     this._iva = iva;
 }
Esempio n. 14
0
 BO.User UserDoBoAdapter(DO.User userDO)
 {
     BO.User userBO = new BO.User();
     userDO.CopyPropertiesTo(userBO);
     return(userBO);
 }
Esempio n. 15
0
 BO.User UserDoBoAdapter(DO.User userDo)
 {
     BO.User userBo = new BO.User();
     userDo.CopyPropertiesTo(userBo);
     return(userBo);
 }
Esempio n. 16
0
 DO.User UserBoDoAdapter(BO.User userBo)
 {
     DO.User userDo = new DO.User();
     userBo.CopyPropertiesTo(userDo);
     return(userDo);
 }
Esempio n. 17
0
        public User UnUser(int UserId)
        {
            User result = null;
            ///hago un select y si me lo devuelve es que esta logeado
            //try
            //{
            connServ.Abrir();

            using (SqlCommand command3 = new SqlCommand())
            {   //                                 0          1         2       3     4      5        6       7
                command3.CommandText = "SELECT id_usuario,categoria,apellido,nombre,pass,domicilio,email,nickname FROM Usuarios where id_usuario='" + UserId + "'";
                command3.Connection = connServ.Conexion();

                SqlDataReader rdr3 = command3.ExecuteReader();

                while (rdr3.Read())
                {
                    result = new User(rdr3.GetString(3), rdr3.GetString(2), rdr3.GetString(6), rdr3.GetString(7), rdr3.GetString(4), rdr3.GetString(5), rdr3.GetInt32(0), rdr3.GetInt32(1));

                }
            }
            connServ.Cerrar();
            //}

            //catch (Exception e)
            //{
            //    throw new ArgumentException("Error LEYENDO UN USUARIO", e);
            //}
            if (result == null)
            {
                throw new Exception("ERROR: NO EXISTE TAL USUARIO");
            }
            return result;
        }
Esempio n. 18
0
 public void AgregarUsuario(BO.User usuario)
 {
     Usuarios.Add(usuario);
 }
Esempio n. 19
0
 public Session(User usuario)
 {
     this._user = usuario;
 }