Example #1
0
        public static List <string> getPesticideJobList()
        {
            PesticideJob    pest  = new PesticideJob();
            List <string>   flist = new List <string>();
            MySqlDataReader rdr   = null;

            try
            {
                string tableName = "pesticidejob";
                string query     = "SELECT * FROM " + tableName;

                MySqlCommand cmd = new MySqlCommand(query, MysqlDbc.Instance.getConn());
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    pest.Description = rdr.GetString("description");
                    flist.Add(pest.Description);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }

            return(flist);
        }
        private void updatePesticideJob()
        {
            PesticideJob pj = new PesticideJob();

            pj.Id          = pjj11.Id;
            pj.Description = textBox1.Text;
            string idStr = cbPesticide.Text.Split('.')[0];

            pj.Pesticide_id = int.Parse(idStr);
            pj.Quantity_kg  = int.Parse(textBox3.Text);
            string idStr1 = cbSoj.Text.Split('.')[0];

            pj.SowingJob_id = int.Parse(idStr1);
            string idStr2 = cbFarm.Text.Split('.')[0];

            pj.Farm_id = int.Parse(idStr2);
            string idStr3 = cbVehicle.Text.Split('.')[0];

            pj.Vehicle_id = int.Parse(idStr3);
            string idStr4 = cbCrop.Text.Split('.')[0];

            pj.Crop_id = int.Parse(idStr4);
            string idStr5 = cbEmployee.Text.Split('.')[0];

            pj.Employee_id = int.Parse(idStr5);
            pj.Date_start  = Convert.ToDateTime(dtpStart.Text);
            pj.Date_end    = Convert.ToDateTime(dtpEnd.Text);

            UpdateSQL hdl = new UpdateSQL();

            hdl.updatePesticideJob(pj);
            MessageBox.Show("Success!!");
            this.Close();
        }
Example #3
0
        public PesticideJob GetPesticideJobFromID(int itemId)
        {
            PesticideJob p1 = new PesticideJob();

            MySqlDataReader rdr = null;

            try
            {
                string tableName = "pesticiejob";
                string query     = "SELECT * FROM " + tableName + " WHERE id = " + itemId;

                MySqlCommand cmd = new MySqlCommand(query, MysqlDbc.Instance.getConn());
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    p1.Id           = itemId;
                    p1.Description  = rdr.GetString("description");
                    p1.Pesticide_id = rdr.GetInt32("pesticide_id");
                    p1.Quantity_kg  = rdr.GetInt32("quantity_kg");
                    p1.SowingJob_id = rdr.GetInt32("sowingJob_id");
                    p1.Farm_id      = rdr.GetInt32("farm_id");
                    p1.Crop_id      = rdr.GetInt32("crop_id");
                    p1.Vehicle_id   = rdr.GetInt32("vehicle_id");
                    p1.Employee_id  = rdr.GetInt32("employee_id");
                    p1.Date_start   = rdr.GetDateTime("date_start");
                    p1.Date_end     = rdr.GetDateTime("date_end");
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }

            return(p1);
        }