Esempio n. 1
0
        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);
                    }
                }
            }
        }
Esempio n. 2
0
        public void checkAssignJobandAdd()
        {
            TestSQL ts = new TestSQL();

            cropLists    = ts.GetCropList();
            employeeList = ts.GetEmployeeList();
            farmLists    = ts.GetFarmList();
            vehicleList  = ts.GetVehicleList();
            harvestLists = ts.GetHarvestingJobList();

            DateTime start_date = Convert.ToDateTime("12/12/2018");
            DateTime end_date = Convert.ToDateTime("12/12/2018");
            DateTime currentDate = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"));
            int      duration = 0; int todayduration = 0;

            foreach (Employee employee in employeeList)
            {
                foreach (HarvestingJob harvest in harvestLists)
                {
                    start_date    = Convert.ToDateTime(harvest.Date_start.ToString());
                    end_date      = Convert.ToDateTime(harvest.Date_end.ToString());
                    duration      = Convert.ToInt32((end_date - start_date).TotalDays);
                    todayduration = Convert.ToInt32((currentDate - start_date).TotalDays);
                    if (duration < todayduration)
                    {
                        cbEmployee.Items.Add(employee.Id.ToString());
                        //add();
                        MessageBox.Show("yes");
                    }
                    else
                    {
                        MessageBox.Show("no");
                    }
                }
            }
        }