protected void GV_user_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("bloquear"))
     {
         Int64 dato = Convert.ToInt64(e.CommandArgument.ToString());
         new DAOUser().bloquear_User(dato);
     }
     if (e.CommandName.Equals("desbloquear"))
     {
         Int64 dato = Convert.ToInt64(e.CommandArgument.ToString());
         new DAOUser().DesbloquearUser(dato);
     }
     if (e.CommandName.Equals("editar"))
     {
         Int64 dato = Convert.ToInt64(e.CommandArgument.ToString());
         Session["editar"] = dato;
         Response.Redirect("~/View/Admin/recepcionistas/editarRecep.aspx?user="******"info"))
     {
         Int64     dato  = Convert.ToInt64(e.CommandArgument.ToString());
         DataTable tabla = new DAOUser().ver_User(dato);
         ((Image)FV_usuario.FindControl("Imagen_user")).ImageUrl  = tabla.Rows[0]["foto"].ToString();
         ((Label)FV_usuario.FindControl("label_nombres")).Text    = tabla.Rows[0]["primer_nombre"].ToString() + " " + tabla.Rows[0]["segundo_nombre"].ToString();
         ((Label)FV_usuario.FindControl("label_apellidos")).Text  = tabla.Rows[0]["primer_apellido"].ToString() + " " + tabla.Rows[0]["segundo_apellido"].ToString();
         ((Label)FV_usuario.FindControl("label_direccion")).Text  = tabla.Rows[0]["direccion"].ToString();
         ((Label)FV_usuario.FindControl("label_telefono")).Text   = tabla.Rows[0]["telefono"].ToString();
         ((Label)FV_usuario.FindControl("label_correo")).Text     = tabla.Rows[0]["correo"].ToString();
         ((Label)FV_usuario.FindControl("label_clave")).Text      = tabla.Rows[0]["clave"].ToString();
         ((Label)FV_usuario.FindControl("label_nacimiento")).Text = tabla.Rows[0]["fecha_nacimieno"].ToString();
         ((Label)FV_usuario.FindControl("label_sexo")).Text       = tabla.Rows[0]["sexo"].ToString();
     }
 }
Exemplo n.º 2
0
    protected void LN_Prueba_Authenticate(object sender, AuthenticateEventArgs e)
    {
        EUsuariocs eUser = new EUsuariocs();

        eUser.UserName = LN_Prueba.UserName.ToString();
        eUser.Clave    = LN_Prueba.Password.ToString();

        eUser = new DAOUser().login2(eUser);

        if (eUser == null)
        {
            ((Label)LN_Prueba.FindControl("L_Mensaje")).Text = "Usuario o Clave Incorrecta";
        }
        else if (eUser.RolId == 1)
        {
            ((Label)LN_Prueba.FindControl("L_Mensaje")).Text = "Bienvenido " + eUser.Nombre;
            Session["userValido"] = eUser;
            Response.Redirect("CrudeUsuario.aspx");
        }
        else if (eUser.RolId == 2)
        {
            ((Label)LN_Prueba.FindControl("L_Mensaje")).Text = "Bienvenido " + eUser.Nombre;
            Session["Archivos"] = eUser;
            Response.Redirect("Archivos.aspx");
        }
    }
Exemplo n.º 3
0
        public UserModel Insert(UserModel userModel)
        {
            Crypto cripto = new Crypto();

            userModel.Password = cripto.EncryptToString(userModel.Password);

            User user = this.ModelToUSer(userModel);

            try
            {
                using (IDAOUser daoUser = new DAOUser())
                {
                    user.Wallets.Add(new Wallet()
                    {
                        Money = 0
                    });

                    user = daoUser.Add(user);

                    if (user != null)
                    {
                        return(this.UserToModel(user));
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(null);
        }
Exemplo n.º 4
0
        public ActionResult chinh_sua_kh(FormCollection formCollection)
        {
            User user = new User();

            user.id    = Convert.ToInt32(formCollection["id"]);
            user.email = formCollection["email"];
            // user.password = formCollection["password"];
            user.userName = formCollection["username"];
            user.phone    = formCollection["phone"];
            user.address  = formCollection["address"];
            user.gender   = formCollection["gender"];
            user.level    = Convert.ToInt32(formCollection["level"]);
            Console.WriteLine("User:: {'ID: " + user.id + "','userName: "******"pass:"******" email: " + user.email
                              + " address: " + user.address + "phone: " + user.phone + " gender: " + user.gender +
                              " level: " + user.level + "'}");
            if (DAOUser.editUser(user))
            {
                new DaoLog().INFO("success", "chinh_sua_kh");
                return(RedirectToAction("khach_hang", "Admin"));
            }
            else
            {
                new DaoLog().INFO("fail", "chinh_sua_kh");
                ViewBag.error = "not success";
                return(RedirectToAction("chinh_sua_kh", "Admin", new { ID = Convert.ToInt32(formCollection["id"]) }));
            }
        }
Exemplo n.º 5
0
 private void btnDeleteUser_Click(object sender, RoutedEventArgs e)
 {
     if (TableValues(0) != null)
     {
         MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show("Você tem certeza de que gostaria de excluir este usuário? AVISO! Se o usuário for um professor todas suas turmas serão excluídas.",
                                                                     "Aviso!", MessageBoxButton.YesNoCancel);
         if (result == MessageBoxResult.Yes)
         {
             DAOUser dao = new DAOUser();
             TOUser  u   = new TOUser();
             u = dao.Selection(Int16.Parse(TableValues(0)));
             if (dao.DeleteUser(u))
             {
                 Xceed.Wpf.Toolkit.MessageBox.Show("Usuário excluído com sucesso.", "Sucesso!", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
             }
             else
             {
                 Xceed.Wpf.Toolkit.MessageBox.Show("Algo errado aconteceu durante a exclusão.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
             }
         }
         else
         {
             //Do nothing.
         }
     }
     else
     {
     }
     LoadScreen();
 }
Exemplo n.º 6
0
        private void btnSaturdayVacancys_Click(object sender, RoutedEventArgs e)
        {
            DAOClass dao = new DAOClass();

            if (dao.VacancyCount("sábado") == 0)
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Não há vagas disponíveis.", "MC Sales", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
                tblStudents.ItemsSource  = null;
                lblCount_Vacancy.Content = "0";
                lblCount.Content         = "10";
                lblNoVancacys.Visibility = Visibility.Visible;
            }
            else
            {
                //class info.
                _class = dao.LoadQuickMenu("sábado");
                lblClass_Time.Content = _class.Class_TotalHours;

                //teacher info.
                TOUser  u    = new TOUser();
                DAOUser daoU = new DAOUser();
                u = daoU.Selection(_class.User_id);
                lblTeacher_Name.Content = u.User_name;

                btnViewCurrentClass.Visibility = Visibility.Visible;
                btnResetTable.Visibility       = Visibility.Visible;

                LoadTable(_class.Class_id);

                lblDay.Visibility = Visibility.Visible;
                lblDay.Content    = "Sábado";
            }
        }
Exemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            btnSave.Enabled   = false;
            btnCancel.Enabled = false;

            String   Name      = txtName.Text.Trim();
            String   Cpf       = txtCpf.Text.Trim();
            DateTime Birthdate = DateTime.Parse(txtBirthdate.Text.Trim());
            String   Email     = txtEmail.Text.Trim();
            String   Password  = txtPassword.Text;
            String   Address   = txtAddress.Text;

            txtCpf.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

            if (!User.ValidateCpf(txtCpf.Text.Trim()))
            {
                MessageBox.Show("CPF inválido.");

                txtCpf.Focus();
            }
            else if (!txtPassword.Text.Equals(txtPasswordConfirm.Text))
            {
                MessageBox.Show("Senhas incompatíveis.");
            }
            else
            {
                DAOUser dao = new DAOUser();

                User user = new User {
                    Name      = Name,
                    Cpf       = Cpf,
                    Birthdate = Birthdate,
                    Email     = Email,
                    Password  = Password,
                    Address   = Address,
                    Income    = 0.00
                };

                if (dao.Save(user))
                {
                    MessageBox.Show("Usuário #" + user.Id + " cadastrado com sucesso!");

                    if (LoginForm is Login)
                    {
                        ((Login)LoginForm).SetCpf(Cpf);

                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Não foi possível cadastrar o usuário.\n\nContate o administrador.");
                }
            }

            btnSave.Enabled   = true;
            btnCancel.Enabled = true;
        }
    protected void but_registrar_Click(object sender, EventArgs e)
    {
        User      user   = new User();
        long      cedula = Convert.ToInt64(text_cedula.Text);
        DataTable datos  = new DAOUser().buscar_Cedula(cedula);

        if (datos.Rows.Count > 0)
        {
            return;
        }
        else
        {
            user.Cedula = Convert.ToInt64(text_cedula.Text);
        }
        user.Primer_nombre    = text_primer_nombre.Text;
        user.Segundo_nombre   = text_segundo_nombre.Text;
        user.Primer_apellido  = text_primer_apellido.Text;
        user.Segundo_apellido = text_segundo_apellido.Text;
        user.Direccion        = text_direccion.Text;
        user.Telefono         = text_telefono.Text;
        user.Correo           = text_correo.Text;
        user.Password         = text_pass.Text;
        String confirmacion = text_confirmacion_pass.Text;

        if (!user.Password.Equals(confirmacion))
        {
            return;
        }
        user.Nacimiento = Convert.ToDateTime(text_fecha.Text);
        String sexo = DDL_sexo.SelectedValue;

        if (sexo.Equals("Seleccione un Sexo"))
        {
            return;
        }
        else
        {
            user.Sexo = DDL_sexo.SelectedValue;
        }
        user.Session = Session.SessionID;
        user.Rol     = 1;
        user.Sede    = Convert.ToInt32(Session["sede"].ToString());
        FileUpload file = FU_imagen;

        if (file.PostedFile.FileName != null && !(System.IO.Path.GetExtension(file.PostedFile.FileName).Equals(".jpg") || System.IO.Path.GetExtension(file.PostedFile.FileName).Equals(".png")))
        {
            return;
        }
        else
        {
            user.Foto = "~\\Imagenes\\Perfiles\\Paciente\\" + System.IO.Path.GetFileName(file.PostedFile.FileName);

            file.PostedFile.SaveAs(Server.MapPath(user.Foto));
        }
        new DAOUser().insertar_User(user);
        Response.Redirect("~/View/Principal/registro.aspx");
    }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["usuario"] == null || !Session["rol"].ToString().Equals("2"))
        {
            Response.Redirect("../Principal/index.aspx");
        }
        DataTable foto = new DAOUser().ver_User(Convert.ToInt64(Session["usuario"].ToString()));

        image_user.ImageUrl = foto.Rows[0]["foto"].ToString();
    }
Exemplo n.º 10
0
        public void LoadScreen()
        {
            DAOUser dao = new DAOUser();

            //loads the table.
            tblUser.CanUserAddRows      = false;
            tblUser.IsReadOnly          = true;
            tblUser.AutoGenerateColumns = false;
            tblUser.ItemsSource         = dao.LoadUsers();
            lblCount.Content            = tblUser.Items.Count;
        }
Exemplo n.º 11
0
        public ActionResult xoa_kh(int id)
        {
            if (DAOUser.delUser(id))
            {
                new DaoLog().WARNING("success", "xoa_kh");
            }
            else
            {
                new DaoLog().WARNING("fail", "xoa_kh");
            }

            return(RedirectToAction("khach_hang", "Admin"));
        }
Exemplo n.º 12
0
        public static void CheckUsers()
        {
            DAOUser     daoUser = new DAOUser();
            List <User> users   = daoUser.FindAll();

            DAOContact daoContact = new DAOContact();

            foreach (User c in users)
            {
                c.Print();
                daoContact.FindOneById(c.Contact_Id).Print();
            }
        }
Exemplo n.º 13
0
        private void btnViewUser_Click(object sender, RoutedEventArgs e)
        {
            if (TableValues(0) != null)
            {
                DAOUser dao = new DAOUser();
                TOUser  i   = new TOUser();
                i = dao.Selection(Int16.Parse(TableValues(0)));

                REG_user reg_u = new REG_user(i);
                reg_u.ShowDialog();

                LoadScreen();
            }
        }
Exemplo n.º 14
0
        private void tblUser_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (TableValues(0) != null)
            {
                DAOUser dao = new DAOUser();
                TOUser  i   = new TOUser();
                i = dao.Selection(Int16.Parse(TableValues(0)));

                REG_user reg_u = new REG_user(i);
                reg_u.ShowDialog();

                LoadScreen();
            }
        }
Exemplo n.º 15
0
    protected void button_editar_Click1(object sender, EventArgs e)
    {
        String password = ((TextBox)FV_usuario.FindControl("text_validar_pass")).Text;

        DataTable validar = new DAOUser().buscar_Usuario(Convert.ToInt64(Session["usuario"].ToString()), password);

        if (validar.Rows.Count < 1)
        {
            return;
        }
        else
        {
            Response.Redirect("~/View/Doctor/editarUsuario.aspx");
        }
    }
Exemplo n.º 16
0
        public UserModel Select(string email)
        {
            using (IDAOUser daoUser = new DAOUser())
            {
                User user = daoUser.GetSingle(x => x.Email == email, "Wallets");

                if (user != null)
                {
                    UserModel model = this.UserToModel(user);
                    model.WalletId = user.Wallets.First().Id;

                    return(model);
                }
            }

            return(null);
        }
Exemplo n.º 17
0
        public UserModel ValidateUser(string email, string password)
        {
            using (IDAOUser daoUser = new DAOUser())
            {
                User user = daoUser.GetSingle(x => x.Email == email);

                if (user != null)
                {
                    if (user.Password == password)
                    {
                        return(this.UserToModel(user));
                    }
                }
            }

            return(null);
        }
Exemplo n.º 18
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            DAOUser dao = new DAOUser();
            TOUser  ver = new TOUser();

            ver = dao.Login(user.User_name, user.User_password);
            if (ver.User_id != 0)
            {
                ACTIndex index = new ACTIndex(ver);
                index.Show();
                this.Close();
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Crecendicais incorretas ou não cadastradas.", "Erro!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
        }
Exemplo n.º 19
0
        public bool VerificaUsuario(Usuario usuario)
        {
            //AQUI VAI ENTRAR O METODO QUE VAI BUSCAR O USUARIO DO BANCO DE DADOS
            //USANDO A CLASSE DAO

            DAOUser daoUser = new DAOUser();

            return(daoUser.VerificaUsuarioNoBanco(usuario));

            //if(usuario.nome == "fernando" && usuario.senha == "200790")
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}
        }
