Пример #1
0
        /// <summary>
        /// add family button listner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Add_Famille_Click(object sender, EventArgs e)
        {
            FamillyController Familly_Controller = new FamillyController();

            String Reference = Text_Box_Reference.Text;
            String Name      = Text_Box_Name.Text;

            if (!Reference.Equals("") && !Name.Equals(""))
            {
                try
                {
                    int     Reference_Int = int.Parse(Reference);
                    Familly Familly       = Familly_Controller.GetFamillyByRef(Reference_Int);
                    if (Familly == null)
                    {
                        Familly_Controller.InsertFamilly(Reference_Int, Name);
                        MessageBox.Show("Familly added successfully ;) ", "Added Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("This reference already exists in DataBase", "Error Add Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                catch (FormatException e2)
                {
                    MessageBox.Show(e2.Message, "Error add familly ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please fill in all fields", "Error Add Familly ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }