Tuesday, July 24, 2018

how to calculate DAILY WAGES CALCULATION. in asp.net | sradha webcreations

                                   DAILY WAGES CALCULATION.

LABOUR NAME
DATE
WORKING HOURS
PER HOUR
TOTAL


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 dailyWages : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonTOTAL_Click(object sender, EventArgs e)
    {
        string sLabourName;
        string sDate;
        float fWorkingHours;
        float fPerHours;
        float fTotal;

        sLabourName = TextBoxLABOUR.Text;
        sDate = TextBoxDATE.Text;
        fWorkingHours = Convert.ToInt32(TextBoxWORKING.Text);
        fPerHours = Convert.ToInt32(TextBoxPER.Text);
        fTotal = fWorkingHours * fPerHours;
        TextBoxTOTAL.Text = Convert.ToString(fTotal);

    }
   
protected void ButtonSAVE_Click(object sender, EventArgs e)
    {
        string connectionstring=ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;

        string insertsql = "insert into dailywages (labourname,date,workinghours,perhours,total) values(@labourname,@date,@workinghours,@perhours,@total)";

        using (SqlConnection myconnection = new SqlConnection(connectionstring))
        {
            myconnection.Open();
            SqlCommand mycommand = new SqlCommand(insertsql,myconnection);
            mycommand.Parameters.AddWithValue("@labourname",TextBoxLABOUR.Text);
            mycommand.Parameters.AddWithValue("@date",TextBoxDATE.Text);
            mycommand.Parameters.AddWithValue("@workinghours",TextBoxWORKING.Text);
            mycommand.Parameters.AddWithValue("@perhours",TextBoxPER.Text);
            mycommand.Parameters.AddWithValue("@total",TextBoxTOTAL.Text);
            mycommand.ExecuteNonQuery();
            myconnection.Close();
                     
        }
        TextBoxLABOUR.Text = string.Empty;
        TextBoxDATE.Text = string.Empty;
        TextBoxWORKING.Text = string.Empty;
        TextBoxPER.Text = string.Empty;
        TextBoxTOTAL.Text = string.Empty;
    }
}



No comments:

Post a Comment