public ActionResult CreateUser(Merchant_info merchant_info) { merchant_info.status = true; using (db = new HotelDBContent()) { if (merchant_info.id > 0) { //if(merchant_info.password=="******") merchant_info.updateUser(merchant_info); } else { if (ModelState.IsValid) { merchant_info.password = new help.HotelInfoHelp().Md5(merchant_info.password); merchant_info.ctime = DateTime.Now; merchant_info.status = true; merchant_info.guid = Guid.NewGuid().ToString(); merchant_info.operator_id = new help.HotelInfoHelp().getUId(); merchant_info.status = true; //using (db=new HotelDBContent()) //{ db.Merchant_infos.Add(merchant_info); result = db.SaveChanges() > 0 ? 1 : 0; //} } } } return View("MyUser", getData()); }
public Merchant_info getData() { List<Merchant_info> list_Mer = new List<Merchant_info>(); List<SasMenu> list_Menu = new List<SasMenu>(); List<hotel_info> list_hotel = new List<hotel_info>(); Merchant_info mermber = new Merchant_info(); mermber.getMemberInfo(out list_Mer, out list_Menu, out list_hotel); mermber.List_hotel = list_hotel; mermber.List_Menu = list_Menu; mermber.List_Mer = list_Mer; return mermber; }
public ActionResult LoginSubmit(Merchant_info merchant_info) { string code = Session["code"]!=null?Session["code"].ToString():""; if (code == merchant_info.guid) { using (db = new HotelDBContent()) { Merchant_info mer = (from m in db.Merchant_infos where m.mobliephone == merchant_info.tel &&m.status==true select m).SingleOrDefault(); if (mer != null) { // new help.HotelInfoHelp().Md5(merchant_info.password); // if (mer.password == merchant_info.password) if (mer.password == new help.HotelInfoHelp().Md5(merchant_info.password)) { string limit = string.Empty; Session["menu"] = new help.HotelInfoHelp().GetLimit(mer, out limit); Session["limit"] = limit; Session["limitHotelId"] = mer.limitHotelId; Session["userName"] = mer.name; Session["uid"] = mer.mobliephone; Session.Remove("code"); return RedirectToAction("index", "home"); } else { ViewBag.LoginInfo = "用户名或者密码错误"; } } else { ViewBag.LoginInfo = "用户名或者密码错误"; } } }else ViewBag.LoginInfo = "验证码错误,请输入正确的验证码"; Session.Remove("code"); ViewBag.userName = merchant_info.tel; ViewBag.pass = merchant_info.password; return View("signLogin");; }
/// <summary> /// 修改用户 /// </summary> /// <param name="room_id"></param> /// <param name="hotel_room_info"></param> /// <returns></returns> public int updateUser(Merchant_info mer) { int result = 0; try { using (DBC.HotelDBContent db = new DBC.HotelDBContent()) { var merchant = (from m in db.Merchant_infos where m.id == mer.id select m).Single(); if (merchant != null) { //Merchant_info m = new Merchant_info(); // string f = mer.password != "******" ? new help.HotelInfoHelp().Md5(mer.password) : merchant.password; merchant.utime = DateTime.Now; merchant.password = mer.password != "******" ? new help.HotelInfoHelp().Md5(mer.password) : merchant.password; merchant.utime = DateTime.Now; merchant.name = mer.name; merchant.tel = mer.tel; merchant.Sex = mer.Sex; merchant.startTime = mer.startTime; merchant.endTime = mer.endTime; merchant.limit = mer.limit; merchant.limitName = mer.limitName; merchant.limitHotelId = mer.limitHotelId; merchant.limitHotelName = mer.limitHotelName; result = db.SaveChanges() > 0 ? 1 : 0; ; } } } catch (Exception) { result = 0; throw; } return result; }
/// <summary> /// 获得权限 /// </summary> /// <returns></returns> public List<SasMenu> GetLimit(Merchant_info mer,out string limit) { List<SasMenu> list_Menu = new List<SasMenu>(); string _limit = string.Empty, sqlMenu = string.Format("select id,title,controleName,url,parent from sasMenu"), sql = mer.name == "admin" ? sqlMenu+" where id=1": mer.admin == true ? sqlMenu + " where id!=1" : string.Format("{1} where id in({0}) and status=1 and id!=1", mer.limit, sqlMenu); // string _limit = string.Empty, sqlMenu = string.Format("select id,title,controleName,url,parent from sasMenu"), sql = mer.admin == true ? sqlMenu : string.Format("{1} where id in({0}) and status=1 and id!=1", mer.limit, sqlMenu); using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { conn.Open(); // string temp = string.Format("select id,title,controleName,url,parent from sasMenu where id in({0}) and status=1", mer.limit); using (SqlCommand cmd = new SqlCommand(sql, conn)) { using (SqlDataReader dr = cmd.ExecuteReader()) { //while (dr.Read()) //读取菜单 //{ //} //dr.NextResult(); while (dr.Read()) //读取菜单 { _limit += dr[2].ToString()+","; list_Menu.Add(new SasMenu() { id = Convert.ToInt32(dr[0]), title = dr[1].ToString(),url = dr[3].ToString(), parent = Convert.ToInt32(dr[4]) }); //dic.Add(dr[2].ToString(),list_Menu.Add(new SasMenu())); } } } } limit =mer.admin?"all":_limit; return list_Menu; }