Tuesday, July 24, 2018

how to CONVERSION OF FAHRENHEIT TO CENTIGRADE in Asp.net | sradha webcreations



          ENTER FARENHEIT

          CENTIGRADE



  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 fFarenheit;
        float fcentigrade;
        fFarenheit = Convert.ToInt32(txtfarenheit.Text);
        fcentigrade=(fFarenheit-32)*5/9;
        TXTCENTIGRADE.Text = Convert.ToString(fcentigrade);

    }
  
 protected void btnsave_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        string insertSql = "INSERT INTO conversion(farenheit,centigrade) VALUES(@farenheit,@centigrade)";

        using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
     SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
   myCommand.Parameters.AddWithValue("@farenheit", txtfarenheit.Text);
 myCommand.Parameters.AddWithValue("@centigrade", TXTCENTIGRADE.Text);

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

        // "Reset" the Subject and Body TextBoxes
        txtfarenheit.Text = string.Empty;
        TXTCENTIGRADE.Text = string.Empty;
    }
}
               



https://www.facebook.com/Sradhawebeducation/
                                             

No comments:

Post a Comment