예제 #1
0
        public int addNewLabourer(MySqlConnection conn, Labourer labourer)
        {
            string sql = "INSERT INTO labourer (name, age, gender) "
                         + " VALUES ('" + labourer.Name + "', " + labourer.Age
                         + "   , '" + labourer.Gender + "')";

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            return(sqlComm.ExecuteNonQuery());
        }
예제 #2
0
        private void btnTestAdd_Click(object sender, EventArgs e)
        {
            DbConnector dbConn = new DbConnector();

            dbConn.connect();

            Labourer labr = new Labourer();

            labr.Name   = "Adam";
            labr.Age    = 30;
            labr.Gender = "male";

            LabourerHandler labHnd    = new LabourerHandler();
            int             recordCnt = labHnd.addNewLabourer(dbConn.getConn(), labr);

            MessageBox.Show(recordCnt + " record has been inserted !!");
        }