Beispiel #1
0
 public NewMalFunctionViewModel()
 {
     CustomerList     = CustomerModule.GetCustomerList();
     FabricList       = FabricModule.GetFabricList();
     FactoryList      = FactoryModule.GetFactoryList();
     ProcessOrderList = ProcessModule.GetProcessOrder();
 }
Beispiel #2
0
        public AddProcessSequenceDialog(Fabric fabric, FabricColor fabricColor, Dictionary <int, ObservableCollection <ProcessSequenceDetail> > processSequenceListGroup)
        {
            InitializeComponent();
            _fabric                  = fabric;
            _fabricColor             = fabricColor;
            LabelTextileID.Content   = fabric.FabricID;
            LabelTextileName.Content = fabric.FabricName;

            LabelFabricColor.Content  = fabricColor.Color;
            _processSequenceListGroup = processSequenceListGroup;
            var processSequenceDetails = FabricModule.GetProcessSequencesByFabricID(_fabric.FabricID)
                                         .GroupBy(g => g.Group)
                                         .ToDictionary(g => g.Key, g => new ObservableCollection <ProcessSequenceDetail>(g.OrderBy(o => o.Order).ToList()));

            foreach (var item in processSequenceDetails)
            {
                if (!_processSequenceListGroup.Keys.Contains(item.Key))
                {
                    _processSequenceListGroup.Add(item.Key, item.Value);
                }
            }

            ComboBoxProcessGroup.ItemsSource    = _processSequenceListGroup.Keys.ToList();
            ComboBoxFactoryList.ItemsSource     = FactoryModule.GetFactoryList();
            DataGridProcessSequence.ItemsSource = _processSequenceDetails;
        }
Beispiel #3
0
        private void ComboBoxSelectionChangedExecute()
        {
            IEnumerable <YarnSpecification> yarnSpecifications = FabricModule.GetYarnSpecificationListByYarnMerchant(SearchFactory.FactoryID);

            YarnSpecificationList = new ObservableCollection <YarnSpecification>(yarnSpecifications);
            RaisePropertyChanged("YarnSpecificationList");
        }
Beispiel #4
0
        private void OnSelectionChangedExecute()
        {
            _stackPanel.Children.Clear();

            if (SelectedYarnSpecification == null)
            {
                return;
            }
            IEnumerable <MerchantYarnPrice> yarnPrices = FabricModule.GetYarnPriceByYarnSpecificationNo(SelectedYarnSpecification.YarnSpecificationNo);
            //MerchantYarnPrices = new ObservableCollection<YarnPrice>(yarnPrices);
            MerchantYarnPrice merchantYarnPriceMax  = yarnPrices.OrderByDescending(o => o.PiecePrice).FirstOrDefault();
            MerchantYarnPrice merchantYarnPriceMin  = yarnPrices.OrderBy(o => o.PiecePrice).FirstOrDefault();
            MerchantYarnPrice merchantYarnPriceTime = yarnPrices.OrderByDescending(o => o.CreateDate).FirstOrDefault();
            var merchantYarnPriceGroup = yarnPrices.GroupBy(g => g.YarnMerchant).ToDictionary(g => g.Key, g => g.ToList());

            if (merchantYarnPriceMax != null || merchantYarnPriceMin != null || merchantYarnPriceTime != null)
            {
                CreateDataGrid(0, merchantYarnPriceMax, merchantYarnPriceMin, merchantYarnPriceTime, yarnPrices);
                foreach (var item in merchantYarnPriceGroup)
                {
                    IEnumerable <MerchantYarnPrice> merchants = item.Value;
                    CreateDataGrid(item.Key, merchants.OrderByDescending(o => o.PiecePrice).First(), merchants.OrderBy(o => o.PiecePrice).First(), merchants.OrderBy(o => o.CreateDate).First(), merchants);
                }
            }
            //RaisePropertyChanged("MerchantYarnPrices");
        }
Beispiel #5
0
 public FabricViewModel()
 {
     FabricNameList   = new ObservableCollection <string>();
     FabricList       = new ObservableCollection <Fabric>(FabricModule.GetFabricList());
     AverageUnitPrice = 200;
     AverageCost      = 170;
 }
Beispiel #6
0
        private void ButtonEditProcessSequence_Click(object sender, RoutedEventArgs e)
        {
            ProcessSequenceDetail processSequenceDetail = DataGridProcessSequence.SelectedItem as ProcessSequenceDetail;
            bool success = FabricModule.EditProcessSequence(processSequenceDetail);

            success.CheckSuccessMessageBox("修改成功!!", "修改失敗!!");
        }
Beispiel #7
0
        private void ButtonDeleteFabricIngredientProportions_Click(object sender, RoutedEventArgs e)
        {
            FabricColor fabricColor = ComboBoxFabricColor.SelectedItem as FabricColor;
            int         groupNo     = Convert.ToInt16(ComboBoxGroup.SelectedItem);
            bool        success     = FabricModule.DeleteFabricIngredientProportions(fabricColor.ColorNo, groupNo);

            success.CheckSuccessMessageBox("刪除成功!!", "好像有錯誤喔!!");
        }
