示例#1
0
        public UserModel CheckUser(string userName, string password, out int status, out Boolean isActive)
        {
            isActive = false;
            status   = 2;
            UserModel userModel  = new UserModel();
            DALogin   da         = new DALogin();
            DataTable usersTable = da.CheckUser(userName);

            if (usersTable.Rows.Count == 0)
            {
                status = 1; //wrong user
            }
            else
            {
                for (int i = 0; i < usersTable.Rows.Count; i++)
                {
                    if (Base64Encode(password) == usersTable.Rows[i]["UserPassword"].ToString())
                    {
                        userModel.UserId       = Convert.ToInt32(usersTable.Rows[i]["UserId"]);
                        userModel.UserName     = usersTable.Rows[i]["UserName"].ToString();
                        userModel.UserPassword = usersTable.Rows[i]["UserPassword"].ToString();
                        userModel.IsActive     = Convert.ToBoolean(usersTable.Rows[i]["IsActive"]);
                        userModel.UserTypeId   = Convert.ToInt32(usersTable.Rows[i]["UserTypeId"]);
                        userModel.UserInfoId   = Convert.ToInt32(usersTable.Rows[i]["UserInfoId"]);
                        isActive = userModel.IsActive;
                    }
                    else
                    {
                        status = 0; //wrong pass
                    }
                }
            }

            return(userModel);
        }
示例#2
0
        public UserModel CheckUser(string userName, string password, out int status)
        {
            UserModel User = new UserModel();

            DALogin   da         = new DALogin();
            DataTable tableusers = da.CheckUser(userName);

            if (tableusers.Rows.Count == 0)
            {
                status = 1; // Username Wrong
            }
            else
            {
                if (Base64Encode(password) == tableusers.Rows[0]["UserPassword"].ToString())
                {
                    status            = 2;
                    User.UserId       = Convert.ToInt32(tableusers.Rows[0]["UserId"]);
                    User.UserName     = tableusers.Rows[0]["UserName"].ToString();
                    User.UserPassword = tableusers.Rows[0]["UserPassword"].ToString();
                    User.LastLogin    = DateTime.Now;
                    da.UpdateDateTime(User.LastLogin, User.UserId);
                }
                else
                {
                    status = 0; // Password Wrong
                }
            }

            return(User);
        }
        public void InsertUser(string userName, string password, out bool status, out string errorMessage)
        {
            UserModel user = new UserModel();

            status       = false;
            errorMessage = "OK";

            DALogin   daLogin   = new DALogin();
            DataTable dataTable = daLogin.CheckUsers(userName);

            if (dataTable.Rows.Count == 1)
            {
                status       = true;
                errorMessage = "Utilizator existent";
            }
            else
            {
                daLogin.InsertUser(userName, Base64Encode(password));
                DataTable dataTable2 = daLogin.CheckUsers(userName);

                if (dataTable2.Rows.Count == 1)
                {
                    status       = false;
                    errorMessage = "Utilizator adaugat!";
                }
            }
        }
示例#4
0
        public UserModel CheckUser(String UserName, String Password, out bool status)
        {
            //base64 pass
            var EncryptedPassB = System.Text.Encoding.UTF8.GetBytes(Password);
            var EncryptedPass  = System.Convert.ToBase64String(EncryptedPassB);

            UserModel user = new UserModel();

            status = false;
            DALogin da = new DALogin();

            da.CheckUser(UserName);
            DataTable tableUsers = da.CheckUser(UserName);

            if (tableUsers.Rows.Count == 0)
            {
                status = false;
            }

            else
            {
                for (int i = 0; i < tableUsers.Rows.Count; i++)
                {
                    if (EncryptedPass == tableUsers.Rows[i]["UserPassword"].ToString())
                    {
                        status            = true;
                        user.UserId       = Convert.ToInt32(tableUsers.Rows[i]["UserId"]);
                        user.UserName     = tableUsers.Rows[i]["UserName"].ToString();
                        user.UserPassword = tableUsers.Rows[i]["UserPassword"].ToString();
                        user.LastLogin    = DateTime.Now;
                    }
                }
            }
            return(user);
        }
