Exemple #1
0
 public ActionResult Edit([Bind(Include = "categoryID,categoryName,workstreamID")] CATEGORY cATEGORY)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cATEGORY).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.workstreamID = new SelectList(db.WORKSTREAMs, "workstreamID", "workstreamName", cATEGORY.workstreamID);
     return(View(cATEGORY));
 }
        public IHttpActionResult GetCATEGORY(int id)
        {
            CATEGORY cATEGORY = db.CATEGORies.Find(id);

            if (cATEGORY == null)
            {
                return(NotFound());
            }

            return(Ok(cATEGORY));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "ID,Name,Note")] CATEGORY cATEGORY)
        {
            if (ModelState.IsValid)
            {
                db.CATEGORies.Add(cATEGORY);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cATEGORY));
        }
        public ActionResult Create(CATEGORY category)
        {
            if (ModelState.IsValid)
            {
                db.CATEGORies.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Exemple #5
0
        public bool getTrailing(CATEGORY cat)
        {
            bool bResult = false;

            if (hTrailing.Count == 0)
            {
                return(bResult);
            }
            hTrailing.TryGetValue(cat, out bResult);
            return(bResult);
        }
Exemple #6
0
        private void AddInitiativeToTableButton_Click(object sender, EventArgs e)
        {
            Random rnd = new Random();
            var    selectedInitiativeQuery = from ini in mainForm.dbo.INITIATIVE
                                             where ini.NAME == InitiativeComboBox.Text
                                             select ini;

            if (selectedInitiativeQuery.Count() == 0)
            {
                selectedInitiative              = new INITIATIVE();
                selectedInitiative.NAME         = InitiativeComboBox.Text;
                selectedInitiative.INITIATIVEID = rnd.Next();
                var selectedBusinessObjectiveQuery = from bus in mainForm.dbo.BUSINESSOBJECTIVE
                                                     where bus.NAME == BusinessObjectiveComboBox.Text
                                                     select bus;

                if (selectedBusinessObjectiveQuery.Count() == 0)
                {
                    selectedBusinessObjective      = new BUSINESSOBJECTIVE();
                    selectedBusinessObjective.NAME = BusinessObjectiveComboBox.Text;
                    selectedBusinessObjective.BUSINESSOBJECTIVEID = rnd.Next();
                    var selectedCategoryQuery = from cat in mainForm.dbo.CATEGORY
                                                where cat.NAME == CategoryComboBox.Text
                                                select cat;

                    if (selectedCategoryQuery.Count() == 0)
                    {
                        selectedCategory            = new CATEGORY();
                        selectedCategory.NAME       = CategoryComboBox.Text;
                        selectedCategory.CATEGORYID = rnd.Next();
                        selectedCategory.BUSINESSOBJECTIVE.Add(selectedBusinessObjective);
                        mainForm.dbo.AddToCATEGORY(selectedCategory);
                    }

                    selectedBusinessObjective.CATEGORY = selectedCategory;
                    selectedBusinessObjective.INITIATIVE.Add(selectedInitiative);
                    mainForm.dbo.AddToBUSINESSOBJECTIVE(selectedBusinessObjective);
                }

                selectedInitiative.BUSINESSOBJECTIVE = selectedBusinessObjective;
                mainForm.dbo.AddToINITIATIVE(selectedInitiative);

                mainForm.dbo.SaveChanges();
            }


            DataGridViewRow row = (DataGridViewRow)mainForm.BOMTable.Rows[0].Clone();

            row.Cells[0].Value = selectedCategory.NAME;
            row.Cells[1].Value = selectedBusinessObjective.NAME;
            row.Cells[2].Value = selectedInitiative.NAME;
            mainForm.BOMTable.Rows.Add(row);
            this.Close();
        }
Exemple #7
0
        public bool getLeader(CATEGORY cat)
        {
            bool bResult = false;

            if (hLeaders.Count == 0)
            {
                return(bResult);
            }
            hLeaders.TryGetValue(cat, out bResult);
            return(bResult);
        }
Exemple #8
0
        public CATEGORY MockCat()
        {
            CATEGORY cat = new CATEGORY();

            cat.CATEGORYID    = 1;
            cat.NAME          = "Test";
            cat.REFERENCE_KEY = "TestKey";
            cat.DESCRIPTION   = "Unit Test Category";

            return(cat);
        }
Exemple #9
0
        public async Task <IActionResult> Create([Bind("CategoryId,CategoryName")] CATEGORY cATEGORY)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cATEGORY);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cATEGORY));
        }
