Showing posts with label sql server data base. Show all posts
Showing posts with label sql server data base. Show all posts

Thursday, July 26, 2018

how to perform NESTED IF ELSE in asp.net | sradha webcreations

how to perform NESTED IF ELSE in asp.net 


NESTED IF ELSE
ENTER A NUMBER
OUTPUT

SAVE


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;

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

    }
    protected void ButtonSAVE_Click(object sender, EventArgs e)
    {
        string connectionstring=ConfigurationManager.ConnectionStrings ["dbconnection"].ConnectionString;
        string insertsql = "insert into nestedif(enternumber,output)values(@enternumber,@output)";

        using (SqlConnection myconnection = new SqlConnection(connectionstring))
        {
            myconnection.Open();
            SqlCommand mycommand = new SqlCommand(insertsql,myconnection);
            mycommand.Parameters.AddWithValue("@enteranumber",TextBoxNUMBER.Text);
            mycommand.Parameters.AddWithValue("@output",TextBox2.Text);

            mycommand.ExecuteNonQuery();
            myconnection.Close();
        }

        TextBoxNUMBER.Text=string.Empty;
        TextBox2.Text=string.Empty;

        }

  protected void TextBoxNUMBER_TextChanged(object sender, EventArgs e)
    {
        int iDay = Convert.ToInt32(TextBoxNUMBER.Text);

        if (iDay == 1)
        {
            TextBox2.Text = "SUNDAY";
        }
        else if (iDay == 2)
        {
           TextBox2.Text = "MONDAY";
        }
        else if (iDay == 3)
        {
            TextBox2.Text = "TUESDAY";
        }
        else if (iDay == 4)
        {
            TextBox2.Text = "WEDNESDAY";
        }
        else if (iDay == 5)
        {
            TextBox2.Text = "THURSDAY";
        }
        else if (iDay == 6)
        {
            TextBox2.Text = "FRIDAY";
        }
        else if (iDay == 7)
        {
            TextBox2.Text = "SATURDAY";
        }
        else
        {
            TextBox2.Text = "invalid entry";
        }
    }

}





Wednesday, July 25, 2018

how to calculate salary on the basic of leave day | sradha webcreations

how to calculate salary on the basic of leave day

salary calculation on the basic of leave day



EMP NAME
BASIC SALAR
LEAVE DAY
HRA
TOTAL SALARY

save


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;

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

    }
    protected void TextBoxLEAVE_TextChanged(object sender, EventArgs e)
    {
        string sName = TextBoxNAME.Text;
        double dbasic = Convert.ToDouble(TextBoxBASIC.Text);
        int iLeave = Convert.ToInt32(TextBoxLEAVE.Text);
        double dHra;
        double dTotal;
        if (iLeave >= 15)
        {
            dHra = 0;
        }
        else
        {
            dHra = 1500;
        }
        TextBoxHRA.Text = Convert.ToString(dHra);
        dTotal = dbasic + dHra;
        TextBoxTOTAL.Text = Convert.ToString(dTotal);
    }
    protected void ButtonSAVE_Click(object sender, EventArgs e)
    {
        string ConnectionString= ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString;
        string insertsql = "insert into LeaveDay(name,basic,leave,hra,total)values(@name,@basic,@leave,@hra,@total)";
        using (SqlConnection myconnection = new SqlConnection(ConnectionString))
        {
            myconnection.Open();
    SqlCommand mycommand = new SqlCommand(insertsql,myconnection);
           mycommand.Parameters.AddWithValue("@name",TextBoxNAME.Text);
            mycommand.Parameters.AddWithValue("@basic",TextBoxBASIC.Text);
            mycommand.Parameters.AddWithValue("@leave",TextBoxLEAVE.Text);
    mycommand.Parameters.AddWithValue("@hra",TextBoxHRA.Text);
          mycommand.Parameters.AddWithValue("@total",TextBoxTOTAL.Text);

            mycommand.ExecuteNonQuery();
            myconnection.Close();
        }
        TextBoxNAME.Text = string.Empty;
        TextBoxBASIC.Text = string.Empty;
        TextBoxLEAVE.Text = string.Empty;
        TextBoxHRA.Text = string.Empty;
        TextBoxTOTAL.Text = string.Empty;
        }
}