public ActionResult RoleCreate(string Id) { string eMsg = SiteMainMenuList("Role Details", "Settings", "RoleList"); if (!string.IsNullOrEmpty(eMsg)) { return(RedirectToOut(eMsg)); } //else if (!SiteUserAccess("", "V")) return RedirectToOut(); ViewBag.MainFeatureList = List_MainFeature(); ViewBag.DashboardList = SiteDashboardList(); AdmRolemasterEntity obj = new AdmRolemasterEntity(); if (!string.IsNullOrEmpty(Id)) { obj = (AdmRolemasterEntity)ExecuteDB(HCareTaks.AG_GetSingleAdmRolemasterRecordById, Id); if (obj == null) { obj = new AdmRolemasterEntity(); } } ViewBag.TableData = RoleDetailsTableData(Id); return(View(obj)); }
public object UpdateAdmRolemasterInfo(object param) { Database db = DatabaseFactory.CreateDatabase(); object retObj = null; using (DbConnection connection = db.CreateConnection()) { connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { AdmRolemasterEntity admRolemasterEntity = (AdmRolemasterEntity)param; AdmRolemasterDAL admRolemasterDAL = new AdmRolemasterDAL(); retObj = (object)admRolemasterDAL.UpdateAdmRolemasterInfo(admRolemasterEntity, db, transaction); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } return(retObj); }
public AdmRolemasterEntity GetSingleAdmRolemasterRecordById(object param) { Database db = DatabaseFactory.CreateDatabase(); string sql = "SELECT ID, RoleName, RoleDescription, DefaultBoard, AllDashboard, IsActive, CreatedBy, CreatedTime, UpdatedBy, UpdatedTime FROM Adm_RoleMaster WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, param); AdmRolemasterEntity admRolemasterEntity = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { admRolemasterEntity = new AdmRolemasterEntity(); if (dataReader["ID"] != DBNull.Value) { admRolemasterEntity.Id = dataReader["ID"].ToString(); } if (dataReader["RoleName"] != DBNull.Value) { admRolemasterEntity.Rolename = dataReader["RoleName"].ToString(); } if (dataReader["RoleDescription"] != DBNull.Value) { admRolemasterEntity.Roledescription = dataReader["RoleDescription"].ToString(); } if (dataReader["DefaultBoard"] != DBNull.Value) { admRolemasterEntity.DefaultBoard = dataReader["DefaultBoard"].ToString(); } if (dataReader["AllDashboard"] != DBNull.Value) { admRolemasterEntity.AllDashboard = dataReader["AllDashboard"].ToString(); } if (dataReader["IsActive"] != DBNull.Value) { admRolemasterEntity.Isactive = dataReader["IsActive"].ToString(); } if (dataReader["CreatedBy"] != DBNull.Value) { admRolemasterEntity.Createdby = dataReader["CreatedBy"].ToString(); } if (dataReader["CreatedTime"] != DBNull.Value) { admRolemasterEntity.Createdtime = dataReader["CreatedTime"].ToString(); } if (dataReader["UpdatedBy"] != DBNull.Value) { admRolemasterEntity.Updatedby = dataReader["UpdatedBy"].ToString(); } if (dataReader["UpdatedTime"] != DBNull.Value) { admRolemasterEntity.Updatedtime = dataReader["UpdatedTime"].ToString(); } } } return(admRolemasterEntity); }
public JsonResult RoleSaveUpdate(AdmRolemasterEntity obj) { JavaScriptSerializer serializer = new JavaScriptSerializer(); List <AdmRoledetailsEntity> dGetObj = serializer.Deserialize <List <AdmRoledetailsEntity> >(obj.JsonDetails); bool Success = false; if (string.IsNullOrEmpty(obj.Isactive)) { obj.Isactive = "Active"; } if (string.IsNullOrEmpty(obj.Id)) { obj.Createdby = Session["UserId"].ToString(); obj.Createdtime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); obj.Id = (string)ExecuteDB(HCareTaks.AG_SaveAdmRolemasterInfo, obj); if (!string.IsNullOrEmpty(obj.Id)) { Success = true; } } else { obj.Updatedby = Session["UserId"].ToString(); obj.Updatedtime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); Success = (bool)ExecuteDB(HCareTaks.AG_UpdateAdmRolemasterInfo, obj); } if (Success) { foreach (AdmRoledetailsEntity uObj in dGetObj) { uObj.Roleid = obj.Id; if (string.IsNullOrEmpty(uObj.Id)) { ExecuteDB(HCareTaks.AG_SaveAdmRoledetailsInfo, uObj); } else { ExecuteDB(HCareTaks.AG_UpdateAdmRoledetailsInfo, uObj); } } } string Message = Success ? "Process has been done successfully" : "Sorry something went wrong!"; return(Json(new { Success = Success, Message = Message, Id = obj.Id })); }
public JsonResult RoleDeleteById(string Id) { bool Success = false; AdmRolemasterEntity obj = (AdmRolemasterEntity)ExecuteDB(HCareTaks.AG_GetSingleAdmRolemasterRecordById, Id); if (obj != null) { obj.Updatedby = Session["UserId"].ToString(); obj.Updatedtime = DateTime.Now.ToString("dd/MM/yyyy"); obj.Isactive = "Inactive"; Success = (bool)ExecuteDB(HCareTaks.AG_UpdateAdmRolemasterInfo, obj); } string Message = Success ? "Delete Success" : "Sorry something went wrong!"; return(Json(new { Success = Success, Message = Message })); }
public List <SelectListItem> List_UserRole() { List <SelectListItem> Items = new List <SelectListItem>(); AdmRolemasterEntity obj = new AdmRolemasterEntity(); obj.Isactive = "Active"; DataTable dt = (DataTable)ExecuteDB(HCareTaks.AG_GetAllAdmRolemasterRecord, obj); foreach (DataRow dr in dt.Rows) { Items.Add(new SelectListItem { Text = dr["RoleName"].ToString(), Value = dr["ID"].ToString() }); } return(Items); }
public bool UpdateAdmRolemasterInfo(AdmRolemasterEntity admRolemasterEntity, Database db, DbTransaction transaction) { string sql = "UPDATE Adm_RoleMaster SET RoleName= @Rolename, RoleDescription= @Roledescription, DefaultBoard= @DefaultBoard, AllDashboard= @AllDashboard, IsActive= @Isactive, UpdatedBy= @Updatedby, UpdatedTime= @Updatedtime WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, admRolemasterEntity.Id); db.AddInParameter(dbCommand, "Rolename", DbType.String, admRolemasterEntity.Rolename); db.AddInParameter(dbCommand, "Roledescription", DbType.String, admRolemasterEntity.Roledescription); db.AddInParameter(dbCommand, "DefaultBoard", DbType.String, admRolemasterEntity.DefaultBoard); db.AddInParameter(dbCommand, "AllDashboard", DbType.String, admRolemasterEntity.AllDashboard); db.AddInParameter(dbCommand, "Isactive", DbType.String, admRolemasterEntity.Isactive); db.AddInParameter(dbCommand, "Updatedby", DbType.String, admRolemasterEntity.Updatedby); db.AddInParameter(dbCommand, "Updatedtime", DbType.String, admRolemasterEntity.Updatedtime); db.ExecuteNonQuery(dbCommand, transaction); return(true); }
public object SaveAdmRolemasterInfo(AdmRolemasterEntity admRolemasterEntity, Database db, DbTransaction transaction) { string sql = "INSERT INTO Adm_RoleMaster ( RoleName, RoleDescription, DefaultBoard, AllDashboard, IsActive, CreatedBy, CreatedTime) output inserted.ID VALUES ( @Rolename, @Roledescription, @DefaultBoard, @AllDashboard, @Isactive, @Createdby, @Createdtime )"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Rolename", DbType.String, admRolemasterEntity.Rolename); db.AddInParameter(dbCommand, "Roledescription", DbType.String, admRolemasterEntity.Roledescription); db.AddInParameter(dbCommand, "DefaultBoard", DbType.String, admRolemasterEntity.DefaultBoard); db.AddInParameter(dbCommand, "AllDashboard", DbType.String, admRolemasterEntity.AllDashboard); db.AddInParameter(dbCommand, "Isactive", DbType.String, admRolemasterEntity.Isactive); db.AddInParameter(dbCommand, "Createdby", DbType.String, admRolemasterEntity.Createdby); db.AddInParameter(dbCommand, "Createdtime", DbType.String, admRolemasterEntity.Createdtime); var id = db.ExecuteScalar(dbCommand, transaction).ToString(); return(id); }
string RoleListTableData() { string TableData = ""; AdmRolemasterEntity obj = new AdmRolemasterEntity(); DataTable dt = (DataTable)ExecuteDB(HCareTaks.AG_GetAllAdmRolemasterRecord, obj); int Count = 1; foreach (DataRow dr in dt.Rows) { string Action = "<i class='mdi mdi-table-edit iAction' title='Edit This' onclick=\"EditDetails('" + dr["Id"].ToString() + "')\" style='color:orange'></i>"; Action += "<i class='mdi mdi-close-box iAction' title='Inactive This' onclick=\"DeleteDetails('" + dr["Id"].ToString() + "', this)\" style='color:red'></i>"; TableData += "<tr>" + "<td>" + Count + "</td>" + "<td>" + dr["RoleName"] + "</td>" + "<td>" + dr["RoleDescription"] + "</td>" + "<td class='IsActive'>" + dr["IsActive"] + "</td>" + "<td>" + Action + "</td>" + "</tr>"; Count += 1; } string CreateBtn = "<button class='btn btn-primary' type='button' onclick='CreateDetails()' style='margin-bottom:10px;'> New</button>"; string tHead = "<tr>" + "<th>SortBy</th>" + "<th>RoleName</th>" + "<th>RoleDescription</th>" + "<th>IsActive</th>" + "<th>Action</th>" + "</tr>"; TableData = CreateBtn + "<div class='table-responsive'><table id='zero_config' class='table table-striped table-bordered'>" + "<thead>" + tHead + "</thead><tbody>" + TableData + "</tbody></table></div>"; return(TableData); }
public DataTable GetAllAdmRolemasterRecord(object param) { Database db = DatabaseFactory.CreateDatabase(); string sql = @"SELECT ID, RoleName, RoleDescription, DefaultBoard, AllDashboard, IsActive, CreatedBy, CreatedTime, UpdatedBy, UpdatedTime FROM Adm_RoleMaster Where 1=1"; AdmRolemasterEntity obj = new AdmRolemasterEntity(); if (param != null) { obj = (AdmRolemasterEntity)param; } if (!string.IsNullOrEmpty(obj.Isactive)) { sql += " And IsActive = '" + obj.Isactive + "'"; } sql += " Order By RoleName Asc"; DbCommand dbCommand = db.GetSqlStringCommand(sql); DataSet ds = db.ExecuteDataSet(dbCommand); return(ds.Tables[0]); }
bool fnUserInfoSession(string Id) { bool Success = false; HcUsersEntity uInfo = (HcUsersEntity)ExecuteDB(HCareTaks.AG_GetSingleHcUsersRecordById, Id); if (uInfo != null) { Success = true; string uId = uInfo.Id, uName = uInfo.FirstName + " " + uInfo.LastName, uType = uInfo.Usertype, uDetlId = uInfo.Userid, uRoleId = uInfo.Roleid, UserDefaultBoard = "", UserAllDashboard = "", UserImage = "/Content/rkscript/docx/UserImage/NoImage.jpg"; //................................................. Role Info if (uType == "Admin") { UserDefaultBoard = "Admin"; List <SiteInfo> Items = SiteDashboardList(); foreach (SiteInfo dr in Items) { UserAllDashboard += dr.MenuId + ","; } } else if (!string.IsNullOrEmpty(uRoleId)) { AdmRolemasterEntity sObj = (AdmRolemasterEntity)ExecuteDB(HCareTaks.AG_GetSingleAdmRolemasterRecordById, uRoleId); if (sObj != null) { UserDefaultBoard = sObj.DefaultBoard; UserAllDashboard = sObj.AllDashboard; } } //................................................. User Details Info if (!string.IsNullOrEmpty(uDetlId)) { if (uType == "Doctor") { HcDoctorinfoEntity sObj = (HcDoctorinfoEntity)ExecuteDB(HCareTaks.AG_GetSingleHcDoctorinfoRecordById, uDetlId); if (sObj != null && !string.IsNullOrEmpty(sObj.Photo)) { uName = sObj.Name; if (!string.IsNullOrEmpty(sObj.Photo)) { UserImage = sObj.Photo; } } } else if (uType == "Patient") { //HcDoctorinfoEntity sObj = (HcDoctorinfoEntity)ExecuteDB(HCareTaks.AG_GetSingleHcDoctorinfoRecordById, uDetlId); //if (sObj != null && !string.IsNullOrEmpty(sObj.Photo)) //{ // uName = sObj.Name; // if (!string.IsNullOrEmpty(sObj.Photo)) UserImage = sObj.Photo; //} } } if (Success) { //................................................. Set Sessions Session["UserId"] = uId; Session["UserName"] = uName; Session["UserType"] = uType; // Admin, Doctor, Patient, Staff Session["UserRoleId"] = uRoleId; Session["UserImage"] = UserImage; Session["UserDefaultBoard"] = UserDefaultBoard; Session["UserAllDashboard"] = UserDefaultBoard + "," + UserAllDashboard; //................................................. Set LastLogIn Time HcUsersEntity log = new HcUsersEntity(); log.Id = Id; log.Lastlogin = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); log.QueryFlag = "LastLogIn"; ExecuteDB(HCareTaks.AG_UpdateHcUsersInfo, log); } } return(Success); }