void TbxSettingValue_TextChanged(object sender, TextChangedEventArgs e) { TextBox textBox = sender as TextBox; if (textBox == null) { return; } DataGridRow row = Classes.FindItem.FindParentItem <DataGridRow>(textBox); if (row == null) { return; } CRMSetting crmSetting = (CRMSetting)row.Item; if (crmSetting == null) { return; } if (crmSetting.Setting_value != textBox.Text) { crmSetting.Setting_value = textBox.Text; crmSetting.IsSaved = false; } }
void BtnSaveRow_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button == null) { return; } DataGridRow row = Classes.FindItem.FindParentItem <DataGridRow>(button); if (row == null) { return; } CRMSetting crmSetting = (CRMSetting)row.Item; if (crmSetting == null) { return; } if (!crmSetting.save()) { MessageBox.Show(crmSetting.LastError); return; } crmSetting.IsSaved = true; }
DbContext GetDbContext(CRMSetting setting) { if (setting.DatabaseProvider == sqlserver.DatabaseProvider.Name) { return(new CRMDbSqlMigrationSession(setting.ConnectionString)); } else if (setting.DatabaseProvider == postgres.DatabaseProvider.Name) { return(new CRMDbPostgresMigrationSession(setting.ConnectionString)); } else { throw new UnsupportedDatabaseProviderException(setting.DatabaseProvider); } }
public bool @remove <T>(T modelItem) { CRMSetting crmSetting = modelItem as CRMSetting; if (crmSetting == null) { crmSetting.LastError = "Не удалось преобразовать входные данные."; return(false); } if (!_collection.Contains(crmSetting)) { return(true); } return(_collection.Remove(crmSetting)); }
public bool @add <T>(T modelItem) { CRMSetting crmSetting = modelItem as CRMSetting; if (crmSetting == null) { crmSetting.LastError = "Не удалось преобразовать входные данные."; return(false); } CRMSetting exist = getById(crmSetting.Id); if (exist != null || _collection.Contains(crmSetting)) { crmSetting.LastError = "Данная запись уже есть в коллекции."; return(false); } _collection.Add(crmSetting); return(true); }
public PlannedShipmentDateSetWindow(Bid bid, Action <DateTime> okCallback = null, Action cancelCallback = null) { InitializeComponent(); Title = "Установка предполагаемой даты отгрузки для заявки №" + bid.Id.ToString(); defaultBrush = dpPlannedShipmentDate.Background; CRMSetting crmSetting = CRMSettingViewModel.instance().getByMashineName("planned_shipment_day_count"); int dayCount = 0; if (crmSetting != null) { try { dayCount = int.Parse(crmSetting.Setting_value); } catch {} } if (bid.Planned_shipment_date == null) { dpPlannedShipmentDate.SelectedDate = DateTime.Now.AddDays(dayCount); } else { dpPlannedShipmentDate.SelectedDate = bid.Planned_shipment_date; } dpPlannedShipmentDate.SelectedDateChanged += delegate { dpPlannedShipmentDate.Background = defaultBrush; }; tbxComment.Text = bid.Comment; this.bid = bid; this.okCallback = okCallback; this.cancelCallback = cancelCallback; CollectionViewSource viewSource = new CollectionViewSource(); viewSource.Source = TransportCompanyViewModel.instance().Collection; cbxPlannedTransportCompany.ItemsSource = viewSource.View; viewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending)); cbxPlannedTransportCompany.SelectedIndex = -1; }