예제 #1
0
        public int addNewHarvestingJob(HarvestingJob harvestingjob)
        {
            MySqlCommand sqlComm = new MySqlCommand("INSERT INTO" + " harvestingjob(description, sowingJob_id, farm_id, crop_id, vehicle_id, est_quantity, harvested_quantity, employee_id, date_start, date_end)" +
                                                    " VALUES" + " (@description, @sowingJob_id, @farm_id, @crop_id, @vehicle_id, @est_quantity, @harvested_quantity, @employee_id, @date_start, @date_end)", MysqlDbc.Instance.getConn());

            sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value        = harvestingjob.Description;
            sqlComm.Parameters.Add("@sowingJob_id", MySqlDbType.UInt32).Value     = harvestingjob.Crop_id;
            sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value          = harvestingjob.Farm_id;
            sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value          = harvestingjob.Crop_id;
            sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value       = harvestingjob.Vehicle_id;
            sqlComm.Parameters.Add("@est_quantity", MySqlDbType.Text).Value       = harvestingjob.Est_quantity;
            sqlComm.Parameters.Add("@harvested_quantity", MySqlDbType.Text).Value = harvestingjob.Harvested_quantity;
            sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value      = harvestingjob.Employee_id;
            sqlComm.Parameters.Add("@date_start", MySqlDbType.Date).Value         = harvestingjob.Date_start;
            sqlComm.Parameters.Add("@date_end", MySqlDbType.Date).Value           = harvestingjob.Date_end;

            return(sqlComm.ExecuteNonQuery());
        }
예제 #2
0
        public List <HarvestingJob> GetHarvestingJobList() //string employee_id
        {
            List <HarvestingJob> harvestLists = new List <HarvestingJob>();
            MySqlDataReader      rdr          = null;

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

                while (rdr.Read())
                {
                    HarvestingJob sj1 = new HarvestingJob();
                    sj1.Id                 = rdr.GetInt32("id");;
                    sj1.Description        = rdr.GetString("description");
                    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.Est_quantity       = rdr.GetInt32("est_quantity");
                    sj1.Harvested_quantity = rdr.GetInt32("harvested_quantity");
                    sj1.Employee_id        = rdr.GetInt32("employee_id");
                    sj1.Date_start         = rdr.GetDateTime("date_start");
                    sj1.Date_end           = rdr.GetDateTime("date_end");

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

            return(harvestLists);
        }
예제 #3
0
        public int updateHarvestingJob(HarvestingJob harvestingjob)
        {
            string query = "UPDATE" + " harvestingjob SET description=@description, sowingJob_id=@sowingJob_id, farm_id=@Farm_id, crop_id=@crop_id," +
                           " vehicle_id=@vehicle_id, est_quantity=@est_quantity, harvested_quantity=@harvested_quantity, employee_id=@employee_id," +
                           " date_start=@date_start, date_end=@date_end " +
                           "WHERE id = " + harvestingjob.Id;

            MySqlCommand sqlComm = new MySqlCommand(query, MysqlDbc.Instance.getConn());

            sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value          = harvestingjob.Description;
            sqlComm.Parameters.Add("@sowingJob_id", MySqlDbType.UInt32).Value       = harvestingjob.SowingJob_id;
            sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value            = harvestingjob.Farm_id;
            sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value            = harvestingjob.Crop_id;
            sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value         = harvestingjob.Vehicle_id;
            sqlComm.Parameters.Add("@est_quantity", MySqlDbType.UInt32).Value       = harvestingjob.Est_quantity;
            sqlComm.Parameters.Add("@harvested_quantity", MySqlDbType.UInt32).Value = harvestingjob.Harvested_quantity;
            sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value        = harvestingjob.Employee_id;
            sqlComm.Parameters.Add("@date_start", MySqlDbType.Time).Value           = harvestingjob.Date_start;
            sqlComm.Parameters.Add("@date_end", MySqlDbType.Time).Value             = harvestingjob.Date_end;

            return(sqlComm.ExecuteNonQuery());
        }