Exemplo n.º 1
0
        public int addNewFertilisingJob(FertilisingJob fertilisingjob)
        {
            MySqlCommand sqlComm = new MySqlCommand("INSERT INTO" + " fertilisingjob(description, fertiliser_id, quantity_kg, sowingJob_id, farm_id, crop_id, vehicle_id, employee_id, date_start, date_end)" +
                                                    "VALUES" + "(@description, @fertiliser_id, @quantity_kg, @sowingJob_id, @farm_id, @crop_id, @vehicle_id, @employee_id, @date_start, date_end)", MysqlDbc.Instance.getConn());

            sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value     = fertilisingjob.Description;
            sqlComm.Parameters.Add("@fertiliser_id", MySqlDbType.UInt32).Value = fertilisingjob.Fertiliser_id;
            sqlComm.Parameters.Add("@quantity_kg", MySqlDbType.UInt32).Value   = fertilisingjob.Quantity_kg;
            sqlComm.Parameters.Add("@sowingJob_id", MySqlDbType.UInt32).Value  = fertilisingjob.SowingJob_id;
            sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value       = fertilisingjob.Farm_id;
            sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value       = fertilisingjob.Crop_id;
            sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value    = fertilisingjob.Vehicle_id;
            sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value   = fertilisingjob.Employee_id;
            sqlComm.Parameters.Add("@date_start", MySqlDbType.Date).Value      = fertilisingjob.Date_start;
            sqlComm.Parameters.Add("@date_end", MySqlDbType.Date).Value        = fertilisingjob.Date_end;

            return(sqlComm.ExecuteNonQuery());
        }
Exemplo n.º 2
0
        public List <FertilisingJob> GetFertilisingJobList() //string employee_id
        {
            List <FertilisingJob> fertiliserLists = new List <FertilisingJob>();
            MySqlDataReader       rdr             = null;

            try
            {
                string       stm = "SELECT * FROM fertilisingjob";
                MySqlCommand cmd = new MySqlCommand(stm, MysqlDbc.Instance.getConn());
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    FertilisingJob sj1 = new FertilisingJob();
                    sj1.Id            = rdr.GetInt32("id");;
                    sj1.Description   = rdr.GetString("description");
                    sj1.Fertiliser_id = rdr.GetInt32("fertiliser_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");

                    fertiliserLists.Add(sj1);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }

            return(fertiliserLists);
        }
Exemplo n.º 3
0
        public int updateFertilisingJob(FertilisingJob fertilisingjob)
        {
            string query = "UPDATE" + " fertilisingjob SET description=@description, fertiliser_id=@fertiliser_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_end=@date_end " +
                           "WHERE id = " + fertilisingjob.Id;
            MySqlCommand sqlComm = new MySqlCommand(query, MysqlDbc.Instance.getConn());

            sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value     = fertilisingjob.Description;
            sqlComm.Parameters.Add("@fertiliser_id", MySqlDbType.UInt32).Value = fertilisingjob.Fertiliser_id;
            sqlComm.Parameters.Add("@quantity_kg", MySqlDbType.UInt32).Value   = fertilisingjob.Quantity_kg;
            sqlComm.Parameters.Add("@sowing_id", MySqlDbType.UInt32).Value     = fertilisingjob.SowingJob_id;
            sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value       = fertilisingjob.Farm_id;
            sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value       = fertilisingjob.Crop_id;
            sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value    = fertilisingjob.Vehicle_id;
            sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value   = fertilisingjob.Employee_id;
            sqlComm.Parameters.Add("@date_start", MySqlDbType.Time).Value      = fertilisingjob.Date_start;
            sqlComm.Parameters.Add("@date_end", MySqlDbType.Time).Value        = fertilisingjob.Date_end;

            return(sqlComm.ExecuteNonQuery());
        }