示例#1
0
        public void AddTrainer(TrainerClass t)
        {
            string        sql = "INSERT INTO TrainerProfile(Name, ExOrInType, Telephone, EmailAddress, Id_Topic) VALUES('" + t.Name + "','" + t.ExOrInType + "','" + t.Telephone + "','" + t.Email + "',,'" + t.Id_Topic + "')";
            SqlConnection con = db.GetConnection();
            SqlCommand    cmd = new SqlCommand(sql, con);

            con.Open();
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
示例#2
0
        public void DeleteTrainer(TrainerClass t)
        {
            string        sql = "DELETE TrainerProfile WHERE Id_Trainer =" + t.Id_Trainer;
            SqlConnection con = db.GetConnection();
            SqlCommand    cmd = new SqlCommand(sql, con);

            con.Open();
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
示例#3
0
        public void UpdateTrainer(TrainerClass t)
        {
            string        sql = "UPDATE TrainerProfile SET Name='" + t.Name + "',ExOrInType='" + t.ExOrInType + "',Telephone='" + t.Telephone + "',EmailAddress='" + t.Email + "',Id_Topic='" + t.Id_Topic + "' WHERE Id_Trainer= " + t.Id_Trainer;
            SqlConnection con = db.GetConnection();
            SqlCommand    cmd = new SqlCommand(sql, con);

            con.Open();
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
示例#4
0
        public List <TrainerClass> GetTrainerClasses(string id_Trainer)
        {
            string sql;

            if (string.IsNullOrEmpty(id_Trainer))
            {
                sql = "SELECT * FROM TrainerProfile";
            }
            else
            {
                sql = "SELECT * FROM TrainerProfile WHERE Id_Trainer = " + id_Trainer;
            }
            List <TrainerClass> tList = new List <TrainerClass>();
            DataTable           dt    = new DataTable();
            SqlConnection       con   = db.GetConnection();
            SqlDataAdapter      da    = new SqlDataAdapter(sql, con);

            con.Open();
            da.Fill(dt);
            da.Dispose();
            con.Close();
            TrainerClass tmpT;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                tmpT            = new TrainerClass();
                tmpT.Id_Trainer = Convert.ToInt32(dt.Rows[i]["Id_Topic"].ToString());
                tmpT.Name       = dt.Rows[i]["Name"].ToString();
                tmpT.ExOrInType = dt.Rows[i]["Name"].ToString();
                tmpT.Telephone  = dt.Rows[i]["Telephone"].ToString();
                tmpT.Email      = dt.Rows[i]["EmailAddress"].ToString();
                tmpT.Id_Topic   = Convert.ToInt32(dt.Rows[i]["Id_Course"].ToString());
                tList.Add(tmpT);
            }
            return(tList);
        }