Ejemplo n.º 1
0
        public bool CreateUser(string Username, string Email, string password, int RoleId, string Fname, string LName)
        {
            string salt = String.Empty;

            TB_USERS up           = new TB_USERS();
            string   passwordHash = pwdManager.GeneratePasswordHash(password, out salt);
            int      profileId    = 0;

            using (var db = new AppDbContext())
            {
                var user = new TB_USERS
                {
                    USER_ID         = Username,
                    EMAIL           = Email,
                    FIRST_NAME      = Fname,
                    LAST_NAME       = LName,
                    DISPLAY_NAME    = Fname + " " + LName,
                    ROLE_ID         = RoleId,
                    PASSWORD_HASH   = passwordHash,
                    PASSWORD_SALT   = salt,
                    CREATED_DATE    = DateTime.Now,
                    LAST_LOGIN_DATE = DateTime.Now
                };
                db.TB_USERS.Add(user);
                db.SaveChanges();
                profileId = user.ID;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public JsonResult UpdateStatusUser(TB_USERS value)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                value.UserStatus      = "A";
                value.UserDateCreated = DateTime.Now;
                bool check = false;
                check = User_Service.Update(value);
                if (check)
                {
                    Result.Code   = 0;
                    Result.Result = "Thành công";
                }
                else
                {
                    Result.Code   = 1;
                    Result.Result = "Thao tác không thành công";
                }
            }
            catch (Exception Ex)
            {
                Result.Code   = 1;
                Result.Result = "Thao tác không thành công";
                IOHelper.WriteLog(StartUpPath, IpAddress, "InsertOrUpdateUser:", Ex.Message, Ex.ToString());
            }
            return(Json(new JsonResult()
            {
                Data = Result
            }));
        }
Ejemplo n.º 3
0
        public JsonResult InsertUser(TB_USERS user)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                if (Users_Service.Insert(user))
                {
                    Result.Code   = 00;
                    Result.Result = "Thành công";
                }
                else
                {
                    Result.Code   = 1;
                    Result.Result = "Thao tác không thành công";
                }
            }
            catch (Exception Ex)
            {
                Result.Code   = 2000;
                Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị.";
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString());
            }

            return(Json(Result));
        }
Ejemplo n.º 4
0
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            var cacheKey = string.Format("UserData_{0}", username);

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return((CustomMembershipUser)HttpRuntime.Cache[cacheKey]);
            }

            using (var context = new AppDbContext())
            {
                var user = (from u in context.TB_USERS.Include(x => x.TB_ROLES)
                            where String.Compare(u.USER_ID.ToUpper(), username.ToUpper(), StringComparison.OrdinalIgnoreCase) == 0
                            select u).FirstOrDefault();

                if (user == null)
                {
                    return(null);
                }

                var memebershipUser = new CustomMembershipUser(user);
                if (userIsOnline)
                {
                    TB_USERS tB_USERS = db.TB_USERS.Find(memebershipUser.ProfileId);

                    tB_USERS.LAST_LOGIN_DATE = DateTime.Now;
                    db.Entry(tB_USERS).State = EntityState.Modified;
                    db.SaveChanges();
                }
                HttpRuntime.Cache.Insert(cacheKey, memebershipUser, null, DateTime.Now.AddMinutes(_cacheTimeoutInMinutes), Cache.NoSlidingExpiration);
                return(memebershipUser);
            }
        }
Ejemplo n.º 5
0
 public ActionResult Login(string url)
 {
     if (Session[AppSessionKeys.USER_INFO] != null)
     {
         if (string.IsNullOrEmpty(url))
         {
             TB_USERS user = (TB_USERS)Session[AppSessionKeys.USER_INFO];
             if (user.UserType.Equals("ACCOUNTANT"))
             {
                 return(Redirect("/Admin/Report"));
             }
             else
             {
                 return(RedirectToAction("/Index"));
             }
         }
         else
         {
             return(RedirectPermanent(url));
         }
     }
     else
     {
         ViewBag.username = AppCookieInfo.UserID;
         ViewBag.password = AppCookieInfo.HashedPassword;
         ViewBag.business = AppCookieInfo.LoginType;
     }
     return(View());
 }
Ejemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            TB_USERS tB_USERS = db.TB_USERS.Find(id);

            db.TB_USERS.Remove(tB_USERS);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "ID_USER,USERNAME,USERPASSWORD,BORNDATE,USEREMAIL")] TB_USERS tB_USERS)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tB_USERS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tB_USERS));
 }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "ID_USER,USERNAME,USERPASSWORD,BORNDATE,USEREMAIL")] TB_USERS tB_USERS)
        {
            if (ModelState.IsValid)
            {
                db.TB_USERS.Add(tB_USERS);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tB_USERS));
        }
