private void BtnBoka_Click(object sender, EventArgs e) { double temp; if (TryParse.Double(tbxAntalDagar, out temp)) { string query = $"INSERT Resor(Namn, Destination, AntalDagar) VALUES('{tbxKund.Text}','{tbxDestination.Text}','{temp}')"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(query, connection)) { command.CommandType = CommandType.Text; command.ExecuteNonQuery(); }; } MessageBox.Show("Resand är bokad", "Bekräftelse", MessageBoxButtons.OK, MessageBoxIcon.Information); FetchFromDB(); tbxKund.Clear();; tbxDestination.Clear(); tbxAntalDagar.Clear(); } }
private void BtnSave_Click(object sender, EventArgs e) { double weight, length, height; AnimalSize temp = null; if (TryParse.Double(tbxWeight, out weight) && TryParse.Double(tbxLength, out length) && TryParse.Double(tbxHeight, out height)) { temp = new AnimalSize((float)weight, (float)length, (float)height); } animal.size = temp; Close(); }
static void Null() { Assert.Equal(TryParse.Double(null), None()); }
static void Fail() { Assert.Equal(TryParse.Double("a"), None()); }
static void Success() { Assert.Equal(TryParse.Double("1"), Some((double)1)); }
public static double GetDouble(this System.Xml.XmlReader aReader, string aAttribute, double aDefault = 0.0) { return(TryParse.Double(aReader.GetAttribute(aAttribute), aDefault)); }