Wednesday, July 25, 2018

salary calculation on the basic of leave day in asp.net | sradha webcreations

salary calculation on the basic of leave day in asp.net

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;
        }
}


No comments:

Post a Comment