예제 #1
0
        public void enregistrerModifiaction(Entreprise entrep)
        {
            String nomEntreprise = entrep.Design;
            String enNomEnt      = getNomEnt(entrep.id);

            updateEmploye(nomEntreprise, enNomEnt);
            updateTravail(nomEntreprise, enNomEnt);
            using (MySqlConnection cn = new MySqlConnection(Connexion_param))
            {
                String       query = "update entreprise set Design ='" + entrep.Design + "',raisonSociale='" + entrep.raisonSociale + "', addresse='" + entrep.addresse + "' where id='" + entrep.id + "' ";
                MySqlCommand cmd   = new MySqlCommand(query, cn);
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();
            }
        }
예제 #2
0
        public String getNomEnt(String id)
        {
            String nomEnt = "";
            string sql    = "SELECT * from entreprise where id='" + id + "'";

            conn = new MySqlConnection(Connexion_param);
            cmd  = new MySqlCommand(sql, conn);
            conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                var entreprise = new Entreprise();
                entreprise.Design = reader["Design"].ToString();
                nomEnt            = entreprise.Design;
            }
            conn.Close();

            return(nomEnt);
        }
예제 #3
0
        public List <Entreprise> getOneEntreprise(String nomEntreprise)
        {
            string sql = "SELECT * from entreprise where Design= '" + nomEntreprise + "' ";

            conn = new MySqlConnection(Connexion_param);
            cmd  = new MySqlCommand(sql, conn);
            conn.Open();
            reader = cmd.ExecuteReader();
            var model = new List <Entreprise>();

            while (reader.Read())
            {
                var Entreprise = new Entreprise();
                Entreprise.Design        = reader["Design"].ToString();
                Entreprise.raisonSociale = reader["raisonSociale"].ToString();
                Entreprise.addresse      = reader["addresse"].ToString();
                Entreprise.id            = reader["id"].ToString();
                Entreprise.numEntreprise = reader["numEntreprise"].ToString();
                model.Add(Entreprise);
            }
            return(model);
        }
예제 #4
0
        public void enregistEntreprise(Entreprise ent)
        {
            String lastId  = getlastId();
            String lastNum = getLastNum();
            String numEmp  = "ENT001";

            if (lastNum != "")
            {
                Char[] tabLastNum      = lastNum.ToCharArray();
                String un              = Convert.ToString(tabLastNum[tabLastNum.Length - 1]);
                String deux            = Convert.ToString(tabLastNum[tabLastNum.Length - 2]);
                String troi            = Convert.ToString(tabLastNum[tabLastNum.Length - 3]);
                String chiffre         = troi + deux + un;
                int    chiffreInt      = Convert.ToInt32(chiffre);
                String EMP             = "ENT";
                int    chiffreApresEMP = chiffreInt + 1;
                if (chiffreApresEMP < 10)
                {
                    numEmp = EMP + "00" + Convert.ToString(chiffreApresEMP);
                }
                if (chiffreApresEMP < 100 && chiffreApresEMP > 9)
                {
                    numEmp = EMP + "0" + Convert.ToString(chiffreApresEMP);
                }
                if (chiffreApresEMP > 99 && chiffreApresEMP < 1000)
                {
                    numEmp = EMP + Convert.ToString(chiffreApresEMP);
                }
            }

            using (MySqlConnection cn = new MySqlConnection(Connexion_param))
            {
                String       query = "insert into entreprise(numEntreprise,Design,addresse,raisonSociale) values('" + numEmp + "','" + ent.Design + "','" + ent.addresse + "','" + ent.raisonSociale + "') ";
                MySqlCommand cmd   = new MySqlCommand(query, cn);
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();
            }
        }