protected override void Save() { OnPropertyChanged("CurrentFirma"); if (this.CanSave()) { FirmModel transport = CurrentFirma.Clone(); if (Mode == EditMode.Add) { if (context.Save <FirmModel>(transport, true)) { base.Save(); CurrentFirma = transport; } else { MessageBox.Show("Грешка"); } } else { if (!context.Save <FirmModel>(transport, false)) { MessageBox.Show("Грешка"); } else { base.Save(); } } } else { MessageBox.Show("Невалидни данни! Моля проверете данните маркирани с червено!"); } }
protected override void MoveNext() { _oldindex = _currentIndex; if (Mode == EditMode.Edit) { OldFirma = CurrentFirma.Clone(); } _currentIndex++; if (_currentIndex >= _AllFirms.Count) { _currentIndex = 0; } //CurrentFirma = _AllFirms[_currentIndex].CurrentFirma; CurrentFirmaWraper = _AllFirms[_currentIndex]; }
protected override void MoveLast() { _oldindex = _currentIndex; if (_AllFirms.Count > 0) { //CurrentFirma = _AllFirms.Last().CurrentFirma; if (Mode == EditMode.Edit) { _AllFirms[_currentIndex].CurrentFirma = OldFirma; } _currentIndex = AllFirms.Count - 1; CurrentFirmaWraper = _AllFirms[_currentIndex]; OldFirma = CurrentFirma.Clone(); } }
protected override void Update() { OldFirma = CurrentFirma.Clone(); base.Update(); }
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("Невалидни данни! Моля проверете данните маркирани с червено!"); } }