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; } }
public frmForging(UserInformation userInformation, string costCentCode) { InitializeComponent(); bll = new ForgingMachine(userInformation); ForgingMachineViewModel vm = new ForgingMachineViewModel(userInformation, costCentCode); this.DataContext = vm; this.Closing += vm.CloseMethodWindow; if (vm.CloseAction == null) { vm.CloseAction = new Action(() => this.Close()); } List <ProcessDesigner.Model.V_TABLE_DESCRIPTION> lstTableDescription = bll.GetTableColumnsSize("DDFORGING_MAC"); this.SetColumnLength <TextBox>(lstTableDescription); }