Beispiel #1
0
        private void CalculateAreaButton_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "Triangle")
            {
                AreaValue.Text = shapeCalc.triangleArea(Convert.ToDouble(Input1.Value), Convert.ToDouble(Input2.Value)).ToString();

                SQLiteCommand sqlite_cmd;
                sqlite_cmd             = conn.CreateCommand();
                sqlite_cmd.CommandText = "INSERT INTO AreaValueTable(Shape, Area) VALUES('Triangle ', @area); ";
                sqlite_cmd.Parameters.AddWithValue("@area", Convert.ToDouble(AreaValue.Text));
                sqlite_cmd.ExecuteNonQuery();
            }
            if (comboBox1.Text == "Square")
            {
                AreaValue.Text = shapeCalc.squareArea(Convert.ToDouble(Input1.Value)).ToString();

                SQLiteCommand sqlite_cmd;
                sqlite_cmd             = conn.CreateCommand();
                sqlite_cmd.CommandText = "INSERT INTO AreaValueTable(Shape, Area) VALUES('Square ', @area); ";
                sqlite_cmd.Parameters.AddWithValue("@area", Convert.ToDouble(AreaValue.Text));
                sqlite_cmd.ExecuteNonQuery();
            }
            if (comboBox1.Text == "Rectangle")
            {
                AreaValue.Text = shapeCalc.rectangleArea(Convert.ToDouble(Input1.Value), Convert.ToDouble(Input2.Value)).ToString();

                SQLiteCommand sqlite_cmd;
                sqlite_cmd             = conn.CreateCommand();
                sqlite_cmd.CommandText = "INSERT INTO AreaValueTable(Shape, Area) VALUES('Rectangle ', @area); ";
                sqlite_cmd.Parameters.AddWithValue("@area", Convert.ToDouble(AreaValue.Text));
                sqlite_cmd.ExecuteNonQuery();
            }
            if (comboBox1.Text == "Circle")
            {
                AreaValue.Text = shapeCalc.circleArea(Convert.ToDouble(Input1.Value)).ToString();

                SQLiteCommand sqlite_cmd;
                sqlite_cmd             = conn.CreateCommand();
                sqlite_cmd.CommandText = "INSERT INTO AreaValueTable(Shape, Area) VALUES('Circle ', @area); ";
                sqlite_cmd.Parameters.AddWithValue("@area", Convert.ToDouble(AreaValue.Text));
                sqlite_cmd.ExecuteNonQuery();
            }
            if (comboBox1.Text == "Pentagon")
            {
                AreaValue.Text = shapeCalc.pentagonArea(Convert.ToDouble(Input1.Value)).ToString();

                SQLiteCommand sqlite_cmd;
                sqlite_cmd             = conn.CreateCommand();
                sqlite_cmd.CommandText = "INSERT INTO AreaValueTable(Shape, Area) VALUES('Pentagon ', @area); ";
                sqlite_cmd.Parameters.AddWithValue("@area", Convert.ToDouble(AreaValue.Text));
                sqlite_cmd.ExecuteNonQuery();
            }
        }
 public void PentagonArea()
 {
     Assert.AreEqual(5204.44, shapeCalc.pentagonArea(55));
 }