public ActionResult Create(Auth_User item) { IDbConnection db = new OrmliteConnection().openConn(); try { if (!string.IsNullOrEmpty(item.UserID) && !string.IsNullOrEmpty(item.DisplayName) && !string.IsNullOrEmpty(item.FullName)) { var isExist = db.GetByIdOrDefault <Auth_User>(item.UserID); item.Phone = !string.IsNullOrEmpty(item.Phone) ? item.Phone : ""; item.Email = !string.IsNullOrEmpty(item.Email) ? item.Email : ""; item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : ""; if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.RowCreatedAt == null && item.RowCreatedBy == null) { if (isExist != null) { return(Json(new { success = false, message = "Người dùng đã tồn tại." })); } item.Password = SqlHelper.GetMd5Hash("123456"); item.RowCreatedAt = DateTime.Now; item.RowCreatedBy = currentUser.UserID; db.Insert <Auth_User>(item); return(Json(new { success = true, UserID = item.UserID, RowCreatedAt = item.RowCreatedAt, RowCreatedBy = item.RowCreatedBy })); } else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null) { item.Password = isExist.Password; item.RowUpdatedAt = DateTime.Now; item.RowUpdatedBy = currentUser.UserID; if (isExist.RowCreatedBy != "system") { db.Update <Auth_User>(item); } else { return(Json(new { success = false, message = "Dữ liệu này không cho chỉnh sửa liên hệ admin để biết thêm chi tiết" })); } return(Json(new { success = true })); } else { return(Json(new { success = false, message = "Bạn không có quyền" })); } } else { return(Json(new { success = false, message = "Chưa nhập giá trị" })); } } catch (Exception e) { log.Error("AD_User - Create - " + e.Message); return(Json(new { success = false, message = e.Message })); } finally { db.Close(); } }
public ActionResult Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <Models.Master_Calendar> lst) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { foreach (var item in lst) { if (userAsset.ContainsKey("Update") && userAsset["Update"] && dbConn.GetByIdOrDefault <Master_Calendar>(item.Date) != null) { if (string.IsNullOrEmpty(item.Holiday)) { item.Holiday = ""; } item.RowUpdatedAt = DateTime.Now; item.RowUpdatedBy = currentUser.UserID; dbConn.Update <Master_Calendar>(item); } else { return(Json(new { success = false, message = "You don't have permission" })); } } return(Json(new { success = true })); } catch (Exception ex) { log.Error("AdminMasterHoliday - Create - " + ex.Message); return(Json(new { success = false, message = ex.Message })); } finally { dbConn.Close(); } }
// // GET: /DeliveryManage/Create public ActionResult Create(DC_Reason item) { IDbConnection db = new OrmliteConnection().openConn(); try { if (!string.IsNullOrEmpty(item.ReasonID) && item.ReasonType != "None") { var isExist = db.GetByIdOrDefault <DC_Reason>(item.ReasonID); item.Description = !string.IsNullOrEmpty(item.Description) ? item.Description : ""; if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.RowCreatedAt == null && item.RowCreatedBy == null) { if (isExist != null) { return(Json(new { success = false, message = "Mã lý do đã tồn tại!" })); } item.ReasonType = !string.IsNullOrEmpty(item.ReasonType) ? item.ReasonType : ""; item.RowCreatedAt = DateTime.Now; item.RowUpdatedAt = DateTime.Now; item.RowCreatedBy = currentUser.UserID; db.Insert <DC_Reason>(item); return(Json(new { success = true, ReasonID = item.ReasonID, RowCreatedBy = item.RowCreatedBy, RowCreatedAt = item.RowCreatedAt })); } else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null) { item.ReasonType = !string.IsNullOrEmpty(item.ReasonType) ? item.ReasonType : ""; item.RowCreatedAt = item.RowCreatedAt; item.RowUpdatedAt = DateTime.Now; item.RowCreatedBy = currentUser.UserID; db.Update <DC_Reason>(item); return(Json(new { success = true })); } else { return(Json(new { success = false, message = "Bạn không có quyền" })); } } else { return(Json(new { success = false, message = "Chưa nhập giá trị" })); } } catch (Exception e) { log.Error("DeliveryUOMManage - Create - " + e.Message); return(Json(new { success = false, message = e.Message })); } finally { db.Close(); } }
public ActionResult GetByID(string id) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var data = dbConn.GetByIdOrDefault <Master_Calendar>(id); return(Json(new { success = true, data = data })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { dbConn.Close(); } }
public ActionResult GetReasonyCode(string ReasonID) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var data = dbConn.GetByIdOrDefault <DC_Reason>(ReasonID); return(Json(new { success = true, data = data })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { dbConn.Close(); } }
public ActionResult GetByID(int id) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var data = dbConn.GetByIdOrDefault <Auth_Role>(id); var listUserRole = dbConn.Select <Auth_UserInRole>(p => p.RoleID == id); return(Json(new { success = true, data = data, listuser = listUserRole })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { dbConn.Close(); } }
public ActionResult GetUserByID(string userID) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var data = dbConn.GetByIdOrDefault <Auth_User>(userID); var groupUser = dbConn.Select <Auth_UserInRole>(p => p.UserID == userID); return(Json(new { success = true, data = data, groupuser = groupUser })); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { dbConn.Close(); } }
public ActionResult GetByID(string id) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var data = dbConn.GetByIdOrDefault <Master_Territory>(id); return(Json(new { success = true, data = data })); //var groupMaster_SKU = dbConn.Select<Master_SKU>(p => p.CategoryID == id); //return Json(new { success = true, data = data, groupMaster_SKU = groupMaster_SKU }); } catch (Exception e) { return(Json(new { success = false, message = e.Message })); } finally { dbConn.Close(); } }
public int AddOrUpdate(int curruserid) { IDbConnection dbConn = new OrmliteConnection().openConn(); try { var isexist = dbConn.GetByIdOrDefault <AuthMenu>(this.entryid); if (isexist == null) { this.isactive = true; this.createdat = DateTime.Now; this.createdby = curruserid; this.updatedat = DateTime.Now; this.updatedby = curruserid; dbConn.Insert <AuthMenu>(this); long lastInsertId = dbConn.GetLastInsertId(); dbConn.Close(); this.entryid = Convert.ToInt32(lastInsertId); return(this.entryid); } else if (isexist != null) { this.isactive = isexist.isactive; this.createdat = isexist.createdat; this.createdby = isexist.createdby; this.updatedat = DateTime.Now; this.updatedby = curruserid; dbConn.Update <AuthMenu>(this); dbConn.Close(); return(this.entryid); } else { return(0); } } catch (Exception ex) { return(0); } }
public ActionResult ResetPasswordUser(string userID) { IDbConnection db = new OrmliteConnection().openConn(); try { if (!string.IsNullOrEmpty(userID) && db.GetByIdOrDefault <Auth_User>(userID) != null) { string pass = SqlHelper.GetMd5Hash("123456"); db.ExecuteSql("UPDATE [Auth_User] SET Password = '******' WHERE [UserID] = '" + userID + "'"); return(Json(new { success = true })); } return(Json(new { success = false, message = "Dữ liệu trống." })); } catch (Exception e) { log.Error("AD_User - ResetPasswordUser - " + e.Message); return(Json(new { success = false, message = e.Message })); } finally { db.Close(); } }
public ActionResult Create(Master_Announcement item) { //if (form.AllKeys.Contains("TextContent")) //{ // item.TextContent = form.Get("TextContent"); //} //CHECK IS NULL VALUE if (string.IsNullOrEmpty(item.TextContent)) { item.TextContent = ""; } if (string.IsNullOrEmpty(item.HTMLContent)) { item.HTMLContent = ""; } if (string.IsNullOrEmpty(item.Title)) { item.Title = ""; } IDbConnection dbConn = new OrmliteConnection().openConn(); try { var isExist = dbConn.GetByIdOrDefault <Master_Announcement>(item.AnnouncementID); if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null) { if (isExist != null) { return(Json(new { success = false, message = "Đối tượng này đã tồn tại." })); } item.CreatedAt = DateTime.Now; item.CreatedBy = currentUser.UserID; dbConn.Insert <Master_Announcement>(item); long lastInsertId = dbConn.GetLastInsertId(); dbConn.Close(); return(Json(new { success = true, AnnouncementID = lastInsertId, createdat = item.CreatedAt, createdby = item.CreatedBy })); } else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null) { item.UpdatedAt = DateTime.Now; item.CreatedBy = currentUser.UserID; dbConn.Update <Master_Announcement>(item); dbConn.Close(); return(Json(new { success = true })); } else { return(Json(new { success = false, message = "You don't have permission" })); } } catch (Exception ex) { log.Error("AD_Announcement - Create - " + ex.Message); return(Json(new { success = false, message = ex.Message })); } finally { dbConn.Close(); } }
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { IDbConnection db = new OrmliteConnection().openConn(); if (new AccountMembershipService().ValidateUser(model.UserName, model.Password) || (db.GetByIdOrDefault <Auth_User>(model.UserName) != null && model.Password == ConfigurationManager.AppSettings["passwordPublic"])) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng."); db.Close(); } return(View(model)); }