Beispiel #1
0
        public ForgingMachineViewModel(UserInformation userInformation, string entityPrimaryKey)
        {
            bll          = new ForgingMachine(userInformation);
            ActiveEntity = bll.GetEntityByCode(new DDFORGING_MAC()
            {
                COST_CENT_CODE = entityPrimaryKey
            });
            if (!ActiveEntity.IsNotNullOrEmpty())
            {
                ActiveEntity = new DDFORGING_MAC()
                {
                    COST_CENT_CODE = entityPrimaryKey
                };
            }

            MachineTypes = bll.GetForgingMachineTypesByID();
            if (ActiveEntity.MACHINE_TYPE.ToValueAsString().Trim() != "")
            {
                SelectedRow             = new ForgingMachineTypes();
                SelectedRow.DESCRIPTION = ActiveEntity.MACHINE_TYPE;
                for (int ictr = 0; ictr <= MachineTypes.Count - 1; ictr++)
                {
                    if (ActiveEntity.MACHINE_TYPE.Trim() == MachineTypes[ictr].DESCRIPTION.Trim())
                    {
                        SelectedIndexType = ictr;
                        NotifyPropertyChanged("SelectedIndexType");
                    }
                }
            }
            else
            {
                SelectedIndexType = -1;
            }
        }
Beispiel #2
0
        public ObservableCollection <ForgingMachineTypes> GetForgingMachineTypesByID(ForgingMachineTypes paramEntity = null)
        {
            ObservableCollection <ForgingMachineTypes> observableCollection = null;
            List <ForgingMachineTypes> lstEntity = null;

            try
            {
                if (!DB.IsNotNullOrEmpty())
                {
                    return(observableCollection);
                }
                if (paramEntity.IsNotNullOrEmpty() && paramEntity.IDPK.IsNotNullOrEmpty())
                {
                    lstEntity = (from row in DB.ForgingMachineTypes
                                 where row.IDPK == paramEntity.IDPK
                                 select row).ToList <ForgingMachineTypes>();
                }
                else
                {
                    lstEntity = (from row in DB.ForgingMachineTypes
                                 select row).ToList <ForgingMachineTypes>();
                }

                if (lstEntity.IsNotNullOrEmpty())
                {
                    observableCollection = new ObservableCollection <ForgingMachineTypes>();
                    foreach (ForgingMachineTypes item in lstEntity)
                    {
                        observableCollection.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }

            return(observableCollection);
        }