Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!bln)
                {
                    agent.inserts();
                    MessageBox.Show("Enregistrement éffectué", "Enregistrement", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (bsrc.DataSource != null)
                    {
                        clsagent s   = new clsagent();
                        Object[] obj = ((DataRowView)bsrc.Current).Row.ItemArray;
                        int      i   = 0;
                        foreach (DataColumn dtc in ((DataRowView)bsrc.Current).Row.Table.Columns)
                        {
                            if (dtc.ToString().Equals("matricule"))
                            {
                                s.Matricule = ((obj[i]) == DBNull.Value) ? null : ((string)obj[i]);
                            }
                            else if (dtc.ToString().Equals("numeroinss"))
                            {
                                s.Numeroinss = (((string)obj[i]) == DBNull.Value.ToString()) ? null : ((string)obj[i]);
                            }
                            else if (dtc.ToString().Equals("grade"))
                            {
                                s.Grade = (((string)obj[i]) == DBNull.Value.ToString()) ? null : ((string)obj[i]);
                            }
                            else if (dtc.ToString().Equals("dateangagement"))
                            {
                                s.Dateangagement = ((DateTime)obj[i]);
                            }
                            else if (dtc.ToString().Equals("idAg"))
                            {
                                s.IdAgent = ((int)obj[i]);
                            }
                            else if (dtc.ToString().Equals("id_fonction"))
                            {
                                s.Id_fonction = ((int)obj[i]);
                            }
                            else if (dtc.ToString().Equals("id_personne"))
                            {
                                s.Id_personne = ((int)obj[i]);
                            }
                            else if (dtc.ToString().Equals("id_qualification"))
                            {
                                s.Id_qualification = ((int)obj[i]);
                            }
                            else if (dtc.ToString().Equals("id_categorieagent"))
                            {
                                s.Id_categorieagent = ((int)obj[i]);
                            }
                            else if (dtc.ToString().Equals("id_service"))
                            {
                                s.Id_service = ((int)obj[i]);
                            }
                            i++;
                        }
                        new clsagent().update(s);
                        MessageBox.Show("Modification effectuée!", "Modification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                try
                {
                    loadData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erreur lors du chargement des informations du malade sélectionné =>" + ex.Message, "Affichage informations malade", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Echec de la mise à jour" + ex.Message, "Mise à jour", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            //this.New();
            //refresh();
        }
Ejemplo n.º 2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult result = MessageBox.Show("Voulez - vous vraiment supprimer cet enregistrement ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             if (bsrc.DataSource != null)
             {
                 clsagent s   = new clsagent();
                 Object[] obj = ((DataRowView)bsrc.Current).Row.ItemArray;
                 int      i   = 0;
                 foreach (DataColumn dtc in ((DataRowView)bsrc.Current).Row.Table.Columns)
                 {
                     if (dtc.ToString().Equals("matricule"))
                     {
                         s.Matricule = ((obj[i]) == DBNull.Value) ? null : ((string)obj[i]);
                     }
                     else if (dtc.ToString().Equals("numeroinss"))
                     {
                         s.Numeroinss = (((string)obj[i]) == DBNull.Value.ToString()) ? null : ((string)obj[i]);
                     }
                     else if (dtc.ToString().Equals("grade"))
                     {
                         s.Grade = ((obj[i]) == DBNull.Value) ? null : ((string)obj[i]);
                     }
                     else if (dtc.ToString().Equals("dateangagement"))
                     {
                         s.Dateangagement = ((DateTime)obj[i]);
                     }
                     else if (dtc.ToString().Equals("idAg"))
                     {
                         s.IdAgent = ((int)obj[i]);
                     }
                     else if (dtc.ToString().Equals("id_fonction"))
                     {
                         s.Id_fonction = ((int)obj[i]);
                     }
                     else if (dtc.ToString().Equals("id_personne"))
                     {
                         s.Id_personne = ((int)obj[i]);
                     }
                     else if (dtc.ToString().Equals("id_qualification"))
                     {
                         s.Id_qualification = ((int)obj[i]);
                     }
                     else if (dtc.ToString().Equals("id_categorieagent"))
                     {
                         s.Id_categorieagent = ((int)obj[i]);
                     }
                     else if (dtc.ToString().Equals("id_service"))
                     {
                         s.Id_service = ((int)obj[i]);
                     }
                     i++;
                 }
                 new clsagent().delete(s);
                 MessageBox.Show("Suppression éffectuée", "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 //this.New();
                 refresh();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Echec de la suppression " + ex.Message, "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Ejemplo n.º 3
0
        private void New()
        {
            agent = new clsagent();
            bln   = false;
            bindingcls();

            btnAfficherDonnees.Enabled = false;
            txtNom.Clear();
            txtPNom.Clear();
            txtPrenom.Clear();
            txtTelephone.Clear();
            txtMatriculeAgent.Clear();
            txtSexe.Clear();
            txtEtatCivil.Clear();
            txtNumInss.Clear();
            pbPhotoPersonne.Image = null;
            txtPersonne.Clear();
            txtGrade.Clear();
            txtPersonne.Focus();

            try
            {
                bsrc.DataSource     = clsMetier.GetInstance().getAllClsagent1(-100);
                dgvAgent.DataSource = bsrc;

                if (cboFonction.Items.Count > 0)
                {
                    cboFonction.SelectedIndex = 0;
                }
                if (cboQualification.Items.Count > 0)
                {
                    cboQualification.SelectedIndex = 0;
                }
                if (cboCategorieAgent.Items.Count > 0)
                {
                    cboCategorieAgent.SelectedIndex = 0;
                }
                if (cboService.Items.Count > 0)
                {
                    cboService.SelectedIndex = 0;
                }
            }
            catch (Exception) { }

            RecherchePersonneFrm frm = new RecherchePersonneFrm();

            frm.setFormPrincipal(principal);
            frm.Icon = principal.Icon;
            frm.ShowDialog();

            if (clsDoTraitement.doubleclicRecherchePersonneDg)
            {
                btnSave.Enabled = true;
                clsDoTraitement.doubleclicRecherchePersonneDg = false;
                txtPersonne.Text = clsDoTraitement.FullNamePersonne;
            }
            else
            {
                btnSave.Enabled = false;
            }
        }