Exemplo n.º 1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            DTO_Beverage row = (DTO_Beverage)dgMenu.SelectedItem;

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "Xóa món",
                Content               = new PopupDeleteConfirm(row, this._context),
                Width                 = 420,
                Height                = 210,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
            setNumPage();
            if (maxNumpage < int.Parse(tbNumPage.Text))
            {
                tbNumPage.Text = (int.Parse(tbNumPage.Text) - 1).ToString();
            }
            loadData();
        }
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            tbNameValidation.Text = tbPriceValidation.Text = "";
            if (tbName.Text == "")
            {
                tbNameValidation.Text = "Tên món không được để trống.";
                return;
            }

            if (tbPrice.Text == "")
            {
                tbPriceValidation.Text = "Giá không được để trống.";
                return;
            }

            DTO_Beverage beverage = new DTO_Beverage();

            beverage.BeverageID     = ID;
            beverage.BeverageName   = tbName.Text;
            beverage.BeverageTypeID = bus.getBeverageTypeID(cbBeverageType.Text);
            beverage.Price          = Int32.Parse(tbPrice.Text);
            beverage.Link           = imageBytes;
            if (bus.editBevverage(beverage) > 0)
            {
                MessageBox.Show($"Đã sửa thông tin của {tbName.Text}");
                Window.GetWindow(this).Close();
            }
            else
            {
                MessageBox.Show($"Đã có lỗi trong quá trình chỉnh sửa {tbName.Text}");
            }
        }
Exemplo n.º 3
0
 public PopupDeleteConfirm(DTO_Beverage beverage, MainWindow context)
 {
     InitializeComponent();
     tblContent.Text = "Dữ liệu về " + beverage.BeverageName + " sẽ bị xóa vĩnh viễn.\nBạn chắc chắn muốn xóa?";
     ID            = beverage.BeverageID;
     name          = beverage.BeverageName;
     this._context = context;
 }
Exemplo n.º 4
0
        public int createNewBeverage(DTO_Beverage beverage)
        {
            int    rs  = 0;
            string sql = $"Insert into BeverageName values ('" + beverage.BeverageID + "','" + beverage.BeverageTypeID + "','" + beverage.BeverageName + "'," + beverage.Price + ", false, 'Cup', @image)";

            try
            {
                SQLiteCommand command = new SQLiteCommand(sql, getConnection());
                command.Parameters.Add("@image", DbType.Binary, 20).Value = beverage.Link;
                command.Connection.Open();
                rs = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
            return(rs);
        }
Exemplo n.º 5
0
        public int editBeverage(DTO_Beverage beverage)
        {
            int rs = 0;

            Console.WriteLine(beverage.BeverageID);
            string sql = $"Update BeverageName set BeverageTypeID='" + beverage.BeverageTypeID + "', BeverageName='" + beverage.BeverageName + "', Price=" + beverage.Price + ",IsOutOfStock=" + beverage.IsOutOfStock + ",Unit='" + beverage.Unit + $"' , Link=@image Where BeverageID='" + beverage.BeverageID + "'";

            try
            {
                SQLiteCommand command = new SQLiteCommand(sql, getConnection());
                command.Parameters.Add("@image", DbType.Binary, 20).Value = beverage.Link;
                command.Connection.Open();
                rs = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
            return(rs);
        }
Exemplo n.º 6
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            DTO_Beverage row     = (DTO_Beverage)dgMenu.SelectedItem;
            var          rowView = dgMenu.SelectedItem;

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "Sửa món",
                Content               = new PopupEditMenu(row.BeverageName, row.BeverageTypeID, row.Price.ToString(), row.BeverageID, row.Link, this._context),
                Width                 = 460,
                Height                = 620,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
            loadData();
        }
Exemplo n.º 7
0
 public int editBevverage(DTO_Beverage beverage)
 {
     return(dalBeverage.editBeverage(beverage));
 }
Exemplo n.º 8
0
 public int createNewBevverage(DTO_Beverage beverage)
 {
     return(dalBeverage.createNewBeverage(beverage));
 }