Esempio n. 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Course_elearnDAO cdao = new Course_elearnDAO();
            int      id_int       = Convert.ToInt32(id.Text);
            Boolean  check        = false;
            DateTime exp          = new DateTime();

            if (expiry != null)
            {
                if (expiry.Text != "")
                {
                    exp   = Convert.ToDateTime(expiry.Text);
                    check = true;
                }
            }

            Course_elearn c = null;

            if (check) // if no expiry date
            {
                c = new Course_elearn(id_int, name.Text, provider.Text, DateTime.Now, status.Text, desc.Text, "Leadership");
            }
            else // if got expiry date
            {
                c = new Course_elearn(id_int, name.Text, provider.Text, DateTime.Now, exp, status.Text, desc.Text, "Leadership");
            }
            //check pre req here
            //pull pre req from model, check the course object here before creating the entry in the database


            //create the course object
            //now insert into database by calling DAO

            Course_elearnDAO cDao = new Course_elearnDAO();
            Course_elearn    res  = cDao.create_elearnCourse(c);

            Session.Add("res", res);
            Response.Redirect("WebForm1.aspx");
        }
        protected void submitBtn_Click(object sender, EventArgs e)
        {
            Page.Validate("ValidateForm");
            if (!Page.IsValid)
            {
            }
            else
            {
                Course_elearnDAO cdao = new Course_elearnDAO();
                //int id_int = Convert.ToInt32(id.Text);
                Boolean       check = true;
                User          user  = (User)Session["currentUser"];
                Course_elearn c     = null;
                string        type  = Request.QueryString["type"];
                string        name  = nameOfModuleInput.Text;

                string fromDate = fromDateInput.Text.Substring(3, 2) + "/" + fromDateInput.Text.Substring(0, 2) + "/" + fromDateInput.Text.Substring(6, 4);
                string toDate   = toDateInput.Text.Substring(3, 2) + "/" + toDateInput.Text.Substring(0, 2) + "/" + toDateInput.Text.Substring(6, 4);

                if (check && moduleType.Text != "") // if no expiry date
                {
                    c = new Course_elearn(name, user.getDepartment(), DateTime.Now,
                                          DateTime.ParseExact(fromDate, "MM/dd/yyyy", CultureInfo.InvariantCulture), DateTime.ParseExact(toDate, "MM/dd/yyyy", CultureInfo.InvariantCulture), "active", descriptionModuleInput.Text, Convert.ToInt32(moduleType.SelectedValue), user, Convert.ToDouble(hoursInput.Text), txtTargetAudience.Text, ddlCourseType.SelectedValue);
                }

                //check pre req here
                //pull pre req from model, check the course object here before creating the entry in the database

                /*List<int> allSelectedID = new List<int>();
                 * int counter = 0;
                 * foreach (GridViewRow row in gvPrereq.Rows)
                 * {
                 *  CheckBox chkRow = (row.Cells[0].FindControl("chkboxPrereq") as CheckBox);
                 *  if (chkRow.Checked)
                 *  {
                 *      int prereqID = Convert.ToInt32(gvPrereq.DataKeys[counter].Value.ToString());
                 *      allSelectedID.Add(prereqID);
                 *  }
                 *  counter++;
                 * }*/

                //create the course object
                //now insert into database by calling DAO
                Course_elearnDAO cDao           = new Course_elearnDAO();
                Course_elearn    res            = cDao.create_elearnCourse(c);
                Course_elearn    course_with_id = cDao.get_course_by_name(res);
                List <int>       prereqIDlist   = (List <int>)Session["selectedPrereq"];
                int id = course_with_id.getCourseID();

                if (ddlCourseType.SelectedValue.Equals("Online Learning"))
                {
                    foreach (int prereqID in prereqIDlist)
                    {
                        cDao.insertPrerequisite(id, prereqID);
                    }


                    //create dir
                    string file = "~/Data/";
                    string add  = Server.MapPath(file) + id;
                    Directory.CreateDirectory(add);
                }

                //set audit
                User currentUser = (User)Session["currentUser"];
                setAudit(currentUser, "course", "create", res.getCourseID().ToString(), "course name: " + res.getCourseName());

                Response.Redirect("viewModuleInfo.aspx?id=" + id);
            }
        }