Beispiel #1
0
        private void lbCategory_SelectionChanged(object sender, SelectionChangedEventArgs e) // 카테고리가 바뀔 때
        {
            if (lbCategory.SelectedIndex == -1)
            {
                return;
            }
            pageCount = 0;
            Data.Category category = (Data.Category)lbCategory.SelectedIndex;

            if (lbCategory.SelectedIndex == 0)
            {
                lbMenus.ItemsSource  = App.burgerList;
                previewBtn.IsEnabled = false;
                nextBtn.IsEnabled    = true;
            }
            else if (lbCategory.SelectedIndex == 1)
            {
                lbMenus.ItemsSource  = App.drinkList;
                previewBtn.IsEnabled = false;
                nextBtn.IsEnabled    = true;
            }
            else if (lbCategory.SelectedIndex == 2)
            {
                lbMenus.ItemsSource  = App.sideList;
                previewBtn.IsEnabled = false;
                nextBtn.IsEnabled    = true;
            }
        }
Beispiel #2
0
        internal static CategoryInfo FetchCategoryInfo(Data.Category data)
        {
            var result = new CategoryInfo();

            result.Fetch(data);
            return(result);
        }
Beispiel #3
0
        public EventViewModels CreateEvent(Container_Classes.Event NewEvent)
        {
            int typeID = int.Parse(NewEvent.Type);

            // Convert the type string and category string to database keys
            Data.Type dataType = _repository.Get <Data.Type>(x => x.TypeID == typeID);
            if (dataType == null)
            {
                // Could not map type to the database
                return(null);
            }

            Data.Category dataCategory = _repository.Get <Data.Category>(x => x.Category1.Equals(NewEvent.Category));

            // Convert the Container Event into a Data Event so it can be added to the database
            Data.Event dataEvent = Container_Classes.Event.ContainerEventToDataEvent(NewEvent, dataCategory.CategoryID, dataType.TypeID, NewEvent.Owner_ID);
            _repository.Add <Data.Event>(dataEvent);
            _repository.SaveChanges();

            // Weak way of getting new event, this should break if two events have the same name!
            dataEvent = _repository.Get <Data.Event>(x => x.Title == NewEvent.Title);

            // Assign the ID to the added container object event
            NewEvent.ID = dataEvent.EventID;

            EventViewModels model = new EventViewModels();

            model.Event = NewEvent;

            return(model);
        }
Beispiel #4
0
 private void _tableAddSaleViewModel_ToTableAddSaleSubViewRequested(Data.Category category)
 {
     _tableAddSaleSubViewModel = new TableAddSaleSubViewModel(category);
     _tableAddSaleSubViewModel.ToTableAddSaleProductViewRequested += _tableAddSaleSubViewModel_ToTableAddSaleProductViewRequested;
     _tableAddSaleSubViewModel.ViewBackRequested += ViewBackRequested;
     CurrentViewModel = _tableAddSaleSubViewModel;
     ViewModelHistory.Add(_tableAddSaleSubViewModel);
 }
Beispiel #5
0
        public FakeProductsRepo()
        {
            Data.Address address = new Data.Address()
            {
                Country = "Belgium",
                Id      = 1,
                Number  = 77,
                Street  = "Ter Platen",
                Zipcode = "9000"
            };

            Data.Company company = new Data.Company()
            {
                Address     = address,
                Name        = "My Company",
                Id          = 1,
                PhoneNumber = 0483663598,
                VAT         = "BE12345678",
                Website     = "MyCompany.com"
            };

            Data.Category category = new Data.Category()
            {
                Company = company,
                Id      = 1,
                Name    = "Drank"
            };

            Data.SubCategory subCategory = new Data.SubCategory()
            {
                Category = category,
                Id       = 1,
                Name     = "Bier"
            };

            _products = new List <Data.Product>();
            _products.Add(new Data.Product()
            {
                SubCategory = subCategory,
                Id          = 1,
                Name        = "Westmalle",
                Price       = 4.5
            });
            _products.Add(new Data.Product()
            {
                SubCategory = subCategory,
                Id          = 2,
                Name        = "Westvleteren",
                Price       = 10
            });
            _products.Add(new Data.Product()
            {
                SubCategory = subCategory,
                Id          = 3,
                Name        = "Jupiler",
                Price       = 2
            });
        }
Beispiel #6
0
 private static Model.Category MapDataCategoryToModelCategory(Data.Category datacategory)
 {
     Model.Category category = new Model.Category();
     if (datacategory != null)
     {
         category.Id   = datacategory.Id;
         category.Name = datacategory.Name;
     }
     return(category);
 }
