Пример #1
0
        public List <CsTa> SELECT_CodeLibelle_By_NUM(int NUM)
        {
            CsTa        _ta;
            List <CsTa> ListeTA = new List <CsTa>();

            cn = new SqlConnection(ConnectionString);

            cmd             = new SqlCommand();
            cmd.Connection  = cn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = EnumProcedureStockee.SelectTaCodeLibelleByNum;
            SqlParameter param = new SqlParameter("@NUM", SqlDbType.SmallInt);

            param.Direction = ParameterDirection.Input;
            param.Value     = NUM;
            cmd.Parameters.Add(param);

            try
            {
                if (cn.State == ConnectionState.Closed)
                {
                    cn.Open();
                }

                SqlDataReader reader = cmd.ExecuteReader();
                if (!reader.HasRows)
                {
                    reader.Close();
                    //throw new Exception("Aucune colonne trouvée pour cette table.");
                }
                while (reader.Read())
                {
                    _ta = new CsTa();
                    //_ta.CODE = reader.GetValue(0).ToString().Trim();
                    _ta.LIBELLE = reader.GetValue(1).ToString().Trim();
                    ListeTA.Add(_ta);
                }
                //Fermeture reader
                reader.Close();
                return(ListeTA);
            }
            catch (Exception ex)
            {
                throw new Exception(EnumProcedureStockee.SelectTaCodeLibelleByNum + ":" + ex.Message);
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                {
                    cn.Close(); // Fermeture de la connection
                }
                cmd.Dispose();
            }
        }
Пример #2
0
        public CsTa SELECT_Exploitation()
        {
            bool ErreurSql = false;
            CsTa _ta       = new CsTa();

            cn = new SqlConnection(ConnectionString);

            cmd             = new SqlCommand();
            cmd.Connection  = cn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = EnumProcedureStockee.SelectTaExploitation;
            try
            {
                if (cn.State == ConnectionState.Closed)
                {
                    cn.Open();
                }

                SqlDataReader reader = cmd.ExecuteReader();
                if (!reader.HasRows)
                {
                    reader.Close();
                    //throw new Exception("Aucune colonne trouvée pour cette table.");
                }
                while (reader.Read())
                {
                    // _ta.CODE = reader.GetValue(0).ToString().Trim();
                    _ta.LIBELLE = reader.GetValue(1).ToString().Trim();
                }
                //Fermeture reader
                reader.Close();
                return(_ta);
            }
            catch (SqlException)
            {
                return(null);
            }
            catch (Exception ex)
            {
                throw new Exception(EnumProcedureStockee.SelectTaCodeLibelleByNum + ":" + ex.Message);
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                {
                    cn.Close(); // Fermeture de la connection
                }
                cmd.Dispose();
            }
        }
Пример #3
0
        public CsTa SELECT_Exploitation(string Code)
        {
            CsTa _ta = null;

            cn = new SqlConnection(ConnectionString);
            SqlCommand command = new SqlCommand("SPX_TA_SELECT_VALEUR_58_By_CODE", cn);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Clear();
            command.Parameters.Add("@Code", SqlDbType.VarChar, 6).Value = Code;
            try
            {
                if (cn.State == ConnectionState.Closed)
                {
                    cn.Open();
                }

                SqlDataReader reader = command.ExecuteReader();
                if (!reader.HasRows)
                {
                    reader.Close();
                    //throw new Exception("Aucune colonne trouvée pour cette table.");
                }
                while (reader.Read())
                {
                    _ta = new CsTa();
                    //_ta.CODE = reader.GetValue(0).ToString().Trim();
                    _ta.LIBELLE = reader.GetValue(1).ToString().Trim();
                }
                //Fermeture reader
                reader.Close();
                return(_ta);
            }
            catch (SqlException)
            {
                return(null);
            }
            catch (Exception ex)
            {
                throw new Exception("SPX_TA_SELECT_VALEUR_58_By_CODE" + ":" + ex.Message);
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                {
                    cn.Close(); // Fermeture de la connection
                }
                command.Dispose();
            }
        }
Пример #4
0
        private void cbo_evnt5_DropDownClosed(object sender, EventArgs e)
        {
            if (dgINIT.SelectedItem == null || cbo_evnt5.SelectedItem == null)
            {
                return;
            }
            CsTa index = new CsTa();

            index = cbo_evnt5.SelectedItem as CsTa;
            CsTypeDemande casSelected = dgINIT.SelectedItem as CsTypeDemande;

            //casSelected.EVT5 = index.PK_CODE;

            AjouterListeMaj(casSelected);
        }