Esempio n. 1
0
 protected void lnkAddStudent_OnClick(object sender, EventArgs e)
 {
     CustomDialog1.OpenDialog();
 }
Esempio n. 2
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/");
                    }
                }
            }
        }