Ejemplo n.º 1
0
        [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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        [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));
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        [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);
            }
        }
Ejemplo n.º 6
0
        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()
            }));
        }
Ejemplo n.º 7
0
        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");
                }
            }
        }
Ejemplo n.º 8
0
        ///删除地址
        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()
            }));
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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()
            }));
        }
Ejemplo n.º 11
0
        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()
            }));
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        [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);
            }
        }
Ejemplo n.º 14
0
        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");
                }
            }
        }
Ejemplo n.º 15
0
        [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);
            }
        }
Ejemplo n.º 16
0
 public string ToMassage(string content)
 {
     try
     {
         using (var db = new NCtecanEntities())
         {
             var product = new t_f_shops()
             {
                 sh_content = content,
                 isDel      = false
             };
             db.t_f_shops.Add(product);
             db.SaveChanges();
             return("success");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Ejemplo n.º 17
0
        public string GetPro(string json)
        {
            JsonObject obj     = new JsonObject(json);
            decimal    ID      = decimal.Parse(obj["id"].Value.ToString());
            decimal    com_num = decimal.Parse(obj["num"].Value.ToString());

            try
            {
                using (var db = new NCtecanEntities())
                {
                    var product = db.t_f_cart.FirstOrDefault(s => s.cart_ID == ID);
                    product.coms_num = com_num;
                    product.option1  = "1";
                    db.SaveChanges();
                    return("success");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 18
0
        //结算
        public ActionResult jiesuanCart(string i)
        {
            dl_basic_users user    = Session["user"] as dl_basic_users;
            decimal        userid1 = user.userid;
            var            db      = new NCtecanEntities();
            var            cool    = from a in db.t_f_cart
                                     where a.option1 == "1"
                                     select a;

            foreach (var q in cool)
            {
                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()
            }));
        }
Ejemplo n.º 19
0
        public string SaveLogistics(string json)
        {
            JsonObject obj     = new JsonObject(json);
            string     option3 = obj["option3"].Value.ToString();                //快递单号
            string     option4 = obj["option4"].Value.ToString();                //快递公司
            decimal    orderid = decimal.Parse(obj["orderid"].Value.ToString()); //订单ID

            try
            {
                using (var db = new NCtecanEntities())
                {
                    var product = db.t_f_order.FirstOrDefault(s => s.orders_ID == orderid);
                    product.option3 = option3;
                    product.option4 = option4;
                    db.SaveChanges();
                    return("success");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 20
0
        //冻结
        public ActionResult DongJ(string id)
        {
            dl_basic_users user    = Session["user"] as dl_basic_users;
            decimal        userid1 = user.userid;
            var            db      = new NCtecanEntities();
            decimal        userid  = decimal.Parse(id);
            var            q       = db.dl_basic_users.FirstOrDefault(m => m.userid == userid);

            q.isDel = true;
            db.SaveChanges();
            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()
            }));
        }
Ejemplo n.º 21
0
        //已下订单-->配送中
        public ActionResult Ttadetoing(string id)
        {
            dl_basic_users user    = Session["user"] as dl_basic_users;
            decimal        userid1 = user.userid;
            var            db      = new NCtecanEntities();
            decimal        orderid = decimal.Parse(id);
            var            q       = db.t_f_order.FirstOrDefault(m => m.orders_ID == orderid);

            q.option2 = "配送中";
            db.SaveChanges();
            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(Json(new GridModel()
            {
                Data = data,
                Total = data.Count()
            }));
        }
Ejemplo n.º 22
0
        public string SaveOrder(string id)
        {
            ///
            ///新增订单
            ///
            dl_basic_users user      = Session["user"] as dl_basic_users;
            decimal        userid1   = user.userid;       //消费者ID
            decimal        productid = decimal.Parse(id); //物流id
            var            db        = new NCtecanEntities();
            var            root      = (from a in db.t_f_cart
                                        join b in db.t_f_commodity on a.coms_ID equals b.com_ID
                                        join c in db.dl_basic_users on b.com_belong equals c.userid
                                        where a.option1 == "1" && a.cons_ID == userid1
                                        select new Commdity2
            {
                consumers_ID = userid1,        //消费者ID
                shop_id = b.com_belong,        //商家ID
                com_ID = a.coms_ID,            //商品ID
                cart_ID = a.cart_ID,           //购物车ID
                adress_ID = productid,         //物流ID
                coms_num = a.coms_num,         //商品数量
                com_price = b.com_price,       //商品价格
                com_postage = b.com_postage,   //商品邮费
            }).Distinct().OrderBy(ob => ob.cart_ID);

            System.DateTime happendate = new System.DateTime();//发生时间
            happendate = DateTime.Now;
            try
            {
                using (db = new NCtecanEntities())
                {
                    foreach (var q in root)
                    {
                        var address = (from a in db.t_f_adress
                                       where a.adr_ID == q.adress_ID
                                       select a).ToList();
                        decimal?opton1   = q.coms_num * q.com_price + q.com_postage;
                        var     theorder = new t_f_order()
                        {
                            consumers_ID  = userid1,            //消费者ID
                            shop_id       = q.shop_id,          //商家ID
                            commoditys_ID = q.com_ID,           //商品ID
                            adress_ID     = address[0].adress,  //收货地址
                            logs_ID       = address[0].comment, //收货人
                            Commodity_num = q.coms_num,         //商品数量
                            isdel         = false,
                            happendate    = happendate,         //发生时间
                            option1       = opton1,             //交易金额
                            option2       = "已下订单",             //状态:已下订单,配送中,交易成功
                        };
                        db.t_f_order.Add(theorder);
                    }
                    foreach (var p in root)
                    {
                        var m = db.t_f_cart.Where(c => c.cart_ID == p.cart_ID).First();
                        db.t_f_cart.Remove(m);
                    }
                    foreach (var m in root)
                    {
                        var h   = db.t_f_commodity.Where(c => c.com_ID == m.com_ID).First();
                        var num = decimal.Parse(h.com_number);
                        h.com_number = (num - m.coms_num).Value.ToString();
                    }
                    db.SaveChanges();
                }
                return("success");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }