Пример #1
0
        /// <summary>
        /// get the infomations of the selected item
        /// </summary>
        /// <param name="SelectedSubFamily"></param>
        public void GetSubFamilyToModify(ListViewItem SelectedSubFamily)
        {
            SubFamillyController SubFamController  = new SubFamillyController();
            SubFamilly           SubFamilyToModify = new SubFamilly();

            SubFamilyToModify = SubFamController.GetSubFamillyByRef(int.Parse(SelectedSubFamily.Text));
            //Console.WriteLine("列表中选中的sub id"+SelectedSubFamily.Text);

            this.textBox_RefSF.Text  = SubFamilyToModify.RefSousFamille1.ToString();
            this.textBox_NameSF.Text = SubFamilyToModify.Nom1.ToString();
            this.comboBox_F.Text     = SubFamilyToModify.RefFamille1.Nom1.ToString();
        }
Пример #2
0
        /// <summary>
        /// add subfamily
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Add_Sous_Famille_Click(object sender, EventArgs e)
        {
            String Reference = Text_Box_Reference.Text;
            String Name      = Text_Box_Name.Text;

            int Familly_Index = Combo_Box_Famille.SelectedIndex;

            if (Familly_Index > -1 && !Reference.Equals("") && !Name.Equals(""))
            {
                try
                {
                    int Reference_Int = int.Parse(Reference);

                    SubFamillyController Sub_Familly_Controller = new SubFamillyController();
                    SubFamilly           Sub_Familly            = Sub_Familly_Controller.GetSubFamillyByRef(Reference_Int);

                    List <Familly> List_Familly      = new FamillyController().GetAllFamilly();
                    int            Reference_Familly = List_Familly[Familly_Index].RefFamille1;


                    if (Sub_Familly == null)
                    {
                        Sub_Familly_Controller.InsertSubFamilly(Reference_Int, Reference_Familly, Name);
                        MessageBox.Show("Sub Familly added successfully ;)", "Sub Familly Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Sub Familly exists already in database", "Error Add Sub Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                catch (FormatException e1)
                {
                    MessageBox.Show(e1.Message, "Error Add Sub Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please fill in all the fields", "Error Add Sub Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }