Esempio n. 1
0
        public bool addStudent(string name, string lastName, DateTime birthday, string phone, string gender, string address, MemoryStream picture)
        {
            MySqlCommand command = new MySqlCommand("INSERT INTO `students`(`first_name`, `last_name`, `birthday`, `gender`, `phone`, `address`, `picture`) VALUES (@n,@ln,@bdt,@gdr,@phn,@adrs,@pic)", db.getConnection);

            //@n,@ln,@bdt,@gdr,@phn,@adrs,@pic
            command.Parameters.Add("@n", MySqlDbType.VarChar).Value    = name;
            command.Parameters.Add("@ln", MySqlDbType.VarChar).Value   = lastName;
            command.Parameters.Add("@bdt", MySqlDbType.Date).Value     = birthday;
            command.Parameters.Add("@gdr", MySqlDbType.VarChar).Value  = phone;
            command.Parameters.Add("@phn", MySqlDbType.VarChar).Value  = gender;
            command.Parameters.Add("@adrs", MySqlDbType.Text).Value    = address;
            command.Parameters.Add("@pic", MySqlDbType.LongBlob).Value = picture.ToArray();

            db.openConnection();
            if (command.ExecuteNonQuery() == 1)
            {
                db.closeConnection();
                return(true);
            }
            else
            {
                db.closeConnection();
                return(false);
            }
        }
        public bool addCourse(string courseName, int hourNumber, string description)
        {
            MySqlCommand command = new MySqlCommand("INSERT INTO `studies`(`label`, `hours`, `description`) VALUES (@name,@hoursnumber,@description)", db.getConnection);

            command.Parameters.Add("@name", MySqlDbType.VarChar).Value      = courseName;
            command.Parameters.Add("@hoursnumber", MySqlDbType.Int32).Value = hourNumber;
            command.Parameters.Add("@description", MySqlDbType.Text).Value  = description;

            db.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                db.closeConnection();
                return(true);
            }
            else
            {
                db.closeConnection();
                return(false);
            }
        }