Beispiel #7
0
        public static void CreateCategories()
        {
            var category = new Data.Category();

            {
                Console.Clear();
                GetCategories();
                Console.WriteLine();
                Console.WriteLine(" Är det säkert att du vill lägga till en ny kategori? skriv j/n");
                string exit = Console.ReadLine();
                if (exit == "n")
                {
                    ShowMenu();
                }
                else
                {
                    Console.WriteLine(" ================================");
                    Console.WriteLine(" Lägg till ny kategori");
                    Console.WriteLine(" ================================");
                    Console.Write("\r\n Kategorinamn: ");
                    category.Name = Console.ReadLine();
                    Console.Write("\r\n Är Storleken över eller lika med 40 fot? j/n: ");
                    string choice = Console.ReadLine();
                    if (choice == "j")
                    {
                        category.OverSizeFourty = true;
                    }
                    else
                    {
                        category.OverSizeFourty = false;
                    }

                    using (var DB = new Data.BoatBookingSystemEntities1())
                    {
                        try
                        {
                            DB.Categories.Add(category);
                            DB.SaveChanges();
                            var id = category.CatID;
                        }
                        catch (Exception ex)
                        {
                            Console.Write("The category could't be saved becouse of \"{0}\" .", ex.Message);

                        }
                    }
                }
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine(" Återgå till meny - tryck valfri tangent");
            Console.ReadKey();
            ShowMenu();
        }
Beispiel #8
0
        public static Category FromModel(Data.Category data)
        {
            Category res = new Category
            {
                Id     = data.Id,
                Name   = data.Name,
                Color  = data.Color,
                UserId = data.UserId,
                Status = data.Status,
            };

            return(res);
        }
Beispiel #9
0
        protected override void DataPortal_DeleteSelf()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Category
                {
                    CategoryId = this.ReadProperty(CategoryIdProperty)
                };

                ctx.ObjectContext.Categories.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Beispiel #10
0
 private void CreateCategories()
 {
     for (int i = 1; i <= NUM_CATEGORIES; i++)
     {
         Data.Category newCategory = new Data.Category {
             Id           = ConvertIntToGuid(NUM_CATEGORIES - i + 1),
             Created      = DateTime.Now.AddDays(-i),
             LastModified = DateTime.Now.AddDays(-i),
             Title        = $"Category {i}",
             Slug         = $"Slug{i}",
             Description  = $"Description for category with Id {i}"
         };
         categoriesList.Add(newCategory);
     }
 }
Beispiel #11
0
        protected override void DataPortal_Insert()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Category();

                this.Insert(data);

                ctx.ObjectContext.AddToCategories(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(CategoryIdProperty, data.CategoryId);
                this.LoadProperty(CreatedByProperty, data.CreatedBy);
                this.LoadProperty(CreatedDateProperty, data.CreatedDate);
            }
        }
Beispiel #12
0
        protected override void DataPortal_Update()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Category
                {
                    CategoryId = this.ReadProperty(CategoryIdProperty)
                };

                ctx.ObjectContext.Categories.Attach(data);

                this.Update(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(ModifiedByProperty, data.ModifiedBy);
                this.LoadProperty(ModifiedDateProperty, data.ModifiedDate);
            }
        }
Beispiel #13
0
        private void AddNewCategoryToDb()
        {
            try
            {
                MainWindow M = (MainWindow)App.Current.MainWindow;
                using (Data.ConnectContainer conn = new Data.ConnectContainer())
                {
                    var cate = new Data.Category()
                    {
                        Name       = NameTextbox.Text,
                        ModifiedBy = M.StaffKey,
                        ModifiedOn = ExtendedFunctions.GetNetworkTime(),
                        AddedBy    = M.StaffKey,
                        AddedOn    = ExtendedFunctions.GetNetworkTime(),
                        Color      = this.colorPicker.CurrentSelectedColor.Color.ToString(),
                        IsDeleted  = false,
                        Key        = Encryption.GetUniqueKey(16)
                    };
                    var Parent = ((ComboBoxItem)this.NestCombobox.SelectedItem).Tag as Category;

                    cate.ParentKey = Parent.Key;
                    cate.Level     = Parent.Level + 1;

                    conn.Categories.Add(cate);
                    int i = conn.SaveChanges();
                    if (i > 0)
                    {
                        this.Confirmed?.Invoke(this, EventArgs.Empty);
                    }
                    else
                    {
                        this.Failed?.Invoke(this, EventArgs.Empty);
                    }
                };
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Data.Category obj = new Data.Category();
         obj.Id = txtId.Value;
         obj.Tag = Common.StringClass.NameToTag(txtName.Text);
         obj.Name = txtName.Text;
         obj.Content = fckContent.Value;
         obj.Level = Level + "00000";
         obj.Priority = chkPriority.Checked ? "1" : "0";
         obj.Index = chkIndex.Checked ? "1" : "0";
         obj.Image = txtImage.Text;
         obj.Title = txtTitle.Text;
         obj.Description = txtDescription.Text;
         obj.Keyword = txtKeyword.Text;
         obj.Active = chkActive.Checked ? "1" : "0";
         obj.Ord = txtOrd.Text != "" ? txtOrd.Text : "1";
         obj.Lang = Lang;
         obj.Image2 = txtImage2.Text;
         if (Insert == true)
         {
             CategoryService.Category_Insert(obj);
         }
         else
         {
             CategoryService.Category_Update(obj);
         }
         Common.PageHelper.LoadDropDownListFilterActive(ddlFilterActive);
         Common.PageHelper.LoadDropDownListFilterActive(drlNhomtrangchu);
         Common.PageHelper.LoadDropDownListFilterActive(drlNhomuutien);
         BindGrid();
         pnView.Visible = true;
         pnUpdate.Visible = false;
         Level = "";
         Insert = false;
     }
 }
 protected void lbtUpdateOrd_Click(object sender, EventArgs e)
 {
     DataGridItem item = default(DataGridItem);
     for (int i = 0; i < grdCategory.Items.Count; i++)
     {
         item = grdCategory.Items[i];
         if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item)
         {
             TextBox stxtOrd = ((TextBox)item.FindControl("txtOrd"));
             NumberClass.OnlyInputNumber(stxtOrd);
             if (stxtOrd.Text != "" && stxtOrd.Text!="0")
             {
                 string strId = item.Cells[1].Text;
                 Data.Category obj = new Data.Category();
                 obj.Id = strId;
                 obj.Ord = stxtOrd.Text;
                 CategoryService.Category_Update_Ord(obj);
             }
         }
     }
     BindGrid();
 }