Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Time sheet Entry :
Mon:04/04/13  Tue:04/05/13  Wed:04/05/13  Thu:04/05/13 Fri:04/05/13 Sat:04/05/13 sun:04/05/13
   7              7           8               8            8               0          0



leave reason : drop down
OT,Sick,Leave,Holiday,Fixed hours per day,

as per the above entry , max working hours of a day is 8. but for monday,tuesday he entered 7,7 so after clicking on the submit there should be one alert message to slect one reason from drop down due the less working hours.

this is the code i used to save the date wise data in to the db.
C#
for (int i = 0; i < 7; i++)
        {

            ManageTimeSheetsModel obj = new ManageTimeSheetsModel();
            obj.EmployeeID = Convert.ToInt32(strvalue.ToString());
            obj.OrganisationID = Convert.ToInt32(ddlOrgId.SelectedItem.Value);
            obj.Timesheetdate = Convert.ToDateTime(weekStartDate.AddDays(i).ToShortDateString());
            if (i == 5 || i == 6)
            {
                obj.Workinghours = Convert.ToDecimal(strHours[i].ToString());
                obj.Leavehours = 0;
                obj.OT = Convert.ToDecimal(strHours[i].ToString());
            }
            else
            {
                obj.Workinghours = (strHours[i].ToString().Length > 0) ? Convert.ToDecimal(strHours[i].ToString()) : 0.0m;
                if ((ResourceManagementConstants.MaxWorkHours - Convert.ToDecimal(strHours[i].ToString())) > 0.0m)
                {
                    obj.Leavehours = (ResourceManagementConstants.MaxWorkHours - Convert.ToDecimal(strHours[i].ToString()));
                }
                else
                {
                    obj.Leavehours = 0.0m;
                }
                if ((Convert.ToDecimal(strHours[i].ToString()) - ResourceManagementConstants.MaxWorkHours) > 0.0m)
                {
                    obj.OT = (Convert.ToDecimal(strHours[i].ToString()) - ResourceManagementConstants.MaxWorkHours);
                }
                else
                {
                    obj.OT = 0.0m;
                }
            }
            obj.status = "Yes";

            obj.AttachmentPath = Server.MapPath("~/Documents/") + Session["ID"].ToString() + "_" +weekStartDate+"_"+ fileName;

            newlist.Add(obj);

        }






i tried to keep the alert like this :

XML
if (Convert.ToDecimal(strHours[i].ToString()) < ResourceManagementConstants.MaxWorkHours && Convert.ToInt32(leavereason[i].ToString()) == 1)
          {
              ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Select the reason ')</script>");

          }
          else if (Convert.ToDecimal(strHours[i].ToString()) > ResourceManagementConstants.MaxWorkHours && Convert.ToInt32(leavereason[i].ToString()) == 1)
          {
              ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Select the reason ')</script>");


          }
Posted
Updated 9-Apr-13 21:15pm
v3
Comments
_Amy 10-Apr-13 2:09am    
Where you are storing this data? Is it in a datatable with day wise columns?
Dhritirao's 10-Apr-13 2:27am    
yes

1 solution

i got it.

XML
if (Convert.ToDecimal(strHours[i].ToString()) < ResourceManagementConstants.MaxWorkHours && Convert.ToInt32(leavereason[i].ToString()) == 1)
          {
              ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language="'javascript'">alert('Select the reason ')</script>");
return;

          }
          else if (Convert.ToDecimal(strHours[i].ToString()) > ResourceManagementConstants.MaxWorkHours && Convert.ToInt32(leavereason[i].ToString()) == 1)
          {
              ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language="'javascript'">alert('Select the reason ')</script>");
return;

          }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900