예제 #1
0
        public ActionResult AddAdmin(int SID, string LoginName)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                Users user = new Users();
                {
                    user.S_ID        = SID;
                    user.U_LoginName = LoginName;
                    user.U_Password  = "******";
                }
                db.Users.Add(user);
                int result = db.SaveChanges();

                paramModel <object> param = new paramModel <object>();
                if (result > 0)
                {
                    param.status = 1;
                    param.msg    = "分配成功!";
                }
                else
                {
                    param.status = 0;
                    param.msg    = "分配失败!";
                }
                return(Json(param, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
        public ActionResult AddShop(string ShopName, string Category, string TellName, string Phone, string Address, string Remark)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                Shops shop = new Shops();
                shop.S_Category    = Convert.ToInt32(Category);
                shop.S_Name        = ShopName;
                shop.S_ContactName = TellName;
                shop.S_ContactTel  = Phone;
                shop.S_Address     = Address;
                shop.S_Remark      = Remark;
                shop.S_CreateTime  = DateTime.Now;

                db.Shops.Add(shop);
                int len = db.SaveChanges();

                paramModel <int> result = new paramModel <int>();
                if (len > 0)
                {
                    result.status = 1;
                    result.msg    = "添加成功!";
                }
                else
                {
                    result.status = 0;
                    result.msg    = "添加失败!";
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
        public ActionResult UpdateShop(string ShopName, string Category, string TellName, string Phone, string Address, string Remark, string ID)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                Shops shop = new Shops();
                {
                    shop.S_ID          = Convert.ToInt32(ID);
                    shop.S_Name        = ShopName;
                    shop.S_Category    = Convert.ToInt32(Category);
                    shop.S_ContactName = TellName;
                    shop.S_ContactTel  = Phone;
                    shop.S_Address     = Address;
                    shop.S_Remark      = Remark;
                }

                db.Entry <Shops>(shop).State = EntityState.Modified;
                int result = db.SaveChanges();

                paramModel <object> param = new paramModel <object>();
                if (result > 0)
                {
                    param.status = 1;
                    param.msg    = "修改成功!";
                }
                else
                {
                    param.status = 0;
                    param.msg    = "修改失败!";
                }
                return(Json(param, JsonRequestBehavior.AllowGet));
            }
        }
예제 #4
0
        public ActionResult AddUser(string LoginName, string Password, string RealName, string Sex, string Phone, string RoleName, bool CanDelete)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                var cateLinq = from C in db.CategoryItems where C.CI_Name == RoleName select new { RoleID = C.CI_ID };

                Users user = new Users();
                {
                    user.U_LoginName = LoginName;
                    user.U_Password  = Password;
                    user.U_RealName  = RealName;
                    user.U_Sex       = Sex;
                    user.U_Telephone = Phone;
                    user.U_Role      = cateLinq.FirstOrDefault().RoleID;
                    user.U_CanDelete = CanDelete;
                }
                db.Users.Add(user);
                int result = db.SaveChanges();

                paramModel <object> param = new paramModel <object>();
                if (result > 0)
                {
                    param.status = 1;
                    param.msg    = "添加成功";
                }
                else
                {
                    param.status = 0;
                    param.msg    = "添加失败";
                }
                return(Json(param, JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
        public ActionResult NonDeleteUser(int ID)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                Users user = new Users();
                {
                    user.U_ID       = ID;
                    user.U_isDelete = true;
                }

                db.Entry <Users>(user).State = EntityState.Modified;
                db.Entry <Users>(user).Property(u => u.U_CanDelete).IsModified = false;
                db.Entry <Users>(user).Property(u => u.S_ID).IsModified        = false;
                db.Entry <Users>(user).Property(u => u.U_LoginName).IsModified = false;
                db.Entry <Users>(user).Property(u => u.U_Password).IsModified  = false;
                db.Entry <Users>(user).Property(u => u.U_Role).IsModified      = false;
                db.Entry <Users>(user).Property(u => u.U_Sex).IsModified       = false;
                db.Entry <Users>(user).Property(u => u.U_Telephone).IsModified = false;
                int result = db.SaveChanges();

                paramModel <object> param = new paramModel <object>();
                if (result > 0)
                {
                    param.status = 1;
                    param.msg    = "删除成功";
                }
                else
                {
                    param.status = 0;
                    param.msg    = "删除失败";
                }
                return(Json(param, JsonRequestBehavior.AllowGet));
            }
        }
예제 #6
0
        public ActionResult UpdateLevel(string ID, string LevelName, string NeedPoint, string Point, string Percent)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                CardLevels cd = new CardLevels();
                {
                    cd.CL_ID        = Convert.ToInt32(ID);
                    cd.CL_LevelName = LevelName;
                    cd.CL_NeedPoint = NeedPoint;
                    cd.CL_Point     = Convert.ToDouble(Point);
                    cd.CL_Percent   = Convert.ToDouble(Percent);
                }
                db.Entry <CardLevels>(cd).State = EntityState.Modified;
                int len = db.SaveChanges();

                paramModel <int> result = new paramModel <int>();
                if (len > 0)
                {
                    result.status = 1;
                    result.msg    = "修改成功!";
                }
                else
                {
                    result.status = 0;
                    result.msg    = "修改失败!";
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
예제 #7
0
        public ActionResult AddLevel(string ID, string LevelName, string NeedPoint, string Point, string Percent)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                CardLevels cd = new CardLevels();
                {
                    cd.CL_LevelName = LevelName;
                    cd.CL_NeedPoint = NeedPoint;
                    cd.CL_Point     = Convert.ToDouble(Point);
                    cd.CL_Percent   = Convert.ToDouble(Percent);
                    db.CardLevels.Add(cd);
                }

                int len = db.SaveChanges();

                paramModel <int> result = new paramModel <int>();
                if (len > 0)
                {
                    result.status = 1;
                    result.msg    = "添加成功!";
                }
                else
                {
                    result.status = 0;
                    result.msg    = "添加失败!";
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
예제 #8
0
        public ActionResult DeleteShop(string ID)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                Shops shop = new Shops(); { shop.S_ID = Convert.ToInt32(ID); }
                db.Shops.Attach(shop);
                db.Shops.Remove(shop);
                int result = db.SaveChanges();

                paramModel <object> param = new paramModel <object>();
                if (result > 0)
                {
                    param.status = 1;
                    param.msg    = "删除成功!";
                }
                else
                {
                    param.status = 0;
                    param.msg    = "删除失败!";
                }
                return(Json(param, JsonRequestBehavior.AllowGet));
            }
        }
예제 #9
0
        public ActionResult DeleteLevel(string ID)
        {
            using (UPMSEntities db = new UPMSEntities())
            {
                CardLevels cd = new CardLevels(); { cd.CL_ID = Convert.ToInt32(ID); }
                db.CardLevels.Attach(cd);
                db.CardLevels.Remove(cd);
                int result = db.SaveChanges();

                paramModel <object> param = new paramModel <object>();
                if (result > 0)
                {
                    param.status = 1;
                    param.msg    = "删除成功!";
                }
                else
                {
                    param.status = 0;
                    param.msg    = "删除失败!";
                }
                return(Json(param, JsonRequestBehavior.AllowGet));
            }
        }