示例#5
0
        public UserModel CheckUser(string userName, string password, out bool status)
        {
            string passwordEncrypted;
            var    plainTextBytes = System.Text.Encoding.UTF8.GetBytes(password);

            passwordEncrypted = System.Convert.ToBase64String(plainTextBytes);

            UserModel user = new UserModel();

            status = false;
            DALogin   da         = new DALogin();
            DataTable tableUsers = da.CheckUser(userName);

            if (tableUsers.Rows.Count == 0)
            {
                status = false;
            }
            else
            {
                for (int i = 0; i < tableUsers.Rows.Count; i++)
                {
                    if (passwordEncrypted == tableUsers.Rows[i]["UserPassword"].ToString())
                    {
                        user.UserId       = Convert.ToInt32(tableUsers.Rows[i]["UserId"]);
                        user.UserName     = tableUsers.Rows[i]["UserName"].ToString();
                        user.UserPasswrod = tableUsers.Rows[i]["UserPassword"].ToString();
                        user.LastLogin    = DateTime.Now;
                        status            = true;
                    }
                }
            }

            return(user);
        }
示例#6
0
        public int BAaddLoginDetails(LoginEntities objLoginDetails)
        {
            DALogin objaddLoginDA = new DALogin();
            int     returnValue   = objaddLoginDA.DAaddLoginDetails(objLoginDetails);

            return(returnValue);
        }
示例#7
0
 private void Dispose(bool disposing)
 {
     if (disposed)
     {
         return;
     }
     if (disposing)
     {
         oda.Dispose();
         oda = null;
     }
     disposed = true;
 }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            DALogin.GetLoginByKorisnickoImeAndLozinka(dsLogin.LoginPodaci, txtKorisnickoIme.Text, txtLozinka.Text);
            int count = dsLogin.LoginPodaci.Count;

            if (count == 1)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                lblError.Visible = true;
            }
        }
        public UserModel CheckUser(string userName, string password, out bool status, out string errorMessage)
        {
            UserModel user = new UserModel();

            status = false;

            DALogin   daLogin   = new DALogin();
            DataTable dataTable = daLogin.CheckUsers(userName);

            errorMessage = "";

            if (dataTable.Rows.Count == 0)
            {
                status       = false;
                errorMessage = "Utilizator inexistent";
            }
            else
            {
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    if (password == Base64Decode(dataTable.Rows[i]["UserPassword"].ToString()))
                    {
                        user.UserId       = Convert.ToInt32(dataTable.Rows[i]["UserId"]);
                        user.UserName     = Convert.ToString(dataTable.Rows[i]["UserName"]);
                        user.UserPassword = Convert.ToString(dataTable.Rows[i]["UserPassword"]);
                        user.LastLogin    = DateTime.Now;
                        status            = true;
                        errorMessage      = "Logare reusita!";
                        daLogin.UpdateLastLogin(userName);
                    }
                    else
                    {
                        errorMessage = "Parola incorecta!";
                    }
                }
            }
            return(user);
        }
示例#10
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //send txt username and pw to getuserlogin function
            var username = txtBox_Username.Text.Trim();
            var password = txtBox_Password.Text.Trim();

            DSLogin.KorisniksDataTable dtLogin = new DSLogin.KorisniksDataTable();
            dtLogin.Clear();


            DALogin.getKorisnikByUsernameAndPassword(dtLogin, username, password);


            if (dtLogin.Rows.Count == 1)
            {
                FrmDashboard formDashboard = new FrmDashboard();
                this.Hide();
                formDashboard.Show();
            }
            else
            {
                MessageBox.Show("Check your username and password");
            }
        }
 public LoginController()
 {
     dalogin = new DALogin();
 }
示例#12
0
 public static bool Login(string correo, string password)
 {
     return(DALogin.Login(correo, password));
 }
示例#13
0
        public Boolean ValidaInicioSesion(BE_Req_Login Request)
        {
            DALogin ObjLogin = new DALogin();

            return(ObjLogin.ValidaInicioSesion(Request));
        }
示例#14
0
        public BE_Res_Login ValidateUser(BE_Req_Login Request)
        {
            DALogin ObjLogin = new DALogin();

            return(ObjLogin.ValidaterUser(Request));
        }
示例#15
0
 public BRLogin()
 {
     oda = new DALogin();
 }