Showing posts with label store floating dat ain asp.net. Show all posts
Showing posts with label store floating dat ain asp.net. Show all posts

Tuesday, July 24, 2018

how to calculate PERIMETER OF RECTANGULAR in asp.net | sradha webcreations

PERIMETER OF RECTANGULAR
              ENTER WIDTH

             ENTER HEIGHT

  PERIMETER OF RECTANGULAR


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 BTNCALCULATE_Click(object sender, EventArgs e)
    {
        float fWidth;
        float fHeight;
        float fPerimeter;
        fWidth = Convert.ToInt32(TextBoxWIDTH.Text);
        fHeight = Convert.ToInt32(TextBoxHEIGHT.Text);
        fPerimeter=2*(fWidth+fHeight);
        TextBoxRECTANGULAR.Text = Convert.ToString(fPerimeter);
       
    }
    protected void BTNSAVE_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        string insertSql = "INSERT INTO perimeter(width,height,perimeter) VALUES(@width,@height,@perimeter)";

using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
    SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
    myCommand.Parameters.AddWithValue("@width", TextBoxWIDTH.Text);
    myCommand.Parameters.AddWithValue("@height", TextBoxHEIGHT.Text);
            myCommand.Parameters.AddWithValue("@perimeter",TextBoxRECTANGULAR.Text);

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

        // "Reset" the Subject and Body TextBoxes
        TextBoxWIDTH.Text = string.Empty;
        TextBoxHEIGHT.Text= string.Empty;
        TextBoxRECTANGULAR.Text = string.Empty;
    }
}