Exemplo n.º 1
0
        private void PrepareForInsert(KeyAndValue modelUOM, KeyAndValue modelBrand, out bool isValid)
        {
            CodeSize = txtCodeSize.Text;
            Description = txtDescription.Text;
            // IDs containt Generic values in the database if request only
            UOM = modelUOM == null ? 134 : (int)modelUOM.Key;
            Brand = modelBrand == null ? 7 : (int)modelBrand.Key;

            if (!isRequestItemOnly) {
                if (CostObjectiveId == 0) {
                    btnCostObjSelect.FlagAsError();
                    isValid = false;
                    return;
                } btnCostObjSelect.FlagAsCorrect();

                if (Description.IsNullOrEmpty()) {
                    txtDescription.FlagAsError();
                    isValid = false;
                    return;
                } txtDescription.FlagAsCorrect();
            }
            isValid = true;
        }
Exemplo n.º 2
0
        private void btnAddItem_Click(object sender, RoutedEventArgs e)
        {
            modelUOM = (KeyAndValue)cbUnitOfMeasurement.SelectedItem;
            modelBrand = (KeyAndValue)cbBrand.SelectedItem;

            bool IsValid = false;

            //Cost Objective is Always Mandatory Select Cost objective
            CostObjectiveId = SelectedCostObjective == 0 ? 0 : SelectedCostObjective;
            if (CostObjectiveId == 0) {
                btnCostObjSelect.FlagAsError();
                MessageBox.Show("Cost Objective is Mandatory.", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                btnCostObjSelect.FlagAsError();
                return;
            } btnCostObjSelect.FlagAsCorrect();

            if (!isRequestItemOnly) {
                #region ComboBox Validations
                //Validate ComboBoxes
                if (cbUnitOfMeasurement.SelectedIndex == -1) {
                    cbUnitOfMeasurement.FlagAsError();
                    return;
                } cbUnitOfMeasurement.FlagAsCorrect();

                if (cbBrand.SelectedIndex == -1) {
                    cbBrand.FlagAsError();
                    return;
                } cbBrand.FlagAsCorrect();

                #endregion
            }
            //Prepare for Addition and Validate Textboxes
            PrepareForInsert(modelUOM, modelBrand, out IsValid);

            if (!IsValid) {
                MessageBox.Show("Please correct the highlighted boxes");
                return;
            }

            //Add Item
            background.Do(AddNewItem, AddNewItem_Complete);
        }
Exemplo n.º 3
0
        private void PopulateData()
        {
            brands = new List<object>();
            uoms = new List<object>();

            foreach (var uom in db.UnitOfMeasurements) {
                KeyAndValue tmpUOM = new KeyAndValue(uom.Id, uom.Name);
                uoms.Add(tmpUOM);
            }

            foreach (var brand in db.ItemBrands) {
                KeyAndValue tmpBrand = new KeyAndValue(brand.Id, brand.Name);
                brands.Add(tmpBrand);
            }
        }
Exemplo n.º 4
0
        private void ValidateComboBoxes(KeyAndValue Company, KeyAndValue Branch, KeyAndValue Department, KeyAndValue UserType, out bool Validated)
        {
            Validated = false;

            if (UserType == null && CurrentUser != null) {
                comboUserType.FlagAsError();
                return;
            } comboUserType.FlagAsCorrect();

            if(Company == null) {
                comboCompany.FlagAsError();
                return;
            } comboCompany.FlagAsCorrect();

            if (Branch == null) {
                comboBranch.FlagAsError();
                return;
            } comboBranch.FlagAsCorrect();

            if (Department == null) {
                comboDepartment.FlagAsError();
                return;
            } comboDepartment.FlagAsCorrect();

            Validated = true;
        }
Exemplo n.º 5
0
 private void PrepareValuesForInsert(KeyAndValue Company, KeyAndValue Branch, KeyAndValue Department, KeyAndValue UserType)
 {
     Username = txtUsername.Text;
     Password = txtPassword.Password;
     LastName = txtLastName.Text;
     FirstName = txtFirstName.Text;
     ContactNo = txtContactNo.Text;
     Email = txtEmail.Text;
     this.Company = (int)Company.Key;
     this.Branch = (int)Branch.Key;
     this.Department = (int)Department.Key;
     if (CurrentUser != null) {
         this.UserType = (int)UserType.Key;
     }
     else {
         this.UserType = (int)Enums.UserTypes.Requisitioner;
     }
     Street = txtStreet.Text;
     City = txtCity.Text;
     Zip = txtZip.Text;
 }
Exemplo n.º 6
0
        private void PopulateDepAndBranches()
        {
            departments = new List<object>();
            foreach (var department in db.Departments.Where(x => x.CompanyId == companyId)) {
                KeyAndValue tmpdepartment = new KeyAndValue(department.Id, department.Name);
                departments.Add(tmpdepartment);
            }

            branches = new List<object>();
            foreach (var branch in db.Branches.Where(x => x.CompanyId == companyId)) {
                KeyAndValue tmpdepartment = new KeyAndValue(branch.Id, branch.Name);
                branches.Add(tmpdepartment);
            }
        }
Exemplo n.º 7
0
        private void PopulateCompanies()
        {
            companies = new List<object>();
            userTypes = new List<object>();
            foreach (var company in db.Companies) {
                KeyAndValue tmpCompany = new KeyAndValue(company.Id, company.Name);
                companies.Add(tmpCompany);
            }

            foreach (var type in db.UserTypes) {
                KeyAndValue tmpType = new KeyAndValue(type.Id, type.UserType1);
                userTypes.Add(tmpType);
            }
        }
        private void PopulateData()
        {
            categories = new List<object>();

            if(categoryId != 0)
                CostObjectives = db.CostObjectives.Where(x => x.CategoryId == categoryId && x.CompanyId == CurrentUser.CompanyId).Select(x => new CostObjectiveModel { Id = x.Id, Name = x.Name, Company = x.Company.Name, Category = x.CostObjectiveCategory.Name });
            else
                CostObjectives = db.CostObjectives.Where(x=>x.CompanyId == CurrentUser.CompanyId).Select(x => new CostObjectiveModel { Id = x.Id, Name = x.Name, Company = x.Company.Name, Category = x.CostObjectiveCategory.Name });

            foreach (var type in db.CostObjectiveCategories) {
                KeyAndValue tmpType = new KeyAndValue(type.Id, type.Name);
                categories.Add(tmpType);
            }
        }