public ActionResult Creat() { // 加验证 NCtecanEntities db = new NCtecanEntities(); List <SelectListItem> product = new List <SelectListItem>(); List <SelectListItem> prod = new List <SelectListItem>(); var m = from a in db.sys_role where a.rid == 4 || a.rid == 5 || a.rid == 6 || a.rid == 7 || a.rid == 8 || a.rid == 9 select new { rid = a.option1, rolename = a.rolename }; foreach (var o in m) { product.Add(new SelectListItem { Text = o.rolename, Value = o.rid.ToString() }); } ViewData["product"] = new SelectList(product, "Value", "Text"); return(View()); }
[GridAction]// 用户列表 public ActionResult UserList() { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); var dataq = from h in db.dl_basic_users join n in db.sys_user_role on h.userid equals n.userid where n.rid == 3 orderby h.userid ascending select new UserRole1 { userid = h.userid, userphone = h.userphone, username = h.username, exname = h.exname, userpwd = h.userpwd, idnum = h.idnum, shopid = h.shopid, jointime = h.jointime, usercode = h.usercode, useraddr = h.useraddr, userQQ = h.userQQ, isDel = h.isDel, comment = h.comment }; return(View(new GridModel() { Data = dataq, Total = dataq.Count() })); }
public string JoinCollect(string json) { if (Session["user"] == null) { return("请先登录!"); } dl_basic_users user = Session["user"] as dl_basic_users; decimal userid = user.userid; //消费者ID JsonObject obj = new JsonObject(json); decimal commodity_id = decimal.Parse(obj["coms_ID"].Value.ToString()); //商品ID System.DateTime happendate = new System.DateTime(); happendate = DateTime.Now; try { using (var db = new NCtecanEntities()) { var cart = new t_f_collect() { con_id = userid, commodity_id = commodity_id, isdel = false, happendate = happendate }; db.t_f_collect.Add(cart); db.SaveChanges(); return("success"); } } catch (Exception ex) { return(ex.Message); } }
public ActionResult SelectSid(string id) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); decimal productid = decimal.Parse(id); var data = from a in db.t_f_order join b in db.t_f_commodity on a.commoditys_ID equals b.com_ID join c in db.dl_basic_users on a.consumers_ID equals c.userid where a.option2 == "交易成功" && a.shop_id == productid orderby a.orders_ID ascending select new Commdity5 { orderid = a.orders_ID, //订单ID com_ID = b.com_ID, //商品ID com_price = a.option1, //订单金额 com_postage = b.com_postage, //商品邮费 com_name = b.com_name, //商品名称 com_content = b.com_content, //商品图片 con_id = a.consumers_ID, //消费者ID shop_id = a.shop_id, con_name = c.username, //消费者名字 happendate = a.happendate, //下订单时间 adress = a.adress_ID, //收货地址 commodity_num = a.Commodity_num, //商品数量 option3 = a.option3, //快递单号 option4 = a.option4 //物流公司 }; return(Json(new GridModel() { Data = data, Total = data.Count() })); }
[GridAction]//已下订单商品列表 public ActionResult YProductList() { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); var data = from a in db.t_f_order join b in db.t_f_commodity on a.commoditys_ID equals b.com_ID join c in db.dl_basic_users on a.consumers_ID equals c.userid where a.shop_id == userid1 && a.option2 == "已下订单" orderby a.orders_ID ascending select new Commdity5 { orderid = a.orders_ID, //订单ID com_ID = b.com_ID, //商品ID com_price = a.option1, //订单金额 com_postage = b.com_postage, //商品邮费 com_name = b.com_name, //商品名称 com_content = b.com_content, //商品图片 con_id = a.consumers_ID, //消费者ID con_name = c.username, //消费者名字 happendate = a.happendate, //下订单时间 adress = a.adress_ID, //收货地址 commodity_num = a.Commodity_num, //商品数量 option5 = b.option2 //商品重量 }; return(View(new GridModel() { Data = data, Total = data.Count() })); }
[HttpPost]// 保存edit product public string SaveEdit(string json) { JsonObject obj = new JsonObject(json); decimal com_ID = decimal.Parse(obj["com_ID"].Value.ToString()); decimal com_price = decimal.Parse(obj["com_price"].Value.ToString()); string com_name = obj["com_name"].Value.ToString(); string com_number = obj["com_number"].Value.ToString(); decimal com_postage = decimal.Parse(obj["com_postage"].Value.ToString()); //string com_content = obj["com_content"].Value.ToString(); //decimal shop_ID string comment = obj["com_comment"].Value.ToString(); string option2 = obj["option2"].Value.ToString(); string option1 = obj["option1"].Value.ToString(); try { using (var db = new NCtecanEntities()) { var product = db.t_f_commodity.FirstOrDefault(s => s.com_ID == com_ID); product.com_price = com_price; product.com_name = com_name; product.com_number = com_number; product.com_postage = com_postage; product.comment = comment; product.option1 = option1; product.option2 = option2; db.SaveChanges(); return("success"); } } catch (Exception ex) { return(ex.Message); } }
public ActionResult MoneySum() { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); var data = from a in db.t_f_order join b in db.t_f_commodity on a.commoditys_ID equals b.com_ID join c in db.dl_basic_users on a.consumers_ID equals c.userid where a.option2 == "交易成功" orderby a.orders_ID ascending select new Commdity5 { orderid = a.orders_ID, //订单ID com_ID = b.com_ID, //商品ID com_price = a.option1, //订单金额 com_postage = b.com_postage, //商品邮费 }; decimal?sum = 0; var num = data.Count();//数量 foreach (var m in data) { sum += m.com_price + m.com_postage; } ViewData["sum"] = sum; return(View()); }
[HttpPost]//保存SaveNewPassword public ActionResult SaveNewPassword(string newPassword, string old, decimal userid) { var result = new ResultInfo(false); try { using (var db = new NCtecanEntities()) { var user = db.dl_basic_users.FirstOrDefault(s => s.userid == userid); if (user.userpwd != old) { result.IsSucceed = false; result.Message = "原密码错误!"; return(Json(result)); } user.userpwd = newPassword; if (db.SaveChanges() > 0) { result.IsSucceed = true; result.Message = "保存成功"; } else { result.IsSucceed = false; result.Message = "保存失败db.savechangs()<=0"; } } } catch (Exception e) { result.IsSucceed = false; result.Message = e.Message; } return(Json(result)); }
public string SaveFunction(string json) { using (var db = new NCtecanEntities()) { sys_function m = new sys_function(); JsonObject obj = new JsonObject(json); decimal fid = decimal.Parse(obj["id"].Value); if (obj["id"].Value != "0") { m = db.sys_function.FirstOrDefault(ss => ss.fid == fid); } m.pid = int.Parse(obj["pid"].Value); m.title = obj["name"].Value; m.function = obj["funname"].Value; m.control = obj["control"].Value; m.functionname = obj["functionname"].Value; m.parameters = obj["parameters"].Value; m.url = obj["comment"].Value; if (obj["id"].Value == "0") { db.sys_function.Add(m); } if (db.SaveChanges() > 0) { return(GetFunctionTree()); } else { return("failed"); } } }
public ActionResult ReadMassage(string id) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); decimal productid = decimal.Parse(id); var q = db.t_f_shops.FirstOrDefault(m => m.sh_ID == productid); q.isDel = true; db.SaveChanges(); var data = from b in db.t_f_shops join a in db.sys_user_role on b.option1 equals a.option1 where a.rid == 1 && a.userid == userid1 orderby b.sh_ID ascending select new Massage { com_ID = b.sh_ID, //意见ID com_content = b.sh_content, //商品意见内容 isdel = b.isDel //时候删除 }; return(View(new GridModel() { Data = data, Total = data.Count() })); }
public string JoinCart(string id) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid = user.userid; //消费者ID decimal productid = decimal.Parse(id); //商品ID System.DateTime happendate = new System.DateTime(); happendate = DateTime.Now; try { using (var db = new NCtecanEntities()) { var cart = new t_f_cart() { cons_ID = userid, coms_ID = productid, coms_num = 1, isdel = false, happendate = happendate }; db.t_f_cart.Add(cart); db.SaveChanges(); return("success"); } } catch (Exception ex) { return(ex.Message); } }
///删除地址 public ActionResult DeleteAdress(string id) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); decimal adrid = decimal.Parse(id); var q = db.t_f_adress.FirstOrDefault(m => m.adr_ID == adrid); q.isdel = true; db.SaveChanges(); var data = from a in db.t_f_adress where a.conss_ID == userid1 && a.isdel == false select new { a.adress, a.conss_ID, a.happendate, a.comment }; return(Json(new GridModel() { Data = data, Total = data.Count() })); }
public ActionResult Delete(string id) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); decimal productid = decimal.Parse(id); var q = db.t_f_commodity.FirstOrDefault(m => m.com_ID == productid); q.isdel = true; db.SaveChanges(); var data = from b in db.t_f_commodity where b.com_belong == userid1 && b.isdel == false orderby b.com_ID ascending select new Commdity1 { com_ID = b.com_ID, //商品ID com_price = b.com_price, //商品价格 com_belong = b.com_belong, //商品所属用户 com_name = b.com_name, //商品名称 com_number = b.com_number, //商品数量 com_postage = b.com_postage, //商品邮费 com_content = b.com_content, //商品介绍内容 com_state = b.com_state, //商品状态 com_starttime = b.com_starttime, //新增时间 com_saletime = b.com_saletime, //商品销售时间 shop_ID = b.shop_ID, //商品所属店铺 comment = b.comment //商品备注 }; return(Json(new GridModel() { Data = data, Total = data.Count() })); }
public ActionResult Adress() { NCtecanEntities db = new NCtecanEntities(); dl_basic_users user = Session["user"] as dl_basic_users; decimal? userid1 = user.userid; var data = from a in db.t_f_cart join b in db.t_f_commodity on a.coms_ID equals b.com_ID where a.option1 == "1" && a.cons_ID == userid1 select new Commdity2 { com_ID = a.coms_ID, //商品ID cart_ID = a.cart_ID, //购物车ID com_price = b.com_price, //商品价格 com_postage = b.com_postage, //商品邮费 com_name = b.com_name, //商品名称 com_content = b.com_content, //商品图片 option2 = b.option2, //商品重量 coms_num = a.coms_num //商品数量 }; decimal?sum = 0; foreach (var q in data) { sum += (q.coms_num * q.com_price + q.com_postage); } ViewData["sum"] = sum;// return(View()); }
public string AddAdress(string json) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; JsonObject obj = new JsonObject(json); string address = obj["adress"].Value.ToString(); string comment = obj["comment"].Value.ToString(); System.DateTime happendate = new System.DateTime(); happendate = DateTime.Now; try { using (var db = new NCtecanEntities()) { var cart = new t_f_adress() { adress = address, conss_ID = userid1, comment = comment, isdel = false, happendate = happendate }; db.t_f_adress.Add(cart); db.SaveChanges(); return("success"); } } catch (Exception ex) { return(ex.Message); } }
[GridAction]//商品列表 public ActionResult ProductList() { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); var data = from m in db.t_f_collect join b in db.t_f_commodity on m.commodity_id equals b.com_ID join a in db.dl_basic_users on b.com_belong equals a.userid where m.con_id == userid1 && m.isdel == false && b.isdel == false orderby m.collect_id ascending select new Commdity { com_ID = m.commodity_id, //商品ID com_price = b.com_price, //商品价格 com_belongu = a.username, //商家姓名 com_belongp = a.userphone, //商家电话 com_postage = b.com_postage, //商品邮费 com_name = b.com_name, //商品名称 com_content = b.com_content, option2 = b.option2 }; return(View(new GridModel() { Data = data, Total = data.Count() })); }
public ActionResult SelectPro(string id) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); var data = from b in db.t_f_commodity join a in db.sys_role on b.option1 equals a.option1 where b.com_belong == userid1 && b.isdel == false && b.com_name == id orderby b.com_ID ascending select new Commdity1 { com_ID = b.com_ID, //商品ID com_price = b.com_price, //商品价格 com_belong = b.com_belong, //商品所属用户 com_name = b.com_name, //商品名称 com_number = b.com_number, //商品数量 com_postage = b.com_postage, //商品邮费 com_content = b.com_content, //商品介绍内容 com_state = b.com_state, //商品状态 com_starttime = b.com_starttime, //新增时间 com_saletime = b.com_saletime, //商品销售时间 shop_ID = b.shop_ID, //商品所属店铺 comment = b.comment, //商品备注 option1 = a.rolename, // 商品的类别 option2 = b.option2 }; return(Json(new GridModel() { Data = data, Total = data.Count() })); }
public ActionResult DeleteCart(string id) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; var db = new NCtecanEntities(); decimal productid = decimal.Parse(id); var q = db.t_f_cart.FirstOrDefault(m => m.cart_ID == productid); q.isdel = true; db.SaveChanges(); var data = from m in db.t_f_cart join b in db.t_f_commodity on m.coms_ID equals b.com_ID join a in db.dl_basic_users on b.com_belong equals a.userid where m.cons_ID == userid1 && m.isdel == false && b.isdel == false orderby m.cart_ID ascending select new Commdity { com_ID = m.coms_ID, //商品ID cart_ID = m.cart_ID, //购物车ID com_price = b.com_price, //商品价格 com_belongu = a.username, //商家姓名 com_belongp = a.userphone, //商家电话 com_postage = b.com_postage, //商品邮费 com_name = b.com_name, //商品名称 com_content = b.com_content, //商品图片 option2 = b.option2, //商品重量 coms_num = m.coms_num }; return(Json(new GridModel() { Data = data, Total = data.Count() })); }
public ActionResult Logistics(decimal id) { NCtecanEntities db = new NCtecanEntities(); ViewData["orderid"] = id; return(View()); }
// // GET: /Front/ #region 首页 public ActionResult Index() { if (Session["user"] == null) { //return RedirectToAction("Index", "Front"); return(View()); } //收藏 dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; NCtecanEntities db = new NCtecanEntities(); var colle = db.t_f_collect.Where(s => s.con_id == userid1 && s.isdel == false); var num = colle.Count(); ViewData["numbercolle"] = num; //订单 //购物车 var cart = db.t_f_cart.Where(s => s.cons_ID == userid1 && s.isdel == false); var num1 = cart.Count(); ViewData["numbercart"] = num1;//购物车数量 var data = (from s in db.t_f_cart join m in db.t_f_commodity on s.coms_ID equals m.com_ID where s.cons_ID == userid1 && s.isdel == false && m.isdel == false select m.com_price).Sum(); ViewData["catprice"] = data;//购物车总价 return(View()); }
public ActionResult EditPsd() { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; NCtecanEntities db = new NCtecanEntities(); dl_basic_users dd = db.dl_basic_users.Where(s => s.userid == userid1).First(); ViewData["username"] = dd.username;//获取用户密码的值 ViewData["userid"] = dd.userid; ViewData["userpwd"] = dd.userpwd; return(View()); }
[HttpPost]//保存new user public string Save(string json) { JsonObject obj = new JsonObject(json); var roleid = decimal.Parse(obj["roleid"].Value.ToString()); var userid1 = decimal.Parse(obj["phone"].Value.ToString()); var phone = obj["phone"].Value.ToString(); string exname1 = obj["username"].Value.ToString(); string userpwd1 = obj["loginpwd"].Value.ToString(); System.DateTime com_starttime = new System.DateTime(); com_starttime = DateTime.Now; try { using (var db = new NCtecanEntities()) { var uuser = db.dl_basic_users.FirstOrDefault(x => x.userid == userid1 && x.isDel == false); if (uuser == null) { var user = new dl_basic_users() { userid = userid1, exname = exname1, userpwd = userpwd1, jointime = com_starttime, userphone = phone, username = exname1, isDel = false }; db.dl_basic_users.Add(user); db.SaveChanges(); var nuser = new sys_user_role() { userid = user.userid, rid = roleid }; db.sys_user_role.Add(nuser); db.SaveChanges(); return("success"); } else { return("existed"); } } } catch (Exception ex) { return(ex.Message); } }
public string SaveRoleFunction(string json) { try { using (var db = new NCtecanEntities()) { JsonObject obj = new JsonObject(json); decimal rid = decimal.Parse(obj["rid"].Value); foreach (JsonProperty jp in obj["funs"].Items) { decimal fid = decimal.Parse(jp.Items[0]["fid"].Value); bool selected = jp.Items[0]["selected"].ToString().ToLower() == "true"; int count = db.sys_role_function.Where(c => c.rid == rid && c.fid == fid).Count(); if (selected) //选中 { if (count == 0) //但数据库中没有 { var m = new sys_role_function() { rid = rid, fid = fid }; db.sys_role_function.Add(m); } } else //未选中 { if (count == 1) { var m = db.sys_role_function.First(c => c.rid == rid && c.fid == fid); db.sys_role_function.Remove(m); } } } if (db.SaveChanges() > 0) { return("success"); } else { return("failed"); } } } catch (Exception ex) { return(ex.StackTrace); } }
public ActionResult MyWuliu(decimal id) { NCtecanEntities db = new NCtecanEntities(); var data = (from a in db.t_f_order where a.orders_ID == id select new { a.option3, a.option4 }).ToList(); ViewData["option3"] = data[0].option3; ViewData["option4"] = data[0].option4; return(View()); }
[HttpPost]// 保存new product public string Save(string json) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; JsonObject obj = new JsonObject(json); decimal com_price = decimal.Parse(obj["com_price"].Value.ToString()); decimal com_belong = userid1; string com_name = obj["com_name"].Value.ToString(); string com_number = obj["com_number"].Value.ToString(); string option1 = obj["option1"].Value.ToString(); decimal com_postage = decimal.Parse(obj["com_postage"].Value.ToString()); string com_content = obj["com_content"].Value.ToString(); string option2 = obj["option2"].Value.ToString(); System.DateTime com_starttime = new System.DateTime(); com_starttime = DateTime.Now; //decimal shop_ID string comment = obj["com_comment"].Value.ToString(); try { using (var db = new NCtecanEntities()) { var product = new t_f_commodity() { com_price = com_price, com_belong = com_belong, com_name = com_name, com_number = com_number, com_postage = com_postage, com_content = com_content, com_starttime = com_starttime, comment = comment, option1 = option1, option2 = option2, isdel = false }; db.t_f_commodity.Add(product); db.SaveChanges(); return("success"); } } catch (Exception ex) { return(ex.Message); } }
public string GetFunctionsByRole(string rid) { try { using (var db = new NCtecanEntities()) { decimal id = decimal.Parse(rid); var data = from t in db.sys_role_function where t.rid == id select new { rid = t.rid, fid = t.fid }; return(JsonConvert.SerializeObject(data)); } } catch (Exception ex) { return(ex.Message); } }
public string DeleteByID(string fid) { using (var db = new NCtecanEntities()) { decimal id = decimal.Parse(fid); var m = db.sys_function.Where(c => c.fid == id).First(); db.sys_function.Remove(m); if (db.SaveChanges() > 0) { return(GetFunctionTree()); } else { return("failed"); } } }
public ActionResult EditMassage() { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; NCtecanEntities db = new NCtecanEntities(); dl_basic_users dd = db.dl_basic_users.Where(s => s.userid == userid1).First(); ViewData["userid"] = dd.userid;//用户ID,手机号码 ViewData["userphone"] = dd.userphone; ViewData["exname"] = dd.exname; ViewData["username"] = dd.username; ViewData["idnum"] = dd.idnum; ViewData["shopid"] = dd.shopid; ViewData["jointime"] = dd.jointime; ViewData["useraddr"] = dd.useraddr; ViewData["userQQ"] = dd.userQQ; ViewData["comment"] = dd.comment; return(View()); }
[HttpPost] //保存新资料 public string SaveM(string json) { JsonObject obj = new JsonObject(json); dl_basic_users user = Session["user"] as dl_basic_users; decimal userid = user.userid; string userphone = obj["userphone"].Value.ToString(); string exname = obj["exname"].Value.ToString(); string username = obj["username"].Value.ToString(); string idnum = obj["idnum"].Value.ToString(); string useraddr = obj["useraddr"].Value.ToString(); string userQQ = obj["userQQ"].Value.ToString(); string comment = obj["comment"].Value.ToString(); try { using (var db = new NCtecanEntities()) { var uuser = db.dl_basic_users.FirstOrDefault(x => x.userid == userid); if (uuser != null) { uuser.userphone = userphone; uuser.exname = exname; uuser.username = username; uuser.idnum = idnum; uuser.useraddr = useraddr; uuser.userQQ = userQQ; uuser.comment = comment; } if (db.SaveChanges() > 0) { return("success"); } else { return("existed"); } } } catch (Exception ex) { return(ex.Message); } }
////案例 public ActionResult Photo_Save(HttpPostedFileBase pic_upload) { //获取图片的类型 string filetype = "." + pic_upload.ContentType.Split('/')[1]; //获取图片的路径 string fileName = pic_upload.FileName; //判断格式 if (filetype == ".jpg" || filetype == ".png" || filetype == ".jpeg") { //转换只取文件名,去掉路径。 if (fileName.LastIndexOf("\\") > -1) { fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1); } //保存到相对路径下。 if (Directory.Exists(Server.MapPath("~/Upload")) == false) { Directory.CreateDirectory(Server.MapPath("~/Upload")); } pic_upload.SaveAs(Server.MapPath("/Upload/" + fileName)); //以下代码是将路径保存到数据库。 string ImagePath = "/Upload/" + fileName; //插入到数据库 try { using (var db = new NCtecanEntities()) { return(Content("1|" + ImagePath + "|上传成功!|")); } } catch (Exception ex) { return(Content("0|网络繁忙,请稍后在试!")); } } else { return(Content("0|请选择.jpg或.png格式的图片!")); } }