/// <summary> /// Return the size of element accessible by accessor /// </summary> private int getElementSize() { TypeEnum typeAsEnum; TypeEnum.TryParse(type, out typeAsEnum); return(getComponentTypeSize(componentType) * getNbComponents(typeAsEnum)); }
private void btSave_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(tbFromCode.Text) || string.IsNullOrEmpty(tbToCode.Text) || dpOnDay.SelectedDate.Equals(null) || cmbType.SelectedItem == null) { MessageBox.Show("Please input value", "Information"); return; } int id; int.TryParse(tbId.Text, out id); DateTime onDay = dpOnDay.SelectedDate.Value; string fromCodeStr = tbFromCode.Text; string toCodeStr = tbToCode.Text; TypeEnum.TryParse(cmbType.Text, out TypeEnum type); int passengers = (int)sldPassenger.Value; AddNewFlightCallback?.Invoke(new Flight(id, onDay, fromCodeStr, toCodeStr, type, passengers)); DialogResult = true; } catch (DataInvalidException ex) { MessageBox.Show(ex.Message, "Error Information"); } }
public Flight(SqlDataReader reader) { Id = reader.GetInt32(reader.GetOrdinal("Id")); OnDay = Convert.ToDateTime(reader.GetDateTime(reader.GetOrdinal("OnDay"))); FromCode = reader.GetString(reader.GetOrdinal("FromCode")); ToCode = reader.GetString(reader.GetOrdinal("ToCode")); TypeEnum.TryParse(reader.GetString(reader.GetOrdinal("Type")), out _type); Type = _type; Passengers = reader.GetInt32(reader.GetOrdinal("Passengers")); }