Exemple #1
0
        public List <C_Mission> Liste_Mission()
        {
            List <C_Mission> Les_Mission = new List <C_Mission>();

            SqlConnection La_Connection = new SqlConnection();

            La_Connection.ConnectionString = @"Data Source=DESKTOP-KVG156O\SQLEXPRESS;Initial Catalog=PPE3;Integrated Security=True";
            La_Connection.Open();

            SqlCommand La_Requete = new SqlCommand();

            La_Requete.Connection  = La_Connection;
            La_Requete.CommandType = CommandType.StoredProcedure;
            La_Requete.CommandText = "Liste_Mission_all";
            SqlDataReader La_Reponse = La_Requete.ExecuteReader();

            while (La_Reponse.Read())
            {
                C_Mission Une_Mission = new C_Mission();
                Une_Mission.Mission        = La_Reponse.GetInt32(0);
                Une_Mission.Personne       = La_Reponse.GetInt32(1);
                Une_Mission.Note_de_frais  = La_Reponse.GetInt32(2);
                Une_Mission.Nom_Mission    = La_Reponse.GetString(3);
                Une_Mission.date_mission   = La_Reponse.GetDateTime(4);
                Une_Mission.persone_select = La_Reponse.GetInt32(5);

                Les_Mission.Add(Une_Mission);
            }
            La_Reponse.Close();
            La_Connection.Close();
            return(Les_Mission);
        }
 public JsonResult Edit(C_Mission mission)
 {
     try
     {
         db.Entry(mission).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         var rs = db.C_Mission.Where(s => s.Id == 1).Select(s => new { s.Id, s.Title, s.SubTitle, s.SubContentTitle01, s.SubContentTitle02, s.SubContentTitle03, s.SubContent03, s.SubContent01, s.SubContent02 }).FirstOrDefault();
         return(Json(new { msg = "Chỉnh sửa thành công", mi = rs }));
     }
     catch (Exception e)
     {
         return(Json(new { msg = "Có lỗi xảy ra. Vui lòng thử lại" }));
     }
 }
Exemple #3
0
        public List <C_Mission> Missions_By_Id_User(string P_personne)
        {
            List <C_Mission> Les_Missions = new List <C_Mission>();

            SqlConnection LaConnexion = new SqlConnection();

            LaConnexion.ConnectionString = @"Data Source=DESKTOP-KVG156O\SQLEXPRESS;Initial Catalog=PPE3;Integrated Security=True";

            try
            {
                LaConnexion.Open();
                SqlCommand LaRequette = new SqlCommand();
                LaRequette.Connection  = LaConnexion;
                LaRequette.CommandType = System.Data.CommandType.StoredProcedure;
                LaRequette.CommandText = "Liste_Mission_By_Id";
                LaRequette.Parameters.Add("@P_personne", SqlDbType.Int);
                LaRequette.Parameters["@P_personne"].Value = P_personne;

                SqlDataReader LaReponse = LaRequette.ExecuteReader();

                while (LaReponse.Read())
                {
                    C_Mission Une_Mission = new C_Mission();
                    Une_Mission.Mission        = LaReponse.GetInt32(0);
                    Une_Mission.Personne       = LaReponse.GetInt32(1);
                    Une_Mission.Note_de_frais  = LaReponse.GetInt32(2);
                    Une_Mission.Nom_Mission    = LaReponse.GetString(3);
                    Une_Mission.date_mission   = LaReponse.GetDateTime(4);
                    Une_Mission.persone_select = LaReponse.GetInt32(5);

                    Les_Missions.Add(Une_Mission);
                }
                LaReponse.Close();
                LaConnexion.Close();
            }
            catch (SqlException P_Erreur)
            {
                Console.WriteLine(P_Erreur);
                Console.ReadLine();
                Environment.Exit(-1);
            }


            return(Les_Missions);
        }