public bool insertData(mcourier k) { bool stat = false; try { Connection ConnG = new Connection(); ConnG.Konek(); strQuery = new MySql.Data.MySqlClient.MySqlCommand(); strQuery.Connection = ConnG.Conn; strQuery.CommandType = CommandType.Text; //strQuery.CommandText = "INSERT INTO tKaryawan VALUES('" + k.getNIP() + "','" + k.getNama() + "','" + k.getAlamat() + "','" + k.getNotelp() + "','" + k.getHP() + "')"; strQuery.CommandText = "INSERT INTO tblmcourier VALUES(@COURIERID,@Description,@Active)"; strQuery.Parameters.AddWithValue("@COURIERID", k.CourierID); strQuery.Parameters.AddWithValue("@Description", k.Description); //strQuery.Parameters.AddWithValue("@Type", k.Type); strQuery.ExecuteNonQuery(); stat = true; ConnG.Putus(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(stat); }
public bool updateData(string nip, mcourier k) { bool stat = false; try { Connection ConnG = new Connection(); ConnG.Konek(); strQuery = new MySql.Data.MySqlClient.MySqlCommand(); strQuery.Connection = ConnG.Conn; strQuery.CommandType = CommandType.Text; strQuery.CommandText = "UPDATE tblmcourier SET DESCRIPTION=@Description,ACTIVE=@Active WHERE COURIERID=@COURIERID"; strQuery.Parameters.AddWithValue("@Description", k.Description); //strQuery.Parameters.AddWithValue("@Type", k.Type); strQuery.Parameters.AddWithValue("@COURIERID", k.CourierID); strQuery.ExecuteNonQuery(); ConnG.Putus(); stat = true; } catch { } return(stat); }