dropdownlist

csharp , db Kuwait
  • 9 years ago

     hai this is ramesh i want to calculate the no of employee working days for employee for this i have designed a login page in that i have login time and logout time .when employee login time is noted and again logout time is noted now i want to calulate the no of working days by taking both these fields for particular months for these i have taken two dropdown list one for empid and another for month now by selecting both these i should get the emp working for particular month can any tell this pls its very urgent

  • 9 years ago

    are you using database?

  • 9 years ago
    [quote user="GueAnaqSelat"]

    are you using database?

    [/quote]

    yes iam using sqlserver2005.actually i have tried this code

     cn.Open();
            Session["item"] = DropDownList1.SelectedItem.Text;

            if (DropDownList2.SelectedIndex == 0)
            {
                string i;
                cn.Open();
                SqlCommand cmd = new SqlCommand("select sum(datediff(minute,logintime,logouttime)) from login where empid='" + DropDownList1.SelectedItem.Text + "' and date between '1/1/2008' and '1/31/2008'", cn);
                i = cmd.ExecuteReader().ToString();
                if (int.Parse(i) > 0)
                {
                    int hours, totdays = 27, days, ot;
                    hours = int.Parse(i) / 60;
                    days = hours / 8;
                    ot = hours % 8;
                    SqlCommand cmd1 = new SqlCommand("update payslips set empworkingdays='" + days + "',totalworkingdays='" + totdays + "',ot='" + ot + "'", cn);
                    //SqlCommand cmd1 = new SqlCommand("insert into payslips(empworkingdays,totalworkingdays,ot) values ('" + days + "','" + totdays + "','" + ot + "')", cn);
                    cmd1.ExecuteNonQuery();
                }
                else
                {
                    Label4.Text = "no data";

                }

    autually i have tried for one month like january but iam not getting[quote user="GueAnaqSelat"]

    are you using database?

    [/quote] 
  • 9 years ago

    why you want to use datediff? instead u can use distinct all the particular emloyee for that particula login date and logout time. and count them

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan