Tuesday, July 24, 2018

how to calculate AREA OF A CIRCLE in asp.net | sradha webcreations



AREA OF A CIRCLE


            ENTER RADIUS OF A CIRCLE


            THE AREA OF CIRCLE IS




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonCALCULATE_Click(object sender, EventArgs e)
    {
        float fRadius;
        float fArea;

        fRadius = Convert.ToInt32(TXTRADIUS.Text);
        fArea = (3*(fRadius*fRadius));
        TXTAREA.Text = Convert.ToString(fArea);

    }
    protected void ButtonSAVE_Click(object sender, EventArgs e)
    {
  string connectionString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
string insertSql = "INSERT INTO circle(radious,area) VALUES(@radious,@area)";

        using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
  SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
  myCommand.Parameters.AddWithValue("@radious", TXTRADIUS.Text);
  myCommand.Parameters.AddWithValue("@area", TXTAREA.Text);

            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }

        // "Reset" the Subject and Body TextBoxes
        TXTRADIUS.Text = string.Empty;
        TXTAREA.Text = string.Empty;
        
    }
}

No comments:

Post a Comment