Exemple #1
0
        public void checkAsignJobandAdd()
        {
            //string tableName = "sowingJob";
            //string query = "SELECT * FROM " + tableName;
            //MySqlCommand cmd = new MySqlCommand(query, MysqlDbc.Instance.getConn());
            TestSQL ts = new TestSQL();

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

            DateTime start_date = dtpDate.Value;
            DateTime end_date = dtpDateEnd.Value;
            DateTime currentDate = Convert.ToDateTime(DateTime.Now.ToString("MMM/dd/yyyy"));
            int      duration = 0; int todayduration = 0;

            foreach (Employee employee1 in employeeList)
            {
                var sowing_list = sowingLists.Where(employee => employee.Id == employee1.Id);

                foreach (SowingJob sowing in sowingLists)
                {
                    start_date = Convert.ToDateTime(sowing.Date_start.ToString());
                    //start_date = DateTime.ParseExact(, "MM/dd/yyyy", null);
                    end_date = Convert.ToDateTime(sowing.Date_end.ToString());
                    //end_date = DateTime.ParseExact(this.dtpDateEnd.ToString(), "MM/dd/yyyy", null);
                    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");
                    }
                }
            }
        }
        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);
                }
            }
        }
        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);
                }
            }
        }