Exemplo n.º 1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ModeleEtudiant  oModele   = (ModeleEtudiant)dataGrid.CurrentRow.DataBoundItem;
                MDI_DB.Students oStudents = new MDI_DB.Students();
                oStudents.Students_Delete(oModele.Nom, oModele.Prenom);
            }
            catch (BusinessError be)
            {
                MessageBox.Show(be.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            getStudents();
        }
Exemplo n.º 2
0
        public List <dynamic> MyExecuteSelect(string pStoredName, string pTab)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = _Connection;
            SqlDataReader  oReader;
            List <dynamic> lModele = new List <dynamic>();

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand();


                cmd.CommandText = "secretariat." + pStoredName;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = con;

                oReader = cmd.ExecuteReader();

                while (oReader.Read())
                {
                    List <dynamic> lParam = new List <dynamic>();

                    for (int i = 0; i < oReader.FieldCount; i++)
                    {
                        lParam.Add(oReader.GetValue(i));
                    }

                    if (pTab == "Classe")
                    {
                        ModeleClasse oModele = new ModeleClasse();
                        lModele.Add(oModele.Init(lParam));
                    }
                    else if (pTab == "Students")
                    {
                        ModeleEtudiant oModele = new ModeleEtudiant();
                        lModele.Add(oModele.Init(lParam));
                    }
                    else
                    {
                        ModeleParticipe oModele = new ModeleParticipe();
                        lModele.Add(oModele.Init(lParam));
                    }
                }

                con.Close();
            }

            catch (SqlException exsql)
            {
                BusinessError oErreur = new BusinessError(exsql);
                throw oErreur;
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(lModele);
        }
Exemplo n.º 3
0
        public dynamic MyExecuteSelectOne(string pStoredName, string pTab, List <SqlParameter> lstParamIn)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = _Connection;
            SqlDataReader oReader;
            dynamic       oDyn = null;

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand();


                cmd.CommandText = "secretariat." + pStoredName;
                cmd.CommandType = CommandType.StoredProcedure;

                foreach (SqlParameter oParam in lstParamIn)
                {
                    cmd.Parameters.Add(oParam);
                }

                cmd.Connection = con;

                oReader = cmd.ExecuteReader();

                while (oReader.Read())
                {
                    List <dynamic> lParam = new List <dynamic>();

                    for (int i = 0; i < oReader.FieldCount; i++)
                    {
                        lParam.Add(oReader.GetValue(i));
                    }

                    if (pTab == "Classe")
                    {
                        ModeleClasse oModele = new ModeleClasse();
                        oDyn = oModele.Init(lParam);
                    }
                    else
                    {
                        ModeleEtudiant oModele = new ModeleEtudiant();
                        oDyn = oModele.Init(lParam);
                    }
                }

                con.Close();
            }

            catch (SqlException exsql)
            {
                BusinessError oErreur = new BusinessError(exsql);
                throw oErreur;
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(oDyn);
        }