Esempio n. 1
0
        private void loadListRowIntoDetails(int RowIndex)
        {
            DataGridViewRow row = gvMenuItems.Rows[RowIndex];

            activeID = int.Parse(row.Cells[0].Value.ToString());
            data_models.Models.MenuItem m = MenuItemController.GetOneById(_context, (int)activeID);
            ddlCategory.Text = m.Category;
            tbxTitle.Text    = m.Title;
            if (m.Description != null)
            {
                rtbDescription.Text = m.Description;
            }
            if (m.Price != null)
            {
                tbxPrice.Text = toPaddedString((decimal)m.Price);
            }
            if (m.DiscountPrice == null)
            {
                cbxDiscount.Checked = false;
            }
            else
            {
                cbxDiscount.Checked   = true;
                tbxDiscountPrice.Text = toPaddedString((decimal)m.DiscountPrice);
            }

            cbxAvailable.Checked = m.IsAvailable;
            cbxSpecialty.Checked = m.IsSpecialty;
        }
Esempio n. 2
0
        private void btnUpdateSave_Click(object sender, EventArgs e)
        {
            String error = validateAllControls();

            if (error == "")
            {
                data_models.Models.MenuItem m = new data_models.Models.MenuItem();
                updateObjectFromForm(ref m);
                MenuItemController.UpdateItemByObject(_context, (int)activeID, m);
                loadMenuData();
                showMenuList();
            }
            else
            {
                MessageBox.Show(error, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
 private void updateObjectFromForm(ref data_models.Models.MenuItem obj)
 {
     obj.Category    = ddlCategory.Text;
     obj.Title       = tbxTitle.Text;
     obj.Description = rtbDescription.Text;
     obj.Price       = (decimal)Double.Parse(tbxPrice.Text.Substring(1));
     if (cbxDiscount.Checked)
     {
         obj.DiscountPrice = (decimal)Double.Parse(tbxDiscountPrice.Text.Substring(1));
     }
     else
     {
         obj.DiscountPrice = null;
     }
     obj.IsAvailable = cbxAvailable.Checked;
     obj.IsSpecialty = cbxSpecialty.Checked;
 }