using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Self_Project
{
    public partial class FoodName : Form
    {
        public FoodName()
        {
            InitializeComponent();
        }
        Food objFood = new Food();
        private void FoodName_Load(object sender, EventArgs e)
        {
            lst_Day.SelectedIndex = lst_Month.SelectedIndex = 0;
            objFood.ShowFoodNames(Food.FoodTypes.صبحانه, lst_Breackfast);
            objFood.ShowFoodNames(Food.FoodTypes.نهار, lst_Launch);
            objFood.ShowFoodNames(Food.FoodTypes.شام, lst_Dinner);
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {
            try
            {
                if (lst_Month.SelectedIndex < 9)
                    objFood.Tarikh = "0" + (lst_Month.SelectedIndex + 1).ToString() + "/" + lst_Day.Text;
                else
                    objFood.Tarikh = (lst_Month.SelectedIndex + 1).ToString() + "/" + lst_Day.Text;
                objFood.Radif_BreakFast = Convert.ToInt32(lst_Breackfast.SelectedValue);
                objFood.Radif_Launch = Convert.ToInt32(lst_Launch.SelectedValue);
                objFood.Radif_Dinner = Convert.ToInt32(lst_Dinner.SelectedValue);
                objFood.SaveReserveFood();
                MessageBox.Show("اطلاعات با موفقیت ثبت شد", "ثبت غذا", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Food_Exceptions_Tarikh ex)
            {
                MessageBox.Show(ex.Message, "ثبت غذا", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lst_Day.Focus();
                return;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "ثبت غذای سلف", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}