Example #1
0
        public void update()
        {
            SowingJob s1 = new SowingJob();

            s1.Id          = sowj.Id;
            s1.Description = tbDescription.Text;
            string idStr = cbCrop.Text.Split('.')[0];

            s1.Crop_id       = int.Parse(idStr);
            s1.Quantity_prop = int.Parse(nUDQty.Text);
            string idStr1 = cbFarm.Text.Split('.')[0];

            s1.Farm_id   = int.Parse(idStr1);
            s1.Used_area = textBox1.Text;
            string idStr2 = cbVehicle.Text.Split('.')[0];

            s1.Vehicle_id = int.Parse(idStr2);
            string idStr3 = cbEmployee.Text.Split('.')[0];

            s1.Employee_id = int.Parse(idStr3);
            s1.Date_start  = this.dtpDate.Value;
            s1.Date_end    = this.dtpDateEnd.Value;


            UpdateSQL add       = new UpdateSQL();
            int       addrecord = add.UpdateSowingJob(s1);

            MessageBox.Show("Success!!");
            this.Close();
        }
Example #2
0
        public void add()
        {
            //checkAsignJobandAdd();
            SowingJob s1 = new SowingJob();

            s1.Description = tbDescription.Text;
            string idStr = cbCrop.Text.Split('.')[0];

            s1.Crop_id       = int.Parse(idStr);
            s1.Quantity_prop = Int32.Parse(nUDQty.Text);
            string idStr1 = cbFarm.Text.Split('.')[0];

            s1.Farm_id   = int.Parse(idStr1);
            s1.Used_area = textBox1.Text;
            string idStr2 = cbVehicle.Text.Split('.')[0];

            s1.Vehicle_id = int.Parse(idStr2);
            string idStr3 = cbEmployee.Text.Split('.')[0];

            s1.Employee_id = int.Parse(idStr3);
            s1.Date_start  = this.dtpDate.Value;
            s1.Date_end    = this.dtpDateEnd.Value;
            //s1.Employee_id = Int32.Parse(cbEmployee.Text);

            InsertSQL add       = new InsertSQL();
            int       addrecord = add.addNewSowingJob(s1);

            MessageBox.Show("Success!!");

            this.Close();
        }
Example #3
0
        public static List <string> getSowingJobList()
        {
            SowingJob       sowing = new SowingJob();
            List <string>   flist  = new List <string>();
            MySqlDataReader rdr    = null;

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

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

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

            return(flist);
        }
        private void FormStoringJob_Load(object sender, EventArgs e)
        {
            InsertSQL StoringJob = new InsertSQL();

            if (state == "Edit")
            {
                textBox1.Text   = sj1.Description;
                cbHarvest.Text  = sj1.Harvest_id.ToString();
                cbCrop.Text     = sj1.Crop_id.ToString();
                cbBox.Text      = sj1.Box_id.ToString();
                textBox5.Text   = sj1.Quantity.ToString();
                cbVehicle.Text  = sj1.Vehicle_id.ToString();
                cbEmployee.Text = sj1.Employee_id.ToString();
                dtpStart.Value  = sj1.Date_start;
                dtpEnd.Value    = sj1.Date_end;

                TestSQL ts = new TestSQL();
                cropLists    = ts.GetCropList();
                employeeList = ts.GetEmployeeList();
                vehicleList  = ts.GetVehicleList();
                boxList      = ts.GetBoxList();
                harvestLists = ts.GetHarvestingJobList();

                SowingJob sj11 = new SowingJob();

                foreach (HarvestingJob harvest in harvestLists)
                {
                    string showText = harvest.Id + ". " + harvest.Description;
                    cbCrop.Items.Add(showText);
                }

                foreach (Box box in boxList)
                {
                    string showText = box.Id + ". " + box.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Crop crop1 in cropLists)
                {
                    string showText = crop1.Id + ". " + crop1.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Vehicle vehicle in vehicleList)
                {
                    string showText = vehicle.Id + ". " + vehicle.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Employee employee in employeeList)
                {
                    if (employee.Admin == false)
                    {
                        string showText = employee.Id + ". " + employee.Username;
                        cbEmployee.Items.Add(showText);
                    }
                }
            }
        }
Example #5
0
        public SowingJob GetSowingJobFromID(int itemId)
        {
            SowingJob sj1 = new SowingJob();

            MySqlDataReader rdr = null;

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

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

                while (rdr.Read())
                {
                    sj1.Id            = itemId;
                    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");
                    //sj1.Time_start = rdr.GetDateTime("time_start");
                    //sj1.Time_end = rdr.GetDateTime("time_end");
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }

            return(sj1);
        }
        private void FormPesticideJob_Load(object sender, EventArgs e)
        {
            InsertSQL pesticideJob = new InsertSQL();

            if (state == "Edit")
            {
                textBox1.Text    = pjj11.Description;
                cbPesticide.Text = pjj11.Pesticide_id.ToString();
                textBox3.Text    = pjj11.Quantity_kg.ToString();
                cbSoj.Text       = pjj11.SowingJob_id.ToString();
                cbFarm.Text      = pjj11.Farm_id.ToString();
                cbCrop.Text      = pjj11.Crop_id.ToString();
                cbVehicle.Text   = pjj11.Vehicle_id.ToString();
                cbEmployee.Text  = pjj11.Employee_id.ToString();
                dtpStart.Value   = pjj11.Date_start;
                dtpEnd.Value     = pjj11.Date_end;

                TestSQL ts = new TestSQL();
                cropLists     = ts.GetCropList();
                employeeList  = ts.GetEmployeeList();
                farmLists     = ts.GetFarmList();
                vehicleList   = ts.GetVehicleList();
                pesticideList = ts.GetPesticideList();
                sowingLists   = ts.GetSowingJobList();
                employeeList  = ts.GetEmployeeList();

                SowingJob sj11 = new SowingJob();

                foreach (SowingJob sow in sowingLists)
                {
                    cbSoj.Items.Add(sow.Id);
                }

                foreach (Crop crop1 in cropLists)
                {
                    string showText = crop1.Id + ". " + crop1.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Pesticide pest in pesticideList)
                {
                    string showText = pest.Id + ". " + pest.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Vehicle vehicle in vehicleList)
                {
                    string showText = vehicle.Id + ". " + vehicle.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Employee employee in employeeList)
                {
                    if (employee.Admin == false)
                    {
                        string showText = employee.Id + ". " + employee.Username;
                        cbEmployee.Items.Add(showText);
                    }
                }

                foreach (Farm farm in farmLists)
                {
                    string showText = farm.Id + ". " + farm.Description;
                    cbFarm.Items.Add(showText);
                }
            }
        }
