コード例 #1
0
ファイル: SchoolTypeUC.ascx.cs プロジェクト: skrishnau/LMS
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (txtSchoolTypeName.Text == "")
     {
         lblVali.Visible = true;
         return;
     }
     {
         using (var helper = new DbHelper.Office())
         {
             var schTyp = new Academic.DbEntities.Office.SchoolType()
             {
                 Name = txtSchoolTypeName.Text
             };
             //if (InstitutionId != 0)
             //{
             //    schTyp.InstitutionId = InstitutionId;
             //}
             var tp = helper.AddOrUpdateSchoolType(schTyp);
             if (tp != null)
             {
                 txtId.Text = tp.Id.ToString();
             }
             Visible_ = false;
         }
     }
 }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: skrishnau/LMS
 private void DisplaySchoolInfo(int userId)
 {
     using (var helper = new DbHelper.Office())
     {
         var school = helper.GetSchoolOfUser(userId);
         if (school != 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 = school.Name
                                //,Value = SiteMap.CurrentNode.ParentNode.Url
                                //,Void=true
                     }
                 };
                 SiteMapUc.SetData(list);
             }
             lblName.Text = school.Name;
             //lblSchoolName.Text = school.Name;
             //lblSchoolType.Text = school.SchoolType == null ? "" : school.SchoolType.Name;
             //lblCity.Text = string.IsNullOrEmpty(school.City)?"N/A":school.City;
             lblCountry.Text = string.IsNullOrEmpty(school.Address)?"N/A":school.Address;
             lblEmail.Text   = string.IsNullOrEmpty(school.EmailGeneral)?"N/A":school.EmailGeneral;
             lblWebsite.Text = string.IsNullOrEmpty(school.Website)?"N/A":school.Website;
             lblPhoneNo.Text = string.IsNullOrEmpty(school.PhoneMain)?"N/A":school.PhoneMain;
         }
     }
 }
コード例 #3
0
ファイル: Contact.aspx.cs プロジェクト: skrishnau/LMS
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var user = Page.User as CustomPrincipal;
                if (user == null)
                {
                    loginDiv.Visible = true;
                }
                else
                {
                    SiteMapUc.SetData(new List <IdAndName>()
                    {
                        new IdAndName()
                        {
                            Name = "Contact"
                        }
                    });
                }
                using (var helper = new DbHelper.Office())
                {
                    var school = helper.GetSchoolOfUser(user == null ? 0 : user.SchoolId);
                    lblAddress.Text             = school.Address;
                    lblPhoneAfterHours.Text     = school.PhoneAfterHours;
                    lblPhoneMain.Text           = school.PhoneMain;
                    lnkEmailGeneral.Text        = school.EmailGeneral;
                    lnkEmailGeneral.NavigateUrl = "mailto:" + school.EmailGeneral;

                    lnkEmailMarketing.Text        = school.EmailMarketing;
                    lnkEmailMarketing.NavigateUrl = "mailto:" + school.EmailMarketing;

                    lnkEmailSupport.Text        = school.EmailSupport;
                    lnkEmailSupport.NavigateUrl = "mailto:" + school.EmailSupport;
                }
            }
        }
