示例#1
0
        public static List <string> getHarvestingJobList()
        {
            HarvestingJob   harvesting = new HarvestingJob();
            List <string>   flist      = new List <string>();
            MySqlDataReader rdr        = null;

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

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

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

            return(flist);
        }
        private void addHarvestingJob()
        {
            HarvestingJob hj = new HarvestingJob();

            hj.Description  = textBox1.Text;
            hj.SowingJob_id = Convert.ToInt32(cbSoj.Text);
            string idStr = cbFarm.Text.Split('.')[0];

            hj.Farm_id = int.Parse(idStr);
            string idStr1 = cbCrop.Text.Split('.')[0];

            hj.Crop_id = int.Parse(idStr1);
            string idStr2 = cbVehicle.Text.Split('.')[0];

            hj.Vehicle_id         = int.Parse(idStr2);
            hj.Est_quantity       = int.Parse(numericUpDown1.Text);
            hj.Harvested_quantity = int.Parse(numericUpDown2.Text);
            string idStr3 = cbEmployee.Text.Split('.')[0];

            hj.Employee_id = int.Parse(idStr3);
            hj.Date_start  = Convert.ToDateTime(dtpStart1.Value);
            hj.Date_end    = Convert.ToDateTime(dtpEnd.Value);

            InsertSQL hdl = new InsertSQL();

            hdl.addNewHarvestingJob(hj);
            MessageBox.Show("Success!!");
            this.Close();
        }
示例#3
0
        public HarvestingJob GetHarvestingJobFromID(int itemId)
        {
            HarvestingJob hj = new HarvestingJob();

            MySqlDataReader rdr = null;

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

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

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

            return(hj);
        }