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 cvDuplicateMealsAllowanceEdit_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 employeeId = Int32.Parse(hdfEmployeeID.Value);
                        bool isMealsAllowance = false;// ((CheckBox)row.FindControl("ckbxMealsAllowanceEdit")).Checked;
                        int projectTimeId = 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;
                                CustomValidator cvAlreadyRegisterdMealsAllowanceEdit = (CustomValidator)source;
                                cvAlreadyRegisterdMealsAllowanceEdit.ErrorMessage = "Please don't select meals allowance.";
                            }
                        }
                        else
                        {
                            ProjectTimeTemp projectTimeTemp = new ProjectTimeTemp(projectTimeTDS);
                            bool validMealsAllowance1 = projectTimeTemp.ValidateMealsAllowanceEdit(employeeId, isMealsAllowance, projectTimeId);

                            args.IsValid = true;
                            if (!validMealsAllowance1)
                            {
                                args.IsValid = false;
                            }
                        }
                    }
                }
            }
        }