Example #7
0
        private void FormSowingJob_Load(object sender, EventArgs e)
        {
            InsertSQL sowing = new InsertSQL();

            if (state == "Edit")
            {
                tbDescription.Text = sowj.Description;
                cbCrop.Text        = sowj.Crop_id.ToString();
                nUDQty.Text        = sowj.Quantity_prop.ToString();
                cbFarm.Text        = sowj.Farm_id.ToString();
                textBox1.Text      = sowj.Used_area.ToString();
                cbVehicle.Text     = sowj.Vehicle_id.ToString();
                cbEmployee.Text    = sowj.Employee_id.ToString();
                dtpDate.Value      = sowj.Date_start;
                dtpDateEnd.Value   = sowj.Date_end;
            }


            // when form loads, get all fields data from mysql
            // then store to a bunch of list<class>
            // then all combo boxes gets data from the list<class>

            // mysql :
            // 1. get crop list from crop table
            // 2. get farm list from farm table
            // 3. get vehicle list from vehicle table
            // 4. get employee list from employee table

            // combo box
            // 5. load crop list to combo box
            // 6. load farm list to combo box
            // 7. load vehicle list to combo box
            // 8. load employee list to combo box

            // 1.
            TestSQL ts = new TestSQL();

            cropLists    = ts.GetCropList();
            employeeList = ts.GetEmployeeList();
            farmLists    = ts.GetFarmList();
            vehicleList  = ts.GetVehicleList();
            SowingJob sj11 = new SowingJob();

            //    // 5.
            foreach (Crop crop in cropLists)
            {
                string showText = crop.Id + ". " + crop.Name;
                cbCrop.Items.Add(showText);
            }

            foreach (Vehicle vehicle in vehicleList)
            {
                string showText = vehicle.Id + ". " + vehicle.Name;
                cbVehicle.Items.Add(showText);
            }

            foreach (Employee employee in employeeList)
            {
                if (employee.Admin == false)
                {
                    string showText = employee.Id + ". " + employee.Username;
                    cbEmployee.Items.Add(showText);
                }
            }

            foreach (Farm farm in farmLists)
            {
                string showText = farm.Id + ". " + farm.Description;
                cbFarm.Items.Add(showText);
            }
        }
        private void FormHarvestingJob_Load(object sender, EventArgs e)
        {
            InsertSQL crop = new InsertSQL();

            if (state == "Edit")
            {
                textBox1.Text       = hj11.Description;
                cbSoj.Text          = hj11.SowingJob_id.ToString();
                cbFarm.Text         = hj11.Farm_id.ToString();
                cbCrop.Text         = hj11.Crop_id.ToString();
                cbVehicle.Text      = hj11.Vehicle_id.ToString();
                numericUpDown1.Text = hj11.Est_quantity.ToString();
                numericUpDown2.Text = hj11.Harvested_quantity.ToString();
                cbEmployee.Text     = hj11.Employee_id.ToString();
                dtpStart1.Text      = hj11.Date_start.ToString();
                dtpEnd.Text         = hj11.Date_end.ToString();


                TestSQL ts = new TestSQL();
                cropLists    = ts.GetCropList();
                employeeList = ts.GetEmployeeList();
                farmLists    = ts.GetFarmList();
                vehicleList  = ts.GetVehicleList();
                sowingLists  = ts.GetSowingJobList();

                SowingJob sj11 = new SowingJob();

                foreach (SowingJob sow in sowingLists)
                {
                    cbSoj.Items.Add(sow.Id);
                }

                foreach (Crop crop1 in cropLists)
                {
                    string showText = crop1.Id + ". " + crop1.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Vehicle vehicle in vehicleList)
                {
                    string showText = vehicle.Id + ". " + vehicle.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Employee employee in employeeList)
                {
                    if (employee.Admin == false)
                    {
                        string showText = employee.Id + ". " + employee.Username;
                        cbEmployee.Items.Add(showText);
                    }
                }

                foreach (Farm farm in farmLists)
                {
                    string showText = farm.Id + ". " + farm.Description;
                    cbFarm.Items.Add(showText);
                    //cbFarm.Items.Add(farm.Id);
                    //cbFarm.Items.Add(farm.Description);
                }
            }
        }