예제 #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();
            }
        }
예제 #2
0
 public void CircleArea()
 {
     Assert.AreEqual(78.5, shapeCalc.circleArea(5));
 }