string getMessageBody() { int transportCompanyId = (int)cbxTransportCompany.SelectedValue; TransportCompany transportCompany = TransportCompanyViewModel.instance().getById(transportCompanyId); if (transportCompany == null) { return(""); } MessageTemplates messageTemplate = MessageTemplatesViewModel.instance().getById(transportCompany.Id_message_template); if (messageTemplate == null) { return(""); } string msg = messageTemplate.Template; msg = msg.Replace("{SHIPMENT_DATE}", dpShipmentDate.SelectedDate.Value.ToString("dd.MM.yyyy")); msg = msg.Replace("{TRANSPORT_COMPANY_NAME}", transportCompany.Name); msg = msg.Replace("{WAYBILL}", tbxWaybill.Text); msg = msg.Replace("{TRANSPORT_COMPANY_SITE}", transportCompany.Site); return(msg); }
public TransportCompanyWindow() { InitializeComponent(); viewSource.Source = TransportCompanyViewModel.instance().Collection; viewSource.Filter += delegate(object sender, FilterEventArgs e) { TransportCompany transportCompany = e.Item as TransportCompany; if (transportCompany == null) { return; } e.Accepted = transportCompany.IsVisible; }; viewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending)); DataContext = new { TransportCompanyCollection = viewSource.View }; }
public BidShipmentSaveWindow(Bid bid, Action callback = null) { InitializeComponent(); defaultBrush = cbxTransportCompany.Background; Title += bid.Id.ToString(); current_archive = bid.Is_archive; tbxComment.Text = bid.Comment; this.bid = bid; this.callback = callback; CollectionViewSource viewSource = new CollectionViewSource(); viewSource.Source = TransportCompanyViewModel.instance().Collection; cbxTransportCompany.ItemsSource = viewSource.View; viewSource.SortDescriptions.Add(new SortDescription("Row_order", ListSortDirection.Descending)); cbxTransportCompany.SelectedIndex = -1; if (bid.Id_transport_company != null) { cbxTransportCompany.SelectedValue = bid.Id_transport_company; } tbxWaybill.Text = bid.Waybill; bidFilesViewSource.Source = bid.BidFilesCollection; bidFilesViewSource.Filter += delegate(object sender, FilterEventArgs e) { BidFiles bidFiles = e.Item as BidFiles; if (bidFiles == null) { e.Accepted = false; return; } e.Accepted = bidFiles.IsCurrent; }; DataContext = new { BidFilesCollection = bidFilesViewSource.View, }; }
string getTheme() { int transportCompanyId = (int)cbxTransportCompany.SelectedValue; TransportCompany transportCompany = TransportCompanyViewModel.instance().getById(transportCompanyId); if (transportCompany == null) { return(""); } MessageTemplates messageTemplate = MessageTemplatesViewModel.instance().getById(transportCompany.Id_message_template); if (messageTemplate == null) { return(""); } return(messageTemplate.Theme); }
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; }
void TbxSearch_TextChanged(object sender, TextChangedEventArgs e) { TransportCompanyViewModel.instance().search(tbxSearch.Text); viewSource.View.Refresh(); }
//распределние между транспортными компаниями private void TransportCompanyDistribution() { Dictionary <int, int> transportCompanyDict = new Dictionary <int, int>(); for (int i = 0; i < archiveBid.Count; i++) { if (archiveBid[i].Id_transport_company == null) { continue; } if (!transportCompanyDict.ContainsKey((int)archiveBid[i].Id_transport_company)) { transportCompanyDict.Add((int)archiveBid[i].Id_transport_company, 1); } else { transportCompanyDict[(int)archiveBid[i].Id_transport_company]++; } } if (transportCompanyDict.Count == 0) { return; } ReportRow rowH = new ReportRow(); rowH.Add(new ReportCell("Выбор транспортной компании:")); Rows.Add(rowH); ReportRow rowT = new ReportRow(); rowT.Add(new ReportCell("Наименование") { BorderColor = System.Drawing.Color.Black, ColumnSpan = 1 }); rowT.Add(null); rowT.Add(new ReportCell("Кол-во раз") { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); Rows.Add(rowT); foreach (KeyValuePair <int, int> kv in transportCompanyDict.OrderByDescending(x => x.Value)) { TransportCompany transportCompany = TransportCompanyViewModel.instance().getById(kv.Key); if (transportCompany == null) { continue; } ReportRow row = new ReportRow(); row.Add(new ReportCell(transportCompany.Name) { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); row.Add(null); row.Add(new ReportCell(kv.Value.ToString()) { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); Rows.Add(row); } }