예제 #1
0
        protected override void Add()
        {
            HoldingViewModel holding =
                new HoldingViewModel(new HoldingModel {
                Name = "New", IpServer = "localhost", Nom = Holdings.Count + 1
            });
            var conf = ConfigTempoSinglenton.GetInstance();

            holding.ConnectionString = string.Format(Entrence.ConectionStringTemplate, holding.IpServer, conf.BaseDbPath, "H" + holding.Nom);
            Holdings.Add(holding);
            if (
                MessageBoxWrapper.Show("Копиране на празна база от темплейтите?", "Предупреждение",
                                       MessageBoxWrapperButton.YesNo) == MessageBoxWrapperResult.Yes)
            {
                IoHelper.DirectoryCopy(ConfigTempoSinglenton.GetInstance().BaseTemplatePath,
                                       Path.Combine(ConfigTempoSinglenton.GetInstance().BaseDbPath, "H" + holding.Nom), true);
            }
            foreach (var item in conf.ConfigNames)
            {
                var spliter = item.Split('|');
                FirmSettingModel newsett = new FirmSettingModel();
                newsett.Key       = spliter[0];
                newsett.Name      = spliter[1];
                newsett.Value     = spliter[2];
                newsett.FirmaId   = 1;
                newsett.HoldingId = holding.Nom;
                conf.FirmSettings.Add(newsett);
            }
            conf.SaveConfiguration();
        }
예제 #2
0
 public FirmSettingViewModel(FirmSettingModel model)
 {
     _fm = model;
 }
예제 #3
0
 protected override void  Save()
 {
     if (this.CanSave())
     {
         //FirmModel transport = CurrentFirma.Clone();
         CurrentFirma.City  = CityItem.LiD;
         CurrentFirma.City1 = CityItem1.LiD;
         if (Mode == EditMode.Add)
         {
             if (Context.Save <FirmModel>(CurrentFirma, true))
             {
                 _AllFirms.Add(new FirmModelWraper(CurrentFirma));
                 ConfigTempoSinglenton currentconfig = ConfigTempoSinglenton.GetInstance();
                 foreach (var item in currentconfig.ConfigNames)
                 {
                     var spliter = item.Split('|');
                     FirmSettingModel newsett = new FirmSettingModel();
                     newsett.Key = spliter[0];
                     if (spliter.Length > 0)
                     {
                         newsett.Name = spliter[1];
                     }
                     if (spliter.Length > 1)
                     {
                         newsett.Value = spliter[2];
                     }
                     newsett.FirmaId   = CurrentFirma.Id;
                     newsett.HoldingId = currentconfig.ActiveHolding;
                     currentconfig.FirmSettings.Add(newsett);
                 }
                 if (CurrentFirma.Id == currentconfig.CurrentFirma.Id)
                 {
                     currentconfig.CurrentFirma = CurrentFirma.Clone();
                 }
                 currentconfig.SaveConfiguration();
                 base.Save();
             }
             else
             {
                 MessageBoxWrapper.Show("Грешка при запис");
             }
         }
         else
         {
             if (!Context.Save <FirmModel>(CurrentFirma, false))
             {
                 MessageBoxWrapper.Show("Грешка при запис");
             }
             else
             {
                 if (CurrentFirmaWraper != null)
                 {
                     CurrentFirmaWraper.CurrentFirma = CurrentFirma;
                 }
                 ConfigTempoSinglenton currentconfig = ConfigTempoSinglenton.GetInstance();
                 if (CurrentFirma.Id == currentconfig.CurrentFirma.Id)
                 {
                     currentconfig.CurrentFirma = CurrentFirma.Clone();
                     currentconfig.SaveConfiguration();
                 }
                 OnPropertyChanged("CurrentFirmaWraper");
                 base.Save();
             }
         }
     }
     else
     {
         MessageBoxWrapper.Show("Невалидни данни! Моля проверете данните маркирани с червено!");
     }
 }