示例#1
0
        public frm_ModifyActor(string strActor, Actor actor)
        {
            InitializeComponent();
            lbl_Actor.Text = strActor;
            _Actor         = actor;
            #region Load the form text fields to Fields list.
            Fields.Add(txtBx_LastName);
            Fields.Add(txtBx_FirstName);
            Fields.Add(txtBx_Email);
            Fields.Add(txtBx_Phone);
            Fields.Add(txtBx_Address);
            Fields.Add(txtBx_Role);
            Fields.Add(txtBx_Specialty);
            Fields.Add(txtBx_Login);
            Fields.Add(txtBx_Password);
            Fields.Add(txtBx_ConfirmPassword);
            #endregion

            #region Load the form labels to FieldLabels list.
            FieldLabels.Add(lbl_LastName);
            FieldLabels.Add(lbl_FirstName);
            FieldLabels.Add(lbl_Email);
            FieldLabels.Add(lbl_Phone);
            FieldLabels.Add(lbl_Address);
            FieldLabels.Add(lbl_Role);
            FieldLabels.Add(lbl_Specialty);
            FieldLabels.Add(lbl_Login);
            FieldLabels.Add(lbl_Password);
            FieldLabels.Add(lbl_ConfirmPassword);
            #endregion

            #region Fill the form's text fields
            txtBx_FirstName.Text       = _Actor.getFirstName();
            txtBx_LastName.Text        = _Actor.getLastName();
            txtBx_Email.Text           = _Actor.getEmail();
            txtBx_Phone.Text           = _Actor.getPhoneNumber();
            txtBx_Address.Text         = _Actor.getAddress();
            txtBx_Role.Text            = _Actor.getRole();
            txtBx_Specialty.Text       = _Actor.getSpecialty();
            txtBx_Login.Text           = _Actor.getLogin();
            txtBx_Password.Text        = _Actor.getPassword();
            txtBx_ConfirmPassword.Text = _Actor.getPassword();

            #endregion
        }
        public frm_ModifyActor(string strActor,Actor actor)
        {
            InitializeComponent();
            lbl_Actor.Text = strActor;
            _Actor = actor;
            #region Load the form text fields to Fields list.
            Fields.Add(txtBx_LastName);
            Fields.Add(txtBx_FirstName);
            Fields.Add(txtBx_Email);
            Fields.Add(txtBx_Phone);
            Fields.Add(txtBx_Address);
            Fields.Add(txtBx_Role);
            Fields.Add(txtBx_Specialty);
            Fields.Add(txtBx_Login);
            Fields.Add(txtBx_Password);
            Fields.Add(txtBx_ConfirmPassword);
            #endregion

            #region Load the form labels to FieldLabels list.
            FieldLabels.Add(lbl_LastName);
            FieldLabels.Add(lbl_FirstName);
            FieldLabels.Add(lbl_Email);
            FieldLabels.Add(lbl_Phone);
            FieldLabels.Add(lbl_Address);
            FieldLabels.Add(lbl_Role);
            FieldLabels.Add(lbl_Specialty);
            FieldLabels.Add(lbl_Login);
            FieldLabels.Add(lbl_Password);
            FieldLabels.Add(lbl_ConfirmPassword);
            #endregion

            #region Fill the form's text fields
            txtBx_FirstName.Text=_Actor.getFirstName();
            txtBx_LastName.Text = _Actor.getLastName();
            txtBx_Email.Text = _Actor.getEmail();
            txtBx_Phone.Text = _Actor.getPhoneNumber();
            txtBx_Address.Text = _Actor.getAddress();
            txtBx_Role.Text = _Actor.getRole();
            txtBx_Specialty.Text = _Actor.getSpecialty();
            txtBx_Login.Text = _Actor.getLogin();
            txtBx_Password.Text = _Actor.getPassword();
            txtBx_ConfirmPassword.Text = _Actor.getPassword();

            #endregion
        }
示例#3
0
        //Add an Actor (Expert/Technician) to the data base.
        private void btn_Validate_Click(object sender, EventArgs e)
        {
            if (Check_Fields())
            {
                //T for Technician
                if (lbl_Actor.Text[0] == 'T')
                {
                    //The instructions to modify a technician data.
                    Manager.Technician tech = new Manager.Technician(txtBx_FirstName.Text, txtBx_LastName.Text, txtBx_Email.Text,
                                                                     txtBx_Phone.Text, txtBx_Address.Text, txtBx_Role.Text, txtBx_Specialty.Text, txtBx_Login.Text, txtBx_Password.Text);

                    if (Check_Technician(tech))
                    {
                        if (PasswordDontMatch())
                        {
                            lbl_Password.ForeColor        = Color.OrangeRed;
                            lbl_ConfirmPassword.ForeColor = Color.OrangeRed;
                            MessageBox.Show(this, "Les mots de passe ne sont pas identiques.", "Message d'erreur",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        else//Modify the Technician.
                        {
                            //If the login(id) doesn't already exist in the DB add this technician.
                            MessageBox.Show(tech.getLogin());
                            if (!tech.Exists() || (tech.getLogin() == _Actor.getLogin()))
                            {
                                if (tech.Modify(_Actor.getLogin()))
                                {
                                    MessageBox.Show(this, "Modification terminée avec succès.", "Message d'information", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show(this, "Modification terminée avec erreurs.", "Message d'information", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "Le login existe deja.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Il y a des champs invalides dans le formulaires(en rouge).");
                    }
                }
                else//E for an Expert
                if (lbl_Actor.Text[0] == 'E')
                {
                    //The instructions to modify an expert data.
                    Manager.Expert expert = new Manager.Expert(txtBx_FirstName.Text, txtBx_LastName.Text, txtBx_Email.Text,
                                                               txtBx_Phone.Text, txtBx_Address.Text, txtBx_Role.Text, txtBx_Specialty.Text, txtBx_Login.Text, txtBx_Password.Text);
                    if (Check_Expert(expert))
                    {
                        if (PasswordDontMatch())
                        {
                            lbl_Password.ForeColor        = Color.OrangeRed;
                            lbl_ConfirmPassword.ForeColor = Color.OrangeRed;
                            MessageBox.Show(this, "Les mots de passe ne sont pas identiques.", "Message d'erreur",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        else    //Modify the Expert.
                        {
                            //If the login(id) doesn't already exist in the DB add this expert.
                            if (!expert.Exists() || (expert.getLogin() == _Actor.getLogin()))
                            {
                                if (expert.Modify(_Actor.getLogin()))
                                {
                                    MessageBox.Show(this, "Modification terminée avec succès.", "Message d'information", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show(this, "Modification terminée avec erreurs.", "Message d'information", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "Le login existe deja.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Il y a des champs invalides dans le formulaires(en rouge).");
                    }
                }
            }
            else
            {
                MessageBox.Show(this, "Remplir tous les champs d'abord.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }