예제 #1
0
 public AddMenu(DAL.Menu menu)
 {
     InitializeComponent();
     this.label2.Text     = "Edit menu";
     this.btnAddMenu.Text = "Update";
     this.menu            = menu;
     this.txtName.Text    = this.menu.Name;
 }
예제 #2
0
        public List <Menu> getWeeklyTopSales()
        {
            List <Menu> menus       = new List <Menu>();
            string      queryString =
                @"SELECT id, name, price, img_url 
                FROM
                (
                    SELECT menu_id, COUNT(menu_id) as sale

                    FROM order_items

                    WHERE create_at BETWEEN dateadd(day, -7, getdate()) AND getdate()

                    GROUP BY menu_id
                ) AS weeklyMenuSales
                INNER JOIN menus
                on menus.id = weeklyMenuSales.menu_id
                WHERE menus.deleted_at IS NULL
                ORDER BY sale DESC";

            using (connection)
            {
                // Create the Command and Parameter objects.
                SqlCommand command = new SqlCommand(queryString, connection);

                // Open the connection in a try/catch block.
                // Create and execute the DataReader, writing the result
                // set to the console window.
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        DAL.Menu menu = new DAL.Menu();

                        menu.id      = (int)reader[0];
                        menu.name    = (string)reader[1];
                        menu.price   = (decimal)reader[2];
                        menu.img_url = (string)reader[3];

                        menus.Add(menu);
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                return(menus);
            }
        }
예제 #3
0
        /**
         * Get selected row on table and bind to
         */
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            selectedIndex = dataGridView1.CurrentCell.RowIndex;

            if (selectedIndex == -1)
            {
                resetUpdateInput();
                return;
            }

            DAL.Menu menu = menus[selectedIndex];

            textUpdateID.Text    = menu.id.ToString();
            textUpdateNama.Text  = menu.name;
            textUpdateHarga.Text = menu.price.ToString();
            urlFotoUpdate        = @"\resources\images\" + menu.img_url;
        }
예제 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                MenuBLL menuBL   = new MenuBLL();
                string  name     = textAddNama.Text;
                double  price    = Double.Parse(textAddHarga.Text);
                string  url_foto = urlFotoAdd;

                menuBL.handleCreate(name, price, url_foto);

                DAL.Menu newMenu = menuBL.getLastInsertedData();
                addToTable(newMenu);

                menus.Add(newMenu);
                resetAddInput();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DAL.Menu                svMenu       = new DAL.Menu();
            BLL.RestaurantBLL       svRestaurant = new BLL.RestaurantBLL();
            MODEL.Criteria.reqeMenu req          = new MODEL.Criteria.reqeMenu();
            req.restaurantID = "2";
            req.recommend    = "0";
            svMenu.getFoodseMenu(req);
            //MODEL.Criteria.reqOrder req = new MODEL.Criteria.reqOrder();
            //req.restaurantID = "1";
            //req.tableID = "1";
            //req.userID = "1";
            //req.statusID = "2";

            //string password = "******";

            //string encryptedstring = DAL.StringCipher.Encrypt("{\"restaurantID\":\"3\",\"tableID\":\"10\"}", password);

            //string decryptedstring = DAL.StringCipher.Decrypt(encryptedstring, password);
            //List<MODEL.FoodsItems> list = new List<MODEL.FoodsItems>();

            //MODEL.FoodsItems x;
            //x = new MODEL.FoodsItems();
            //x.foodsID = "1";
            //x.price = 25;
            //x.qty = 5;
            //list.Add(x);
            //req.orderList = list;

            //svRestaurant.insertOrder(req);

            //svRestaurant.updateOrder(req);



            //List<M_Bill_Header> model = new List<M_Bill_Header>();
            //M_Bill_Header data;
            //data = new M_Bill_Header();
            //data.BillNo = "B201908200001";
            //data.BillTableName = "X1";
            //data.BillMenuCount = "12";
            //data.BillTotalPrice = "19500";
            //data.BillStatusText = "Pending";
            //model.Add(data);

            //data = new M_Bill_Header();
            //data.BillNo = "B201908200002";
            //data.BillTableName = "X1";
            //data.BillMenuCount = "10";
            //data.BillTotalPrice = "19500";
            //data.BillStatusText = "Pending";
            //model.Add(data);

            //data = new M_Bill_Header();
            //data.BillNo = "B201908200003";
            //data.BillTableName = "X1";
            //data.BillMenuCount = "9";
            //data.BillTotalPrice = "19500";
            //data.BillStatusText = "Pending";
            //model.Add(data);

            DAL.Restaurant sv = new DAL.Restaurant();


            dgvData.DataSource = sv.getBillList("", "");
            dgvData.DataBind();
        }
예제 #6
0
 private void addToTable(DAL.Menu menu)
 {
     dataGridView1.Rows.Add(menu.id, menu.name, menu.price.ToString("N0"));
 }