Exemplo n.º 20
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            btnEntrar.Enabled = false;

            MaskFormat format = txtCpf.TextMaskFormat;

            String Cpf      = txtCpf.Text.Trim();
            String Password = txtPassword.Text;

            txtCpf.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

            if (!User.ValidateCpf(txtCpf.Text.Trim()))
            {
                MessageBox.Show("CPF inválido!");

                txtCpf.Focus();
            }
            else
            {
                User user = null;

                DAOUser dao = new DAOUser();

                user = dao.DoLogin(Cpf, Password);

                if (user is User)
                {
                    WalletPanel panel = new WalletPanel(this, user);

                    panel.Show();

                    this.Visible = false;
                }
                else
                {
                    MessageBox.Show("CPF ou senha inválidos.");
                }
            }

            txtCpf.TextMaskFormat = format;

            btnEntrar.Enabled = true;
        }
Exemplo n.º 21
0
    protected void btnIngresar_Click(object sender, EventArgs e)
    {
        EUsuario user = new EUsuario
        {
            Nombre_usuario = textUsuario.Text,
            Contraseña     = textContraseña.Text
        };

        user = new DAOUser().Login(user);

        if (user == null)
        {
            Response.Redirect("CuentaErronea.aspx");
        }
        else
        {
            Response.Redirect("CuentaValida.aspx");
        }
    }
