public ActionResult Create(FormCollection form)
        {
            IDbConnection db = new OrmliteConnection().openConn();
            try
            {
                if (!string.IsNullOrEmpty(form["RoleName"]))
                {
                    var item = new Auth_Role();
                    item.RoleName = form["RoleName"];
                    item.IsActive = form["IsActive"] != null ? Convert.ToBoolean(form["IsActive"]) : false;
                    item.Note = !string.IsNullOrEmpty(form["Note"]) ? form["Note"] : "";
                    if (userAsset.ContainsKey("Insert") && userAsset["Insert"] &&
                        string.IsNullOrEmpty(form["RoleID"]))    // Tạo mới
                    {
                        item.RowCreatedAt = DateTime.Now;
                        item.RowCreatedBy = currentUser.UserID;
                        db.Insert<Auth_Role>(item);
                        long lastID = db.GetLastInsertId();
                        if (lastID > 0)
                        {
                            // Thêm Role vào Auth_Action
                            db.ExecuteSql("EXEC p_Auth_Role_GenerateAction_By_RoleID " + lastID + "," + currentUser.UserID);
                        }
                        return Json(new { success = true, insert = true, RoleID = lastID, createdat = item.RowCreatedAt, createdby = item.RowCreatedBy });
                    }
                    else if (userAsset.ContainsKey("Insert") && userAsset["Insert"] &&
                            Convert.ToInt32(form["RoleID"]) > 0 &&
                            Convert.ToInt32(form["IsCopy"]) == 1)  // Sao chép
                    {
                        item.RoleID = Convert.ToInt32(form["RoleID"]);
                        item.RowCreatedAt = DateTime.Now;
                        item.RowCreatedBy = currentUser.UserID;
                        db.Insert<Auth_Role>(item);
                        long lastID = db.GetLastInsertId();
                        if (lastID > 0)
                        {
                            // Sao chép Action RoleID đã chọn vào RoleID vừa tạo
                            db.ExecuteSql("p_Auth_Role_CopyAction_By_RoleID " + item.RoleID + "," + lastID + "," + currentUser.UserID);
                        }
                        return Json(new { success = true, insert = true, RoleID = lastID, createdat = item.RowCreatedAt, createdby = item.RowCreatedBy });
                    }
                    else if (userAsset.ContainsKey("Update") && userAsset["Update"] &&
                            Convert.ToInt32(form["RoleID"]) > 0)    // Cập nhật
                    {
                        item.RoleID = Convert.ToInt32(form["RoleID"]);
                        item.RowCreatedAt = DateTime.Parse(form["RowCreatedAt"]);
                        item.RowCreatedBy = form["RowCreatedBy"];
                        item.RowUpdatedAt = DateTime.Now;
                        item.RowUpdatedBy = currentUser.UserID;
                        if (item.RowCreatedBy != "system")
                        {
                            db.Update<Auth_Role>(item);
                        }

                        return Json(new { success = true, RoleID = item.RoleID });
                    }
                    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("HOAdminAuthRole - Create - " + e.Message);
                return Json(new { success = false, message = e.Message });
            }
            finally { db.Close(); }
        }
 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(); }
 }