コード例 #1
0
        protected void rgClassRoom_DeleteCommand(object source, GridCommandEventArgs e)
        {
            DayCareBAL.ClassRoomService proxyCheckAssignedClassRoom = new DayCareBAL.ClassRoomService();
            Guid Id    = new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString());
            bool Check = proxyCheckAssignedClassRoom.CheckClassRoomAssignedSchoolProgramm(Id);

            if (!Check)
            {
                if (proxyCheckAssignedClassRoom.Delete(Id, new Guid(Session["CurrentSchoolYearId"].ToString())))
                {
                    rgClassRoom.MasterTableView.Rebind();
                    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "Delete Successfully", "false"));
                    return;
                }
                else
                {
                    MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                    MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "This Class Room cannot be deleted until all kids and school programs have been reassigned to another class room.", "false"));
                    return;
                }
            }
            else
            {
                MasterAjaxManager = this.Page.Master.FindControl("RadAjaxManager1") as Telerik.Web.UI.RadAjaxManager;
                MasterAjaxManager.ResponseScripts.Add(string.Format("ShowMessage('{0}','{1}')", "This Class Room cannot be deleted until all kids and school programs have been reassigned to another class room.", "false"));
                return;
            }
        }
コード例 #2
0
        protected void rgClassRoom_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.EditItem)
            {
                DayCarePL.ClassRoomProperties objClassRoom = e.Item.DataItem as DayCarePL.ClassRoomProperties;
                DropDownList ddlStaff = e.Item.FindControl("ddlStaff") as DropDownList;
                Guid         SchoolId = new Guid();
                if (Session["SchoolId"] != null)
                {
                    SchoolId = new Guid(Session["SchoolId"].ToString());
                }
                Guid CurrentSchoolYearId = new Guid();
                if (Session["CurrentSchoolYearId"] != null)
                {
                    CurrentSchoolYearId = new Guid(Session["CurrentSchoolYearId"].ToString());
                }
                if (ddlStaff != null)
                {
                    Common.BindStaff(ddlStaff, SchoolId, CurrentSchoolYearId);
                }
                if (objClassRoom != null)
                {
                    if (ddlStaff != null && ddlStaff.Items.Count > 0)
                    {
                        ddlStaff.SelectedValue = Convert.ToString(objClassRoom.StaffId);
                    }
                }

                if (e.Item.ItemIndex != -1)
                {
                    GridEditableItem            itm            = e.Item as GridEditableItem;
                    CheckBox                    chkActive      = itm["Active"].Controls[0] as CheckBox;
                    DayCareBAL.ClassRoomService proxyClassRoom = new DayCareBAL.ClassRoomService();
                    if (proxyClassRoom.CheckClassRoomAssignedSchoolProgramm(new Guid(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString())))
                    {
                        chkActive.Enabled = false;
                        chkActive.ToolTip = "Class is already assigned to program";
                    }
                }
            }
            if (e.Item.ItemIndex == -1)
            {
                if (e.Item.Edit == true)
                {
                    GridEditableItem dataItem  = e.Item as Telerik.Web.UI.GridEditableItem;
                    CheckBox         chkActive = dataItem["Active"].Controls[0] as CheckBox;
                    chkActive.Checked = true;
                }
            }
        }