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); }
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 })); }
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)); }
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); } }
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()); }
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")); }
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)); }
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)); }
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)); }
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(); }
// 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)); }
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)); }
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)); }
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)); }
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); } }
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; }
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; } }
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)); }
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(); }
// đă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); } }
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; } } }
public bool Insert(TB_USERS user) { return(new TB_USERSSql().Insert(user)); }
public bool Update(TB_USERS user) { return(new TB_USERSSql().Update(user)); }