Beispiel #1
0
        private void InitializeData()
        {
            //TODO Database Get Last row for Table Product
            ResetForm();


            DatabaseHandle dbHandle = new DatabaseHandle();

            string jsonString = dbHandle.ListOfPopup();

            if (jsonString != null)
            {
                List <PopupModel> lstPopupModel = JsonConvert.DeserializeObject <List <PopupModel> >(jsonString);

                var dbSource = lstPopupModel.Select(x => new { x.Name, x.PopupID }).ToList();

                cbPopup.DisplayMember = "Name";
                cbPopup.ValueMember   = "PopupID";
                cbPopup.DataSource    = dbSource;
            }


            //TODO Database Get list of Priter
            //TODO Database Get list of Ingredients for Product
        }
Beispiel #2
0
        private void btnQuickDelete_Click(object sender, EventArgs e)
        {
            DatabaseHandle dbHandle = new DatabaseHandle();

            if (dgvProduct.SelectedRows.Count > 0)
            {
                int    popupID   = (int)dgvProduct.SelectedRows[0].Cells[0].Value;
                string titleName = dgvProduct.SelectedRows[0].Cells[1].Value.ToString();

                //1 is NONE Popup cann't delete it.
                if (popupID != 1)
                {
                    if (MessageBox.Show("Do you want to delete " + titleName + " Popup!", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        if (dbHandle.RemovePopup(popupID) > 0)
                        {
                            RefreshTable();
                            MessageBox.Show("Delete Complete!");
                        }
                        else
                        {
                            MessageBox.Show("Something wrong!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Cann't Delete NONE Popup!");
                }
            }
        }
Beispiel #3
0
        private void btnAddPopup_Click(object sender, EventArgs e)
        {
            int        index = 0, i = 0;
            PopupModel popupModel = new PopupModel();
            ListPopup  listPopup;

            popupModel.Name = txtPopName.Text;
            Image tempImage;

            foreach (ListViewItem eachItem in lsvSubPopup.Items)
            {
                listPopup       = new ListPopup();
                listPopup.Name  = eachItem.SubItems[1].Text;
                listPopup.Price = float.Parse(eachItem.SubItems[2].Text);
                index           = i;
                tempImage       = _imageList.Images[index];

                Bitmap bitmap = new Bitmap(_imageList.Images[index]);

                if (tempImage != null)
                {
                    listPopup.Image64 = ConvertImage.ImageToString(bitmap);
                }
                else
                {
                    listPopup.Image64 = "";
                }

                popupModel.ListSubPopup.Add(listPopup);

                i++;
            }

            string         JSON           = JsonConvert.SerializeObject(popupModel);
            DatabaseHandle databaseHandle = new DatabaseHandle();

            if (databaseHandle.AddPopup(JSON) > 0)
            {
                MessageBox.Show("Add Popup Complete!", "Success", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("Something wrong", "Fail", MessageBoxButtons.OK);
            }

            txtPopName.Text      = "";
            txtPopupPrice.Text   = "0";
            pbImage.Image        = null;
            _imageList           = new ImageList();
            _imageList.ImageSize = new Size(50, 50);
            lsvSubPopup.Items.Clear();
        }
Beispiel #4
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            DatabaseHandle dbHandle = new DatabaseHandle();

            if (dbHandle.GetStaffDetailByPassword(txtPW.Text) != null)
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("Password is incorrecet!");
            }
        }
Beispiel #5
0
        private void InitializeData()
        {
            DatabaseHandle dbHandle = new DatabaseHandle();
            string         JSON     = dbHandle.GetPopupDetail(PopupID);

            if (JSON != null)
            {
            }
            else
            {
                //TODO MessangeBox ERROR and Close this form
            }
        }
Beispiel #6
0
        private void RefreshTable()
        {
            DatabaseHandle dbHandle = new DatabaseHandle();
            string         JSON     = dbHandle.ListOfPopup();

            List <PopupModel> lstPopupModel = JsonConvert.DeserializeObject <List <PopupModel> >(JSON);

            DataTable table = new DataTable();

            table.Columns.Add("ID", typeof(int));
            table.Columns.Add("Name", typeof(string));

            List <string> lstName = lstPopupModel.Select(x => x.Name).ToList();
            List <int>    lstID   = lstPopupModel.Select(x => x.PopupID).ToList();

            for (int i = 0; i < lstName.Count; i++)
            {
                table.Rows.Add(lstID[i], lstName[i]);
            }

            dgvProduct.DataSource = table;
        }
Beispiel #7
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DatabaseHandle dbHandle   = new DatabaseHandle();
            string         jsonString = dbHandle.ListOfPopupFilter(txtSearch.Text);

            List <PopupModel> lstPopupModel = JsonConvert.DeserializeObject <List <PopupModel> >(jsonString);

            DataTable table = new DataTable();

            table.Columns.Add("ID", typeof(int));
            table.Columns.Add("Name", typeof(string));

            List <string> lstName = lstPopupModel.Select(x => x.Name).ToList();
            List <int>    lstID   = lstPopupModel.Select(x => x.PopupID).ToList();

            for (int i = 0; i < lstName.Count; i++)
            {
                table.Rows.Add(lstID[i], lstName[i]);
            }

            dgvProduct.DataSource = table;
        }
Beispiel #8
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            ProductModel product = new ProductModel();

            product.ProductID = int.Parse(txtProductID.Text);

            try
            {
                //Textbox Name
                if (txtName.Text.Trim() == "")
                {
                    MessageBox.Show("Please fill Name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    product.Name = txtName.Text;
                }

                //Textbox Shotcut Name
                product.ShortName = txtSCName.Text.Trim() == "" ? "" : txtSCName.Text;

                //Textbox Desicription
                product.Description = txtDescription.Text.Trim() == "" ? "" : txtDescription.Text;

                //Textbox Popup
                if (cbPopup.Text == "")
                {
                    product.PopupID = 0;
                }
                else
                {
                    product.PopupID = int.Parse(cbPopup.SelectedValue.ToString());
                }

                //Textbox PriceInc
                if (txtPriceInc.Text.Trim() == "")
                {
                    product.Price = 0;
                }
                else
                {
                    float parsedValue;
                    if (!float.TryParse(txtPriceInc.Text, out parsedValue))
                    {
                        MessageBox.Show("Price field is only number!");
                        txtPriceInc.Text = "0";
                        return;
                    }
                    else
                    {
                        product.Price = parsedValue;
                    }
                }

                //Textbox Stock
                if (txtStock.Text == "")
                {
                    product.Stock = 0;
                }
                else
                {
                    int parsedValue;
                    if (!int.TryParse(txtPriceInc.Text, out parsedValue))
                    {
                        MessageBox.Show("Stock field is only number!");
                        txtStock.Text = "";
                        return;
                    }
                    else
                    {
                        product.Price = parsedValue;
                    }
                }

                //Checkbox Avaliable
                product.Avaliable = cbAvaliable.Checked == true ? 1 : 0;

                //Type of Food
                if (rbEntree.Checked == true)
                {
                    product.TypeOfFood = 1;
                }
                else if (rbMain.Checked == true)
                {
                    product.TypeOfFood = 2;
                }
                else if (rbBeverage.Checked == true)
                {
                    product.TypeOfFood = 3;
                }
                else if (rbDessert.Checked == true)
                {
                    product.TypeOfFood = 4;
                }
                else
                {
                    product.TypeOfFood = 5;
                }

                string json = JsonConvert.SerializeObject(product);

                DatabaseHandle dbHandle = new DatabaseHandle();

                if (dbHandle.AddProduct(json) > 0)
                {
                    MessageBox.Show("Add Product Complete!");
                }
                else
                {
                    MessageBox.Show("Something Wrong!");
                }

                dbHandle = null;
                ResetForm();
            }
            catch (Exception ex)
            {
                ExceptionLog exceptionLog = new ExceptionLog();
                exceptionLog.Message = ex.Message;
            }
        }