private void btnSaveDrive_Click(object sender, EventArgs e)
        {
            dbconn.connect();

            MySqlCommand labourerValidation = new MySqlCommand("SELECT labourerName = @user FROM drivingTask WHERE (startDate >= @startDate AND endDate <= @endDate)", dbconn.getConn());

            labourerValidation.Parameters.AddWithValue("@user", comboBoxDriver.Text);
            labourerValidation.Parameters.AddWithValue("@startDate", dateTimePickerDvStartDate.Value.Date);
            labourerValidation.Parameters.AddWithValue("@endDate", dateTimePickerDvEndDate.Value.Date);
            MySqlDataReader reader = labourerValidation.ExecuteReader();

            if (reader.HasRows)
            {
                MessageBox.Show("Labourer is already assigned to a task!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                reader.Close();
            }
            else
            {
                dbconn.connect();
                Driving drv = new Driving();
                drv.LabourerName = comboBoxDriver.Text;
                drv.FarmSector   = int.Parse(comboBoxFarmD.Text);
                drv.TaskStatus   = comBoxSowTaskStatus.Text;
                drv.StartDate    = dateTimePickerDvStartDate.Value.Date;
                drv.EndDate      = dateTimePickerDvEndDate.Value.Date;
                drv.VehicleUsed  = comboBoxVehicles.Text;

                ScheduleHandler scHand = new ScheduleHandler();
                scHand.addDrivingSchedule(dbconn.getConn(), drv);
                MessageBox.Show("Task Assigned!");
            }
        }
Beispiel #2
0
        private void btnHarvUpd_Click(object sender, EventArgs e)
        {
            dbcon.connect();
            Harvest harv = new Harvest();

            harv.LabourerName = txtBoxHarvLabr.Text;
            harv.TaskStatus   = comBoxUpdHarvTask.Text;

            ScheduleHandler scHand = new ScheduleHandler();

            scHand.updateHarvTask(dbcon.getConn(), harv);
            MessageBox.Show("Task Updated!");
        }
Beispiel #3
0
        private void btnUpdTreat_Click(object sender, EventArgs e)
        {
            dbcon.connect();
            Treating trt = new Treating();

            trt.LabourerName = txtBoxTrtLabr.Text;
            trt.TaskStatus   = comBoxUpdTrtTask.Text;

            ScheduleHandler scHand = new ScheduleHandler();

            scHand.updateTrtTask(dbcon.getConn(), trt);
            MessageBox.Show("Task Updated!");
        }
Beispiel #4
0
        private void btnUpdDrv_Click(object sender, EventArgs e)
        {
            dbcon.connect();
            Driving drv = new Driving();

            drv.LabourerName = txtBoxDrv.Text;
            drv.TaskStatus   = comBoxUpdDrvTask.Text;

            ScheduleHandler scHand = new ScheduleHandler();

            scHand.updateDrvTask(dbcon.getConn(), drv);
            MessageBox.Show("Task Updated!");
        }
Beispiel #5
0
        private void btnSowUpd_Click(object sender, EventArgs e)
        {
            dbcon.connect();
            Sowing sow = new Sowing();

            sow.LabourerName = txtBoxSowLabr.Text;
            sow.TaskStatus   = comBoxUpdSowTask.Text;

            ScheduleHandler scHand = new ScheduleHandler();

            scHand.updateSowTask(dbcon.getConn(), sow);
            MessageBox.Show("Task Updated!");
        }
        //Buttons to save data into the database
        private void btnSaveSow_Click(object sender, EventArgs e)
        {
            try
            {
                dbconn.connect();
                string checkQuery = "SELECT labourerName = @user FROM sowingTask WHERE (startDate >= @startDate AND endDate <= @endDate)";
                using (MySqlCommand labourerValidation = new MySqlCommand(checkQuery, dbconn.getConn()))
                {
                    labourerValidation.Parameters.AddWithValue("@user", comboBoxWorkers.Text);
                    labourerValidation.Parameters.AddWithValue("@startDate", dateTimePickerSowStartDate.Value.Date);
                    labourerValidation.Parameters.AddWithValue("@endDate", dateTimePickerSowEndDate.Value.Date);
                    using (MySqlDataReader reader = labourerValidation.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            MessageBox.Show("Labourer is already assigned to a task!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            reader.Close();
                        }
                        else
                        {
                            dbconn.connect();
                            Sowing sow = new Sowing();
                            sow.LabourerName = comboBoxWorkers.Text;
                            sow.FarmSector   = int.Parse(comboBoxFarmSectorSow.Text);
                            sow.TaskStatus   = comBoxSowTaskStatus.Text;
                            sow.StartDate    = dateTimePickerDvStartDate.Value.Date;
                            sow.EndDate      = dateTimePickerDvEndDate.Value.Date;
                            sow.Method       = comboBoxMethods.Text;
                            sow.Seed         = comboBoxSeeds.Text;
                            sow.Quantity     = numericUpDownQauntity.Value;
                            sow.StartTime    = dateTimePickerStartSow.Value;
                            sow.EndTime      = dateTimePickerEndSow.Value;

                            ScheduleHandler scHand = new ScheduleHandler();
                            scHand.addSowingSchedule(dbconn.getConn(), sow);
                            MessageBox.Show("Task Assigned!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnSaveT_Click(object sender, EventArgs e)
        {
            dbconn.connect();

            MySqlCommand labourerValidation = new MySqlCommand("SELECT labourerName = @user FROM treatmentTask WHERE (startDate >= @startDate AND endDate <= @endDate)", dbconn.getConn());

            labourerValidation.Parameters.AddWithValue("@user", comboBoxWorkerT.Text);
            labourerValidation.Parameters.AddWithValue("@startDate", dateTimePickerStartT.Value.Date);
            labourerValidation.Parameters.AddWithValue("@endDate", dateTimePickerEndT.Value.Date);
            MySqlDataReader reader = labourerValidation.ExecuteReader();

            if (reader.HasRows)
            {
                MessageBox.Show("Labourer is already assigned to a task!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                reader.Close();
            }
            else
            {
                dbconn.connect();

                Treating trt = new Treating();
                trt.LabourerName   = comboBoxWorkerT.Text;
                trt.FarmSector     = int.Parse(comboBoxFarmT.Text);
                trt.TaskStatus     = comBoxTrTaskStatus.Text;
                trt.StartDate      = dateTimePickerStartT.Value.Date;
                trt.EndDate        = dateTimePickerEndT.Value.Date;
                trt.FertiliserUsed = comboBoxFertilisers.Text;
                trt.Quantity       = numericUpDownFertilisers.Value;
                trt.StartTime      = dateTimePickerStartTr.Value;
                trt.EndTime        = dateTimePickerEndTr.Value;

                ScheduleHandler scHand = new ScheduleHandler();
                scHand.addTreatingSchedule(dbconn.getConn(), trt);
                MessageBox.Show("Task Assigned!");
            }
        }
        private void btnSaveHarv_Click(object sender, EventArgs e)
        {
            dbconn.connect();

            MySqlCommand labourerValidation = new MySqlCommand("SELECT labourerName = @user FROM harvestTask WHERE (startDate >= @startDate AND endDate <= @endDate)", dbconn.getConn());

            labourerValidation.Parameters.AddWithValue("@user", comboBoxWorkerHarv.Text);
            labourerValidation.Parameters.AddWithValue("@startDate", dateTimePickerHrStartDate.Value.Date);
            labourerValidation.Parameters.AddWithValue("@endDate", dateTimePickerHrvEndDate.Value.Date);
            MySqlDataReader reader = labourerValidation.ExecuteReader();

            if (reader.HasRows)
            {
                MessageBox.Show("Labourer is already assigned to a task!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                reader.Close();
            }
            else
            {
                dbconn.connect();
                Harvest harv = new Harvest();
                harv.LabourerName = comboBoxWorkerHarv.Text;
                harv.FarmSector   = int.Parse(comboBoxFarmSectorHarv.Text);
                harv.TaskStatus   = comBoxHvTaskStatus.Text;
                harv.StartDate    = dateTimePickerHrStartDate.Value.Date;
                harv.EndDate      = dateTimePickerHrvEndDate.Value.Date;
                harv.Method       = comboBoxHarvestMehtod.Text;
                harv.Machine      = comboBoxPlantType.Text;
                harv.StorageUnit  = comboBoxStorageUnit.Text;
                harv.StartTime    = dateTimePickerStartHarv.Value;
                harv.EndTime      = dateTimePickerEndHarv.Value;

                ScheduleHandler scHand = new ScheduleHandler();
                scHand.addHarvestSchedule(dbconn.getConn(), harv);
                MessageBox.Show("Task Assigned!");
            }
        }