protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["StaffFullName"] != null)
            {
                hlName.Text = Session["StaffFullName"].ToString();
            }
            if (!Page.IsPostBack)
            {
                DayCareBAL.SchoolYearService proxySchoolYear = new DayCareBAL.SchoolYearService();
                Guid SchoolId = new Guid();
                if (Session["SchoolId"] != null)
                {
                    SchoolId = new Guid(Session["SchoolId"].ToString());
                }
                ddlSchoolYear.DataSource     = proxySchoolYear.LoadAllSchoolYear(SchoolId);
                ddlSchoolYear.DataTextField  = "Year";
                ddlSchoolYear.DataValueField = "Id";
                ddlSchoolYear.DataBind();

                if (Session["CurrentSchoolYearId"] != null)
                {
                    ddlSchoolYear.SelectedValue = Session["CurrentSchoolYearId"].ToString();
                }
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SchoolId"] == null)
            {
                Response.Redirect("~/Login.aspx");
            }
            if (!IsPostBack)
            {
                DayCareBAL.SchoolYearService proxySchoolYear = new DayCareBAL.SchoolYearService();
                Guid SchoolId = new Guid();
                if (Session["SchoolId"] != null)
                {
                    SchoolId = new Guid(Session["SchoolId"].ToString());
                }
                ddlSchoolYear.DataSource     = proxySchoolYear.LoadAllSchoolYear(SchoolId);
                ddlSchoolYear.DataTextField  = "Year";
                ddlSchoolYear.DataValueField = "Id";
                ddlSchoolYear.DataBind();

                if (ddlSchoolYear.Items != null && ddlSchoolYear.Items.Count > 0)
                {
                    ddlSchoolYear.SelectedValue = Convert.ToString(proxySchoolYear.GetCurrentSchoolYear(SchoolId));
                }
            }
        }
예제 #3
0
        protected void rgSchoolYear_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DayCareBAL.SchoolYearService proxySchoolYear = new DayCareBAL.SchoolYearService();
            Guid SchoolId = new Guid();

            if (Session["SchoolId"] != null)
            {
                SchoolId = new Guid(Session["SchoolId"].ToString());
            }
            List <DayCarePL.SchoolYearProperties> lstSchoolYear = proxySchoolYear.LoadSchoolYear(SchoolId);

            rgSchoolYear.DataSource = lstSchoolYear;
            objCurrentYear          = lstSchoolYear.Find(i => i.CurrentId.Equals(true));
        }