Ejemplo n.º 9
0
 public CustomMembershipUser(TB_USERS user)
     : base("CustomMembershipProvider", user.USER_ID, user.ID, user.EMAIL, string.Empty, string.Empty, true, false,
            (DateTime)user.CREATED_DATE, (DateTime)user.LAST_LOGIN_DATE, DateTime.Now, DateTime.Now, DateTime.Now)
 {
     FirstName    = user.FIRST_NAME;
     LastName     = user.LAST_NAME;
     UserRoleId   = (int)user.ROLE_ID;
     UserRoleName = user.TB_ROLES.ROLE_NAME;
     DisplayName  = user.DISPLAY_NAME;
     ProfileId    = (int)user.ID;
 }
        public IHttpActionResult DeleteTB_USERS(int id)
        {
            TB_USERS tB_USERS = db.TB_USERS.Find(id);

            if (tB_USERS == null)
            {
                return(NotFound());
            }

            db.TB_USERS.Remove(tB_USERS);
            db.SaveChanges();

            return(Ok(tB_USERS));
        }
        public IHttpActionResult Register(TB_USERS tB_USERS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            tB_USERS.dt_icl = DateTime.Now;

            db.TB_USERS.Add(tB_USERS);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 12
0
        private void btn_edit_Click(object sender, EventArgs e)
        {
            FRM_USER_ADD frm_user_add = new FRM_USER_ADD();

            id      = Convert.ToInt32(gridView1.GetFocusedRowCellValue("USER_ID"));
            tb_user = dbs.TB_USERS.Where(x => x.USER_ID == id).FirstOrDefault();

            frm_user_add.txt_Name.Text = tb_user.USER_NAME;
            frm_user_add.txt_pass.Text = tb_user.USER_PASS;
            frm_user_add.txt_roll.Text = tb_user.USER_ROLL;
            frm_user_add.id            = id;
            frm_user_add.btn_add.Text  = "التعديل";
            frm_user_add.Show();
        }
Ejemplo n.º 13
0
        // GET: USERS/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TB_USERS tB_USERS = db.TB_USERS.Find(id);

            if (tB_USERS == null)
            {
                return(HttpNotFound());
            }
            return(View(tB_USERS));
        }
Ejemplo n.º 14
0
        public PartialViewResult _Students_Details(string userID)
        {
            TB_USERS user = new TB_USERS();

            try
            {
                user = User_Service.GetById(int.Parse(userID));
            }
            catch (Exception ex)
            {
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, "UserController :", ex.Message, ex.ToString());
            }

            return(PartialView(user));
        }
Ejemplo n.º 15
0
        public PartialViewResult _ChiTiet(int userId = 0)
        {
            int      height = (int)(Request.Browser.ScreenPixelsHeight * 0.85);
            TB_USERS b      = new TB_USERS();

            try
            {
                b = Users_Service.GetById(userId);
            }
            catch (Exception ex)
            {
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "Blogs/_List :", ex.Message, ex.ToString());
            }
            ViewBag.Slider = b;
            return(PartialView(height));
        }
Ejemplo n.º 16
0
        public PartialViewResult _Accountant_Details(string userID)
        {
            TB_USERS user = new TB_USERS();

            try
            {
                user            = User_Service.GetById(int.Parse(userID));
                user.UserStatus = user.UserStatus.Equals("A") ? "1" : "0";
            }
            catch (Exception ex)
            {
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, "UserController :", ex.Message, ex.ToString());
            }

            return(PartialView(user));
        }
Ejemplo n.º 17
0
        public void AssignPower(TB_USERS oUser, TB_ROLE oRole)
        {
            if (oUser == null || oRole == null)
            {
                return;
            }
            var oUserRole = _userroleRepository.Find(x => x.USER_ID == oUser.USER_ID && x.ROLE_ID == oRole.ROLE_ID).FirstOrDefault();

            if (oUserRole == null)
            {
                oUserRole         = new TB_USERROLE();
                oUserRole.ROLE_ID = oRole.ROLE_ID;
                oUserRole.USER_ID = oUser.USER_ID;
                oUserRole.ID      = 0001;
                _userroleRepository.Insert(oUserRole);
            }
        }
Ejemplo n.º 18
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            tb_user = dbs.TB_USERS.Where(x => x.USER_STATE == "True").FirstOrDefault();
            if (tb_user != null)
            {
                frm_main.lb_user.Text = tb_user.USER_NAME;
                frm_main.lb_roll.Text = tb_user.USER_ROLL;
                frm_main.Show();
            }
            else
            {
                frm_login.Show();
            }

            this.Hide();
            timer1.Enabled = false;
        }