Beispiel #8
0
        private void ButtonDeleteProcessSequence_Click(object sender, RoutedEventArgs e)
        {
            List <ProcessSequenceDetail> processSequenceDetails = _processSequenceDetails.ToList();

            int  group   = processSequenceDetails.First().Group;
            bool success = FabricModule.DeleteProcessSequence(_fabricColor.ColorNo, group, processSequenceDetails.Select(s => s.SequenceNo));

            success.CheckSuccessMessageBox("刪除成功!!", "刪除失敗!!");
        }
Beispiel #9
0
        private void CheckFabricClickExecute()
        {
            var names = FabricModule.CheckExcelAndSqlFabricName();

            foreach (var name in names)
            {
                FabricNameList.Add(name);
            }
        }
Beispiel #10
0
        public FabricCostQueryViewModel(StackPanel stackPanel, StackPanel stackPanelProcessSequence)
        {
            FabricList      = new ObservableCollection <Fabric>(FabricModule.GetFabricList());
            FabricColorList = new ObservableCollection <FabricColor>();
            FabricIngredientProportionGroup.Add(1, new ObservableCollection <FabricIngredientProportion>());

            _stackPanel = stackPanel;
            _stackPanelProcessSequence = stackPanelProcessSequence;
        }
Beispiel #11
0
        public YarnPriceViewModel(StackPanel stackPanel)
        {
            _stackPanel = stackPanel;
            var factoryList = FactoryModule.GetFactoryList().Where(w => w.Process == DataClass.Enumeration.ProcessItem.Yarn);

            FactoryList = new ObservableCollection <Factory>(factoryList);

            IEnumerable <YarnSpecification> yarnSpecificationList = FabricModule.GetYarnSpecificationList();

            YarnSpecificationList = new ObservableCollection <YarnSpecification>(yarnSpecificationList);
        }
Beispiel #12
0
 private async Task<IEnumerable<string>> GetPermissions<T>(FabricModule<T> module, string grain, string securableItemName)
 {
     var permissionResolutionResult = await _permissionResolverService.Resolve(new PermissionResolutionRequest
     {
         SubjectId = module.SubjectId,
         IdentityProvider = module.IdentityProvider,
         Grain = grain,
         SecurableItem = securableItemName,
         UserGroups = await GetGroupsForAuthenticatedUser(module.SubjectId, module.IdentityProvider, module.Context.CurrentUser)
     });
     var permissions = permissionResolutionResult.AllowedPermissions
         .Except(permissionResolutionResult.DeniedPermissions)
         .Select(p => p.ToString());
     return permissions;
 }
Beispiel #13
0
 private void AddYarnPriceExecute()
 {
     if (YarnPrice.Price == 0)
     {
         MessageBox.Show("單價未填!!");
     }
     else if (YarnPrice.YarnSpecificationNo == 0)
     {
         MessageBox.Show("未選擇紗規格!!");
     }
     else
     {
         bool success = FabricModule.InsertYarnPrice(YarnPrice);
         success.CheckSuccessMessageBox("新增成功", "新增失敗");
     }
 }
Beispiel #14
0
        private void AddYarnSpecificationExecute()
        {
            bool success = FabricModule.AddYarnSpecification(YarnSpecification);

            if (success)
            {
                MessageBox.Show("新增成功!!");
                IEnumerable <YarnSpecification> yarnSpecificationList = FabricModule.GetYarnSpecificationList();
                YarnSpecificationList = new ObservableCollection <YarnSpecification>(yarnSpecificationList);
                RaisePropertyChanged("YarnSpecificationList");
            }
            else
            {
                MessageBox.Show("新增失敗!!");
            }
        }
Beispiel #15
0
        private void NewFabricExecute()
        {
            var result = MessageBox.Show(string.Concat(@"是否要新增'", SelectedFabricName, "'?"), "新增布種", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                Fabric fabric = new Fabric()
                {
                    FabricName       = SelectedFabricName,
                    AverageUnitPrice = AverageUnitPrice,
                    AverageCost      = AverageCost,
                    UpdateDate       = DateTime.Now
                };

                int count = FabricModule.AddFabric(fabric);
            }
        }
Beispiel #16
0
        private void ChangeYarn(SpecificationYarnPrice specificationYarnPrice)
        {
            int selectedIndex = DataGridFabricIngredientProportion.SelectedIndex;
            int groupNo       = Convert.ToInt32(ComboBoxGroup.SelectedItem);

            //如果紗成分比例沒有選擇一個色的話則會新增一個比例
            //否則會將選擇到的比例
            if (selectedIndex == -1)
            {
                MessageBox.Show("請選擇一筆要修改的資料!");
            }
            else
            {
                var selectedItem = DataGridFabricIngredientProportion.SelectedItem as FabricIngredientProportion;
                FabricIngredientProportion fabricIngredientProportion = FabricModule.GetFabricIngredientProportion(selectedItem.ProportionNo, selectedItem.Proportion, specificationYarnPrice);
                _dictionaryFabricIngredientProportion[groupNo].RemoveAt(selectedIndex);
                _dictionaryFabricIngredientProportion[groupNo].Insert(selectedIndex, fabricIngredientProportion);
                DataGridFabricIngredientProportion.SelectedIndex = selectedIndex += 1;
            }
        }
Beispiel #17
0
        private void ButtonNewProcessSequence_Click(object sender, RoutedEventArgs e)
        {
            List <ProcessSequenceDetail> processSequenceDetails = _processSequenceDetails.ToList();
            bool isInProcessSequenceColorMapping = FabricModule.CheckIsInProcessSequenceColorMapping(_processSequenceDetails);

            if (isInProcessSequenceColorMapping)
            {
                MessageBox.Show("已存於在資料庫!!");
                return;
            }
            bool success = false;

            if (CheckBoxIsThisColor.IsChecked == true)
            {
                if (ComboBoxProcessGroup.SelectedIndex == -1)
                {
                    List <int> sequenceNoList = FabricModule.InsertProcessSequence(processSequenceDetails);
                    var        processSequenceColorMapping = sequenceNoList.Select(s => new ProcessSequenceColorMapping {
                        ColorNo = _fabricColor.ColorNo, SequenceNo = s
                    });
                    success = FabricModule.InsertProcessSequenceColorMapping(processSequenceColorMapping);
                }
                else
                {
                    var processSequenceColorMapping = processSequenceDetails.Select(s => new ProcessSequenceColorMapping {
                        ColorNo = _fabricColor.ColorNo, SequenceNo = s.SequenceNo
                    });
                    success = FabricModule.InsertProcessSequenceColorMapping(processSequenceColorMapping);
                }
            }
            else
            {
                List <int> sequenceNoList = FabricModule.InsertProcessSequence(processSequenceDetails);
                success = sequenceNoList.Count() == processSequenceDetails.Count();
            }

            success.CheckSuccessMessageBox("新增成功!!", "新增失敗!!");
        }
Beispiel #18
0
        private void ComboBoxFabricColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxGroup.SelectedIndex = -1;
            ComboBox    comboBox    = (ComboBox)sender;
            FabricColor fabricColor = comboBox.SelectedItem as FabricColor;

            if (fabricColor == null)
            {
                return;                     //未知發生的錯誤,有時間再來查看看什麼問題
            }
            var dictionaryFabricIngredientProportion = FabricModule.GetDictionaryFabricIngredientProportion(new List <int> {
                fabricColor.ColorNo
            });

            _dictionaryFabricIngredientProportion = dictionaryFabricIngredientProportion.Count == 0
                                                    ? new Dictionary <int, ObservableCollection <FabricIngredientProportion> > {
                { 1, new ObservableCollection <FabricIngredientProportion>() }
            }
                                                    : dictionaryFabricIngredientProportion;

            DataGridFabricIngredientProportion.ItemsSource = _dictionaryFabricIngredientProportion[_dictionaryFabricIngredientProportion.First().Key];
            ComboBoxGroup.ItemsSource   = _dictionaryFabricIngredientProportion.Select(s => s.Key);
            ComboBoxGroup.SelectedIndex = 0;
        }
Beispiel #19
0
        private void ButtonEditFabricColor_Click(object sender, RoutedEventArgs e)
        {
            bool success = FabricModule.UpdateFabricProportion((DataGridFabricIngredientProportion.ItemsSource as IEnumerable <FabricIngredientProportion>).ToList());

            success.CheckSuccessMessageBox("更新成功!!", "好像有錯誤喔!!");
        }
Beispiel #20
0
        private void AddFabricColorExecute()
        {
            bool success = FabricModule.InsertFabricColor(_fabric.FabricID, FabricColor) == 1;

            success.CheckSuccessMessageBox("新增成功!!", "新增失敗");
        }
Beispiel #21
0
 private void FabricEdit()
 {
     int count = FabricModule.EditFabric(Fabric);
 }
Beispiel #22
0
 public async Task CheckUserAccess<T>(string grain, string securableItemName, FabricModule<T> module, params Predicate<Claim>[] requiredClaims)
 {
     var permissions = (await GetPermissions(module, grain, securableItemName)).ToList();
     module.RequiresPermissionsAndClaims<T>(module.SubjectId, permissions, grain, securableItemName, requiredClaims);
 }
Beispiel #23
0
        public async Task CheckAppAccess<T>(string clientId, string grain, string securableItem, ClientService clientService, FabricModule<T> module, params Predicate<Claim>[] requiredClaims)
        {
            var doesClientOwnItem = false;
            try
            {
                doesClientOwnItem =
                    await clientService.DoesClientOwnItem(clientId, grain, securableItem);
            }
            catch (NotFoundException<SecurableItem>)
            {
                module.AddBeforeHookOrExecute((context) => CreateFailureResponse<T>($"The securableItem: {securableItem} does not exist.",
                    context,
                    HttpStatusCode.BadRequest));
            }
            catch (NotFoundException<Client>)
            {
                doesClientOwnItem = false;
            }

            module.RequiresOwnershipAndClaims<T>(doesClientOwnItem, grain, securableItem, requiredClaims);
        }