Example #1
0
        void CustomDialog1_ItemClick(object sender, Academic.ViewModel.IdAndNameEventArgs e)
        {
            //var selectedValue = ddlAddStudent.SelectedValue.ToString();
            switch (e.Id)
            {
            case -1:
                //MultiView1.ActiveViewIndex = 0;
                break;

            case 0:
                //create student
                Response.Redirect("~/Views/Student/Batch/Student/StudentCreate.aspx?pbId=" + ProgramBatchId);
                //MultiView1.ActiveViewIndex = 1;
                break;

            case 1:

                //MultiView1.ActiveViewIndex = 2;
                break;

            case 2:
                //import from file
                Response.Redirect("~/Views/Student/Batch/Student/ImportStudentFromFile.aspx?pbId=" + ProgramBatchId);
                //MultiView1.ActiveViewIndex = 3;
                break;
            }
            CustomDialog1.CloseDialog();
        }
Example #2
0
 void CustomDialog1_ItemClick(object sender, IdAndNameEventArgs e)
 {
     //copy the year and sub-years from the choosen program  to this program
     if (e.Id == 0)
     {
         CustomDialog1.CloseDialog();
         return;
     }
     using (var helper = new DbHelper.Structure())
     {
         var copied = helper.CopyYearsAndSubyears(e.Id, ParentId);
         if (copied)
         {
             Response.Redirect("~/Views/Structure/?edit=1");
         }
         else
         {
             lblCopyError.Visible = true;
             CustomDialog1.CloseDialog();
         }
     }
 }
