public PMInfo GetPM(int pmID) { using (dbc = new SqlHelper()) { dbc.AddIntParameter("@PMID", pmID); PMInfo pmInfo = null; dbc.Read("select PMID,UserID,UserIDFrom,PMTime,Title,Content from PM where PMID=@PMID", CommandType.Text, dr => { if (dr.HasRows && dr.Read()) { pmInfo = new PMInfo() { PMID = (int)dr[0], UserID = (int)dr[1], UserIDFrom = dr[2] == DBNull.Value ? 0 : (int)dr[2], PMTime = dr[3] == DBNull.Value ? DateTime.MinValue : (DateTime)dr[3], Title = dr[4] == DBNull.Value ? null : (string)dr[4], Content = dr[5] == DBNull.Value ? null : (string)dr[5], }; } }); return(pmInfo); } }
public void ModifyPM(PMInfo pmInfo) { using (dbc = new SqlHelper()) { dbc.AddIntParameter("@PMID", pmInfo.PMID); dbc.AddIntParameter("@UserIDFrom", pmInfo.UserIDFrom); dbc.AddDateTimeParameter("@PMTime", pmInfo.PMTime); dbc.AddStringParameter("@Title", 400, pmInfo.Title); dbc.AddTextParameter("@Content", pmInfo.Content); dbc.ExecuteNonQuery("update PM set UserIDFrom=@UserIDFrom,PMTime=@PMTime,Title=@Title,Content=@Content where PMID=@PMID", CommandType.Text); } }
public void AddPM(PMInfo pmInfo) { using (dbc = new SqlHelper()) { dbc.AddIntParameter("@UserID", pmInfo.UserID); dbc.AddIntParameter("@UserIDFrom", pmInfo.UserIDFrom); dbc.AddDateTimeParameter("@PMTime", pmInfo.PMTime); dbc.AddStringParameter("@Title", 400, pmInfo.Title); dbc.AddTextParameter("@Content", pmInfo.Content); dbc.ExecuteNonQuery("insert into PM (UserID,UserIDFrom,PMTime,Title,Content) values (@UserID,@UserIDFrom,@PMTime,@Title,@Content)", CommandType.Text); } }
public ActionResult ModifyPM() { if (Request.HttpMethod == "GET") { if (!AppData.IsManagerLogin) { return(Redirect("/Manage/Error/1.html")); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 2103)) { return(Redirect("/Manage/Error/2.html")); } return(View()); } if (!AppData.IsManagerLogin) { return(Json(new { success = false, msg = "您未登录后台或会话已过期" })); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 2103)) { return(Json(new { success = false, msg = "您没有执行该操作的权限" })); } Validation vld = new Validation(); int pmID = vld.GetInt("id"); PM pm = new PM(); PMInfo pmInfo = pm.GetPM(pmID); if (pmInfo == null) { return(Json(new { success = false, msg = "该短消息不存在!" })); } pmInfo.Title = vld.Get("title"); pmInfo.Content = HttpUtility.UrlDecode(vld.Get("content"), Encoding.UTF8); pmInfo.UserIDFrom = AppData.SessionUser.UserID; UserBLL userBLL = new UserBLL(); pm.ModifyPM(pmInfo); return(Json(new { success = true })); }
public ActionResult AddPM() { if (Request.HttpMethod == "GET") { if (!AppData.IsManagerLogin) { return(Redirect("/Manage/Error/1.html")); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 2101)) { return(Redirect("/Manage/Error/2.html")); } return(View()); } if (!AppData.IsManagerLogin) { return(Json(new { success = false, msg = "您未登录后台或会话已过期" })); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 2101)) { return(Json(new { success = false, msg = "您没有执行该操作的权限" })); } Validation vld = new Validation(); PMInfo pmInfo = new PMInfo() { UserID = vld.GetInt("userID"), UserIDFrom = AppData.SessionUser.UserID, Title = vld.Get("title"), Content = HttpUtility.UrlDecode(vld.Get("content"), Encoding.UTF8), PMTime = DateTime.Now }; UserBLL userBLL = new UserBLL(); PM pm = new PM(); pm.AddPM(pmInfo); return(Json(new { success = true })); }
public ActionResult DeletePM(int id) { if (!AppData.IsManagerLogin) { return(Json(new { success = false, msg = "您未登录后台或会话已过期" })); } if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 2102)) { return(Json(new { success = false, msg = "您没有执行该操作的权限" })); } PM pm = new PM(); PMInfo pmInfo = pm.GetPM(id); if (pmInfo == null) { return(Json(new { success = false, msg = "该短消息不存在!" })); } pm.DeletePM(id); return(Json(new { success = true })); }
public ActionResult DeletePM(int id) { UserObj user = AppData.SessionUser; if (user == null) { return(Json(new { success = false, msg = "您还未登录" })); } PM pm = new PM(); PMInfo pmInfo = pm.GetPM(id); if (pmInfo == null) { return(Json(new { success = false, msg = "该短消息不存在!" })); } if (pmInfo.UserID != user.UserID) { return(Json(new { success = false, msg = "该短消息不存在1!" })); } pm.DeletePM(id); return(Json(new { success = true })); }
public void ModifyPM(PMInfo pmInfo) { dal.ModifyPM(pmInfo); }
public void AddPM(PMInfo pmInfo) { dal.AddPM(pmInfo); }