Exemplo n.º 22
0
        public ActionResult them_khach_hang(FormCollection formCollection)
        {
            User user = new User();

            user.email    = formCollection["email"];
            user.password = formCollection["password"];
            user.userName = formCollection["username"];
            user.phone    = formCollection["phone"];
            user.address  = formCollection["address"];
            user.gender   = formCollection["gender"];
            if (DAOUser.addUser(user))
            {
                new DaoLog().INFO("success", "them_khach_hang");
            }
            else
            {
                new DaoLog().INFO("fail", "them_khach_hang");
            }

            return(RedirectToAction("khach_hang", "Admin"));
        }
Exemplo n.º 23
0
    protected void button_editar_Click1(object sender, EventArgs e)
    {
        String password = ((TextBox)FV_usuario.FindControl("text_validar_pass")).Text;

        DataTable validar = new DAOUser().buscar_Usuario_id(Convert.ToInt64(Session["usuario"].ToString()), password);

        if (validar.Rows.Count < 1)
        {
            Panel2.CssClass         = "bg-warning";
            label_titulo_error.Text = "!Alerta¡";
            label_error.Text        = "Lo siento su Contraseña es incorrecta";
            modal2.Show();

            return;
        }
        else
        {
            ((ModalPopupExtender)FV_usuario.FindControl("modal")).Hide();
            Session["editar"] = Session["usuario"].ToString();
            Response.Redirect("~/View/Admin/editarUsuario.aspx?id=" + Session["usuario"].ToString());
        }
    }