コード例 #4
0
ファイル: UserMaster.Master.cs プロジェクト: skrishnau/LMS
        protected void Page_Load(object sender, EventArgs e)
        {
            {
                var user     = Page.User as CustomPrincipal;
                var loginUrl = "Home.aspx";//"ViewsSite/Account/Login.aspx";


                if (user != null)
                {
                    LoadActivityResourceSitemap();
                    //EarlierUc.EmptyData += EarlierUc_EmptyData;
                    //check for school
                    UserId            = user.Id;
                    SchoolId          = user.SchoolId;
                    lnkLoginName.Text = user.FirstName;//.UserName;

                    if (!IsPostBack)
                    {
                        CoursesMenuUc1.UserId = user.Id;
                        //using(var fileHelper = new DbHelper.WorkingWithFiles())
                        //CoursesUc.UserId = user.Id;
                        //EarlierUc.UserId = user.Id;
                        try
                        {
                            var editMode = Session["editMode"] as string;
                            if (editMode == null)
                            {
                                //turn on edit mode
                                //TurnOffEditMode();
                                Session["editMode"] = "0";
                                lblEditMode.Text    = "Turn on edit mode";
                            }
                            else
                            {
                                if (editMode == "1")
                                {
                                    //turn off edit mode
                                    //TurnOnEditMode();
                                    lblEditMode.Text = "Turn off edit mode";
                                }
                                else
                                {
                                    //turn on edit mode
                                    //TurnOffEditMode();
                                    lblEditMode.Text = "Turn on edit mode";
                                }
                            }
                        }
                        catch
                        {
                            //turn on edit mode
                            //TurnOffEditMode();
                            Session["editMode"] = "0";
                            lblEditMode.Text    = "Turn on edit mode";
                        }

                        using (var usrHelper = new DbHelper.User())
                            using (var helper = new DbHelper.Office())
                            {
                                #region Student Info

                                var usr     = usrHelper.GetUser(user.Id);
                                var student = usr.Student;

                                //if (student.Any())
                                //{
                                //    var std = student.FirstOrDefault();
                                //    if (std != null)
                                //    {
                                //        var stdBatch = std.StudentBatch.FirstOrDefault();
                                //        if (stdBatch != null)
                                //        {
                                //            lblUserInfo.Text = "(" + stdBatch.ProgramBatch.NameFromBatch;
                                //            try
                                //            {
                                //                //if (user.AcademicYearId > 0)
                                //                {
                                //                    var rc = usr.Classes.Select(x => x.SubjectClass)
                                //                        .Where(x => x.RunningClassId != null && !(x.Void ?? false))
                                //                        .Select(x => x.RunningClass)
                                //                        .FirstOrDefault(x => (x.IsActive ?? false) && !(x.Void ?? false));
                                //                    if (rc != null)
                                //                    {
                                //                        lblUserInfo.Text += "&nbsp;&nbsp;" + rc.GetYearAndSubYearName;
                                //                    }
                                //                }
                                //            }
                                //            catch { }
                                //            lblUserInfo.Text += ")";
                                //        }
                                //    }
                                //}

                                #endregion


                                var school = helper.GetSchoolOfUser(user.Id);
                                if (school != null)
                                {
                                    //imgSchool.ImageUrl = "~/Content/Images/"
                                    lblSchoolName.Text = school.Name;
                                    SchoolId           = user.SchoolId;
                                    var f = helper.GetSchoolImage(school.ImageId);
                                    if (f != null)
                                    {
                                        imgSchool.ImageUrl = f.FileDirectory + f.FileName;
                                    }

                                    if (Request.Url.AbsolutePath.ToLower().StartsWith("/default.aspx"))
                                    {
                                        //noticeboarduc,eventsuc, onlineusersuc
                                        //pnlBody.CssClass = "body-grey";

                                        //earlier--not used now
                                        //middlePanel.Style.Add("border-right", "1px solid darkgrey");
                                        //middlePanel.Style.Add("border-left", "1px solid darkgrey");



                                        right_panel.Visible = true;
                                    }
                                    else
                                    {
                                        //pnlBody.CssClass = "body-white";
                                        middlePanel.Style.Add("background-color", "white");
                                        middlePanel.Attributes.Add("class", "col-md-10");
                                    }
                                }
                            }

                        //if (Request.Url.AbsolutePath.Contains("BookView")
                        //    || Request.Url.AbsolutePath.Contains("Create")
                        //    || Request.Url.AbsolutePath.Contains("Report"))
                        //{
                        //    right_panel.Visible = false;
                        //}
                    }
                    else
                    {
                        var text  = txtSearch.Text;
                        var words = text.Split(new char[] { ' ' });
                        //var lst = words.Select(x => !(string.IsNullOrEmpty(x)));
                        var modifiedText = "";
                        foreach (var w in words.Where(x => !(string.IsNullOrEmpty(x))))
                        {
                            modifiedText += w + "+";
                        }
                        modifiedText = modifiedText.TrimEnd('+');
                        if (!string.IsNullOrEmpty(modifiedText))
                        {
                            Response.Redirect("~/Views/Search/?input=" + modifiedText, false);
                        }
                        else
                        {
                            txtSearch.Text = "";
                        }


                        //string parameter = Request["__EVENTARGUMENT"]; // parameter
                        //var target = Request["__EVENTTARGET"]; // btnSave
                        //if (parameter == "txtSearch")
                        //{
                        //    //var converted = target.Replace(' ', '+');
                        //    Response.Redirect("~/Views/Search/?input=" + modifiedText, false);
                        //}
                    }

                    #region NOtice earlier , now commented

                    using (var helper = new DbHelper.Notifications())
                    {
                        if (user.IsInRole(DbHelper.StaticValues.Roles.Manager))
                        {
                            var due = helper.GetDueClassesNotification(user.SchoolId);
                            if (due.Any())
                            {
                                lblEmptyNotice.Visible = false;
                                //earlier
                                //imgNotificationIcon.ImageUrl = "~/Content/Icons/Notice/Info-urgent-light-26px.png";


                                //var hlink = new HyperLink()
                                //{
                                //    Text = "Due classes, Mark completion (" + due.Count + ")",
                                //    NavigateUrl = "~/Views/Class/DueClasses.aspx"
                                //};

                                var text = "Due classes, Mark completion (" + due.Count + ")";
                                var url  = "/Views/Class/DueClasses.aspx";
                                var li   = "<li><a href = '" + url + "'>"
                                           + text
                                           + "</a></li>";

                                plHolderNotice.Controls.Add(new Literal()
                                {
                                    Text = li
                                });
                            }

                            var noTeacher = helper.GetNoTeacherInClassNotification(user.SchoolId);
                            if (noTeacher.Any())
                            {
                                lblEmptyNotice.Visible = false;
                                //earlier
                                //imgNotificationIcon.ImageUrl = "~/Content/Icons/Notice/Info-urgent-light-26px.png";

                                //var hlink = new HyperLink()
                                //{
                                //    //<span style='background-color:red;color:white;padding:-2px;'></span>"
                                //    Text = "Teacher not assigned to class (" + noTeacher.Count + ")",
                                //    NavigateUrl = "~/Views/Class/TeacherNotAssignedClasses.aspx"
                                //};
                                //Teacher not assigned to class
                                var url  = "/Views/Class/TeacherNotAssignedClasses.aspx";
                                var text = "Classes without teachers (" + noTeacher.Count + ")";
                                var li   = "<li><a href = '" + url + "'>"
                                           + text
                                           + "</a></li>";
                                plHolderNotice.Controls.Add(new Literal()
                                {
                                    Text = li
                                });
                            }
                        }
                    }

                    //using (var nhelper = new DbHelper.Notice())
                    //{
                    //    var notices = nhelper.GetNotices(user.SchoolId, user.Id);

                    //    foreach (var n in notices)
                    //    {
                    //        var nUc =
                    //            (NoticeItemUc)
                    //                Page.LoadControl("~/ViewsSite/User/ModulesUc/NoticeItemUc.ascx");
                    //        nUc.SetData("~/Views/NoticeBoard/NoticeDetail.aspx?nId=" + n.Id, n.Title
                    //            , "posted on : " + ((n.PublishedDate == null) ? "" : n.PublishedDate.Value.ToShortDateString())
                    //            , n.Void ?? false);
                    //        plHolderNotice.Controls.Add(nUc);
                    //    }
                    //    if (notices.Any())
                    //    {
                    //        lblEmptyNotice.Visible = false;
                    //    }
                    //    //DataList1.DataSource = notices.Take(5).ToList();
                    //    //DataList1.DataBind();

                    //    var unViewed = notices.Where(x => (x.Void ?? false)).ToList();
                    //    if (!unViewed.Any())
                    //    {
                    //        imgNoticeIcon.ImageUrl = "~/Content/Icons/Notice/agt_announcements.png";
                    //        //imgNoticeIndicator.Visible = false;
                    //        //lblNoticeIndication.Visible = false;
                    //    }
                    //    else
                    //    {
                    //        imgNoticeIcon.ImageUrl = "~/Content/Icons/Notice/agt_announcements_excla.png";
                    //        //imgNoticeIndicator.Visible = true;
                    //        //lblNoticeIndication.Text = "&nbsp; " + unViewed.Count + " &nbsp; ";
                    //    }
                    //}

                    #endregion

                    UpdateLoginTime(user.Id);


                    if (user.IsInRole("manager"))
                    {
                        var schoolCreateUrl = "Views/Office/School/Create.aspx";
                        var isSchoolUrl     = Request.Url.AbsolutePath.Contains(schoolCreateUrl);
                        if (user.SchoolId <= 0 && !isSchoolUrl)
                        {
                            Response.Redirect("~/" + schoolCreateUrl);
                        }

                        SettingsUc settings =
                            (SettingsUc)Page.LoadControl("~/ViewsSite/User/ModulesUc/SettingsUc.ascx");
                        //settings.UserId = user.Id;
                        pnlSettings.Controls.Add(settings);
                        lnkEditMode.Visible = true;

                        //earlier settings
                        //lnkSettingMenu.Visible = true;

                        FileManagementMenuUc1.ShowServerMenu();
                    }
                    else if (user.IsInRole("teacher"))
                    {
                        SettingsTeacher teachersettings =
                            (SettingsTeacher)Page.LoadControl("~/ViewsSite/User/ModulesUc/SettingsTeacher.ascx");
                        //settings.UserId = user.Id;
                        pnlSettings.Controls.Add(teachersettings);
                        lnkEditMode.Visible = true;
                    }
                }
                else
                {
                    var path = Request.Url.AbsolutePath;//.Contains(loginUrl);
                    if (!path.Contains(loginUrl))
                    {
                        var home    = path.ToLower().Contains("home.aspx");
                        var about   = path.ToLower().Contains("about.aspx");
                        var contact = path.ToLower().Contains("contact.aspx");
                        if (!(home || about || contact))
                        {
                            Response.Redirect("~/" + loginUrl);
                        }
                        else
                        {
                            left_panel.Visible             = false;
                            right_panel.Visible            = true;
                            menubar_right_text_all.Visible = false;
                        }
                        //if (path.Contains("Home.aspx"))
                        //{
                        //    Response.Redirect("~/Home.aspx");
                        //}
                        //else if (path.Contains("About.aspx"))
                        //{
                        //    Response.Redirect("~/About.aspx");
                        //}
                        //else if (path.Contains("Contact.aspx"))
                        //{
                        //    Response.Redirect("~/Contact.aspx");
                        //}
                        //else
                        //{
                        //      Response.Redirect("~/" + loginUrl);
                        //}
                    }
                    return;
                }
            }
        }
