/// <summary> /// 修改文本数据 /// </summary> /// <param name="con"></param> /// <returns></returns> public static int UpdContextData(tb_Context con) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var context = entity.tb_Context.FirstOrDefault(item => item.ContextID == con.ContextID && item.Status == 1); if (context != null) { context.Title = con.Title; context.Explain = con.Explain; context.Intro = con.Intro; context.Title = con.Title; entity.Entry(context).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 更新订单状态 /// </summary> /// <param name="orderid"></param> /// <param name="status"></param> /// <returns></returns> public static int UpdOrderStatus(string orderid, int status) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; var order = entity.tb_Order.FirstOrDefault(item => item.OrderID == orderid); if (order != null) { order.Status = status; entity.Entry(order).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 新增文本数据 /// </summary> /// <param name="con"></param> /// <returns></returns> public static int AddContextData(tb_Context con) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var context = entity.tb_Context.FirstOrDefault(item => item.Type == con.Type && item.Status == 1); if (context == null) { con.ContextID = Utility.GetNewGUID_Tab(); con.Status = 1; con.CreateDate = DateTime.Now; entity.Entry(con).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 编辑需求数据 /// </summary> /// <param name="order"></param> /// <returns></returns> public static int EditOrderData(tb_Order order) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; var orderdata = entity.tb_Order.FirstOrDefault(item => item.OrderID == order.OrderID); if (orderdata != null) { orderdata.Memo = order.Memo; orderdata.OrderClassify = order.OrderClassify; orderdata.OrderIntor = order.OrderIntor; orderdata.OrderTitle = order.OrderTitle; orderdata.OrderType = order.OrderType; entity.Entry(orderdata).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 注册 /// </summary> /// <param name="userInfo"></param> /// <returns></returns> public static int SetUserInfo(tb_User userInfo) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; var user = entity.tb_User.FirstOrDefault(item => item.UserPhone == userInfo.UserPhone); if (user == null) { userInfo.ID = Utility.GetNewGUID_Tab(); userInfo.LoginID = userInfo.UserPhone; userInfo.Sex = 1; userInfo.Status = 1; userInfo.Role = 0; userInfo.RoleStatus = 1; userInfo.ImgUrl = "/Content/img/HeadImg/login.png"; userInfo.LastLognTime = DateTime.Now; userInfo.CreateDate = DateTime.Now; entity.Entry(userInfo).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 兼职申请 /// </summary> /// <returns></returns> public static int SetPartTimeTeacher(tb_PartTime pt) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; var teacher = entity.tb_PartTime.FirstOrDefault(item => item.UserID == pt.UserID && item.Status != -1); if (teacher == null) { pt.PartTimeID = Utility.GetNewGUID_Tab(); pt.Status = 1;//待确定 pt.CreateDate = Utility.GetSysDateTime(); entity.Entry(pt).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 新增需求(订单) /// </summary> /// <param name="order"></param> /// <returns></returns> public static int OwnNeedDataIns(tb_Order order) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; var orderdata = entity.tb_Order.FirstOrDefault(item => item.OrderID == order.OrderID); if (orderdata == null) { order.Status = 0; order.CreateDate = Utility.GetSysDateTime(); entity.Entry(order).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 修改登录密码 /// </summary> /// <param name="phone"></param> /// <param name="pwd"></param> /// <param name="newpwd"></param> /// <returns></returns> public static int UpdAdminPwd(string phone, string pwd, string newpwd) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; var admin = entity.tb_Admins.FirstOrDefault(item => item.Mobile == phone && item.AdminPwd == pwd); if (admin != null) { admin.AdminPwd = newpwd; entity.Entry(admin).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } }
/// <summary> /// 更新登录时间和次数 /// </summary> /// <param name="userid">用户ID</param> /// <param name="lastlogintime">登录时间</param> /// <returns></returns> public static bool UpdateLastLoginTime(string userid, DateTime lastlogintime) { using (CareCenterEntities entity = new CareCenterEntities()) { var user = entity.tb_User.FirstOrDefault(item => item.ID == userid); if (user != null) { user.LastLognTime = lastlogintime; //时间 entity.Entry(user).State = System.Data.Entity.EntityState.Modified; //修改登录时间 entity.SaveChanges(); return(true); } else { return(false); } } }
/// <summary> /// 修改登录时间 /// </summary> /// <param name="adminid"></param> /// <returns></returns> public static int UpdateLastDateTime(string adminid) { using (CareCenterEntities entity = new CareCenterEntities()) { var admin = entity.tb_Admins.FirstOrDefault(item => item.AdminID == adminid || item.Mobile == adminid); if (admin != null) { admin.LastLoginTime = DateTime.Now; entity.Entry(admin).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); return(1); } else { return(-1); } } }
/// <summary> /// 根据用户adminID获取菜单 /// </summary> /// <param name="adminid"></param> /// <returns></returns> //public static List<eo_admins_menu> GetAdminMenu(string adminid) //{ // var strSql = new StringBuilder(); // strSql.Append(@"SELECT M.MenuID // ,M.MenuName // ,M.FMenuID // ,M.FMenuName // ,M.MenuUrl // ,M.FMenuUrl // ,M.Status // ,M.Memo // ,M.CreateDate // FROM eo_admins A // LEFT JOIN eo_admins_role R ON R.RoleID=A.RoleID AND R.Status=1 // LEFT JOIN eo_admins_menu M ON (SELECT CHARINDEX(M.MenuID,R.MenuID))>0 AND M.Status=1 // WHERE A.AdminID='" + adminid + "' AND A.Status=1"); // using (eo_dbEntities entity = new eo_dbEntities()) // { // var menu = entity.Database.SqlQuery<eo_admins_menu>(strSql.ToString()).ToList(); // return menu; // } //} #endregion #region ***后台用户管理*** /// <summary> /// 禁用/启用管理员 /// </summary> /// <returns></returns> public static int UpdAdminStatus(string id, int status) { using (CareCenterEntities entity = new CareCenterEntities()) { var admin = entity.tb_Admins.FirstOrDefault(item => item.ID == id); if (admin != null) { admin.Status = status; entity.Entry(admin).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); return(1); } else { return(-1); } } }
/// <summary> /// 管理员注册 /// </summary> /// <param name="am"></param> /// <returns></returns> public static int Register(tb_Admins am) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; var admin = entity.tb_Admins.FirstOrDefault(item => item.AdminID == am.AdminID); if (admin == null) { am.ID = Utility.GetNewGUID(); am.Status = 1; am.CreateDate = DateTime.Now; am.LastLoginTime = DateTime.Now; //am.Memo = null; entity.Entry(am).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; } return(count); } }
/// <summary> /// 后台用户信息修改 /// </summary> /// <param name="am"></param> /// <returns></returns> public static int UpdRegister(tb_Admins am) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; var admin = entity.tb_Admins.FirstOrDefault(item => item.ID == am.ID); if (admin != null) { admin.AdminID = am.AdminID; admin.NickName = am.NickName; admin.RealName = am.RealName; admin.Mobile = am.Mobile; admin.Memo = null; entity.Entry(admin).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } }
/// <summary> /// 新增评论 /// </summary> /// <param name="com"></param> /// <returns></returns> public static int SetCommentData(tb_Comment com) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; com.CommentID = Utility.GetNewGUID(); com.Status = 1; com.CreateDate = Utility.GetSysDateTime(); entity.Entry(com).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 新增图片 /// </summary> /// <param name="pic"></param> /// <returns></returns> public static int PictureIns(tb_Pictuer pic) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; pic.PicID = Utility.GetNewGUID(); pic.Status = 1; pic.CreateDate = Utility.GetSysDateTime(); entity.Entry(pic).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 新增视频 /// </summary> /// <param name="video"></param> /// <returns></returns> public static int VideoIns(tb_Video video) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; video.VideoID = Utility.GetNewGUID(); video.Status = 1; video.CreateDate = Utility.GetSysDateTime(); entity.Entry(video).State = System.Data.Entity.EntityState.Added; entity.SaveChanges(); count = 1; return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 删除文本 /// </summary> /// <param name="contextid"></param> /// <returns></returns> public static int DelContext(string contextid) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var context = entity.tb_Context.FirstOrDefault(item => item.ContextID == contextid); if (context != null) { entity.Entry(context).State = System.Data.Entity.EntityState.Deleted; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 删除申请职位 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static int DelPart(string userid) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var order = entity.tb_PartTime.FirstOrDefault(item => item.UserID == userid); if (order != null) { entity.Entry(order).State = System.Data.Entity.EntityState.Deleted; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 删除图片 /// </summary> /// <param name="picid"></param> /// <returns></returns> public static int DelPicData(string picid) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var picdata = entity.tb_Pictuer.FirstOrDefault(item => item.PicID == picid); if (picdata != null) { entity.Entry(picdata).State = System.Data.Entity.EntityState.Deleted; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 删除视频 /// </summary> /// <param name="videoid"></param> /// <returns></returns> public static int DelVideoData(string videoid) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var videodata = entity.tb_Video.FirstOrDefault(item => item.VideoID == videoid); if (videodata != null) { entity.Entry(videodata).State = System.Data.Entity.EntityState.Deleted; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 服务方职位申请审核 /// </summary> /// <param name="userid"></param> /// <param name="flag"></param> /// <returns></returns> public static int UpdRoleStatus(string userid, int flag) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var order = entity.tb_User.FirstOrDefault(item => item.ID == userid); if (order != null) { order.RoleStatus = flag; entity.Entry(order).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 修改密码 /// </summary> /// <param name="userphone"></param> /// <param name="userpwd"></param> /// <returns></returns> public static int UpdUserPwd(string userphone, string userpwd) { try { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; var user = entity.tb_User.FirstOrDefault(item => item.UserPhone == userphone); if (user != null) { user.LoginPwd = userpwd; entity.Entry(user).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 兼职申请用户表角色更新 /// </summary> /// <returns></returns> public static int UpdUserRole(string userid, int flag) { using (CareCenterEntities entity = new CareCenterEntities()) { try { int count = 0; var teacher = entity.tb_User.FirstOrDefault(item => item.ID == userid && item.Status == 1); if (teacher != null) { teacher.Role = flag; teacher.RoleStatus = 0;//待确定 entity.Entry(teacher).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 修改图片标题简介 /// </summary> /// <param name="picid"></param> /// <param name="title">标题</param> /// <param name="memo">简介</param> /// <returns></returns> public static int EditPicData(string picid, string title, string memo) { using (CareCenterEntities entity = new CareCenterEntities()) { int count = 0; try { var picdata = entity.tb_Pictuer.FirstOrDefault(item => item.PicID == picid); if (picdata != null) { picdata.PicTitle = title; picdata.Memo = memo; entity.Entry(picdata).State = System.Data.Entity.EntityState.Modified; entity.SaveChanges(); count = 1; } return(count); } catch (Exception ex) { throw ex; } } }