示例#1
0
        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();
            }
        }
示例#2
0
        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();
        }
示例#3
0
 static void Null()
 {
     Assert.Equal(TryParse.Double(null), None());
 }
示例#4
0
 static void Fail()
 {
     Assert.Equal(TryParse.Double("a"), None());
 }
示例#5
0
 static void Success()
 {
     Assert.Equal(TryParse.Double("1"), Some((double)1));
 }
示例#6
0
 public static double GetDouble(this System.Xml.XmlReader aReader, string aAttribute, double aDefault = 0.0)
 {
     return(TryParse.Double(aReader.GetAttribute(aAttribute), aDefault));
 }