コード例 #5
0
ファイル: Create.aspx.cs プロジェクト: skrishnau/LMS
        private void PopulateSchoolInfo(CustomPrincipal user)
        {
            using (var helper = new DbHelper.Office())
            {
                var sch = helper.GetSchoolOfUser(user.Id);

                if (sch != null)
                {
                    CKEditor1.Text       = sch.Description;
                    hidSchoolId.Value    = sch.Id.ToString();
                    txtAddress.Text      = sch.Address;
                    txtName.Text         = sch.Name;
                    txtEmailGeneral.Text = sch.EmailGeneral;
                    //txtEmailMarketing.Text = sch.EmailMarketing;
                    //txtEmailSupport.Text = sch.EmailSupport;
                    txtPhoneMain.Text = sch.PhoneMain;
                    //txtPhoneAfterHours.Text = sch.PhoneAfterHours;
                    hidImageId.Value = sch.ImageId.ToString();

                    //txtStreet.Text = sch.Street;
                    txtWeb.Text     = sch.Website;
                    hidUserId.Value = sch.UserId.ToString();
                    //cmbSchoolType.SelectedValue = sch.SchoolTypeId.ToString();
                    var f = helper.GetSchoolImage(sch.ImageId);
                    if (f != null)
                    {
                        //var fileName = Path.GetFileName(f.FilePath);
                        var image = new FileResourceEventArgs()
                        {
                            Id = f.Id,
                            //CreatedBy = user.Id
                            //,
                            //CreatedDate = DateTime.Now
                            //,
                            FileDisplayName = f.DisplayName //Path.GetFileName(imageFile.FileName)
                                                            //,
                                                            // FileDirectory = DbHelper.StaticValues.SchoolFileLocation //StaticValue.UserImageDirectory
                                                            // ,
                                                            //FileName = fileName
                            ,
                            FilePath = DbHelper.StaticValues.SchoolFileLocation + f.FileName
                                       //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType)
                            ,
                            FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength
                            ,
                            FileType = f.FileType               //imageFile.ContentType
                            ,
                            IconPath = f.IconPath
                            ,
                            //SubjectId = SubjectId
                        };
                        FilesDisplay1.SetInitialValues(new List <FileResourceEventArgs>()
                        {
                            image
                        });
                    }
                }
                if (SiteMap.CurrentNode != null)
                {
                    var list = new List <IdAndName>()
                    {
                        new IdAndName()
                        {
                            Name    = SiteMap.RootNode.Title
                            , Value = SiteMap.RootNode.Url
                            , Void  = true
                        },
                        new IdAndName()
                        {
                            Name    = sch == null?SiteMap.CurrentNode.ParentNode.Title:sch.Name
                            , Value = SiteMap.CurrentNode.ParentNode.Url
                            , Void  = true
                        },
                        new IdAndName()
                        {
                            Name = "Edit"
                        }
                    };
                    SiteMapUc.SetData(list);
                }
            }
        }