Example #3
0
 protected void lnkAddStudent_OnClick(object sender, EventArgs e)
 {
     CustomDialog1.OpenDialog();
 }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //StudentCreateUc1.CloseClicked += StudentCreateUc1_CloseClicked;
            //StudentCreateUc1.SaveClicked += StudentCreateUc1_SaveClicked;
            CustomDialog1.ItemClick += CustomDialog1_ItemClick;
            //LoadAddStudent();
            //var one = FileUpload1.HasFile;

            var user = Page.User as CustomPrincipal;

            if (user != null)
            {
                if (!IsPostBack)
                {
                    if (user.IsInRole("manager") || user.IsInRole("admitter"))
                    {
                        var edit = (Session["editMode"] as string) ?? "0";

                        lnkAddStudent.Visible = edit == "1";
                        //lblAddMethod.Visible = true;
                        // <asp:ListItem Text="Choose..." Value="-1"></asp:ListItem>
                        //<asp:ListItem Text="Create Student" Value="0"></asp:ListItem>
                        //<asp:ListItem Text="Improt From System" Value="1"></asp:ListItem>
                        //<asp:ListItem Text="Import From File" Value="2"></asp:ListItem>
                        var addTypes = new List <IdAndName>()
                        {
                            new IdAndName()
                            {
                                Id = 0, Name = "Create"
                            }
                            , new IdAndName()
                            {
                                Id = 1, Name = "Improt From System"
                            }
                            , new IdAndName()
                            {
                                Id = 2, Name = "Import From File"
                            }
                        };
                        CustomDialog1.SetValues("Chooose method", addTypes, "", "cancel");
                    }
                    else
                    {
                        lnkAddStudent.Visible = false;
                        //lblAddMethod.Visible = false;
                    }
                    if (user.IsInRole("student"))
                    {
                        Response.Redirect("~/ViewsSite/User/Dashboard/Dashboard.aspx", true);
                    }
                    //CustomDialog.SetValues("Add Student",null,"click");
                    try
                    {
                        //here id is programBatchId
                        var programBatchId = Request.QueryString["pbId"];
                        if (programBatchId != null)
                        {
                            var editQuery = Request.QueryString["edit"];
                            var edit      = (editQuery ?? "0").ToString();
                            int pbatchId  = Convert.ToInt32(programBatchId);
                            //var success = Int32.TryParse(programBatchId, out pbatchId);
                            //if (success)
                            //{
                            //ProgramBatchId = pbatchId;

                            hidProgramBatchId.Value = programBatchId;
                            using (var helper = new DbHelper.Batch())
                            {
                                var pbatch = helper.GetProgramBatch(pbatchId);
                                if (pbatch != null)
                                {
                                    if (SiteMap.CurrentNode != null)
                                    {
                                        var list = new List <IdAndName>()
                                        {
                                            new IdAndName()
                                            {
                                                Name    = SiteMap.RootNode.Title
                                                , Value = SiteMap.RootNode.Url
                                                , Void  = true
                                            },
                                            new IdAndName()
                                            {
                                                Name    = SiteMap.CurrentNode.ParentNode.ParentNode.ParentNode.Title
                                                , Value = SiteMap.CurrentNode.ParentNode.ParentNode.ParentNode.Url
                                                , Void  = true
                                            },
                                            new IdAndName()
                                            {
                                                Name    = pbatch.Batch.AcademicYear.Name
                                                , Value = SiteMap.CurrentNode.ParentNode.ParentNode.Url + "?aId=" + pbatch.Batch.AcademicYear.Id
                                                , Void  = true
                                            }
                                            , new IdAndName()
                                            {
                                                Name    = pbatch.Batch.Name
                                                , Value = SiteMap.CurrentNode.ParentNode.Url + "?Id=" + pbatch.BatchId + "&edit=" + edit
                                                , Void  = true
                                            }
                                            , new IdAndName()
                                            {
                                                Name = pbatch.Program.Name
                                            }
                                        };
                                        SiteMapUc.SetData(list);
                                        //SiteMap.CurrentNode.ReadOnly = false;
                                        //SiteMap.CurrentNode.Title = batch.Name;
                                    }
                                    //var stname = "N/A";

                                    var elementFound = false;
                                    //new addition
                                    foreach (var rcls in pbatch.RunningClasses)
                                    {
                                        if (rcls != null && rcls.SubYear != null)
                                        {
                                            elementFound = true;
                                            var subyear = rcls.SubYear;
                                            //if there are any running classes
                                            var link = new HyperLink()
                                            {
                                                //CssClass = "link",
                                                CssClass    = "list-group-item",
                                                NavigateUrl = "~/Views/Academy/RunningClassForm.aspx?rcId=" + rcls.Id
                                            };

                                            var lbl = new Label()
                                            {
                                                Text = subyear.Year.Name + " - " + subyear.Name + " &nbsp;",
                                            };

                                            link.Controls.Add(lbl);


                                            var url = "";

                                            if (rcls.Completed ?? false)
                                            {
                                                url = "~/Content/Icons/Stop/Stop_10px.png";
                                            }
                                            else if (rcls.IsActive ?? false)
                                            {
                                                url = "~/Content/Icons/Start/active_icon_10px.png";
                                            }

                                            var img = new Image()
                                            {
                                                ImageUrl = url,
                                            };
                                            if (url != "")
                                            {
                                                link.Controls.Add(img);
                                            }

                                            pnlYearsSubYears.Controls.Add(link);

                                            //pnlYearsSubYears.Controls.Add(new Literal() { Text = "<br/>" });
                                            //var literal = new Literal()
                                            //{
                                            //    Text = "<br />"
                                            //};
                                            //pnlYearsSubYears.Controls.Add(literal);
                                        }
                                    }

                                    divYearsSubYears.Visible = elementFound;


                                    //var rc =
                                    //    pbatch.RunningClasses.FirstOrDefault(x => (x.IsActive ?? true)// && x.Session.IsActive
                                    //                                                && !(x.Completed ?? false))
                                    //    ;
                                    //if (rc != null)
                                    //{
                                    //    stname = rc.Year.Name;
                                    //    if (rc.SubYearId != null)
                                    //    {
                                    //        stname += " &nbsp; " + rc.SubYear.Name;//.NameFromBatch;
                                    //        // pbId = pb.ProgramBatchId ?? 0;
                                    //    }
                                    //}
                                    //lblCurrentlyIn.Text = stname;


                                    hidBatchId.Value = pbatch.BatchId.ToString();
                                    var pbName = pbatch.NameFromBatch;
                                    lblProgramBatchName.Text = pbName;
                                    lblTitle.Text            = pbName;
                                }
                            }
                            //StudentListUc1.ProgramBatchId = pbatchId;
                            StudentListUC11.ProgramBatchId = pbatchId;

                            //StudentCreateUc1.ProgramBatchId = pbatchId;

                            //TreeViewUc.BatchId = batchId;//Convert.ToInt32(id.ToString());
                            //TreeViewUc.SchoolId = Values.Session.GetSchool(Session);
                            //TreeViewUc.LoadTree(idInt);//.LoadData(idInt);
                            //.BatchId = Convert.ToInt32(id.ToString());
                            //AddProgramsUc.BatchId = Convert.ToInt32(batchId.ToString());
                            //AddProgramsUc.LoadData(schoolId, batchId);

                            //}
                            //else
                            //{

                            //    Response.Redirect("~/Views/Student/Batch/BatchDetail/Detail.aspx" + "?Id=" + hidBatchId.Value);
                            //}
                        }
                        else
                        {
                            Response.Redirect("~/Views/Student/");
                        }
                    }
                    catch
                    {
                        Response.Redirect("~/Views/Student/");
                    }
                }
            }
        }
