protected void cvAlreadyRegisteredMealsAllowanceEdit_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;

            if (grdProjectTime.Rows.Count > 0)
            {
                foreach (GridViewRow row in grdProjectTime.Rows)
                {
                    if ((row.RowType == DataControlRowType.DataRow) && ((row.RowState == DataControlRowState.Edit) || (row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
                    {
                        int companyId = Int32.Parse(hdfCompanyId.Value);
                        int employeeId = Int32.Parse(hdfEmployeeID.Value);
                        DateTime startDate = tkrdpStartDate.SelectedDate.Value;
                        DateTime lastDate = tkrdpEndDate.SelectedDate.Value;
                        bool isMealsAllowance = false;// ((CheckBox)row.FindControl("ckbxMealsAllowanceEdit")).Checked;
                        int projectTimeId2 = Int32.Parse(((Label)row.FindControl("lblProjectTimeIdEdit")).Text);
                        int projectId = int.Parse(ddlProject.SelectedValue);

                        if (projectId == 35 || projectId == 39 || projectId == 716)
                        {
                            if (isMealsAllowance)
                            {
                                args.IsValid = false;
                            }
                        }
                        else
                        {
                            string mealsCountry = ddlMealsCountry.SelectedValue;
                            int projectTimeId = -1;
                            args.IsValid = true;

                            ProjectTimeTemp projectTimeTemp = new ProjectTimeTemp(projectTimeTDS);
                            bool validMealsAllowance1 = projectTimeTemp.ValidateMealsAllowanceEdit(employeeId, isMealsAllowance, projectTimeId2);
                            if (validMealsAllowance1)
                            {
                                if ((mealsCountry != "-1") && (isMealsAllowance))
                                {
                                    ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway();
                                    if (projectTimeId == -1)
                                    {
                                        if (projectTimeGateway.ExistsMealsAllowanceByEmployeIdDate(employeeId, startDate, companyId))
                                        {
                                            args.IsValid = false;
                                        }
                                    }
                                    else
                                    {
                                        if (projectTimeGateway.ExistsMealsAllowanceByProjectTimeIdEmployeIdDate(projectTimeId, employeeId, startDate, companyId))
                                        {
                                            args.IsValid = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        protected void cvAlreadyRegisteredMealsAllowanceFooter_ServerValidate(object source, ServerValidateEventArgs args)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int employeeId = Int32.Parse(hdfEmployeeID.Value);
            DateTime startDate = tkrdpStartDate.SelectedDate.Value;
            DateTime lastDate = tkrdpEndDate.SelectedDate.Value;
            bool isMealsAllowance = false;// ((CheckBox)grdProjectTime.FooterRow.FindControl("ckbxMealsAllowanceFooter")).Checked;
            string mealsCountry = ddlMealsCountry.SelectedValue;
            int projectTimeId = -1;
            args.IsValid = true;

            int projectId = int.Parse(ddlProject.SelectedValue);

            if (projectId == 35 || projectId == 39 || projectId == 716)
            {
                if (isMealsAllowance)
                {
                    args.IsValid = false;
                }
            }
            else
            {
                ProjectTimeTemp projectTimeTemp = new ProjectTimeTemp(projectTimeTDS);
                bool validMealsAllowance1 = projectTimeTemp.ValidateMealsAllowance(employeeId, isMealsAllowance);
                if (validMealsAllowance1)
                {
                    if ((mealsCountry != "-1") && (isMealsAllowance))
                    {
                        ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway();
                        if (projectTimeId == -1)
                        {
                            if (projectTimeGateway.ExistsMealsAllowanceByEmployeIdDate(employeeId, startDate, companyId))
                            {
                                args.IsValid = false;
                            }
                        }
                        else
                        {
                            if (projectTimeGateway.ExistsMealsAllowanceByProjectTimeIdEmployeIdDate(projectTimeId, employeeId, startDate, companyId))
                            {
                                args.IsValid = false;
                            }
                        }
                    }
                }
            }
        }
        protected void cvAlreadyRegisteredMealsAllowanceFooter_ServerValidate(object source, ServerValidateEventArgs args)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int employeeId = Int32.Parse(((DropDownList)grdProjectTime.FooterRow.FindControl("ddlEmployeesFooter")).SelectedValue);
            DateTime date_ = tkrdpDate_.SelectedDate.Value;
            bool isMealsAllowance = false;// ((CheckBox)grdProjectTime.FooterRow.FindControl("ckbxMealsAllowanceFooter")).Checked;
            string mealsCountry = hdfMealsCountry.Value;
            int projectTimeId = -1;
            args.IsValid = true;

            TeamProjectTime2DetailTemp teamProjectTime2DetailTemp = new TeamProjectTime2DetailTemp(teamProjectTime2TDS);
            bool validMealsAllowance1 = teamProjectTime2DetailTemp.ValidateMealsAllowance(employeeId, isMealsAllowance);
            if (validMealsAllowance1)
            {
                if ((mealsCountry != "-1") && (isMealsAllowance))
                {
                    ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway();
                    if (projectTimeId == -1)
                    {
                        if (projectTimeGateway.ExistsMealsAllowanceByEmployeIdDate(employeeId, date_, companyId))
                        {
                            args.IsValid = false;
                        }
                    }
                    else
                    {
                        if (projectTimeGateway.ExistsMealsAllowanceByProjectTimeIdEmployeIdDate(projectTimeId, employeeId, date_, companyId))
                        {
                            args.IsValid = false;
                        }
                    }
                }
            }
        }
 /// <summary>
 /// ValidateMealsAllowance
 /// </summary>
 /// <param name="projectTimeId">projectTimeId</param>
 /// <param name="employeeId">employeeId</param>
 /// <param name="date_">date_</param>
 /// <param name="mealsCountry">mealsCountry</param>
 /// <param name="mealsAllowance">mealsAllowance</param>
 /// <param name="companyId">companyId</param>
 /// <returns></returns>
 public static bool ValidateMealsAllowance(int projectTimeId, int employeeId, DateTime date_, string mealsCountry, bool mealsAllowance, int companyId)
 {
     if ((mealsCountry != "-1") && (mealsAllowance))
     {
         ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway();
         if (projectTimeId == -1)
         {
             if (projectTimeGateway.ExistsMealsAllowanceByEmployeIdDate(employeeId, date_, companyId))
             {
                 return false;
             }
             else
             {
                 return true;
             }
         }
         else
         {
             if (projectTimeGateway.ExistsMealsAllowanceByProjectTimeIdEmployeIdDate(projectTimeId,employeeId, date_, companyId))
             {
                 return false;
             }
             else
             {
                 return true;
             }
         }
     }
     return true;
 }
        protected void cvAlreadyRegisteredMealsAllowanceEdit_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;

            if (grdProjectTime.Rows.Count > 0)
            {
                foreach (GridViewRow row in grdProjectTime.Rows)
                {
                    if ((row.RowType == DataControlRowType.DataRow) && ((row.RowState == DataControlRowState.Edit) || (row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
                    {
                        int companyId = Int32.Parse(hdfCompanyId.Value);
                        int employeeId = Int32.Parse(((DropDownList)row.FindControl("ddlEmployeesEdit")).SelectedValue);
                        DateTime date_ = tkrdpDate_.SelectedDate.Value;
                        bool isMealsAllowance = false;// ((CheckBox)row.FindControl("ckbxMealsAllowanceEdit")).Checked;
                        int projectTimeId2 = Int32.Parse(((Label)row.FindControl("lblDetailIdEdit")).Text);

                        string mealsCountry = hdfMealsCountry.Value;
                        int projectTimeId = -1;
                        args.IsValid = true;

                        TeamProjectTime2DetailTemp teamProjectTime2DetailTemp = new TeamProjectTime2DetailTemp(teamProjectTime2TDS);
                        bool validMealsAllowance1 = teamProjectTime2DetailTemp.ValidateMealsAllowanceEdit(employeeId, isMealsAllowance, projectTimeId2);
                        if (validMealsAllowance1)
                        {
                            if ((mealsCountry != "-1") && (isMealsAllowance))
                            {
                                ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway();
                                if (projectTimeId == -1)
                                {
                                    if (projectTimeGateway.ExistsMealsAllowanceByEmployeIdDate(employeeId, date_, companyId))
                                    {
                                        args.IsValid = false;
                                    }
                                }
                                else
                                {
                                    if (projectTimeGateway.ExistsMealsAllowanceByProjectTimeIdEmployeIdDate(projectTimeId, employeeId, date_, companyId))
                                    {
                                        args.IsValid = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }