Beispiel #1
0
        private void btnAddTask_Click(object sender, EventArgs e)
        {
            DateTime    taskDate            = dtTaskDate.Value;
            Employee    selectedEmployee    = (Employee)cmbEmployees.SelectedItem;
            int         employeeId          = selectedEmployee.Id;
            TaskType    selectedTaskType    = (TaskType)cmbTaskTypes.SelectedItem;
            int         taskTypeId          = selectedTaskType.Id;
            Crop        selectedCrop        = (Crop)cmbCrops.SelectedItem;
            int         cropId              = selectedCrop.Id;
            Field       selectedField       = (Field)cmbFields.SelectedItem;
            int         fieldId             = selectedField.Id;
            Vehicle     selectedVehicle     = (Vehicle)cmbVehicles.SelectedItem;
            int         vehicleId           = selectedVehicle.Id;
            StorageUnit selectedStorageUnit = (StorageUnit)cmbStorageUnit.SelectedItem;
            int         storageUnitId       = selectedStorageUnit.Id;

            BusinessMetaLayer create = BusinessMetaLayer.instance();
            //DateTime taskDate = dtTaskDate;
            int success;

            success = create.setTask(taskDate, employeeId, taskTypeId, cropId, fieldId, vehicleId, storageUnitId);

            if (success == 1)
            {
                MessageBox.Show("Task Created");
            }
            else
            {
                MessageBox.Show("A Input is Incorrect.");
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer ln = BusinessMetaLayer.instance();

            user = ln.farmLogin(Tester.Text, txtPassword.Text);

            if (user[0] == 0)
            {
                this.Hide();
                AdminMain n = new AdminMain();
                n.ShowDialog();
            }
            else if (user[0] == 1)
            {
                this.Hide();
                LabourerMain n = new LabourerMain(user[1]);
                n.ShowDialog();
            }
            else if (user[0] == -1)
            {
                MessageBox.Show("Please Enter a valid 'Username' & 'Password' in the fields provided!");
            }
            else
            {
                MessageBox.Show("Username / password combimation incorrect");
            }
        }
Beispiel #3
0
        private void btnAddCrop_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer create = BusinessMetaLayer.instance();

            int    success;
            String cropName        = txtCropName.Text;
            String fertName        = txtFertName.Text;
            int    cultivationTime = Convert.ToInt32(this.txtCultTime.Text);
            int    fertFrequency   = Convert.ToInt32(this.txtFertFreq.Text);
            int    yieldValue      = Convert.ToInt32(this.txtYieldValue.Text);

            success = create.addCrop(txtCropName.Text, cultivationTime, fertFrequency, yieldValue, fertName);

            if (success == 1)
            {
                MessageBox.Show("Crop added");
                txtCropName.Clear();
                txtCultTime.Clear();
                txtFertFreq.Clear();
                txtYieldValue.Clear();
            }
            else
            {
                MessageBox.Show("An input is incorrect");
            }
        }
Beispiel #4
0
        public editEmployee()
        {
            InitializeComponent();
            m_bs = new BindingSource();
            BusinessMetaLayer ml = BusinessMetaLayer.instance();

            m_employees     = ml.getEmployees();
            m_bs.DataSource = m_employees;
            m_bs.ResetBindings(false);
            this.dataEmployee.DataSource = m_bs.DataSource;
        }
Beispiel #5
0
        private void lstStorage_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer ml = BusinessMetaLayer.instance();

            m_storageUnits  = ml.getStorageUnits();
            m_bs.DataSource = m_storageUnits;
            m_bs.ResetBindings(false);
            this.dgdInventoryWindow.DataSource         = m_bs.DataSource;
            this.dgdInventoryWindow.RowHeadersVisible  = false;
            this.dgdInventoryWindow.Columns[0].Visible = false;
        }
Beispiel #6
0
        private void btnFertiliser_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer ml = BusinessMetaLayer.instance();

            m_fertilisers   = ml.getFertilisers();
            m_bs.DataSource = m_fertilisers;
            m_bs.ResetBindings(false);
            this.dgdInventoryWindow.DataSource         = m_bs.DataSource;
            this.dgdInventoryWindow.RowHeadersVisible  = false;
            this.dgdInventoryWindow.Columns[0].Visible = false;
        }
        private void btnAddVeh_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer create = BusinessMetaLayer.instance();
            string            cmbResult;
            int accessPrivilage = 1;
            int success;

            cmbResult = cmbVehStatus.SelectedItem.ToString();

            if (cmbResult == "Available")
            {
                accessPrivilage = 1;
            }
            else if (cmbResult == "Out of Service")
            {
                accessPrivilage = 2;
            }
            else if (cmbResult == "In Repair")
            {
                accessPrivilage = 3;
            }
            else
            {
                MessageBox.Show("Status is Incorrect");
            }

            if (txtDescription.Text == string.Empty)
            {
                MessageBox.Show("Description is Empty");
            }
            else if (txtType.Text == string.Empty)
            {
                MessageBox.Show("Type of Vehcile is Empty");
            }
            else
            {
                success = create.addVehicle(txtType.Text, txtDescription.Text, accessPrivilage);

                if (success == 1)
                {
                    MessageBox.Show("Account Created");
                    txtType.Clear();
                    txtDescription.Clear();
                }
                else
                {
                    MessageBox.Show("A Input is Incorrect.");
                }
            }
        }
Beispiel #8
0
        private void btnEditEmp_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer create = BusinessMetaLayer.instance();
            int success;

            String privilege;

            if (cboxEdPrivilege.Checked == true)
            {
                privilege = "Yes";
            }
            else
            {
                privilege = "No";
            }

            String Name        = txtEdEmpName.Text;
            String userName    = txtEdEmpUsern.Text;
            String password    = txtEdEmpPass.Text;
            String email       = txtEdEmpEmail.Text;
            String postcode    = txtEdEmpPost.Text;
            String phoneNumber = txtEdEmpPhone.Text;

            success = ml.EditEmployee(Id, postcode, phoneNumber, email, userName, password, privilege);

            if (success == 1)
            {
                MessageBox.Show("Account edited");
                m_bs            = new BindingSource();
                m_employees     = ml.getEmployees();
                m_bs.DataSource = m_employees;
                m_bs.ResetBindings(false);
                this.dataEmployee.DataSource = m_bs.DataSource;
                txtEdEmpName.Clear();
                txtEdEmpUsern.Clear();
                txtEdEmpPass.Clear();
                txtEdEmpEmail.Clear();
                txtEdEmpPost.Clear();
                txtEdEmpPhone.Clear();
                cboxEdPrivilege.Checked = false;
            }
        }
Beispiel #9
0
        private void btnAddField_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer create = BusinessMetaLayer.instance();
            int inUse = 0;
            int success;
            int fieldSize = Convert.ToInt32(this.txtFieldSize.Text);

            success = create.addField(txtFieldRef.Text, fieldSize, inUse);

            if (success == 1)
            {
                MessageBox.Show("Field Created");
                txtFieldRef.Clear();
                txtFieldSize.Clear();
            }
            else
            {
                MessageBox.Show("An input is incorrect");
            }
        }
Beispiel #10
0
        private void btnAddTask_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer create = BusinessMetaLayer.instance();


            int    success;
            String taskType        = txtTaskType.Text;
            String taskDescription = txtTaskDesc.Text;

            success = create.addTaskType(txtTaskType.Text, txtTaskDesc.Text);

            if (success == 1)
            {
                MessageBox.Show("Task Created");
                txtTaskDesc.Clear();
                txtTaskType.Clear();
            }
            else
            {
                MessageBox.Show("An input is Incorrect");
            }
        }
Beispiel #11
0
        public LabourerMain(int employeeId)
        {
            InitializeComponent();

            BusinessMetaLayer u = BusinessMetaLayer.instance();

            List <Task> m_tasks;

            user = u.getUserDetails(employeeId);
            this.gbUserDetails.Text   = user.Username;
            this.lbvName.Text         = user.Name;
            this.lbvAddress.Text      = user.Address;
            this.lbvPhoneNumber.Text  = user.Phone;
            this.lbvEmailAddress.Text = user.Email;
            utl            = new BindingSource();
            m_tasks        = u.getUserTasks(employeeId);
            utl.DataSource = m_tasks;
            utl.ResetBindings(true);
            this.dgdUserTasks.DataSource         = utl.DataSource;
            this.dgdUserTasks.RowHeadersVisible  = false;
            this.dgdUserTasks.Columns[0].Visible = false;
            this.dgdUserTasks.Columns[2].Visible = false;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer create = BusinessMetaLayer.instance();
            string            accessPrivilage;

            if (cboxPrivilege.Checked == true)
            {
                accessPrivilage = "Yes";
            }
            else
            {
                accessPrivilage = "No";
            }

            string password = txtPassword.Text;
            int    success;

            success = create.addEmployee(txtFirstname.Text, txtSurname.Text, txtPostcode.Text, txtPhone.Text, txtEmail.Text, txtUsername.Text, password, accessPrivilage);

            if (success == 1)
            {
                MessageBox.Show("Account Created");
                txtFirstname.Clear();
                txtSurname.Clear();
                txtUsername.Clear();
                txtPostcode.Clear();
                txtPhone.Clear();
                txtPassword.Clear();
                txtEmail.Clear();
                cboxPrivilege.Checked = false;
            }
            else
            {
                MessageBox.Show("A Input is Incorrect.");
            }
        }
Beispiel #13
0
        private void button2_Click(object sender, EventArgs e)
        {
            BusinessMetaLayer asu = BusinessMetaLayer.instance();
            string            storageUnitReference;
            int storageUnitCapacity;
            int storageCurrent = 0;
            int storedCrop     = 1;
            int success;

            storageUnitReference = txtStorageUnitReference.Text;
            storageUnitCapacity  = Convert.ToInt32(txtStorageUnitCapacity.Text);
            success = asu.addStorageUnit(storageUnitReference, storageUnitCapacity, storageCurrent, storedCrop);

            if (success == 1)
            {
                MessageBox.Show("Task Created");
                txtStorageUnitReference.Clear();
                txtStorageUnitCapacity.Clear();
            }
            else
            {
                MessageBox.Show("An input is correct");
            }
        }