예제 #1
0
        private void TreeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            int id = 0;

            if (int.TryParse(e.Node.GetValue(nameof(category.ID)).ToString(), out id))
            {
                var db = new DAL.dbDataContext();
                category = db.ProductCategories.Single(x => x.ID == id);
                GetData();
            }
        }
        // PUT api/values/5
        public ValidationResult_OSC Put([FromBody]OnlineShoppingCart.Model.ProductCategory productCategory)
        {
            var result = new ValidationResult_OSC();
            ValidationHelper validationHelper = new ValidationHelper(ref result, ModelState);

            if (result.Success)
            {
                DAL.ProductCategory productCatDAL = new DAL.ProductCategory();
                return productCatDAL.UpdateCategory(productCategory);
            }
            return result;
        }
예제 #3
0
 private void Lkp_Category_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e)
 {
     if (e.DisplayValue is string st && st.Trim() != string.Empty)
     {
         var newObject = new DAL.ProductCategory()
         {
             Name = st, ParentID = 0, Number = "0"
         };
         using (var db = new DAL.dbDataContext())
         {
             db.ProductCategories.InsertOnSubmit(newObject);
             db.SubmitChanges();
         }
         ((List <DAL.ProductCategory>)lkp_Category.Properties.DataSource).Add(newObject);
         e.Handled = true;
     }
 }
 public Result<List<OnlineShoppingCart.Model.ProductCategory>> GetAllCategories()
 {
     DAL.ProductCategory productCategory = new DAL.ProductCategory();
     return productCategory.GetAllCategoryList();
 }
 public Result<OnlineShoppingCart.Model.ProductCategory> Get(int id)
 {
     DAL.ProductCategory productCategory = new DAL.ProductCategory();
     return productCategory.GetCategory(id);
 }
 // DELETE api/values/5
 public ValidationResult_OSC Delete(int id)
 {
     DAL.ProductCategory productCatDAL = new DAL.ProductCategory();
     return productCatDAL.DeleteCategory(id);
 }
예제 #7
0
 public override void New()
 {
     category = new DAL.ProductCategory();
     base.New();
 }