public static bool AddSessionCourseMaterialNMember(ATTSessionCourse SC)
        {
            GetConnection getConn = new GetConnection();

            try
            {
                OracleTransaction Tran = getConn.GetDbConn(Module.DLPDS).BeginTransaction();
                try
                {
                    DLLSessionCourseMaterial.AddSessionCourseMaterial(SC.LstSessionCourseMaterial, Tran);
                    DLLSessionCourseMember.AddSessionCourseMember(SC.LstSessionCourseMember, Tran);

                    Tran.Commit();

                    return(true);
                }
                catch (Exception ex)
                {
                    Tran.Rollback();
                    throw ex;
                }
                finally
                {
                    getConn.CloseDbConn();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
        }
 public static bool AddSessionCourseMaterialNMember(ATTSessionCourse SC)
 {
     try
     {
         return(DLLSessionCourse.AddSessionCourseMaterialNMember(SC));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static List <ATTSessionCourse> GetSessionCourseList(int orgID, int programID, int sessionID, int CourseID, string ContainDefSessionCourseValue)
        {
            List <ATTSessionCourse> SessionCourseLST = new List <ATTSessionCourse>();

            foreach (DataRow row in DLLSessionCourse.GetSessionCourseTable(orgID, programID, sessionID, CourseID).Rows)
            {
                ATTSessionCourse SC = new ATTSessionCourse
                                      (
                    int.Parse(row["ORG_ID"].ToString()),
                    int.Parse(row["PROGRAM_ID"].ToString()),
                    int.Parse(row["SESSION_ID"].ToString()),
                    int.Parse(row["COURSE_ID"].ToString()),
                    row["FROM_DATE"].ToString(),
                    (row["TO_DATE"] == System.DBNull.Value) ? "" : row["TO_DATE"].ToString(),
                    "",
                    ""

                                      );
                SC.CourseName = row["COURSE_TITLE"].ToString();

                SC.LstSessionCourseMaterial = BLLSessionCourseMaterial.GetSessionCourseMaretial(SC.OrgID, SC.ProgramID, SC.SessionID, SC.CourseID, -1);
                SC.LstSessionCourseMember   = BLLSessionCourseMember.GetSessionCourseMember(SC.OrgID, SC.ProgramID, SC.SessionID, SC.CourseID);

                SessionCourseLST.Add(SC);
            }
            if (ContainDefSessionCourseValue == "Y")
            {
                ATTSessionCourse Default = new ATTSessionCourse();
                Default.CourseName = "----- Select Course -----";
                SessionCourseLST.Insert(0, Default);
            }



            return(SessionCourseLST);
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.ddlProgram_Rqd.SelectedIndex <= 0)
        {
            this.lblStatus.Text        = "Save status";
            this.lblStatusMessage.Text = "Please select program from list.";
            this.ddlProgram_Rqd.Focus();
            this.programmaticModalPopup.Show();
            return;
        }

        if (this.ddlProgram_Rqd.SelectedIndex <= 0)
        {
            this.lblStatus.Text        = "Save status";
            this.lblStatusMessage.Text = "Please select session from list.";
            this.ddlSession_Rqd.Focus();
            this.programmaticModalPopup.Show();
            return;
        }

        if (this.ddlProgram_Rqd.SelectedIndex <= 0)
        {
            this.lblStatus.Text        = "Save status";
            this.lblStatusMessage.Text = "Please select course from list.";
            this.ddlSession_Rqd.Focus();
            this.programmaticModalPopup.Show(); return;
        }

        List <ATTProgram>       programLst       = (List <ATTProgram>)Session["DLPDS_Program_List"];
        List <ATTSession>       sessionLst       = programLst[this.ddlProgram_Rqd.SelectedIndex].SessionLST;
        List <ATTSessionCourse> sessionCourseLst = sessionLst[this.ddlSession_Rqd.SelectedIndex].LstSessionCourse;

        ATTSessionCourse SC = new ATTSessionCourse();

        List <CourseMaterialControls> CMCList = new List <CourseMaterialControls>();

        CMCList.Add(new CourseMaterialControls(this.fup1, this.chk1, this.lnkFile1));
        CMCList.Add(new CourseMaterialControls(this.fup2, this.chk2, this.lnkFile2));
        CMCList.Add(new CourseMaterialControls(this.fup3, this.chk3, this.lnkFile3));
        CMCList.Add(new CourseMaterialControls(this.fup4, this.chk4, this.lnkFile4));
        CMCList.Add(new CourseMaterialControls(this.fup5, this.chk5, this.lnkFile5));

        foreach (CourseMaterialControls cmc in CMCList)
        {
            if (cmc.FileLink.Text == "Filename" && cmc.FileUploader.HasFile == true)
            {
                SC.LstSessionCourseMaterial.Add
                (
                    new ATTSessionCourseMaterial
                    (
                        int.Parse(Session["OrgID"].ToString()),
                        int.Parse(this.ddlProgram_Rqd.SelectedValue),
                        int.Parse(this.ddlSession_Rqd.SelectedValue),
                        int.Parse(this.ddlCourse_Rqd.SelectedValue),
                        0,
                        cmc.FileUploader.FileName,
                        null,
                        "A",
                        cmc.FileUploader
                    )
                );
            }
            else if (cmc.FileLink.Text != "Filename" && cmc.Checkbox.Checked == true)
            {
                SC.LstSessionCourseMaterial.Add
                (
                    new ATTSessionCourseMaterial
                    (
                        int.Parse(Session["OrgID"].ToString()),
                        int.Parse(this.ddlProgram_Rqd.SelectedValue),
                        int.Parse(this.ddlSession_Rqd.SelectedValue),
                        int.Parse(this.ddlCourse_Rqd.SelectedValue),
                        int.Parse(cmc.FileLink.CommandArgument),
                        cmc.FileLink.Text,
                        null,
                        "D",
                        cmc.FileUploader
                    )
                );
            }
            else if (cmc.FileLink.Text != "Filename" && cmc.FileUploader.HasFile == false)
            {
                SC.LstSessionCourseMaterial.Add
                (
                    new ATTSessionCourseMaterial
                    (
                        int.Parse(Session["OrgID"].ToString()),
                        int.Parse(this.ddlProgram_Rqd.SelectedValue),
                        int.Parse(this.ddlSession_Rqd.SelectedValue),
                        int.Parse(this.ddlCourse_Rqd.SelectedValue),
                        int.Parse(cmc.FileLink.CommandArgument),
                        cmc.FileLink.Text,
                        null,
                        "N",
                        cmc.FileUploader
                    )
                );
            }
        }

        #region "Commented code of Course material items"
        //List<FileUpload> lstFup = new List<FileUpload>();

        //if (this.fup1.HasFile == true)
        //    lstFup.Add(this.fup1);
        //if (this.fup2.HasFile == true)
        //    lstFup.Add(this.fup2);
        //if (this.fup3.HasFile == true)
        //    lstFup.Add(this.fup3);
        //if (this.fup4.HasFile == true)
        //    lstFup.Add(this.fup4);
        //if (this.fup5.HasFile == true)
        //    lstFup.Add(this.fup5);

        //foreach (FileUpload fup in lstFup)
        //{
        //    SC.LstSessionCourseMaterial.Add
        //    (
        //        new ATTSessionCourseMaterial
        //        (
        //            1,
        //            int.Parse(this.ddlProgram_Rqd.SelectedValue),
        //            int.Parse(this.ddlSession_Rqd.SelectedValue),
        //            int.Parse(this.ddlCourse_Rqd.SelectedValue),
        //            0,
        //            fup.FileName,
        //            null,
        //            "A"
        //        )
        //    );
        //}
        #endregion

        bool assigned;

        foreach (GridViewRow grow in this.grdFacultymember.Rows)
        {
            CheckBox chk = ((CheckBox)grow.FindControl("chkSelect"));

            if (grow.Cells[10].Text == "Y")
            {
                assigned = true;
            }
            else
            {
                assigned = false;
            }

            #region "comment"
            //assigned = sessionCourseLst[this.ddlCourse_Rqd.SelectedIndex].LstSessionCourseMember.Exists
            //                        (
            //                            delegate(ATTSessionCourseMember mem)
            //                            {
            //                                return mem.OrgID == int.Parse(grow.Cells[1].Text) &&
            //                                    //mem.ProgramID == int.Parse(this.ddlProgram_Rqd.SelectedValue) &&
            //                                    //mem.SessionID == int.Parse(this.ddlSession_Rqd.SelectedValue) &&
            //                                    //mem.CourseID == int.Parse(this.ddlCourse_Rqd.SelectedValue) &&
            //                                    mem.FacultyID == int.Parse(grow.Cells[2].Text) &&
            //                                    mem.PID == int.Parse(grow.Cells[4].Text) &&
            //                                    mem.FromDate == grow.Cells[6].Text;
            //                                    //mem.AssignmentDate == grow.Cells[7].Text;
            //                            }
            //                        );
            #endregion

            if (chk.Checked == true)
            {
                ATTSessionCourseMember member = new ATTSessionCourseMember();
                member.OrgID          = int.Parse(grow.Cells[1].Text);
                member.ProgramID      = int.Parse(this.ddlProgram_Rqd.SelectedValue);
                member.SessionID      = int.Parse(this.ddlSession_Rqd.SelectedValue);
                member.CourseID       = int.Parse(this.ddlCourse_Rqd.SelectedValue);
                member.FacultyID      = int.Parse(grow.Cells[2].Text);
                member.PID            = int.Parse(grow.Cells[4].Text);;
                member.FromDate       = grow.Cells[6].Text;
                member.AssignmentDate = grow.Cells[6].Text;
                member.ToDate         = grow.Cells[7].Text;

                #region "delegate exists() commented"
                //assigned = lstSC.Exists
                //                    (
                //                        delegate(ATTSessionCourseMember mem)
                //                        {
                //                            return mem.OrgID == member.OrgID &&
                //                                mem.ProgramID == member.ProgramID &&
                //                                mem.SessionID == member.SessionID &&
                //                                mem.CourseID == member.CourseID &&
                //                                mem.FacultyID == member.FacultyID &&
                //                                mem.PID == member.PID &&
                //                                mem.FromDate == member.FromDate &&
                //                                mem.AssignmentDate == member.AssignmentDate;
                //                        }
                //                    );
                #endregion

                if (assigned == true)
                {
                    member.Action = "N";
                }
                else
                {
                    member.Action = "A";
                }

                SC.LstSessionCourseMember.Add(member);
            }
            else
            {
                if (assigned == true)
                {
                    ATTSessionCourseMember member = new ATTSessionCourseMember();
                    member.OrgID          = int.Parse(grow.Cells[1].Text);
                    member.ProgramID      = int.Parse(this.ddlProgram_Rqd.SelectedValue);
                    member.SessionID      = int.Parse(this.ddlSession_Rqd.SelectedValue);
                    member.CourseID       = int.Parse(this.ddlCourse_Rqd.SelectedValue);
                    member.FacultyID      = int.Parse(grow.Cells[2].Text);
                    member.PID            = int.Parse(grow.Cells[4].Text);;
                    member.FromDate       = grow.Cells[6].Text;
                    member.AssignmentDate = grow.Cells[6].Text;
                    member.ToDate         = grow.Cells[7].Text;
                    member.Action         = "D";

                    SC.LstSessionCourseMember.Add(member);
                }
            }
        }

        #region "Commented part"
        //DataTable tbl = (DataTable)Session["DLPDS_FileTable"];

        //foreach (DataRow row in tbl.Rows)
        //{
        //    object raw = row["MaterialByte"];
        //    SC.LstSessionCourseMaterial.Add
        //    (
        //        new ATTSessionCourseMaterial
        //        (
        //            int.Parse(row["OrgID"].ToString()),
        //            int.Parse(row["ProgramID"].ToString()),
        //            int.Parse(row["SessionID"].ToString()),
        //            int.Parse(row["CourseID"].ToString()),
        //            int.Parse(row["MaterialID"].ToString()),
        //            row["MaterialName"].ToString(),
        //            (byte[])row["MaterialByte"],
        //            null,
        //            row["Action"].ToString()
        //        )
        //    );
        //}
        #endregion

        try
        {
            foreach (ATTSessionCourseMaterial mat in SC.LstSessionCourseMaterial)
            {
                if (mat.Action == "A")
                {
                    ((FileUpload)mat.FileUploader).SaveAs(Server.MapPath("~") + "\\MODULES\\DLPDS\\COURSEMATERIAL\\" + mat.MaterialName);
                }
            }

            BLLSessionCourse.AddSessionCourseMaterialNMember(SC);

            foreach (ATTSessionCourseMaterial mat in SC.LstSessionCourseMaterial)
            {
                if (mat.Action == "D")
                {
                    if (System.IO.File.Exists(Server.MapPath("~") + "\\MODULES\\DLPDS\\COURSEMATERIAL\\" + mat.MaterialName) == true)
                    {
                        System.IO.File.Delete(Server.MapPath("~") + "\\MODULES\\DLPDS\\COURSEMATERIAL\\" + mat.MaterialName);
                    }
                }
            }
            SC.LstSessionCourseMaterial.RemoveAll
            (
                delegate(ATTSessionCourseMaterial m)
            {
                return(m.Action == "D");
            }
            );

            sessionCourseLst[this.ddlCourse_Rqd.SelectedIndex].LstSessionCourseMaterial = SC.LstSessionCourseMaterial;

            SC.LstSessionCourseMember.RemoveAll
            (
                delegate(ATTSessionCourseMember m)
            {
                return(m.Action == "D");
            }
            );
            sessionCourseLst[this.ddlCourse_Rqd.SelectedIndex].LstSessionCourseMember = SC.LstSessionCourseMember;

            this.ClearME();

            this.lblStatus.Text        = "Save status";
            this.lblStatusMessage.Text = "Course material and member has been saved.";

            this.ddlProgram_Rqd.SelectedIndex = 0;
            this.ddlSession_Rqd.SelectedIndex = 0;
            this.ddlCourse_Rqd.SelectedIndex  = 0;

            this.programmaticModalPopup.Show();
        }
        catch (Exception ex)
        {
            foreach (ATTSessionCourseMaterial mat in SC.LstSessionCourseMaterial)
            {
                if (mat.Action == "D")
                {
                    if (System.IO.File.Exists(Server.MapPath("~") + "\\MODULES\\DLPDS\\COURSEMATERIAL\\" + mat.MaterialName) == true)
                    {
                        System.IO.File.Delete(Server.MapPath("~") + "\\MODULES\\DLPDS\\COURSEMATERIAL\\" + mat.MaterialName);
                    }
                }
            }

            this.lblStatus.Text        = "Save status";
            this.lblStatusMessage.Text = ex.Message;
            this.programmaticModalPopup.Show();
        }
        finally
        {
            //Session["DLPDS_SessionCourse"] = new ATTSessionCourse();
        }
    }
Beispiel #5
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.ddlPrograms.SelectedIndex == 0)
        {
            this.lblStatus.Text        = "Save Error";
            this.lblStatusMessage.Text = "Please Select Program";
            this.programmaticModalPopup.Show();
            return;
        }

        if (this.lstSession.SelectedIndex == -1)
        {
            this.lblStatusMessage.Text = "Save Error";
            this.lblStatusMessage.Text = "Please Select a Session To Assign Course";
            this.programmaticModalPopup.Show();
            return;
        }

        int count = 0;

        foreach (GridViewRow gvRow in this.grdCourses.Rows)
        {
            if (((CheckBox)gvRow.FindControl("chkSelect")).Checked == true)
            {
                count += 1;
            }
        }
        if (count == 0)
        {
            this.lblStatus.Text        = "Save Error";
            this.lblStatusMessage.Text = "Please Select a Course To be Assigned in Session";
            this.programmaticModalPopup.Show();
            return;
        }

        List <ATTSessionCourse> LstSessionCourse = new List <ATTSessionCourse>();
        List <ATTProgram>       ProgramLST       = (List <ATTProgram>)Session["Programs"];

        ATTSession SessionLST = ProgramLST[ddlPrograms.SelectedIndex].SessionLST[lstSession.SelectedIndex];

        try
        {
            foreach (GridViewRow row in grdCourses.Rows)
            {
                CheckBox CBSelect = (CheckBox)row.Cells[0].FindControl("chkSelect");
                if (CBSelect.Checked == true && row.Cells[3].Text != "E")
                {
                    ATTSessionCourse ObjSessionCourse = new ATTSessionCourse
                                                        (
                        (int)Session["OrgID"],
                        int.Parse(this.ddlPrograms.SelectedValue.ToString()),
                        int.Parse(this.lstSession.SelectedValue.ToString()),
                        int.Parse(row.Cells[1].Text.ToString()),
                        Session["NepDate"].ToString(),
                        "",
                        "",
                        "A"
                                                        );
                    LstSessionCourse.Add(ObjSessionCourse);
                }
                else if (CBSelect.Checked == false && row.Cells[3].Text == "E")
                {
                    ATTSessionCourse ObjSessionCourse = new ATTSessionCourse
                                                        (
                        (int)Session["OrgID"],
                        int.Parse(this.ddlPrograms.SelectedValue.ToString()),
                        int.Parse(this.lstSession.SelectedValue.ToString()),
                        int.Parse(row.Cells[1].Text.ToString()),
                        Session["NepDate"].ToString(),
                        "",
                        "",
                        "D"
                                                        );
                    LstSessionCourse.Add(ObjSessionCourse);
                }
            }

            if (BLLSessionCourse.SaveSessionCourse(LstSessionCourse) == true)
            {
                foreach (GridViewRow row in grdCourses.Rows)
                {
                    CheckBox CBSelect = (CheckBox)row.Cells[0].FindControl("chkSelect");
                    if (CBSelect.Checked == true && row.Cells[3].Text != "E")
                    {
                        ATTSessionCourse ObjSessionCourse = new ATTSessionCourse
                                                            (
                            (int)Session["OrgID"],
                            int.Parse(this.ddlPrograms.SelectedValue.ToString()),
                            int.Parse(this.lstSession.SelectedValue.ToString()),
                            int.Parse(row.Cells[1].Text.ToString()),
                            Session["NepDate"].ToString(),
                            "",
                            "",
                            "E"
                                                            );
                        SessionLST.LstSessionCourse.Add(ObjSessionCourse);
                    }
                    else if (CBSelect.Checked == false && row.Cells[3].Text == "E")
                    {
                        SessionLST.LstSessionCourse.RemoveAll(delegate(ATTSessionCourse obj)
                        {
                            return(obj.OrgID == (int)Session["OrgID"] &&
                                   obj.ProgramID == int.Parse(this.ddlPrograms.SelectedValue.ToString()) &&
                                   obj.SessionID == int.Parse(this.lstSession.SelectedValue.ToString()) &&
                                   obj.CourseID == int.Parse(row.Cells[1].Text.ToString()));
                        });
                        //ATTSessionCourse ObjSessionCourse = new ATTSessionCourse
                        //                                                  (
                        //                                                    (int)Session["OrgID"],
                        //                                                    int.Parse(this.ddlPrograms.SelectedValue.ToString()),
                        //                                                    int.Parse(this.lstSession.SelectedValue.ToString()),
                        //                                                    int.Parse(row.Cells[1].Text.ToString()),
                        //                                                    "12/12/2010",
                        //                                                    "",
                        //                                                    "",
                        //                                                    "D"
                        //                                                  );
                        //LstSessionCourse.Add(ObjSessionCourse);
                    }
                }
            }

            ddlPrograms.SelectedIndex = -1;
            lstSession.Items.Clear();
            grdCourses.DataSource = "";
            grdCourses.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }