예제 #1
0
        void SaveMalade()
        {
            try
            {
                Malade mal = new Malade();

                if (idMalade == 0 || designationTxt.Text == "" || formeCombo.Text == "" || dosageTxt.Text == "" || stockTxt.Text == "")
                {
                    MessageBox.Show("Completez tous les champs svp !!!", "Champs Obligatiore", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                }
                else
                {
                    mal.Id      = idMalade;
                    mal.Noms    = designationTxt.Text;
                    mal.Sex     = formeCombo.Text.Equals(Sexe.Masculin.ToString()) ? Sexe.Masculin : Sexe.Féminin;
                    mal.NumOrdo = dosageTxt.Text;
                    mal.Maladie = stockTxt.Text;
                    mal.Enregistrer(mal);

                    InitialseChamps();

                    RefreshData(new Malade());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreureur d'enregistrement " + ex.Message, "Echec", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                ImplementeConnexion.Instance.Conn.Close();
            }
        }
        void SelectData()
        {
            try
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    Malade mal = new Malade();


                    mal = (Malade)dataGridView1.SelectedRows[0].DataBoundItem;

                    idMalade = mal.Id;
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("Error when Selecting data, " + ex.Message, "Selecting data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error when Selecting data, " + ex.Message, "Selecting data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (ImplementeConnexion.Instance.Conn != null)
                {
                    if (ImplementeConnexion.Instance.Conn.State == System.Data.ConnectionState.Open)
                    {
                        ImplementeConnexion.Instance.Conn.Close();
                    }
                }
            }
        }
예제 #3
0
        void DeleteData()
        {
            try
            {
                Malade mal = new Malade();

                mal.Supprimer(idMalade);

                RefreshData(new Malade());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreureur de suppression " + ex.Message, "Echec", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #4
0
        private void btnNouveau_Click(object sender, EventArgs e)
        {
            try
            {
                Malade mal = new Malade();

                InitialseChamps();

                idMalade = mal.Nouveau();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ImplementeConnexion.Instance.Conn.Close();
            }
        }
예제 #5
0
        void SelectData()
        {
            try
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    Malade mal = new Malade();

                    mal = (Malade)dataGridView1.SelectedRows[0].DataBoundItem;

                    idMalade            = mal.Id;
                    designationTxt.Text = mal.Noms.ToString();
                    formeCombo.Text     = mal.Sex == Sexe.Masculin ? Sexe.Masculin.ToString() : Sexe.Féminin.ToString();
                    dosageTxt.Text      = mal.NumOrdo;
                    stockTxt.Text       = mal.Maladie;
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("Error when Selecting data, " + ex.Message, "Selecting data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error when Selecting data, " + ex.Message, "Selecting data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (ImplementeConnexion.Instance.Conn != null)
                {
                    if (ImplementeConnexion.Instance.Conn.State == System.Data.ConnectionState.Open)
                    {
                        ImplementeConnexion.Instance.Conn.Close();
                    }
                }
            }
        }
예제 #6
0
 void RefreshData(Malade mal)
 {
     dataGridView1.DataSource = mal.AllMalade();
 }