public ActionResult Edit(DAO.MemberLevel car) { Dictionary <string, Object> map = new Dictionary <string, Object>(); //修改汽车 MemberLevelBll bll = new MemberLevelBll(); bool r = bll.update(car); return(RedirectToAction("memberLevel")); }
/// <summary> /// 增加一条记录 /// </summary> /// <param name="car">实体</param> /// <returns></returns> public bool Add(DAO.MemberLevel car) { db.MemberLevel.Add(car); int i = db.SaveChanges(); if (i > 0) { return(true); } else { return(false); } }
public ActionResult Add(DAO.MemberLevel car) { Dictionary <string, Object> map = new Dictionary <string, Object>(); //添加汽车 MemberLevelBll bll = new MemberLevelBll(); bool r = bll.Add(car); if (r) { //map.Add("result", "ok"); } else { //map.Add("result", "error"); } return(RedirectToAction("memberLevel")); }
/// <summary> /// 修改 /// </summary> /// <param name="car"></param> /// <returns></returns> public bool update(DAO.MemberLevel m) { DAO.MemberLevel c = db.MemberLevel.Where(mc => mc.ID == m.ID).FirstOrDefault(); c.Name = m.Name; c.MinIntegral = m.MinIntegral; c.MaxIntegral = m.MaxIntegral; c.Ratio = m.Ratio; db.Entry(c).State = System.Data.EntityState.Modified; int result = db.SaveChanges(); if (result > 0) { return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //获取从wxProcess.aspx传递过来的跳转地址reurl if (Request.QueryString["reurl"] != null && Request.QueryString["reurl"] != "") { reurl = Request.QueryString["reurl"].ToString(); } string code = ""; if (Request.QueryString["code"] != null && Request.QueryString["code"] != "") { //获取微信回传的code code = Request.QueryString["code"].ToString(); OAuth_Token Model = Get_token(code); //获取token OAuthUser OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid); DAO.MemberBase m = new DAO.MemberBase(); MemberBLL bll = new MemberBLL(); //if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息 //{ MemberBase selectUser = bll.selectWx(OAuthUser_Model.openid); if (selectUser != null) { bll.updateWx(OAuthUser_Model); Session["memberID"] = selectUser.ID; //Session["mobile"] = model.Mobile; Session.Timeout = 30; } else { FriendCodeBLL fbll = new FriendCodeBLL(); DAO.MemberLevel levelModel = new DAO.MemberLevel(); m.LoginName = OAuthUser_Model.nickname; //m.LoginName = phone; //m.PassWord = Md5Util.PwdMd5(phone.Substring(5)); //m.Mobile = phone; ////m.Email = ""; m.State = 1; //int upUser = fbll.GetUpUser(fcode); m.UpUser = 0; //上级用户 //m.Levels = 0; //m.Integral = 0; //m.Source = "self"; m.wxOpenid = OAuthUser_Model.openid; m.wxNickname = OAuthUser_Model.nickname; m.wxSex = Convert.ToInt32(OAuthUser_Model.sex); m.wxProvince = OAuthUser_Model.province; m.wxCity = OAuthUser_Model.city; m.wxCountry = OAuthUser_Model.country; m.wxHeadimgurl = OAuthUser_Model.headimgurl; m.wxPrivilege = OAuthUser_Model.privilege; m.RegDate = DateTime.Now; DAO.MemberBase u = bll.Reg(m); //注册 Session["memberID"] = u.ID; VoucherBus vbll = new VoucherBus(); vbll.RegGiveAVoucher(u.ID); //给一张注册优惠券 levelModel = bll.GetLevel(u.ID, 0); //注册初始化级别 u.Levels = levelModel.LevelId; u.Integral = levelModel.MinIntegral; DAO.MemberBase allu = bll.UpdateUser(u); Session["memberID"] = u.ID; //Session["mobile"] = model.Mobile; Session.Timeout = 30; } ////在页面上输出用户信息 //Response.Write("用户OPENID:" + OAuthUser_Model.openid + "<br>用户昵称:" + OAuthUser_Model.nickname + "<br>性别:" + OAuthUser_Model.sex + "<br>所在省:" + OAuthUser_Model.province + "<br>所在市:" + OAuthUser_Model.city + "<br>所在国家:" + OAuthUser_Model.country + "<br>头像地址:" + OAuthUser_Model.headimgurl + "<br>用户特权信息:" + OAuthUser_Model.privilege); ////或跳转到自己的页面,想怎么处理就怎么处理 Response.Redirect(reurl); //} //else //未获得openid,回到wxProcess.aspx,访问弹出微信授权页面,提示用户授权 //{ // Response.Redirect("wxProcess.aspx?auth=1"); //} } } }