Example #5
0
        //public event EventHandler<MessageEventArgs> SaveClickedEvent;
        protected void Page_Load(object sender, EventArgs e)
        {
            lblError.Visible         = false;
            CustomDialog1.ItemClick += CustomDialog1_ItemClick;
            if (!IsPostBack)
            {
                var user = Page.User as CustomPrincipal;
                if (user != null)
                {
                    try
                    {
                        var type = Request.QueryString["strTyp"];
                        if (type == null)
                        {
                            Response.Redirect("~/Views/Structure/", true);
                        }
                        else
                        {
                            StructureType = type;

                            LoadStructureType();
                            var strId  = Request.QueryString["strId"];
                            var pId    = Request.QueryString["pId"];
                            var progId = Request.QueryString["progId"];
                            if (progId != null)
                            {
                                hidProgramId.Value = progId;
                            }
                            if (strId != null)
                            {
                                StructureId = Convert.ToInt32(strId);
                                LoadStructure();
                            }
                            else if (pId != null)// there must be parent id if (structure id is not given)
                            {
                                var parentId = Convert.ToInt32(pId);
                                ParentId = parentId;

                                //if year creation is choosen then check if there are any other year in this program
                                //if no year then give to choose the program from which year and subyear can be imported
                                if (type == "yr")
                                {
                                    //EnableSemesterValidation();
                                    //tblSubyear.Visible = true;
                                    //reqValiSubYear1.ValidationGroup = "save";
                                    //reqValiSubYear2.ValidationGroup = "save";
                                    using (var helper = new DbHelper.Structure())
                                    {
                                        var prog = helper.GetProgram(parentId);
                                        if (prog != null)
                                        {
                                            //var cnt = prog.Year.Count;
                                            if (!(prog.Year.Any(x => !(x.Void ?? false))))
                                            {
                                                //show dialog to choose another program and
                                                var programs = helper.GetPrograms(user.SchoolId);
                                                var thisone  = programs.Find(x => x.Id == parentId);
                                                if (thisone != null)
                                                {
                                                    programs.Remove(thisone);
                                                }
                                                //there has to be another program to choose so check for it
                                                if (programs.Count > 0)
                                                {
                                                    //show dialog // and list all the programs to choose
                                                    var items = programs.Select(x => new IdAndName()
                                                    {
                                                        Name = "● " + x.Name,
                                                        Id   = x.Id
                                                    }).ToList();
                                                    items.Add(new IdAndName()
                                                    {
                                                        Id = 0, Name = "□ I would like to add manually"
                                                    });
                                                    CustomDialog1.SetValues("Copy all years and semesters from...", items, "", "cancel");
                                                    CustomDialog1.OpenDialog();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        Response.Redirect("~/Views/Structure/");
                    }
                }
            }
        }