示例#1
0
        private void AddMaterialCommand(object model)
        {
            ErrorMessage = "";
            var material = model as Material;

            if (material.BillAmount <= 0 ||
                material.Quantity <= 0 ||
                string.IsNullOrWhiteSpace(material.BillNumber) ||
                SelectedVendor.VendorId == 0 ||
                material.SelectedMaterialType.MaterialTypeId == 0 ||
                material.SelectedUnit.UnitId == 0)
            {
                ErrorMessage = "*Please check the entry. Some field's Values are missing.";
                return;
            }
            material.SelectedVendor = Vendors.Single(x => x.VendorId == SelectedVendor.VendorId);
            material.SiteId         = SiteId;
            material.CreatedDate    = DateTime.Now;
            _repositoryManager.AddMaterial(material);
            Materials     = new ObservableCollection <Material>(_repositoryManager.GetMaterialBySiteId(SiteId));
            MaterialToAdd = new Material();
            MaterialToAdd.SelectedUnit         = Units.First();
            SelectedVendor                     = VendorList.First();
            MaterialToAdd.SelectedMaterialType = MaterialTypes.First();
            OnPropertyChanged(nameof(MaterialToAdd));
            OnPropertyChanged(nameof(SelectedVendor));
        }
示例#2
0
        private void AddVendorCommand(object model)
        {
            var vendor = model as Vendor;

            if (string.IsNullOrWhiteSpace(vendor.VendorName) || string.IsNullOrWhiteSpace(vendor.Address))
            {
                return;
            }
            vendor.CreatedDate = DateTime.Now;
            _repositoryManager.AddVendor(vendor);
            var list = _repositoryManager.GetVendorBySiteId(SiteId);

            Vendors        = new ObservableCollection <Vendor>(list);
            VendorToAdd    = new Vendor();
            VendorList     = ProcessVendors(list);
            SelectedVendor = VendorList.First();
            OnPropertyChanged(nameof(SelectedVendor));
        }