Exemple #10
0
        /// <summary>
        /// Converts a category to be able to used by the database.
        /// </summary>
        /// <param name="cat">The category.</param>
        /// <returns>The converted category.</returns>
        public static Category CategoryConverter(CATEGORY cat)
        {
            Category output = new Category()
            {
                CategoryId = (int)cat.CATEGORYID,
                Name       = cat.CNAME,
                Picture    = cat.PICTURE
            };

            return(output);
        }
Exemple #11
0
        /// <summary>
        /// Converts a category to be able to used by the database.
        /// </summary>
        /// <param name="cat">The category.</param>
        /// <returns>The converted category.</returns>
        public static CATEGORY CategoryConverter(Category cat)
        {
            CATEGORY output = new CATEGORY()
            {
                CATEGORYID = cat.CategoryId,
                CNAME      = cat.Name,
                PICTURE    = cat.Picture
            };

            return(output);
        }
Exemple #12
0
        public ActionResult CategoryDelete(int id)
        {
            if (Session["ID"] == null)
            {
                return(RedirectToAction("Index"));
            }

            CATEGORY category = categoryDA.GetById(id);

            return(View(category));
        }
Exemple #13
0
 public ActionResult Edit([Bind(Include = "ID_CATEGORY,ID_CATEGORY_TYPE,ACTIVE,NAME")] CATEGORY cATEGORY)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cATEGORY).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID_CATEGORY_TYPE = new SelectList(db.CATEGORY_TYPE, "ID_CATEGORY_TYPE", "NAME", cATEGORY.ID_CATEGORY_TYPE);
     return(View(cATEGORY));
 }
Exemple #14
0
        public ActionResult Create([Bind(Include = "CATEGORY_NAME")] CATEGORY cATEGORY)
        {
            if (ModelState.IsValid)
            {
                db.CATEGORY.Add(cATEGORY);
                db.SaveChanges();
                return(Redirect("~/Place"));
            }

            return(View(cATEGORY));
        }
        public ActionResult UpdateCategory(CATEGORY category)
        {
            var model = categoryDAO.UpdateCategory(category);

            if (model == null)
            {
                return(Json(new { result = false }));
            }

            return(Json(new { result = true, data = PartialViewToString("CategoryDetailForm", model) }));
        }
Exemple #16
0
        public CATEGORY GetById(int input)
        {
            CATEGORY categories = context.Categories.Find(input);

            if (categories == null)
            {
                Console.Write("Id " + input + " Tidak Ada");
                Console.Read();
            }
            return(categories);
        }
        public ActionResult Create([Bind(Include = "ID_CATEGORY,TITLE,DESCRIPTION")] CATEGORY cATEGORY)
        {
            if (ModelState.IsValid)
            {
                db.CATEGORies.Add(cATEGORY);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(cATEGORY);
        }
        public IHttpActionResult PostCATEGORY(CATEGORY cATEGORY)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CATEGORies.Add(cATEGORY);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = cATEGORY.CATE_ID }, cATEGORY));
        }
Exemple #19
0
        public ActionResult CategoryUpdate(int id)
        {
            if (Session["ID"] == null)
            {
                return(RedirectToAction("Index"));
            }

            CATEGORY category = categoryDA.GetById(id);

            PopulateStateDropdownList(category.STATE_ID);
            return(View(category));
        }
 public IActionResult Add(CATEGORY CATEGORY)
 {
     if (CATEGORY.Id == 0)
     {
         _CategoryDAL.Add(CATEGORY);
     }
     else
     {
         _CategoryDAL.Update(CATEGORY);
     }
     return(Redirect("/Admin/Category/Index"));
 }
