Example #1
0
    protected void BtnUploadContent_Click(object sender, EventArgs e)
    {
        obj_SYS_Chapter     = new SYS_Chapter();
        obj_BAL_SYS_Chapter = new SYS_Chapter_BLogic();

        obj_SYS_Chapter.subjectid = Convert.ToInt16(ddlSubject.SelectedValue);
        obj_SYS_Chapter.chapterid = Convert.ToInt64(ddlChapter.SelectedValue);
        obj_SYS_Chapter.topicid   = Convert.ToInt64(ddlTopic.SelectedValue);

        Int64 sctid = obj_BAL_SYS_Chapter.BAL_SYS_SCT_Insert(obj_SYS_Chapter);

        obj_SYS_Chapter.sctid = sctid;
        obj_SYS_Chapter.bmsid = Convert.ToInt64(ViewState["BMSID"]);

        Int64 bmssctid = obj_BAL_SYS_Chapter.BAL_SYS_BMS_SCT_Insert(obj_SYS_Chapter);

        WebMsg.Show("Generated BMS SCT ID is = " + bmssctid);
    }
    protected void BtnGenerate_Click(object sender, EventArgs e)
    {
        obj_SYS_Chapter     = new SYS_Chapter();
        obj_BAL_SYS_Chapter = new SYS_Chapter_BLogic();

        obj_SYS_Chapter.subjectid = Convert.ToInt16(ddlSubject.SelectedValue);
        obj_SYS_Chapter.chapterid = Convert.ToInt64(ddlChapter.SelectedValue);
        obj_SYS_Chapter.topicid   = Convert.ToInt64(ddlTopic.SelectedValue);

        Int64 sctid = obj_BAL_SYS_Chapter.BAL_SYS_SCT_Insert(obj_SYS_Chapter);

        obj_SYS_Chapter.sctid = sctid;
        obj_SYS_Chapter.bmsid = Convert.ToInt64(ViewState["BMSID"]);

        Int64 bmssctid = obj_BAL_SYS_Chapter.BAL_SYS_BMS_SCT_Insert(obj_SYS_Chapter);

        WebMsg.Show("Generated BMS SCT ID is = " + bmssctid);

        DropDownList[] disddl = { ddlTopic };
        DisableDropDwon(disddl);
        ddlChapter.SelectedIndex = 0;
    }
    protected void BtnUpload_Click(object sender, EventArgs e)
    {
        #region File Validation
        if (ddlType.SelectedItem.ToString().Equals("Activity"))
        {
            if (fuChapters.PostedFile.ContentLength > ((int)EnumFile.AssignValue.Zero))
            {
                string ext = System.IO.Path.GetExtension(fuChapters.PostedFile.FileName);
                ext = ext.ToLower();
                if (ext != ".pdf")
                {
                    WebMsg.Show("Please Select .pdf File only");
                    goto Exit;
                }
            }
        }
        else if (ddlType.SelectedItem.ToString().Equals("Video Presentation"))
        {
            if (fuChapters.PostedFile.ContentLength > ((int)EnumFile.AssignValue.Zero))
            {
                string ext = System.IO.Path.GetExtension(fuChapters.PostedFile.FileName);
                ext = ext.ToLower();
                if (ext != ".flv")
                {
                    if (ext != ".swf")
                    {
                        WebMsg.Show("Please Select .swf or .flv File only");
                        goto Exit;
                    }
                }
                else if (ext != ".swf")
                {
                    if (ext != ".flv")
                    {
                        WebMsg.Show("Please Select .swf or .flv File only");
                        goto Exit;
                    }
                }
            }
        }
        else if (ddlType.SelectedItem.ToString().Equals("Question Paper"))
        {
            if (fuChapters.PostedFile.ContentLength > ((int)EnumFile.AssignValue.Zero))
            {
                string ext = System.IO.Path.GetExtension(fuChapters.PostedFile.FileName);
                ext = ext.ToLower();
                if (ext != ".pdf")
                {
                    WebMsg.Show("Please Select .pdf File only");
                    goto Exit;
                }
            }
        }
        else if (ddlType.SelectedItem.ToString().Equals("Worksheet"))
        {
            if (fuChapters.PostedFile.ContentLength > ((int)EnumFile.AssignValue.Zero))
            {
                string ext = System.IO.Path.GetExtension(fuChapters.PostedFile.FileName);
                ext = ext.ToLower();
                if (ext != ".pdf")
                {
                    WebMsg.Show("Please Select .pdf File only");
                    goto Exit;
                }
            }
        }
        else if (ddlType.SelectedItem.ToString().Equals("Teacher Resource"))
        {
            if (fuChapters.PostedFile.ContentLength > ((int)EnumFile.AssignValue.Zero))
            {
                string ext = System.IO.Path.GetExtension(fuChapters.PostedFile.FileName);
                ext = ext.ToLower();
                if (ext != ".pdf")
                {
                    WebMsg.Show("Please Select .pdf File only");
                    goto Exit;
                }
            }
        }
        else if (ddlType.SelectedItem.ToString().Equals("Glossary"))
        {
            if (fuChapters.PostedFile.ContentLength > ((int)EnumFile.AssignValue.Zero))
            {
                string ext = System.IO.Path.GetExtension(fuChapters.PostedFile.FileName);
                ext = ext.ToLower();
                if (ext != ".pdf")
                {
                    WebMsg.Show("Please Select .pdf File only");
                    goto Exit;
                }
            }
        }
        #endregion

        obj_SYS_Chapter     = new SYS_Chapter();
        obj_BAL_SYS_Chapter = new SYS_Chapter_BLogic();

        obj_SYS_Chapter.subjectid = Convert.ToInt16(ddlSubject.SelectedValue);
        obj_SYS_Chapter.chapterid = Convert.ToInt64(ddlChapter.SelectedValue);
        obj_SYS_Chapter.topicid   = Convert.ToInt64(ddlTopic.SelectedValue);

        Int64 sctid = obj_BAL_SYS_Chapter.BAL_SYS_SCT_Insert(obj_SYS_Chapter);

        obj_SYS_Chapter.sctid = sctid;
        obj_SYS_Chapter.bmsid = Convert.ToInt64(ViewState["BMSID"]);

        Int64 bmssctid = obj_BAL_SYS_Chapter.BAL_SYS_BMS_SCT_Insert(obj_SYS_Chapter);

        String DirectoryPath = Server.MapPath("../EduResource/" + bmssctid);
        if (!Directory.Exists(DirectoryPath))
        {
            Directory.CreateDirectory(DirectoryPath);
        }

        String ResourcePath = Server.MapPath("../EduResource/" + bmssctid + "/" + ddlType.SelectedItem.ToString());
        if (!Directory.Exists(ResourcePath))
        {
            Directory.CreateDirectory(ResourcePath);
        }

        string FilePath = ResourcePath + "\\" + fuChapters.FileName;
        fuChapters.PostedFile.SaveAs(FilePath);
        WebMsg.Show("File Uploaded successfully.");
        object    s  = new object();
        EventArgs ea = new EventArgs();
        btnReset_Click(s, ea);

Exit:
        return;
    }