Exemple #1
0
        public int addNewSowingJob(SowingJob sowingjob)
        {
            MySqlCommand sqlComm = new MySqlCommand("INSERT INTO" + " sowingjob(description, crop_id, quantity_prop, farm_id, used_area, vehicle_id, employee_id, date_start, date_end)" +
                                                    "VALUES" + "(@description, @crop_id, @quantity_prop, @farm_id, @used_area, @vehicle_id, @employee_id, @date_start, @date_end)", MysqlDbc.Instance.getConn());

            sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value     = sowingjob.Description;
            sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value       = sowingjob.Crop_id;
            sqlComm.Parameters.Add("@quantity_prop", MySqlDbType.UInt32).Value = sowingjob.Quantity_prop;
            sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value       = sowingjob.Farm_id;
            sqlComm.Parameters.Add("@used_area", MySqlDbType.Text).Value       = sowingjob.Used_area;
            sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value    = sowingjob.Vehicle_id;
            sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value   = sowingjob.Employee_id;
            sqlComm.Parameters.Add("@date_start", MySqlDbType.Date).Value      = sowingjob.Date_start;
            sqlComm.Parameters.Add("@date_end", MySqlDbType.Date).Value        = sowingjob.Date_end;

            return(sqlComm.ExecuteNonQuery());
        }
Exemple #2
0
        public List <SowingJob> GetSowingJobList() //string employee_id
        {
            List <SowingJob> sowingLists = new List <SowingJob>();
            MySqlDataReader  rdr         = null;

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

                while (rdr.Read())
                {
                    SowingJob sj1 = new SowingJob();
                    sj1.Id            = rdr.GetInt32("id");;
                    sj1.Description   = rdr.GetString("description");
                    sj1.Crop_id       = rdr.GetInt32("crop_id");
                    sj1.Quantity_prop = rdr.GetInt32("quantity_prop");
                    sj1.Farm_id       = rdr.GetInt32("farm_id");
                    sj1.Used_area     = rdr.GetString("used_area");
                    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");

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

            return(sowingLists);
        }
Exemple #3
0
        public int UpdateSowingJob(SowingJob sowingjob)
        {
            string query = "UPDATE" + " sowingjob SET description=@description, crop_id=@crop_id, quantity_prop=@quantity_prop, farm_id=@farm_id," +
                           " used_area=@used_area, vehicle_id=@vehicle_id, employee_id=@employee_id, date_start=@date_start, date_end=@date_end, " +
                           "time_start=@time_start, time_end=@time_end " +
                           "WHERE id = " + sowingjob.Id;
            MySqlCommand sqlComm = new MySqlCommand(query, MysqlDbc.Instance.getConn());

            sqlComm.Parameters.Add("@description", MySqlDbType.Text).Value     = sowingjob.Description;
            sqlComm.Parameters.Add("@crop_id", MySqlDbType.UInt32).Value       = sowingjob.Crop_id;
            sqlComm.Parameters.Add("@quantity_prop", MySqlDbType.UInt32).Value = sowingjob.Quantity_prop;
            sqlComm.Parameters.Add("@farm_id", MySqlDbType.UInt32).Value       = sowingjob.Farm_id;
            sqlComm.Parameters.Add("@used_area", MySqlDbType.Text).Value       = sowingjob.Used_area;
            sqlComm.Parameters.Add("@vehicle_id", MySqlDbType.UInt32).Value    = sowingjob.Vehicle_id;
            sqlComm.Parameters.Add("@employee_id", MySqlDbType.UInt32).Value   = sowingjob.Employee_id;
            sqlComm.Parameters.Add("@date_start", MySqlDbType.Date).Value      = sowingjob.Date_start;
            sqlComm.Parameters.Add("@date_end", MySqlDbType.Date).Value        = sowingjob.Date_end;
            //sqlComm.Parameters.Add("@time_start", MySqlDbType.Time).Value = sowingjob.Time_start;
            //sqlComm.Parameters.Add("@time_end", MySqlDbType.Time).Value = sowingjob.Time_end;

            return(sqlComm.ExecuteNonQuery());
        }