Exemple #21
0
        public ActionResult Create(CategoryViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                //Check if nameHero have min  1 value
                IList <CATEGORY_TRANSLATION> catsT = vmodel.CategoriesTrans;
                bool nameCatIsValid = TranslationBL.CheckIfMinOneValued(catsT);
                if (nameCatIsValid)
                {
                    //Check if Cat exist by nameCategory before create
                    bool nameExist = TranslationBL.CheckIfNameExist(catsT);
                    if (!nameExist)
                    {
                        CATEGORY cat = new CATEGORY
                        {
                            imageCat = vmodel.Image
                        };
                        db.CATEGORYs.Add(cat);
                        db.SaveChanges();
                        //Add Translation
                        int id = cat.idCategory;
                        IList <CATEGORY_TRANSLATION> newcatsT = TranslationBL.VerifyIsUniversal(catsT, id);
                        db.CATEGORY_TRANSLATIONs.AddRange(newcatsT);
                        db.SaveChanges();

                        if (vmodel.Parent != null)
                        {
                            SUBCATEGORY subCat = new SUBCATEGORY {
                                parentCategory = vmodel.Parent.Value,
                                childCategory  = cat.idCategory
                            };
                            db.SUBCATEGORYs.Add(subCat);
                            db.SaveChanges();
                        }
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        //to do --> match the error with the name that causes the error
                        ViewBag.nameIsNotValid = "Le nom existe déjà, veuillez saisir un autre nom!";
                    }
                }
                else
                {
                    ViewBag.nameIsNotValid = "Veuillez saisir un nom!";
                }
            }
            int lang = LanguageBL.CheckLanguageSession();

            vmodel.ListLang   = LanguageBL.FindLanguageListWithoutUniversal();
            vmodel.Categories = db.SPP_CategoryTransDistinct(lang).ToList();
            return(View(vmodel));
        }
        public bool Delete(CategoryDetailDTO entity)
        {
            CATEGORY category = new CATEGORY();

            category.ID = entity.ID;
            dao.Delete(category);
            PRODUCT product = new PRODUCT();

            product.CategoryID = entity.ID;
            productdao.Delete(product);
            return(true);
        }
        Bitmap DrawBitmap(int facetype, CATEGORY category)
        {
            Bitmap CanvasBitmap = new Bitmap(this.Canvas.Width, this.Canvas.Height);

            if (BustshotBitmap == null || FaceBitmap == null)
            {
                return(CanvasBitmap);
            }
            Graphics g = Graphics.FromImage(CanvasBitmap);

            GraphicsSetting(g);

            int widthpadding  = (this.Canvas.Width - BustshotBitmap.Width) / 2;
            int heightpadding = PADDING_HEIGHT;

            DrawImage(g, BustshotBitmap, widthpadding, heightpadding, BustshotBitmap.Width, BustshotBitmap.Height);


            int width  = FaceBitmap.Width / 4;
            int height = FaceBitmap.Height / 2;
            int face_x = GetFaceX(facetype);
            int face_y = GetFaceY(facetype);

            if (category == CATEGORY.TYPE)
            {
                Rectangle srcRect  = new Rectangle(face_x, face_y, width, height);
                Rectangle destRect = new Rectangle((int)this.FaceX.Value, (int)this.FaceY.Value, (int)this.FaceW.Value, (int)this.FaceW.Value);
                DrawImage(g, FaceBitmap, destRect, srcRect);
            }
            else if (category == CATEGORY.TYPE_EYE)
            {
                Rectangle srcRect  = new Rectangle(face_x, face_y, width, height);
                Rectangle destRect = new Rectangle((int)this.EyeX.Value, (int)this.EyeY.Value, (int)this.EyeW.Value, (int)this.EyeW.Value);
                DrawImageType(g, FaceBitmap, destRect, srcRect, this.Canvas.Width, this.Canvas.Height);
            }
            else if (category == CATEGORY.TYPE_MOUTH)
            {
                Rectangle srcRect  = new Rectangle(face_x, face_y, width, height);
                Rectangle destRect = new Rectangle((int)this.MouthX.Value, (int)this.MouthY.Value, (int)this.MouthW.Value, (int)this.MouthW.Value);
                DrawImageType(g, FaceBitmap, destRect, srcRect, this.Canvas.Width, this.Canvas.Height);
            }
            g.Dispose();

            int rotateY = RotateYComboBox.SelectedIndex;

            if (rotateY == 0)
            {
                return(CanvasBitmap);
            }

            CanvasBitmap = Rotate3DY(CanvasBitmap, rotateY * 10);
            return(CanvasBitmap);
        }
Exemple #24
0
        public ActionResult Chitietloai(int id)
        {
            //lay giay theo ma
            CATEGORY category = db.CATEGORIES.SingleOrDefault(a => a.ID == id);

            if (category == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(category));
        }
