Exemple #1
0
        public void deleteATypeCake(TypeCake typeCake)
        {
            var type = db.TypeCakes.Find(typeCake.ID);

            db.TypeCakes.Remove(type);
            db.SaveChanges();
        }
Exemple #2
0
        public void updateATypeCake(TypeCake typeCake)
        {
            var type = db.TypeCakes.Find(typeCake.ID);

            type.NameTypeCake = typeCake.NameTypeCake;
            db.SaveChanges();
        }
 private void Screen_handler(object sender)
 {
     if (sender != null)
     {
         var type = sender as TypeCake;
         this.type_filter              = new TypeCake();
         this.type_filter.ID           = type.ID;
         this.type_filter.NameTypeCake = type.NameTypeCake;
     }
     else
     {
         this.type_filter = null;
     }
 }
Exemple #4
0
        private void ListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var item = sender as ListViewItem;

            if (item != null && item.IsSelected)
            {
                dynamic selectedItem = typeCakeListView.SelectedItem;

                this.Type              = new TypeCake();
                this.Type.ID           = selectedItem.ID;
                this.Type.NameTypeCake = selectedItem.NameTypeCake;

                this.Close();
            }
        }
Exemple #5
0
        public bool hasSameNameTypeCake(TypeCake Type)
        {
            var listTypeCake = db.TypeCakes.ToList();

            foreach (var item in listTypeCake)
            {
                if (item.ID != Type.ID && item.NameTypeCake.Equals(Type.NameTypeCake))
                {
                    return(true);
                }
                else
                {
                    // do nothing
                }
            }

            return(false);
        }
        public DialogTypeCake(TypeCake typeCake, int action)
        {
            InitializeComponent();
            this.DataContext = this;

            this.Type   = new TypeCake();
            this.Action = action;

            if (typeCake != null)
            {
                // clone
                this.Type.ID           = typeCake.ID;
                this.Type.NameTypeCake = typeCake.NameTypeCake;
            }
            else
            {
                // create new
                this.Type.ID = QueryDB.Instance.getLastIDTypeCake() + 1;
            }
            if (this.Action == ConstantVariable.ADD_TYPECAKE)
            {
                this.TitleAction          = "Thêm Loại Bánh";
                this.ActionName           = "Thêm";
                this.deleteBtn.Visibility = Visibility.Collapsed;
            }
            else if (this.Action == ConstantVariable.UPDATE_TYPECAKE)
            {
                this.TitleAction = "Cập Nhật Tên Loại Bánh";
                this.ActionName  = "Cập nhật";
                this.keywordPlaceholderTextBlock.Visibility = Visibility.Hidden;
            }
            else
            {
                // do nothing
            }
        }
        private void ListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var item = sender as ListViewItem;

            if (item != null && item.IsSelected)
            {
                switch (this.RibbonItem)
                {
                case ConstantVariable.RIBBON_TYPECAKE:
                {
                    dynamic selectedItem = typeCakeListViewRibbon.SelectedItem;
                    //MessageBox.Show($"{selectedItem.NameTypeCake}");

                    TypeCake typeCake = new TypeCake();
                    typeCake.ID           = selectedItem.ID;
                    typeCake.NameTypeCake = selectedItem.NameTypeCake;

                    var screen = new DialogTypeCake(typeCake, ConstantVariable.UPDATE_TYPECAKE);
                    screen.handler += this.ObjectWindowHandler;
                    screen.Owner    = this;
                    screen.ShowDialog();
                }

                break;

                case ConstantVariable.RIBBON_CAKE:
                {
                    dynamic selectedItem = cakeListViewRibbon.SelectedItem;
                    //MessageBox.Show($"{selectedItem.NameTypeCake}");

                    Product product = new Product();
                    product.ID          = selectedItem.ID;
                    product.Name        = selectedItem.NameCake;
                    product.Price       = selectedItem.Price;
                    product.IDTypeCake  = selectedItem.Type;
                    product.Description = selectedItem.Description;

                    var screen = new DialogCake(product, ConstantVariable.UPDATE_CAKE);
                    screen.handler += this.ObjectWindowHandler;
                    screen.Owner    = this;
                    screen.ShowDialog();
                }

                break;

                case ConstantVariable.RIBBON_CAKEIMPORT:
                {
                    dynamic selectedItem = cakeImportOrderListViewRibbon.SelectedItem;
                    //MessageBox.Show($"{selectedItem.NameTypeCake}");

                    CakeImportOrder cakeImportOrder = new CakeImportOrder();
                    cakeImportOrder.ID = selectedItem.ID;
                    cakeImportOrder.ImportOrderName = selectedItem.ImportOrderName;
                    cakeImportOrder.ProductID       = selectedItem.ProductID;
                    cakeImportOrder.ImportDate      = selectedItem.ImportDate;
                    cakeImportOrder.ExpirationDate  = selectedItem.ExpirationDate;
                    cakeImportOrder.Quantity        = selectedItem.Quantity;
                    cakeImportOrder.ImportPrice     = selectedItem.ImportPrice;
                    cakeImportOrder.Total           = selectedItem.Total;

                    var screen = new DialogCakeImport(cakeImportOrder, ConstantVariable.UPDATE_CAKEIMPORT);
                    screen.handler += this.ObjectWindowHandler;
                    screen.Owner    = this;
                    screen.ShowDialog();
                }

                break;

                case ConstantVariable.RIBBON_PAYMENT:
                {
                    dynamic selectedItem = detailCartListViewRibbon.SelectedItem;

                    Product product = QueryDB.Instance.findProductByID(selectedItem.ID_Product);

                    DetailCakeScreen screen = new DetailCakeScreen(product);
                    screen.Owner = this;
                    screen.ShowDialog();

                    BackstageTabItem_MouseLeftButtonDown(CartItem, null);
                }

                break;
                }
            }
        }
Exemple #8
0
 public void addATypeCake(TypeCake typeCake)
 {
     db.TypeCakes.Add(typeCake);
     db.SaveChanges();
 }