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()); }
private void button20_Click(object sender, EventArgs e) { DbConnecter dbConn = new DbConnecter(); dbConn.connect(); Labourer labr = new Labourer(); labr.Name = textBox2.Text; labr.Age = Convert.ToInt32(numericUpDown1.Value); labr.Gender = comboBox4.Text; LabourerHandler labHnd = new LabourerHandler(); int recordCnt = labHnd.addNewLabourer(dbConn.getConn(), labr); MessageBox.Show(recordCnt + " record has been inserted !! "); }
private void button19_Click(object sender, EventArgs e) { DbConnecter dbConn = new DbConnecter(); 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 !! "); }