public int addNewPesticideJob(PesticideJob pesticidejob) { MySqlCommand sqlComm = new MySqlCommand("INSERT INTO" + " pesticidejob(description, pesticide_id, quantity_kg, sowingJob_id, farm_id, crop_id, vehicle_id, employee_id, date_start, date_end)" + "VALUES" + "(@description, @pesticide_id, @quantity_kg, @sowingJob_id, @farm_id, @rop_id, @vehicle_id, @employee_id, @date_start, @date_end)", MysqlDbc.Instance.getConn()); sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value = pesticidejob.Description; sqlComm.Parameters.Add("@pesticide_id", MySqlDbType.UInt32).Value = pesticidejob.Pesticide_id; sqlComm.Parameters.Add("@quantity_kg", MySqlDbType.Decimal).Value = pesticidejob.Quantity_kg; sqlComm.Parameters.Add("@sowingJob_id", MySqlDbType.UInt32).Value = pesticidejob.SowingJob_id; sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value = pesticidejob.Farm_id; sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value = pesticidejob.Crop_id; sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value = pesticidejob.Vehicle_id; sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value = pesticidejob.Employee_id; sqlComm.Parameters.Add("@date_start", MySqlDbType.Date).Value = pesticidejob.Date_start; sqlComm.Parameters.Add("@date_end", MySqlDbType.Date).Value = pesticidejob.Date_end; return(sqlComm.ExecuteNonQuery()); }
public List <PesticideJob> GetPesticideJobList() //string employee_id { List <PesticideJob> pesticideLists = new List <PesticideJob>(); MySqlDataReader rdr = null; try { string stm = "SELECT * FROM pesticidejob"; MySqlCommand cmd = new MySqlCommand(stm, MysqlDbc.Instance.getConn()); rdr = cmd.ExecuteReader(); while (rdr.Read()) { PesticideJob sj1 = new PesticideJob(); sj1.Id = rdr.GetInt32("id");; sj1.Description = rdr.GetString("description"); sj1.Pesticide_id = rdr.GetInt32("pesticide_id"); sj1.Quantity_kg = rdr.GetInt32("quantity_kg"); sj1.SowingJob_id = rdr.GetInt32("sowingJob_id"); sj1.Farm_id = rdr.GetInt32("farm_id"); sj1.Crop_id = rdr.GetInt32("crop_id"); sj1.Vehicle_id = rdr.GetInt32("vehicle_id"); sj1.Employee_id = rdr.GetInt32("employee_id"); sj1.Date_start = rdr.GetDateTime("date_start"); sj1.Date_end = rdr.GetDateTime("date_end"); pesticideLists.Add(sj1); } } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); } finally { if (rdr != null) { rdr.Close(); } } return(pesticideLists); }
public int updatePesticideJob(PesticideJob pesticidejob) { string query = "UPDATE" + " pesticejob SET description=@description, pesticide_id_id=@pesticide_id, quantity_kg=@quantity_kg," + " sowingJob_id=@sowing_id, farm_id=@farm_id, crop_id=@crop_id, vehicle_id=@vehicle_id " + " employee_id=@employee_id, date_start=@date_start, date_start=@date_end " + "WHERE id = " + pesticidejob.Id; MySqlCommand sqlComm = new MySqlCommand(query, MysqlDbc.Instance.getConn()); sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value = pesticidejob.Description; sqlComm.Parameters.Add("@pesticide_id", MySqlDbType.UInt32).Value = pesticidejob.Pesticide_id; sqlComm.Parameters.Add("@quantity_kg", MySqlDbType.Decimal).Value = pesticidejob.Quantity_kg; sqlComm.Parameters.Add("@sowing_id", MySqlDbType.UInt32).Value = pesticidejob.SowingJob_id; sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value = pesticidejob.Farm_id; sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value = pesticidejob.Crop_id; sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value = pesticidejob.Vehicle_id; sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value = pesticidejob.Employee_id; sqlComm.Parameters.Add("@date_start", MySqlDbType.Date).Value = pesticidejob.Date_start; sqlComm.Parameters.Add("@date_end", MySqlDbType.Date).Value = pesticidejob.Date_end; return(sqlComm.ExecuteNonQuery()); }