コード例 #6
0
ファイル: Create.aspx.cs プロジェクト: skrishnau/LMS
        //private void PopulateCountry()
        //{
        //    List<string> countries = new List<string>();
        //    var getCultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
        //    foreach (var c in getCultureInfo)
        //    {
        //        var getRegionInfo =
        //            new RegionInfo(c.LCID);
        //        var name = getRegionInfo.EnglishName.Split(new char[] { '(' })[0];
        //        if (!countries.Contains(name))
        //        {
        //            countries.Add(name);
        //        }
        //    }
        //    countries.Sort();
        //    var i = 0;
        //    try
        //    {
        //        i = countries.IndexOf("Nepal");
        //    }
        //    catch
        //    {
        //    }
        //    if (i != 0)
        //        countries.Insert(0, "Select");
        //    ddlCountry.DataSource = countries;
        //    ddlCountry.DataBind();
        //    ddlCountry.SelectedIndex = i;
        //}

        protected void btnSave_Click(object sender, EventArgs e)
        {
            //if (cmbSchoolType.SelectedValue == "" || cmbSchoolType.SelectedValue == "0")
            //{
            //    valiSchType.IsValid = false;
            //}
            //if (ddlCountry.SelectedIndex == 0)
            //    valiCountry.IsValid = false;

            if (IsValid)
            {
                var user = User as CustomPrincipal;
                if (user == null)
                {
                    return;
                }

                var school = new Academic.DbEntities.Office.School()
                {
                    Id              = user.SchoolId,
                    Name            = txtName.Text,
                    Address         = txtAddress.Text,
                    EmailGeneral    = txtEmailGeneral.Text,
                    EmailMarketing  = "", //txtEmailMarketing.Text,
                    EmailSupport    = "", //txtEmailSupport.Text,
                    IsActive        = chkActive.Checked,
                    PhoneMain       = txtPhoneMain.Text,
                    PhoneAfterHours = "", //txtPhoneAfterHours.Text,
                    Description     = CKEditor1.Text,
                    //SchoolTypeId = Convert.ToInt32(cmbSchoolType.Text),
                    Website     = txtWeb.Text,
                    CreatedDate = DateTime.Now,
                    ImageId     = Convert.ToInt32(hidImageId.Value)
                };
                if (user.SchoolId <= 0)
                {
                    school.UserId = user.Id;
                }

                using (var helper = new DbHelper.Office())
                {
                    var files = FilesDisplay1.GetFiles();
                    var image = new UserFile();
                    if (files != null)
                    {
                        if (files.Count >= 1)
                        {
                            var f = files[0];
                            //foreach (var f in files)
                            {
                                var fileName = Path.GetFileName(f.FilePath);
                                image = new Academic.DbEntities.UserFile()
                                {
                                    Id        = f.Id,
                                    CreatedBy = user.Id
                                    ,
                                    CreatedDate = DateTime.Now
                                    ,
                                    DisplayName = f.FileDisplayName                          //Path.GetFileName(imageFile.FileName)
                                    ,
                                    FileDirectory = DbHelper.StaticValues.SchoolFileLocation //StaticValue.UserImageDirectory
                                    ,
                                    FileName = fileName
                                               //Guid.NewGuid().ToString() + GetExtension(imageFile.FileName, imageFile.ContentType)
                                    ,
                                    FileSizeInBytes = f.FileSizeInBytes //imageFile.ContentLength
                                    ,
                                    FileType = f.FileType               //imageFile.ContentType
                                    ,
                                    IconPath = f.IconPath
                                    ,
                                    //SubjectId = SubjectId
                                };
                                if (f.Id > 0)
                                {
                                    image.ModifiedBy   = user.Id;
                                    image.ModifiedDate = DateTime.Now;
                                }
                            }
                        }
                    }

                    var saved = helper.AddOrUpdateSchool(school, image);//FileUpload1.PostedFile

                    //update cookie -- add school Id to the cookie
                    //Page.User.Identity.Name;
                    if (saved != null)
                    {
                        if (user.SchoolId <= 0)
                        {
                            var ok = UpdateSchoolInfoInCookie(user, saved.Id);
                            if (ok)
                            {
                                Response.Redirect("~/ViewsSite/User/Dashboard/Dashboard.aspx");
                            }
                            else
                            {
                                lblMsg.Text = "Error while saving.";
                            }

                            //---not needed, since redirect is done above

                            //SchoolTypeUC.SavedId = 0;
                            //lblMsg.Visible = true;
                            //lblMsg.Text = "Save Successful.";
                        }
                        else
                        {
                            Response.Redirect("~/About.aspx");  //"//~/Views/Office/");
                        }
                    }

                    else
                    {
                        lblMsg.Text = "Error while saving.";
                    }
                }
            }
            else
            {
                lblMsg.Text = "Some fields are invalid or not filled.";
            }
        }