Exemple #25
0
        public ActionResult Create([Bind(Include = "ID_CATEGORY,ID_CATEGORY_TYPE,ACTIVE,NAME")] CATEGORY cATEGORY)
        {
            if (ModelState.IsValid)
            {
                db.CATEGORies.Add(cATEGORY);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_CATEGORY_TYPE = new SelectList(db.CATEGORY_TYPE, "ID_CATEGORY_TYPE", "NAME", cATEGORY.ID_CATEGORY_TYPE);
            return(View(cATEGORY));
        }
Exemple #26
0
 public void AddCategory(Category data)
 {
     using (lostfoundDB db = new lostfoundDB())
     {
         CATEGORY category = new CATEGORY
         {
             TITLE = data.Title
         };
         db.CATEGORies.Add(category);
         db.SaveChanges();
     }
 }
        private static TreeNode addNodeToTree(TreeNode myNode, CATEGORY singleC, ICollection <CATEGORY> cats)
        {
            var node = new TreeNode(singleC.Name, singleC.ID.ToString());

            node.ShowCheckBox = true;
            if (cats != null && cats.Count > 0 && cats.Any(cat => cat.ID == singleC.ID))
            {
                node.Checked = true;
            }
            myNode.ChildNodes.Add(node);
            return(node);
        }
Exemple #28
0
        public ActionResult Create([Bind(Include = "categoryID,categoryName,workstreamID")] CATEGORY cATEGORY)
        {
            if (ModelState.IsValid)
            {
                db.CATEGORies.Add(cATEGORY);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.workstreamID = new SelectList(db.WORKSTREAMs, "workstreamID", "workstreamName", cATEGORY.workstreamID);
            return(View(cATEGORY));
        }
Exemple #29
0
        private List <Badge> SortCategory(List <Badge> listToSort, CATEGORY category)
        {
            List <Badge> sortedList = new List <Badge>();

            listToSort.ForEach(el => {
                if (el.Category == category)
                {
                    sortedList.Add(el);
                }
            });
            return(sortedList);
        }
Exemple #30
0
        public JsonResult GetSizes(int CAT_ID)
        {
            List <SIZES> sizeList = new List <SIZES>();

            CATEGORY obj = new CATEGORY();

            obj      = (from sizeGroup in db.CATEGORY where sizeGroup.CAT_ID == CAT_ID select sizeGroup).Single();
            sizeList = (from sizes in db.SIZES where sizes.SIZE_GROUP == obj.SIZE_GROUP select sizes).ToList();
            sizeList.Insert(0, new SIZES {
                SIZE_ID = 0, SIZE_NAME = "Select"
            });
            return(Json(new SelectList(sizeList, "SIZE_ID", "SIZE")));
        }
Exemple #31
0
        public Clouth(int id,string description, string size, string colours,SUBCATEGORY subcategory,CATEGORY category, string action="", string imgName=null, string code=null )
        {
            Id=id;

            LowImg = imgName == null? id.ToString(): imgName;
            HighImg = imgName == null ? id.ToString() : imgName;
            GetCode = code == null ? Id.ToString() : code;

            ShortDescription=description.ToLower();
            SubCategory = subcategory;
            Category = category;
            Action = action;
            if (String.IsNullOrEmpty(colours))
                Description = String.Format("Art. {0} -  {1} - Talles: {2}", id.ToString(), description, size);
            else
                Description = String.Format("Art. {0} -  {1} - Talles: {2} - Colores: {3}",id.ToString(), description, size, colours);
        }
Exemple #32
0
        public void remove(CATEGORY cat)
        {
            try
            {
                var Context = new connext_dbEntities();
                Context.CATEGORies.Remove(cat);
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
            #if DEBUG
                throw new Exception("Impossible de supprimer le lieu." + Environment.NewLine + ex.StackTrace);
            #else
            throw new Exception("Impossible de supprimer le lieu.");

            #endif
            }
        }
Exemple #33
0
        public void add(CATEGORY cat)
        {
            try
            {
                var Context = new connext_dbEntities();
                Context.CATEGORies.Add(cat);
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
            #if DEBUG
                throw new Exception("Impossible de modifier l'agence." + Environment.NewLine + ex.StackTrace);
            #else
            throw new Exception("Impossible de modifier l'agence.");

            #endif
            }
        }
        public static void InsertGoogleStore(string storejson)
        {
            Store s = myConvert.Deserialize<Store>(storejson);
            try
            {
                if (s == null)
                { return; }
                Random r = new Random();
                int i = r.Next(0, 6);
                //string[] users = new string[6] { "gdabli", "harshisame", "nari.dontula", "rungta.sachin", "SiChen", "YongZhuang" };
                string[] users = new string[6] { "Gaurav_Dabli", "Harshita_Gupta", "Harshita_Gupta", "Nari_Dontula", "Nari_Dontula", "Yong_Zhuang" };
                if (mydb.STOREs.SingleOrDefault(ss => ss.PLACE_ID == s.place_id) != null)
                {
                    return;
                }
                //{ "geometry": { "location": { "k": 42.360128, "B": -71.055454 } }, "name": "Cheers", "types": ["cafe", "bar", "restaurant", "food", "establishment"], "vicinity": "1 S Market St, Boston", "html_attributions": [] }
                STORE store = new STORE() { NAME = s.name, PLACE_ID = s.place_id, PRICE_LEVEL = s.price_level, RATING = s.rating, PHONE = s.formatted_phone_number, WEBSITE = s.website, OWNER = users[i], GOOGLE_URL = s.url };
                LOCATION location = new LOCATION() { LATITUDE = s.geometry.location.k, LONGITUDE = s.geometry.location.B };
                mydb.LOCATIONs.InsertOnSubmit(location);
                store.LOCATION = location;
                ADDRESS address = new ADDRESS() { ADDRESS_LINE1 = s.vicinity.Split(',')[0], CITY = s.vicinity.Split(',')[1] };
                if (s.address_components != null)
                {
                    foreach (Address_Components ad in s.address_components)
                    {
                        foreach (string type in ad.types)
                        {
                            switch (type)
                            {
                                case "country":
                                    {
                                        address.COUNTRY = ad.long_name;
                                        break;
                                    }
                                case "postal_code":
                                    {
                                        address.POSTAL_CODE = ad.long_name;
                                        break;
                                    }
                                case "administrative_area_level_1":
                                    {
                                        address.STATE_PROVINCE_REGION = ad.long_name;
                                        break;
                                    }
                            }
                        }
                    }
                }
                mydb.ADDRESSes.InsertOnSubmit(address);
                store.ADDRESS = address;
                if (s.opening_hours != null)
                {
                    foreach (Period period in s.opening_hours.periods)
                    {
                        PERIOD p = new PERIOD() { OPEN_DAY = period.open.day, CLOSE_DAY = period.close.day, OPEN_TIME = Convert.ToDateTime(period.open.hours + ":" + period.open.minutes).TimeOfDay, CLOSE_TIME = Convert.ToDateTime(period.close.hours + ":" + period.close.minutes).TimeOfDay };
                        store.PERIODs.Add(p);
                    }
                }
                if (s.reviews != null)
                {
                    foreach (Review review in s.reviews)
                    {
                        if (string.IsNullOrEmpty(review.author_name) || review.author_name == "A Google User")
                        {
                            continue;
                        }
                        USER user = mydb.USERs.SingleOrDefault(u => u.FIRST_NAME + " " + u.LAST_NAME == review.author_name);
                        if (user == null)
                        {
                            string[] name = review.author_name.Split(' ');
                            if (name.Length > 1)
                            {
                                user = new USER() { FIRST_NAME = name[0], LAST_NAME = name[1], USER_ID = name[0] + "_" + name[1], EMAIL = name[0] + "." + name[1] + "@gmail.com", PASSWORD = "******", ROLE = "0", REGISTER_DATE = DateTime.Now };
                            }
                            else if (name.Length > 0)
                            {
                                user = new USER() { FIRST_NAME = name[0], LAST_NAME = "", USER_ID = name[0], EMAIL = name[0] + "@gmail.com", PASSWORD = "******", ROLE = "0", REGISTER_DATE = DateTime.Now };
                            }
                            mydb.USERs.InsertOnSubmit(user);
                        }
                        if (user != null)
                        {
                            FEEDBACK feed = new FEEDBACK() { COMMENT = review.text, RATING = review.rating  };
                            feed.IS_LIKED = feed.RATING > 2.5 ? 1 : 0;
                            feed.USER = user;
                            feed.STORE = store;
                            mydb.FEEDBACKs.InsertOnSubmit(feed);
                        }
                    }
                }
                if (s.types != null)
                {
                    foreach (string type in s.types)
                    {
                        CATEGORY catergory = mydb.CATEGORies.SingleOrDefault(c => c.NAME == type);
                        if (catergory == null)
                        {
                            catergory = new CATEGORY() { NAME = type, LAYER = 1, PARENT = 0 };
                            mydb.CATEGORies.InsertOnSubmit(catergory);
                        }
                        STORE_CATEGORY s_c = new STORE_CATEGORY();
                        s_c.CATEGORY = catergory;
                        s_c.STORE = store;
                        mydb.STORE_CATEGORies.InsertOnSubmit(s_c);
                    }
                }
                mydb.SubmitChanges();

            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #35
0
 public static CATEGORY CreateCATEGORY(int ID)
 {
     CATEGORY cATEGORY = new CATEGORY();
     cATEGORY.ID = ID;
     return cATEGORY;
 }
Exemple #36
0
 public void AddToCATEGORY(CATEGORY cATEGORY)
 {
     base.AddObject("CATEGORY", cATEGORY);
 }
Exemple #37
0
        public int SaveDataCategory(CategoryModel cate)
        {
            try
            {

                if (cate.CategoryID == 0)
                {
                    var checkdata = _context.CATEGORies.Where(x => x.CategoryName == cate.CategoryName).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return -1;
                    }

                    var data = new CATEGORY();
                    data.CategoryName = cate.CategoryName;
                    data.CategoryNameSort = cate.CategoryNameSort ?? "";
                    data.Color = cate.Color ?? "";
                    data.ProductColor = cate.ProductColor ?? "";
                    data.Status = 1;
                    data.CreateBy = cate.CreateBy ?? 1;
                    data.CreateDate = DateTime.Now;
                    data.UpdateBy = cate.UpdateBy ?? 0;
                    data.UpdateDate = DateTime.Now;
                    data.Note = cate.Note ?? "";

                    _context.Entry(data).State = EntityState.Added;
                    _context.SaveChanges();

                    return 1;

                }
                else
                {
                    var checkdata = _context.CATEGORies.Where(x => x.CategoryName == cate.CategoryName && x.CategoryID != cate.CategoryID).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return -1;
                    }
                    var data = _context.CATEGORies.Find(cate.CategoryID);
                    if (data != null)
                    {
                        data.CategoryName = cate.CategoryName;
                        data.CategoryNameSort = cate.CategoryNameSort ?? "";
                        data.Color = cate.Color ?? "";
                        data.ProductColor = cate.ProductColor ?? "";
                        data.Status = 1;
                        data.UpdateBy = cate.UpdateBy ?? 1;
                        data.UpdateDate = DateTime.Now;
                        data.Note = cate.Note ?? "";

                        _context.Entry(data).State = EntityState.Modified;
                        _context.SaveChanges();

                        return 1;
                    }
                    return 0;

                }
            }
            catch (Exception)
            {
                return 0;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.Params.Get("operate").Equals("new"))
                {
                    try
                    {
                        string idStr = Request.Params.Get("id");
                        int id = int.Parse(idStr);
                        Session["editCourse"] = CourseAccess.GetCourseById(id);

                        CATEGORY category=new CATEGORY();
                        category.CATE_NAME=Request.Params.Get("title");
                        CourseAccess.AddCategory(category);
                    }
                    catch
                    {
                        Response.Write("新建错误,可能存在问题:已经存在该类型");
                        Response.End();
                    }
                    Response.Write("success");
                    Response.End();
                }

                COURSE course=null;
                try
                {
                    string idStr = Request.Params.Get("id");
                    if (idStr == null || idStr == "") return;
                    int id = int.Parse(idStr);
                    course = CourseAccess.GetCourseById(id);
                }
                catch
                {
                    Response.Write("账号不存在");
                    Response.End();
                }
                if (course == null)
                {
                    Response.Write("账号不存在");
                    Response.End();
                }
                course.TITLE = Request.Params.Get("title");
                course.INTRO = Request.Params.Get("intro");
                try
                {
                    course.PRICE = decimal.Parse(Request.Params.Get("price"));
                }
                catch
                {
                    Response.Write("价格错误");
                    Response.End();
                }
                try
                {
                    CATEGORY[] category=CourseAccess.GetAllCategories();
                    int categoryInt=int.Parse(Request.Params.Get("category"));
                    course.CATEGORY = category[categoryInt].ID;
                }
                catch
                {
                    Response.Write("类型错误");
                    Response.End();
                }

                try
                {
                    CourseAccess.UpdateCourse(course);
                }
                catch
                {
                    Response.Write("连接错误");
                    Response.End();
                }
                Response.Write("success");
                Response.End();
            }
            catch
            {
            }
        }