private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedItem == null) { return; } dataGridViewFlights.Rows.Clear(); var selectedTrip = comboBox1.SelectedItem as FlightTrack; foreach (var record in selectedTrip.FlightTripRecord) { var row = new DataGridViewRow { Tag = record }; DataGridViewCell check = new DataGridViewCheckBoxCell() { Value = true }; DataGridViewCell flightNo = new DataGridViewTextBoxCell { Value = record.FlightNo }; DataGridViewCell from = new DataGridViewTextBoxCell { Value = record.StationFrom, Tag = record.StationFrom }; DataGridViewCell to = new DataGridViewTextBoxCell { Value = record.StationTo, Tag = record.StationTo }; DataGridViewCell flightDate = new DataGridViewCalendarCell { Value = DateTime.Today }; DataGridViewCell arrivalDate = new DataGridViewTextBoxCell { Value = record.FlightNumberPeriod.DepartureDate.Date.AddMinutes(record.FlightNumberPeriod.PeriodTo).ToString("HH:mm") }; DataGridViewCell departuteDate = new DataGridViewTextBoxCell { Value = record.FlightNumberPeriod.DepartureDate.Date.AddMinutes(record.FlightNumberPeriod.PeriodFrom).ToString("HH:mm") }; row.Cells.AddRange(check, flightNo, from, to, flightDate, departuteDate, arrivalDate); dataGridViewFlights.Rows.Add(row); } }
private void _animatedThreadWorker_DoLoadFlightCompleted(object sender, RunWorkerCompletedEventArgs e) { if (aircraftFlightEdit == null) { return; } documentControlFlight.CurrentDocument = aircraftFlightEdit.Document; dataGridViewFlights.Rows.Clear(); var row = new DataGridViewRow { Tag = aircraftFlightEdit }; DataGridViewCell check = new DataGridViewCheckBoxCell { Value = _planOpsRecord.ParentFlightId > 0 }; DataGridViewCell flightNo = new DataGridViewTextBoxCell { Value = aircraftFlightEdit.FlightNumber }; DataGridViewCell pageNo = new DataGridViewTextBoxCell { Value = aircraftFlightEdit.PageNo }; DataGridViewCell from = new DataGridViewTextBoxCell { Value = aircraftFlightEdit.StationFromId, Tag = aircraftFlightEdit.StationFromId }; DataGridViewCell to = new DataGridViewTextBoxCell { Value = aircraftFlightEdit.StationToId, Tag = aircraftFlightEdit.StationToId }; DataGridViewCell flightDate = new DataGridViewCalendarCell { Value = aircraftFlightEdit.FlightDate }; DataGridViewCell arrivalDate = new DataGridViewTextBoxCell { Value = aircraftFlightEdit.FlightDate.Date.AddMinutes(aircraftFlightEdit.LDGTime).ToString("HH:mm") }; DataGridViewCell departuteDate = new DataGridViewTextBoxCell { Value = aircraftFlightEdit.FlightDate.Date.AddMinutes(aircraftFlightEdit.TakeOffTime).ToString("HH:mm") }; row.Cells.AddRange(check, flightNo, pageNo, from, to, flightDate, departuteDate, arrivalDate); dataGridViewFlights.Rows.Add(row); }
public DataGridViewColumn GetColumn(ItemSearchPropertyInfo property) { DataGridViewColumn column = null; if (property.PropertyName == "locked_by_id") { var colImage = new DataGridViewImageColumn() { ImageLayout = DataGridViewImageCellLayout.Normal, Image = null, }; property.Label = string.Empty; colImage.DefaultCellStyle.NullValue = null; column = colImage; } else if (property.DataType == PropertyDataType.Boolean) { column = new DataGridViewCheckBoxColumn(true) { FalseValue = 0, TrueValue = 1 }; } else if (property.DataType == PropertyDataType.List) { var source = (property as ListPropertyInfo).ItemsSource; column = new DataGridViewComboBoxColumn() { DataSource = source, DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton, FlatStyle = FlatStyle.Flat }; } else if (property.DataType == PropertyDataType.ColorList) { var source = (property as ColorListPropertyInfo).ColorSource; var template = new DataGridViewComboBoxCellLable() { DataSource = new BindingSource(source, null), DisplayMember = "Value", ValueMember = "Key", DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton, FlatStyle = FlatStyle.Flat, }; column = new DataGridViewComboBoxColumn() { CellTemplate = template, Tag = "color list" }; } else { column = new DataGridViewTextBoxColumn(); if (property.DataType == PropertyDataType.Date && !string.IsNullOrEmpty(property.Pattern)) { DataGridViewCalendarCell cell = new DataGridViewCalendarCell(Utilities.Utils.dateFormatDictionary[property.Pattern], false); column.CellTemplate = cell; } } if (property.DataType == PropertyDataType.Color) { column.Tag = "color"; } column.HeaderText = property.Label; column.Name = property.PropertyName; column.Width = property.Width; //TODO: change to enum. if (!string.IsNullOrEmpty(property.Alignment)) { switch (property.Alignment) { case "left": column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; break; case "center": column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; break; case "right": column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; break; } } //TODO: check to get readonly from property.IsReadonly column.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; column.ReadOnly = true; column.SortMode = DataGridViewColumnSortMode.Programmatic; return(column); }
public DataGridViewCell GetCell(PropertyInfo property) { var lockProperInfo = property as LockedByPropertyInfo; if (lockProperInfo != null) { var cell = new DataGridViewImageCell(); if (lockProperInfo.IsLocked) { cell.Value = Resources.img_locked; } if (!lockProperInfo.IsLockedByMe) { cell.Value = Resources.img_locked_else; } if (!lockProperInfo.IsLocked) { cell.Value = null; } return(cell); } if (property.DataType == PropertyDataType.Boolean) { var cell = new DataGridViewCheckBoxCell(); cell.Value = property.PropertyValue == "1"; return(cell); } if (property.DataType == PropertyDataType.Color) { var cell = new DataGridViewTextBoxCell(); var color = string.IsNullOrEmpty(property.PropertyValue) ? Color.White : System.Drawing.ColorTranslator.FromHtml(property.PropertyValue); cell.Style.BackColor = color; return(cell); } if (property.DataType == PropertyDataType.ColorList) { var colors = (property as ColorListPropertyInfo).ColorSource; var cell = new DataGridViewTextBoxCell(); string value = property.PropertyValue ?? string.Empty; string label; if (!colors.TryGetValue(value, out label)) { label = value; } var color = string.IsNullOrEmpty(value) ? Color.White : ColorTranslator.FromHtml(value); cell.Value = label; cell.Style.BackColor = color; return(cell); } if (property.DataType == PropertyDataType.Date) { var cell = new DataGridViewCalendarCell(); DateTime dt; if (DateTime.TryParse(property.PropertyValue, out dt)) { cell.Value = dt; } else { cell.Value = property.PropertyValue; } return(cell); } if (property.DataType == PropertyDataType.Item) { var cell = new DataGridViewTextBoxCell(); cell.Value = property.Label; return(cell); } var defaultCell = new DataGridViewTextBoxCell(); defaultCell.Value = property.PropertyValue; return(defaultCell); }
private void SetValues(WorkPackageClosingDataGridViewRow row, Audit wp, AbstractPerformanceRecord apr) { row.WorkPackage = wp; row.Record = apr; if (apr != null) { row.ClosingItem = apr.Parent; } if (row.ClosingItem == null || apr == null) { return; } SetLabelsAndText(row); if (apr is DirectiveRecord || apr is MaintenanceCheckRecord) { row.Cells[ColumnClosed.Index].Value = true; //Lifelength performanceSource = apr.OnLifelength; //row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null ? performanceSource.Hours.ToString() : "n/a"; //row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null ? performanceSource.Cycles.ToString() : "n/a"; //row.Cells[ColumnDays.Index].Value = performanceSource.Days != null ? performanceSource.Days.ToString() : "n/a"; row.Cells[ColumnDate.Index].Value = apr.RecordDate; row.PrevPerfDate = apr.PrevPerformanceDate; row.NextPerfDate = apr.NextPerformanceDate; } else if (apr is TransferRecord) { TransferRecord tr = (TransferRecord)apr; if (tr.ItemId > 0) { //если запись о перемещении имеет itemID > 0 //и она не подтвержддена стороной получателя, то ее можно редактировать и удалять //если подтверждена, то редактировать и удалять ее нельзя if (tr.DODR) { row.Cells[ColumnHours.Index].ReadOnly = false; row.PrevPerfDate = tr.PrevPerformanceDate; row.NextPerfDate = tr.TransferDate; } else { row.Cells[ColumnHours.Index].ReadOnly = true; row.PrevPerfDate = tr.PrevPerformanceDate; row.NextPerfDate = tr.NextPerformanceDate; } row.Cells[ColumnCycles.Index].Value = "Transfer to: " + GetDestination(tr); row.Cells[ColumnDate.Index].Value = tr.StartTransferDate; } else { row.Cells[ColumnCycles.Index].Value = "Transfer to: "; row.PrevPerfDate = apr.PrevPerformanceDate; row.NextPerfDate = apr.NextPerformanceDate; } row.Cells[ColumnClosed.Index].Value = true; } DataGridViewCalendarCell cc = row.Cells[ColumnDate.Index] as DataGridViewCalendarCell; if (cc != null) { if (row.PrevPerfDate != null) { cc.MinDate = (DateTime)row.PrevPerfDate; } else { cc.MinDate = DateTimeExtend.GetCASMinDateTime(); } if (row.NextPerfDate != null) { cc.MaxDate = (DateTime)row.NextPerfDate; } else { cc.MaxDate = DateTime.Now; } } row.MinPerfSource = apr.PrevPerformanceSource.IsNullOrZero() ? Lifelength.Zero : apr.PrevPerformanceSource; row.MaxPerfSource = apr.NextPerformanceSource.IsNullOrZero() //TODO:(Evgenii Babak) пересмотреть подход, наработка считается на конец дня, а в метод передаем DateTime.Now(может быть и концом дня) ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(row.ClosingItem.LifeLengthParent, DateTime.Now) : apr.NextPerformanceSource; }
private void SetValues(WorkPackageClosingDataGridViewRow row, Audit wp, NextPerformance nextPerformance) { row.WorkPackage = wp; row.NextPerformance = nextPerformance; if (row.NextPerformance != null) { row.ClosingItem = nextPerformance.Parent; } GetRecordInstance(row, wp, nextPerformance); SetLabelsAndText(row); if (row.ClosingItem == null) { return; } if (row.ClosingItem.IsClosed) { DataGridViewCell cell = row.Cells[ColumnClosed.Index]; cell.Value = false; cell.ReadOnly = true; cell.Style.BackColor = Color.DimGray; cell.ToolTipText = "This item is closed and can't be perform"; SetCellReadOnly(row, new[] { ColumnClosed.Index, ColumnHours.Index, ColumnCycles.Index, ColumnDays.Index, ColumnDate.Index }, false); } if (nextPerformance == null) { return; } row.PrevPerfDate = nextPerformance.PrevPerformanceDate; row.NextPerfDate = nextPerformance.NextPerformanceDate; row.MinPerfSource = nextPerformance.PrevPerformanceSource.IsNullOrZero() ? Lifelength.Zero : nextPerformance.PrevPerformanceSource; row.MaxPerfSource = nextPerformance.NextPerformanceSource.IsNullOrZero() ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(row.ClosingItem.LifeLengthParent, DateTime.Now) : nextPerformance.NextPerformanceSource; row.Cells[ColumnClosed.Index].Value = true; //if(!(row.ClosingItem is Detail)) //{ // Lifelength performanceSource = nextPerformance.PerformanceSource; // row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null ? performanceSource.Hours.ToString() : "n/a"; // row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null ? performanceSource.Cycles.ToString() : "n/a"; // row.Cells[ColumnDays.Index].Value = performanceSource.Days != null ? performanceSource.Days.ToString() : "n/a"; //} if (nextPerformance.PerformanceDate != null) { row.Cells[ColumnDate.Index].Value = (DateTime)nextPerformance.PerformanceDate; } DataGridViewCalendarCell cc = row.Cells[ColumnDate.Index] as DataGridViewCalendarCell; if (cc != null) { if (row.PrevPerfDate != null) { cc.MinDate = (DateTime)row.PrevPerfDate; } else { cc.MinDate = DateTimeExtend.GetCASMinDateTime(); } if (row.NextPerfDate != null) { cc.MaxDate = (DateTime)row.NextPerfDate; } else { cc.MaxDate = DateTime.Now; } } }