Exemplo n.º 24
0
        public static void AddRandomUsers()
        {
            DAOUser dao = new DAOUser();

            User    alex   = new User("Artur", "Excamlott");
            Contact alex_C = new Contact("Alexandre", "Astier", "*****@*****.**");

            User    percy   = new User("Percy", "culdchouette");
            Contact percy_C = new Contact("Perceval", "de Galle", "*****@*****.**");

            User    karadoc   = new User("Karadoc", "saucissonfinesherbes");
            Contact karadoc_C = new Contact("Karadoc", "de Vanne", "*****@*****.**");

            User    admin   = new User("Admin", "admin");
            Contact admin_c = new Contact("Admin", "Admin", "*****@*****.**");



            dao.Create(alex, alex_C);
            dao.Create(percy, percy_C);
            dao.Create(karadoc, karadoc_C);
            dao.Create(admin, admin_c);
        }
Exemplo n.º 25
0
 private void buttonKayit_Click(object sender, EventArgs e)
 {
     DAOUser.insertlogin(textBoxEmail.Text);
     DAOUser.insertUser(textBoxAd.Text, textBoxSoyad.Text, textBoxGsm.Text, textBoxYas.Text, textBoxAdress.Text, textBoxEmail.Text);
     this.Close();
 }
Exemplo n.º 26
0
 public UserController(DAOUser userDao)
 {
     this.UserDao = userDao;
 }
Exemplo n.º 27
0
        public Boolean updateUser(User u)
        {
            DAOUser dao = new DAOUser();

            return(dao.updateUser(u));
        }
Exemplo n.º 28
0
        public Boolean deleteUser(User u)
        {
            DAOUser dao = new DAOUser();

            return(dao.deleteUser(u));
        }
Exemplo n.º 29
0
        public List <User> loadUsers()
        {
            DAOUser dao = new DAOUser();

            return(dao.loadUsers());
        }
Exemplo n.º 30
0
        public User loadUserByUserName(String username)
        {
            DAOUser dao = new DAOUser();

            return(dao.loadUserByUserName(username));
        }