Ejemplo n.º 19
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            id = Convert.ToInt32(gridView1.GetFocusedRowCellValue("USER_ID"));

            var res = MessageBox.Show("هل انت متأكد من حذف المستخدم ؟؟", "عملية الحذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                tb_user = dbs.TB_USERS.Where(x => x.USER_ID == id).FirstOrDefault();
                dbs.Entry(tb_user).State = System.Data.Entity.EntityState.Deleted;
                dbs.SaveChanges();
                MessageBox.Show("تم عملية الحذف بالنجاح", " تم عملية الحذف", MessageBoxButtons.OK, MessageBoxIcon.Information);
                update_data();
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 20
0
        public JsonResult ExportProduct(string userId, string startDate, string endDate, string type)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                TB_USERS user = new TB_USERS();
                user = User_Service.GetById(Int32.Parse(userId));
                string fileName = "\\Export\\HD" + user.UserFullName + "_" + startDate + "_" + endDate + ".xls";
                string filePath = HttpContext.Server.MapPath("~" + fileName);
                string err      = "";
                if (type.Equals("STUDIES"))
                {
                    err = BillExport(filePath, userId, startDate, endDate, type);
                }
                else
                {
                    err = User_Service.ReportSalaryTeacher(userId, startDate, endDate);
                    if (err.Equals("00"))
                    {
                        err = "";
                    }
                }

                if (string.IsNullOrEmpty(err))
                {
                    Result.Code   = 0;
                    Result.Result = fileName;
                }
                else
                {
                    Result.Code   = 999;
                    Result.Result = err;
                }
            }
            catch (Exception Ex)
            {
                Result.Code   = 2000;
                Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị.";
                IOHelper.WriteLog(StartUpPath, IpAddress, "Ajax::ExportProduct :", Ex.Message, Ex.ToString());
            }
            return(Json(Result));
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            var oProgram = new Program();

            Regisgter.regisgter().ComposeParts(oProgram);
            var oUser = new TB_USERS()
            {
                USER_ID = "04acd48a819447d388b20dffb15f672e"
            };
            var oRole = new TB_ROLE()
            {
                ROLE_ID = "cccc"
            };

            oProgram.powerDomainService.AssignPower(oUser, oRole);

            var oBootstrapper = new Bootstrapper();

            oBootstrapper.StartServices();

            Console.ReadKey();
        }
Ejemplo n.º 22
0
        // đăng kí lịch dạy giáo viên
        public int InsertTeacherAndSchedule(TB_USERS user, List <TB_TEACHING_SCHEDULES> listSchedule)
        {
            string ecode, edesc;
            TB_TEACHING_SCHEDULESSql sql = new TB_TEACHING_SCHEDULESSql();
            string xmlUser = "******" + user.ToStringXml() + "</row>";
            string xml     = "";

            foreach (var item in listSchedule)
            {
                xml += "<row>" + item.ToStringXml() + "</row>";
            }
            string xmllistSchedule = "<row>" + xml + "</row>";

            sql.SelectFromStore(out ecode, out edesc, AppSettingKeys.INSERT_TEACHER_AND_SCHEDULES, xmlUser, xmllistSchedule);
            if (ecode.Equals("00"))
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
Ejemplo n.º 23
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (txt_name.Text == string.Empty)
            {
                MessageBox.Show("رجاء ادخل اسم المستخدم");
                txt_name.Focus();
                return;
            }
            if (txt_pass.Text == string.Empty)
            {
                MessageBox.Show("رجاء ادخل كلمة المرور");
                txt_pass.Focus();
                return;
            }

            else
            {
                tb_user = dbs.TB_USERS.Where(x => x.USER_NAME == txt_name.Text && x.USER_PASS == txt_pass.Text).FirstOrDefault();

                if (tb_user != null)
                {
                    tb_user.USER_STATE       = "True";
                    dbs.Entry(tb_user).State = System.Data.Entity.EntityState.Modified;
                    frm_main.lb_roll.Text    = tb_user.USER_ROLL;
                    frm_main.lb_user.Text    = tb_user.USER_NAME;
                    frm_main.Enabled         = true;
                    dbs.SaveChanges();
                    frm_main.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("اسم المسخدم او  كلمة المرور غیر صیحیحة", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);;
                    return;
                }
            }
        }
Ejemplo n.º 24
0
 public bool Insert(TB_USERS user)
 {
     return(new TB_USERSSql().Insert(user));
 }
Ejemplo n.º 25
0
 public bool Update(TB_USERS user)
 {
     return(new TB_USERSSql().Update(user));
 }