예제 #4
0
 public void GetPreSchoolYearOfSelectedSchoolYear(Guid Schoold, Guid CurrentSchoolYearId)
 {
     try
     {
         DayCareBAL.SchoolYearService proxySchoolYear            = new DayCareBAL.SchoolYearService();
         List <DayCarePL.SchoolYearListProperties> lstSchoolYear = proxySchoolYear.GetPreviousYearOfSelectedCurrentYear(Schoold, CurrentSchoolYearId);
         if (lstSchoolYear != null)
         {
             ddlPrevSchoolyearOfSelectedCurrentSchoolYear.DataSource     = lstSchoolYear;
             ddlPrevSchoolyearOfSelectedCurrentSchoolYear.DataTextField  = "Year";
             ddlPrevSchoolyearOfSelectedCurrentSchoolYear.DataValueField = "SchoolYearId";
             ddlPrevSchoolyearOfSelectedCurrentSchoolYear.DataBind();
             ddlPrevSchoolyearOfSelectedCurrentSchoolYear.SelectedIndex = 0;
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #5
0
        public static bool IsCurrentYear(Guid CurrentYearId, Guid SchoolId)
        {
            try
            {
                DayCareBAL.SchoolYearService proxySchoolYear = new DayCareBAL.SchoolYearService();

                if (CurrentYearId.Equals(proxySchoolYear.GetCurrentSchoolYear(SchoolId)))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #6
0
        //Dt: 9May2013 By: A
        public static void GetChildProgEnrollmentFeeDetail(Guid SchoolId, Guid SchoolYearId, Guid StaffId)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.Ledger, "GetChildProgEnrollmentFeeDetail", "GetChildProgEnrollmentFeeDetail method called", DayCarePL.Common.GUID_DEFAULT);
            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.Ledger, "GetChildProgEnrollmentFeeDetail", "Debug GetChildProgEnrollmentFeeDetail called", DayCarePL.Common.GUID_DEFAULT);
                DayCareBAL.LedgerService proxyLedger = new DayCareBAL.LedgerService();

                DayCareBAL.SchoolYearService proxySchoolYear = new DayCareBAL.SchoolYearService();
                if (proxySchoolYear.IsSelectedYearPrevYearORNot(SchoolId, SchoolYearId))//only prev year can only allow to edit closing balance. because in current year or in future year closing balance is not genrated in these year
                {
                    List <DayCarePL.ChildProgEnrollmentProperties> lstChildProgEnrollmentFeeDetail = proxyLedger.GetChildProgEnrollmentFeeDetail(SchoolYearId, new Guid(DayCarePL.Common.GUID_DEFAULT));
                    if (lstChildProgEnrollmentFeeDetail != null)
                    {
                        bool result = false;
                        List <DayCarePL.LedgerProperties> lstChildEnrollForLedger = new List <DayCarePL.LedgerProperties>();
                        DayCarePL.LedgerProperties        objChildEnrollForLedger = null;
                        foreach (DayCarePL.ChildProgEnrollmentProperties objChildProgEnrollmentFeeDetail in lstChildProgEnrollmentFeeDetail)
                        {
                            string   strDay = "";
                            DateTime StartDate = DateTime.Now, EndDate = DateTime.Now;
                            if (objChildProgEnrollmentFeeDetail.StartDate != null)
                            {
                                StartDate = objChildProgEnrollmentFeeDetail.StartDate.Value;
                            }
                            if (objChildProgEnrollmentFeeDetail.EndDate != null)
                            {
                                EndDate = objChildProgEnrollmentFeeDetail.EndDate.Value;
                            }
                            objChildEnrollForLedger = new DayCarePL.LedgerProperties();

                            #region Weekly
                            switch (objChildProgEnrollmentFeeDetail.EffectiveWeekDay)
                            {
                            case 1:
                            {
                                strDay = "Monday";
                                break;
                            }

                            case 2:
                            {
                                strDay = "Tuesday";
                                break;
                            }

                            case 3:
                            {
                                strDay = "Wednesday";
                                break;
                            }

                            case 4:
                            {
                                strDay = "Thursday";
                                break;
                            }

                            case 5:
                            {
                                strDay = "Friday";
                                break;
                            }
                            }
                            if (objChildProgEnrollmentFeeDetail.EffectiveWeekDay != null && objChildProgEnrollmentFeeDetail.EffectiveWeekDay != 0)
                            {
                                DateTime?OldDate = proxyLedger.GetLastTransactionDate(SchoolYearId, objChildProgEnrollmentFeeDetail.ChildFamilyId, objChildProgEnrollmentFeeDetail.ChildDataId, objChildProgEnrollmentFeeDetail.SchoolProgramId);
                                if (OldDate != null)
                                {
                                    DateTime LastDate = OldDate.Value;
                                    if (LastDate.Equals(new DateTime()))
                                    {
                                        LastDate = StartDate;
                                    }
                                    //else
                                    //{
                                    //    LastDate = LastDate.AddDays(7);
                                    //}
                                    while (LastDate.Date <= DateTime.Now.Date && LastDate.Date <= EndDate.Date)
                                    {
                                        if (LastDate.DayOfWeek.ToString().ToLower().Equals(strDay.ToLower()))
                                        {
                                            break;
                                        }
                                        LastDate = LastDate.AddDays(1);
                                    }
                                    DateTime TranDate;
                                    if (!LastDate.Equals(new DateTime()))
                                    {
                                        while (LastDate.Date <= DateTime.Now.Date && LastDate.Date <= EndDate.Date)
                                        {
                                            DateTime.TryParse(LastDate.Month + "/" + LastDate.Day + "/" + LastDate.Year, out TranDate);
                                            if (TranDate.Equals(new DateTime()))
                                            {
                                                TranDate = new DateTime(LastDate.Year, LastDate.Month, System.DateTime.DaysInMonth(LastDate.Year, LastDate.Month));
                                            }
                                            if (!TranDate.Equals(new DateTime()) && TranDate.Date <= System.DateTime.Now.Date && TranDate.Date <= EndDate.Date && !OldDate.Value.Date.Equals(LastDate.Date) && TranDate.Date >= StartDate.Date)
                                            {
                                                objChildEnrollForLedger = new DayCarePL.LedgerProperties();
                                                objChildEnrollForLedger.TransactionDate = TranDate + DateTime.Now.TimeOfDay;
                                                objChildEnrollForLedger.Comment         = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName;// +" " + strDay;
                                                //objChildEnrollForLedger.Detail = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName + " " + strDay;
                                                SetLegderProperties(SchoolYearId, lstChildEnrollForLedger, objChildEnrollForLedger, objChildProgEnrollmentFeeDetail, StaffId);
                                            }
                                            LastDate = TranDate.AddDays(7);
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region Monthly
                            if (objChildProgEnrollmentFeeDetail.EffectiveMonthDay != null)// && objChildProgEnrollmentFeeDetail.EffectiveMonthDay.Equals(DateTime.Now.Month))
                            {
                                DateTime?OldDate = proxyLedger.GetLastTransactionDate(SchoolYearId, objChildProgEnrollmentFeeDetail.ChildFamilyId, objChildProgEnrollmentFeeDetail.ChildDataId, objChildProgEnrollmentFeeDetail.SchoolProgramId);
                                if (OldDate != null)
                                {
                                    DateTime LastDate = OldDate.Value;
                                    if (LastDate.Equals(new DateTime()))
                                    {
                                        LastDate = StartDate;
                                    }
                                    //else
                                    //{
                                    //    LastDate = LastDate.AddMonths(1);
                                    //}
                                    DateTime TranDate;
                                    if (!LastDate.Equals(new DateTime()))
                                    {
                                        while (LastDate.Date <= DateTime.Now.Date && LastDate.Date <= EndDate.Date)
                                        {
                                            DateTime.TryParse(LastDate.Month + "/" + objChildProgEnrollmentFeeDetail.EffectiveMonthDay.Value + "/" + LastDate.Year, out TranDate);
                                            if (TranDate.Equals(new DateTime()))
                                            {
                                                TranDate = new DateTime(LastDate.Year, LastDate.Month, System.DateTime.DaysInMonth(LastDate.Year, LastDate.Month));
                                            }
                                            if (!TranDate.Equals(new DateTime()) && TranDate.Date <= System.DateTime.Now.Date && TranDate.Date <= EndDate.Date && !OldDate.Value.Date.Equals(LastDate.Date) && TranDate.Date >= StartDate.Date)
                                            {
                                                objChildEnrollForLedger = new DayCarePL.LedgerProperties();
                                                objChildEnrollForLedger.TransactionDate = TranDate + DateTime.Now.TimeOfDay;
                                                objChildEnrollForLedger.Comment         = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName;//  + " " + objChildEnrollForLedger.TransactionDate.ToShortDateString();
                                                //objChildEnrollForLedger.Detail = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName + " " + objChildEnrollForLedger.TransactionDate.ToShortDateString();
                                                SetLegderProperties(SchoolYearId, lstChildEnrollForLedger, objChildEnrollForLedger, objChildProgEnrollmentFeeDetail, StaffId);
                                            }
                                            LastDate = TranDate.AddMonths(1);
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region Yearly
                            if (objChildProgEnrollmentFeeDetail.EffectiveYearDate != null)// && objChildProgEnrollmentFeeDetail.EffectiveYearDate.Value.
                            {
                                DateTime?OldDate = proxyLedger.GetLastTransactionDate(SchoolYearId, objChildProgEnrollmentFeeDetail.ChildFamilyId, objChildProgEnrollmentFeeDetail.ChildDataId, objChildProgEnrollmentFeeDetail.SchoolProgramId);
                                if (OldDate != null)
                                {
                                    DateTime LastDate = OldDate.Value;
                                    if (LastDate.Equals(new DateTime()))
                                    {
                                        LastDate = StartDate;
                                    }
                                    //else
                                    //{
                                    //    LastDate = LastDate.AddYears(1);
                                    //}
                                    DateTime TranDate;
                                    if (!LastDate.Equals(new DateTime()))
                                    {
                                        while (LastDate.Date <= System.DateTime.Now.Date && LastDate.Date <= EndDate.Date)
                                        {
                                            DateTime.TryParse(objChildProgEnrollmentFeeDetail.EffectiveYearDate.Value.Month + "/" + objChildProgEnrollmentFeeDetail.EffectiveYearDate.Value.Day + "/" + LastDate.Year, out TranDate);
                                            if (!TranDate.Equals(new DateTime()) && TranDate.Date <= System.DateTime.Now.Date && TranDate.Date <= EndDate.Date && !OldDate.Value.Date.Equals(LastDate.Date) && TranDate.Date >= StartDate.Date)
                                            {
                                                objChildEnrollForLedger = new DayCarePL.LedgerProperties();
                                                objChildEnrollForLedger.TransactionDate = TranDate + DateTime.Now.TimeOfDay;
                                                objChildEnrollForLedger.Comment         = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName;//  + " " + objChildEnrollForLedger.TransactionDate.ToShortDateString();
                                                //objChildEnrollForLedger.Detail = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName + " " + objChildEnrollForLedger.TransactionDate.ToShortDateString();
                                                SetLegderProperties(SchoolYearId, lstChildEnrollForLedger, objChildEnrollForLedger, objChildProgEnrollmentFeeDetail, StaffId);
                                            }
                                            LastDate = TranDate.AddYears(1);
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region One Time
                            if (objChildProgEnrollmentFeeDetail.EffectiveMonthDay == null && (objChildProgEnrollmentFeeDetail.EffectiveWeekDay == null || objChildProgEnrollmentFeeDetail.EffectiveWeekDay == 0) && objChildProgEnrollmentFeeDetail.EffectiveYearDate == null)
                            {
                                DateTime?OldDate = proxyLedger.GetLastTransactionDate(SchoolYearId, objChildProgEnrollmentFeeDetail.ChildFamilyId, objChildProgEnrollmentFeeDetail.ChildDataId, objChildProgEnrollmentFeeDetail.SchoolProgramId);
                                if (OldDate != null)
                                {
                                    DateTime LastDate = OldDate.Value;
                                    if (LastDate.Equals(new DateTime()))
                                    {
                                        LastDate = StartDate;
                                    }
                                    //else
                                    //{
                                    //    LastDate = LastDate.AddMonths(1);
                                    //}
                                    if (!LastDate.Equals(new DateTime()))
                                    {
                                        if (LastDate.Date <= DateTime.Now.Date)
                                        {
                                            if (OldDate.Value.Equals(new DateTime()))
                                            {
                                                objChildEnrollForLedger = new DayCarePL.LedgerProperties();
                                                objChildEnrollForLedger.TransactionDate = LastDate.Date + DateTime.Now.TimeOfDay;
                                                objChildEnrollForLedger.Comment         = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName;//  + " " + objChildEnrollForLedger.TransactionDate.ToShortDateString();
                                                //objChildEnrollForLedger.Detail = objChildProgEnrollmentFeeDetail.ProgramTitle + " " + objChildProgEnrollmentFeeDetail.FeesPeriodName + " " + objChildEnrollForLedger.TransactionDate.ToShortDateString();
                                                SetLegderProperties(SchoolYearId, lstChildEnrollForLedger, objChildEnrollForLedger, objChildProgEnrollmentFeeDetail, StaffId);
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion
                        }
                        if (lstChildEnrollForLedger != null && lstChildEnrollForLedger.Count > 0)
                        {
                            result = proxyLedger.Save(lstChildEnrollForLedger);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.LedgerOfFamily, "GetChildProgEnrollmentFeeDetail", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
            }
        }
예제 #7
0
        protected void rgSchoolYear_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem       item = e.Item as GridEditableItem;
                TableCell              cell;
                RequiredFieldValidator validator;

                if (item != null)
                {
                    ValidationSummary validationsum = new ValidationSummary();
                    validationsum.ID             = "validationsum1";
                    validationsum.ShowMessageBox = true;
                    validationsum.ShowSummary    = false;
                    validationsum.DisplayMode    = ValidationSummaryDisplayMode.SingleParagraph;

                    DropDownList ddlYear = item["Year"].FindControl("ddlYear") as DropDownList;
                    if (ddlYear != null)
                    {
                        cell      = (TableCell)ddlYear.Parent;
                        validator = new RequiredFieldValidator();
                        if (cell != null)
                        {
                            ddlYear.ID = "ddlYear";
                            validator.ControlToValidate = ddlYear.ID;
                            validator.ErrorMessage      = "Please select SchoolYear \n";
                            validator.InitialValue      = "-1";
                            validator.SetFocusOnError   = true;
                            validator.Display           = ValidatorDisplay.None;
                            cell.Controls.Add(validator);
                            cell.Controls.Add(validationsum);
                        }
                    }
                    RadDatePicker rdpStartDate = item["StartDate"].FindControl("rdpStartDate") as RadDatePicker;
                    RadDatePicker rdpEndDate   = item["EndDate"].FindControl("rdpEndDate") as RadDatePicker;

                    if (Session["SchoolId"] == null || Session["CurrentSchoolYearId"] == null)
                    {
                        Response.Redirect("~/Login.aspx");
                    }

                    DayCareBAL.SchoolYearService   proxySchoolYear = new DayCareBAL.SchoolYearService();
                    DayCarePL.SchoolYearProperties ObjSchoolYear   = proxySchoolYear.LoadSchoolYearDtail(new Guid(Session["SchoolId"].ToString()), new Guid(Session["CurrentSchoolYearId"].ToString()));



                    if (rdpStartDate != null)
                    {
                        //   rdpStartDate.MinDate = ObjSchoolYear.EndDate.Value.AddDays(1);
                        // rdpEndDate.MinDate = ObjSchoolYear.EndDate.Value.AddDays(1);

                        cell = (TableCell)rdpStartDate.Parent;
                        //TableCell cell1 = (TableCell)rdpStartDate.Parent;
                        validator = new RequiredFieldValidator();
                        //CompareValidator compare = item["EndDate"].FindControl("cmp") as CompareValidator; //new CompareValidator();
                        //CompareValidator compare = new CompareValidator();
                        if (cell != null)
                        {
                            rdpStartDate.ID             = "rdpStartDate";
                            rdpEndDate.ID               = "rdpEndDate";
                            validator.ControlToValidate = rdpStartDate.ID;
                            validator.ErrorMessage      = "Please select Start Date \n";
                            //validator.InitialValue = "-1";
                            validator.SetFocusOnError = true;
                            validator.Display         = ValidatorDisplay.None;
                            cell.Controls.Add(validator);
                            cell.Controls.Add(validationsum);

                            //compare.Type = ValidationDataType.Date;
                            //compare.Operator = ValidationCompareOperator.GreaterThan;
                            //compare.ControlToValidate = rdpEndDate.ID;
                            //compare.ControlToCompare = r.ID;
                            //compare.ErrorMessage = "Start Date must less than End Date.";
                            //compare.SetFocusOnError = true;
                            //compare.Display = ValidatorDisplay.None;
                            //cell.Controls.Add(compare);
                            //cell.Controls.Add(validationsum);
                        }
                    }
                }
            }
        }
예제 #8
0
        public bool SubmitRecord(object sender, GridCommandEventArgs e)
        {
            DayCarePL.Logger.Write(DayCarePL.LogType.INFO, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", "Submit record method called", DayCarePL.Common.GUID_DEFAULT);
            Guid SchoolYearId = new Guid();
            bool result       = false;

            try
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.DEBUG, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", "Debug Submit Record Of SchoolYear", DayCarePL.Common.GUID_DEFAULT);
                DayCareBAL.SchoolYearService   proxySchoolYear = new DayCareBAL.SchoolYearService();
                DayCarePL.SchoolYearProperties objSchoolYear   = new DayCarePL.SchoolYearProperties();

                GridDataItem item       = (GridDataItem)e.Item;
                var          InsertItem = e.Item as Telerik.Web.UI.GridEditableItem;

                Telerik.Web.UI.GridEditManager editMan = InsertItem.EditManager;

                if (InsertItem != null)
                {
                    foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
                    {
                        if (column is GridEditableColumn)
                        {
                            IGridEditableColumn editTableColumn = (column as IGridEditableColumn);

                            if (editTableColumn.IsEditable)
                            {
                                IGridColumnEditor editor = editMan.GetColumnEditor(editTableColumn);

                                switch (column.UniqueName)
                                {
                                case "Year":
                                {
                                    objSchoolYear.Year = (e.Item.FindControl("ddlYear") as DropDownList).SelectedValue;
                                    break;
                                }

                                case "StartDate":
                                {
                                    objSchoolYear.StartDate = (e.Item.FindControl("rdpStartDate") as RadDatePicker).SelectedDate.Value;
                                    break;
                                }

                                case "EndDate":
                                {
                                    if ((e.Item.FindControl("rdpEndDate") as RadDatePicker).SelectedDate != null)
                                    {
                                        objSchoolYear.EndDate = (e.Item.FindControl("rdpEndDate") as RadDatePicker).SelectedDate.Value;
                                    }
                                    else
                                    {
                                        objSchoolYear.EndDate = null;
                                    }
                                    break;
                                }

                                case "Comment":
                                {
                                    objSchoolYear.Comments = (e.Item.FindControl("txtComment") as TextBox).Text;
                                    break;
                                }

                                case "CurrentId":
                                {
                                    objSchoolYear.CurrentId = (editor as GridCheckBoxColumnEditor).Value;
                                    break;
                                }
                                }
                            }
                        }
                    }
                    if (objSchoolYear.EndDate != null)
                    {
                        if (objSchoolYear.StartDate > objSchoolYear.EndDate)
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Start Date must be less than End Date.", "false"));
                            return(false);
                        }
                    }
                    if (Session["SchoolId"] != null)
                    {
                        objSchoolYear.SchoolId = new Guid(Session["SchoolId"].ToString());
                    }
                    if (e.CommandName != "PerformInsert")
                    {
                        if (Session["StaffId"] != null)
                        {
                            objSchoolYear.LastModifiedById = new Guid(Session["StaffId"].ToString());
                        }
                        objSchoolYear.Id = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
                        if (!objSchoolYear.Year.Trim().Equals(hdnName.Value.Trim()))
                        {
                            bool ans = proxySchoolYear.CheckDuplicateSchoolYear(objSchoolYear.Year, objSchoolYear.Id, objSchoolYear.SchoolId);
                            if (ans)
                            {
                                MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                                MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "School Year Already Exist", "false"));
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        if (Session["StaffId"] != null)
                        {
                            objSchoolYear.CreatedById = new Guid(Session["StaffId"].ToString());
                        }
                        bool ans = proxySchoolYear.CheckDuplicateSchoolYear(objSchoolYear.Year, objSchoolYear.Id, objSchoolYear.SchoolId);
                        if (ans)
                        {
                            MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                            MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "School Year Already Exist", "false"));
                            return(false);
                        }
                    }
                    hdnName.Value = "";

                    SchoolYearId = proxySchoolYear.Save(objSchoolYear, new Guid(Session["CurrentSchoolYearId"].ToString()));
                    if (!SchoolYearId.ToString().Equals(DayCarePL.Common.GUID_DEFAULT))
                    {
                        MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                        MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Saved Successfully", "false"));

                        if (objSchoolYear.CurrentId == true)
                        {
                            Session["CurrentSchoolYearId"] = SchoolYearId;
                        }

                        result = true;
                        Session["SchoolYearMessage"] = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.SchoolYear, "SubmitRecord", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
                result = false;
            }
            return(result);
        }
예제 #9
0
        protected void rgSchoolYear_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item)
            {
                DayCarePL.SchoolYearProperties objSchool = e.Item.DataItem as DayCarePL.SchoolYearProperties;
                if (objSchool != null)
                {
                    Label lblStartDate = e.Item.FindControl("lblStartDate") as Label;
                    Label lblEndDate   = e.Item.FindControl("lblEndDate") as Label;

                    if (objSchool.StartDate != null)
                    {
                        lblStartDate.Text = Convert.ToDateTime(objSchool.StartDate).ToString("MM/dd/yy");
                    }
                    if (objSchool.EndDate != null)
                    {
                        lblEndDate.Text = Convert.ToDateTime(objSchool.EndDate).ToString("MM/dd/yy");
                    }
                    GridDataItem itm        = (GridDataItem)e.Item;
                    ImageButton  imgbtnEdit = (ImageButton)itm["Edit"].Controls[0];
                    if (imgbtnEdit != null)
                    {
                        DayCareBAL.SchoolYearService proxySchoolYear = new DayCareBAL.SchoolYearService();
                        if (!proxySchoolYear.IsSelectedYear_Current_NextYearORPrevYear(new Guid(Session["SchoolId"].ToString()), objSchool.Year))
                        {
                            imgbtnEdit.Enabled = false;
                        }
                    }
                }
                //Guid SchoolId = new Guid();
                //Guid CurrentSchoolYearId = new Guid();
                //if (Session["SchoolId"] != null)
                //{
                //    SchoolId = new Guid(Session["SchoolId"].ToString());
                //}

                //if (Session["CurrentSchoolYearId"] != null)
                //{
                //    CurrentSchoolYearId = new Guid(Session["CurrentSchoolYearId"].ToString());
                //}

                //if (!Common.IsCurrentYear(CurrentSchoolYearId, SchoolId))
                //{
                //    GridDataItem itm = (GridDataItem)e.Item;
                //    if (itm != null)
                //    {
                //        ImageButton imgbtnEdit = (ImageButton)itm["Edit"].Controls[0];
                //        if (imgbtnEdit != null)
                //        {
                //            imgbtnEdit.ToolTip = "";
                //            imgbtnEdit.Enabled = false;
                //            imgbtnEdit.Style.Value = "cursor:auto";
                //        }
                //        GridCommandItem cmdItem = itm.OwnerTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem;
                //        if (cmdItem != null)
                //        {
                //            LinkButton lnkbtnInitInsertButton = (LinkButton)cmdItem.FindControl("InitInsertButton");
                //            lnkbtnInitInsertButton.Enabled = false;
                //            lnkbtnInitInsertButton.Style.Value = "cursor:auto";
                //        }
                //        rgSchoolYear.MasterTableView.IsItemInserted = false;//d new GridTableItemStyle();
                //    }
                //}
            }

            if (e.Item.ItemType == GridItemType.EditItem)
            {
                GridEditableItem itm = e.Item as GridEditableItem;
                DayCarePL.SchoolYearProperties objSchoolYear = e.Item.DataItem as DayCarePL.SchoolYearProperties;
                RadDatePicker rdpStartDate = e.Item.FindControl("rdpStartDate") as RadDatePicker;
                RadDatePicker rdpEndDate   = e.Item.FindControl("rdpEndDate") as RadDatePicker;
                DropDownList  ddlYear      = e.Item.FindControl("ddlYear") as DropDownList;
                CheckBox      chkCurrentId = itm["CurrentId"].Controls[0] as CheckBox;
                Common.BindSchoolYear(ddlYear);

                if (objSchoolYear != null)
                {
                    if (ddlYear.Items != null && ddlYear.Items.Count > 0)
                    {
                        ddlYear.SelectedValue = objSchoolYear.Year.ToString();
                    }
                    if (objSchoolYear.StartDate != null)
                    {
                        rdpStartDate.SelectedDate = objSchoolYear.StartDate;
                    }
                    if (objSchoolYear.EndDate != null)
                    {
                        rdpEndDate.SelectedDate = objSchoolYear.EndDate;
                    }
                    if (objSchoolYear.CurrentId == true)
                    {
                        chkCurrentId.Enabled = false;
                    }
                    chkCurrentId.ToolTip = "";
                    if (objCurrentYear.StartDate > objSchoolYear.StartDate)
                    {
                        chkCurrentId.ToolTip = "Don't allow to make past year as current year";
                        chkCurrentId.Enabled = false;
                    }
                }
            }
        }