Пример #1
0
        /// <summary>
        /// public constrcutor
        /// </summary>
        /// <param name="dispatcher">Dispatcher instance to send updates to DIS.Presentation.KMT. This should be passed null from automated unit tests.</param>
        public SubsidiaryEditorViewModel(ISubsidiaryProxy ssProxy, Subsidiary ss)
        {
            this.ssProxy = ssProxy;

            SubsidiaryTypes = new List<string>();

            SubsidiaryTypes.Add(EnumHelper.GetFieldDecription(InstallType.FactoryFloor.GetType(), InstallType.FactoryFloor.ToString()));
            if (KmtConstants.IsOemCorp)
                SubsidiaryTypes.Insert(0, EnumHelper.GetFieldDecription(InstallType.Tpi.GetType(), InstallType.Tpi.ToString()));

            if (ss == null)
            {
                Subsidiary = new Subsidiary();

                EditMode = false;
                WndTitle = MergedResources.CreateSubSidiaryViewModel_Title_New;
            }
            else
            {
                Subsidiary = ss;

                EditMode = true;
                WndTitle = MergedResources.DLSEditorView_Edit;
            }
            Initialize(Subsidiary);
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ssProxy"></param>
        /// <param name="ss"></param>
        public SubsidiaryEditor(ISubsidiaryProxy ssProxy, Subsidiary ss = null)
        {
            InitializeComponent();

            VM = new SubsidiaryEditorViewModel(ssProxy, ss);
            VM.View = this;
            DataContext = VM;
        }
Пример #3
0
 public void InsertSubsidiary(Subsidiary sub)
 {
     using (var context = GetContext())
     {
         context.Subsidiaries.Add(sub);
         context.SaveChanges();
     }
 }
Пример #4
0
 public void UpdateSubsidiary(Subsidiary subsidiary)
 {
     using (var context = GetContext())
     {
         Subsidiary subToUpdate = GetSubsidiaryById(context, subsidiary.SsId);
         if (subToUpdate == null)
             throw new ApplicationException(string.Format("Subsidiary '{0}' cannot be found.", subsidiary.SsId));
         context.Entry(subToUpdate).CurrentValues.SetValues(subsidiary);
         context.SaveChanges();
     }
 }
Пример #5
0
        /// <summary>
        /// add new Subsidiary
        /// </summary>
        /// <param name="subs"></param>
        public void InsertSubsidiary(Subsidiary subs)
        {
            if (subs == null)
                throw new ApplicationException(string.Format("SubsidiaryManager:InsertSubsidiary - params error."));

            subsRepository.InsertSubsidiary(subs);
        }
Пример #6
0
 private void SearchSubSidiary()
 {
     subsidiarys = new ObservableCollection<Subsidiary>(subProxy.GetSubsidiaries());
     if (subsidiarys.Count > 0)
         selectedSubsidiary = subsidiarys.First();
 }
Пример #7
0
        /// <summary>
        /// Initialize UI according selected subsidiary
        /// </summary>
        /// <param name="current"></param>
        private void Initialize(Subsidiary current)
        {
            try
            {
                DLSName = current.DisplayName;
                DLSType = current.Type;
                if (!string.IsNullOrEmpty(current.ServiceHostUrl))
                {
                    Uri serviceUrl = new Uri(current.ServiceHostUrl);
                    Host = serviceUrl.Host;
                    Port = serviceUrl.Port.ToString(); ;
                }
                UserName = current.UserName;
                AccessKey = current.AccessKey;
                Description = current.Description;

                if (EditMode == false)
                {
                    DLSType = SubsidiaryTypes[0];
                    this.GenerateAccessKey();
                }
            }
            catch (Exception ex)
            {
                ex.ShowDialog();
                ExceptionHandler.HandleException(ex);
            }
        }