public string InsertEmployee(EmployeeManager model)
 {
     if (new ModifyEmployee().CheckExistUsername(model.Insert.Username))
     {
         Md5Function md5  = new Md5Function();
         string      pass = md5.MD5HashFunction(model.Insert.Password);
         new ModifyAccount().Insert(model.Insert.Username, pass);
         new ModifyEmployee().Insert(model.Insert);
         return("true");
     }
     else
     {
         return("Tên tài khoản đã tồn tại");
     }
 }
Example #2
0
        public string ChangePasswordVeri(ChangePassword model)
        {
            Md5Function md5     = new Md5Function();
            Account     acc     = new ModifyAccount().Select(model.username);
            string      oldpass = md5.MD5HashFunction(model.oldPassword);

            if (oldpass == acc.password.Split(' ')[0])
            {
                string        newpass = md5.MD5HashFunction(model.newPassword);
                ModifyAccount ma      = new ModifyAccount();
                ma.UpdatePasswordChange(model.username, newpass);
                return("true");
            }
            else
            {
                return("false");
            }
        }
Example #3
0
        public string InsertTeacherAccount(CreateTeacherAccount model)
        {
            DateTime      birth   = new DateTime(model.year, model.month, model.day);
            string        md5pass = new Md5Function().MD5HashFunction(model.password);
            ModifyAccount ma      = new ModifyAccount();
            ModifyTeacher mt      = new ModifyTeacher();

            if (ma.Check(model.username))
            {
                return("false");
            }
            else
            {
                ma.Insert(model.username, md5pass, 2);
                mt.Insert(model.name, model.gender, model.country, model.branch, birth, model.phoneNumber, model.username);
                return("true");
            }
        }
Example #4
0
        public string InsertStudentAccount(CreateStudentAccount model)
        {
            DateTime      birth   = new DateTime(model.year, model.month, model.day);
            string        md5pass = new Md5Function().MD5HashFunction(model.password);
            ModifyAccount ma      = new ModifyAccount();
            ModifyStudent ms      = new ModifyStudent();

            if (ma.Check(model.username))
            {
                return("false");
            }
            else
            {
                ma.Insert(model.username, md5pass, 3);
                ms.Insert(model.name, birth, model.gender, model.country, model.address, model.username, model.course, model.branch);
                return("true");
            }
        }
        public string InsertAdminAccount(string username, string password, int positionID, string name)
        {
            ModifyAccount ma  = new ModifyAccount();
            Md5Function   md5 = new Md5Function();
            ModifyAdmin   mad = new ModifyAdmin();

            if (ma.Check(username))
            {
                return("false");
            }
            else
            {
                string md5pass = md5.MD5HashFunction(password);
                ma.Insert(username, md5pass, positionID);
                mad.Insert(mad.GetNextID(), name, username);
                return("true");
            }
        }
Example #6
0
        public string VerifyLogin(LoginModel model)
        {
            Md5Function md5  = new Md5Function();
            string      pass = md5.MD5HashFunction(model.passWord);

            if (!new ModifyAccount().CheckUsername(model.userName))
            {
                return("Tài khoản không tồn tại");
            }
            else
            {
                string s = new ModifyAccount().CheckAccount(model.userName, pass);
                if (s == "false")
                {
                    return("Sai mật khẩu");
                }
                else
                {
                    return(s);
                }
            }
        }
        public JsonResult VerifyLogin(LoginModel model)
        {
            SoftwareTechnologyDBContext db = new SoftwareTechnologyDBContext();

            Md5Function md5Hash = new Md5Function();
            string      psw     = md5Hash.MD5HashFunction(model.passWord);

            Account loginAcc = db.Accounts.SingleOrDefault(x => x.UserName == model.userName && x.PassWord == psw);
            string  result   = "0";

            if (loginAcc != null)
            {
                Session["userName"] = loginAcc.UserName;
                if (loginAcc.PositionID == 1)
                {
                    Session["positionID"] = 1;
                    result = "Admin";
                }
                else if (loginAcc.PositionID == 2)
                {
                    Teacher temp = db.Teachers.SingleOrDefault(x => x.UserName == model.userName);
                    Session["positionID"] = 2;
                    Session["branchID"]   = temp.BranchID;
                    result = "Teacher";
                }
                else if (loginAcc.PositionID == 3)
                {
                    Student temp = db.Students.SingleOrDefault(x => x.UserName == model.userName);
                    Session["positionID"] = 3;
                    Session["branchID"]   = temp.BranchID;
                    Session["courseID"]   = temp.CourseID;
                    result = "Student";
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }