protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        //	Submit button.

        int TaskId = Convert.ToInt32(ViewState["TaskId"].ToString());

        try
        {
            ClassTask oTsk = new ClassTask();
            oTsk.ProjectId = Convert.ToInt32(ViewState["ProjectId"].ToString());
            oTsk.TaskName = this.TxtTaskName.Text;
            oTsk.CostCentre = this.TxtCostCentre.Text;
            oTsk.IsProductive = (this.DdlProductive.SelectedValue == "0") ? false : true;
            oTsk.Active = (this.DdlActive.SelectedValue == "0") ? false : true;
            oTsk.ReferenceRegEx = this.TxtReferenceRegEx.Text;
            oTsk.Description = this.TxtDescription.Text;
            oTsk.ValidationType = Convert.ToInt16(this.DdlValidationType.SelectedValue);
            TaskId = oTsk.Save(TaskId);
        }

        catch (Exception ex)
        {
            Log.LogMsg(ex.Message);
        }

        Response.Redirect(string.Format("TaskMenu.aspx?ProjectId={0}&TaskId={1}", Convert.ToInt32(ViewState["ProjectId"].ToString()), TaskId), true);
    }
    protected void BtnConfirm_Click(object sender, EventArgs e)
    {
        ClassTask oTsk = new ClassTask();

        oTsk.Delete(Convert.ToInt32(ViewState["TaskId"].ToString()));

        Response.Redirect(string.Format("TaskMenu.aspx?ProjectId={0}&TaskId=0", Convert.ToInt32(ViewState["ProjectId"].ToString())), true);
    }
        public ActionResult DeleteConfirmed(int id)
        {
            ClassTask classTask = db.ClassTasks.Find(id);

            db.ClassTasks.Remove(classTask);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,heading,body")] ClassTask classTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(classTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(classTask));
 }
        // GET: ClassTasks/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClassTask classTask = db.ClassTasks.Find(id);

            if (classTask == null)
            {
                return(HttpNotFound());
            }
            return(View(classTask));
        }
Exemple #6
0
        public IActionResult CreateNewTask(string tName)
        {
            if (!ds.TaskExists(tName))
            {
                ClassTask tsk = new ClassTask(tName);
                ds.SaveTask(tsk);
                if (ModelState.IsValid)
                {
                    ModelState.Clear();
                }

                ViewBag.Tasks = ds.GetTaskList();
            }
            return(View("~/Views/Home/Index.cshtml"));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            //	First time initialisation.

            Page.Title = TXT_PAGETITLE;
            this.LblPageTitle.Text = TXT_PAGETITLE;

            if (Request.QueryString["ProjectId"] == null)
                Response.Redirect("ProjectMenu.aspx", true);

            ViewState["ProjectId"] = Request.QueryString["ProjectId"].ToString();

            int ProjectId = (int) Convert.ToInt32(ViewState["ProjectId"].ToString());

            ClassProject oPrj = new ClassProject(ProjectId);
            ClassTask oTsk = new ClassTask();

            this.LblProject.Text = oPrj.ProjectName;

            this.DdlTasks.DataSource = oTsk.ShowTasksForProject(ProjectId, false);
            this.DdlTasks.DataTextField = "TaskName";
            this.DdlTasks.DataValueField = "TaskId";
            this.DdlTasks.DataBind();

            if (Request.QueryString["TaskId"] != null)
            {
                try
                {
                    this.DdlTasks.SelectedValue = Request.QueryString["TaskId"].ToString();
                }

                catch (Exception)
                {
                    //	Do nothing. This isn't an error. It just means that the requested
                    //	TaskId isn't in the dropdown listbox.
                }
            }

            if (this.DdlTasks.Items.Count == 0)
            {
                this.BtnDeleteTask.Enabled = false;
                this.BtnEditTask.Enabled = false;
                this.DdlTasks.Enabled = false;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            //	First time initialisation.

            Page.Title = TXT_PAGETITLE;
            this.LblPageTitle.Text = TXT_PAGETITLE;

            if (Request.QueryString["ProjectId"] == null)
                Response.Redirect("ProjectMenu.aspx", true);

            if (Request.QueryString["TaskId"] == null)
                Response.Redirect("TaskMenu.aspx", true);

            ViewState["ProjectId"] = Request.QueryString["ProjectId"].ToString();
            ViewState["TaskId"] = Request.QueryString["TaskId"].ToString();

            ClassTask oCat = new ClassTask(Convert.ToInt32(ViewState["TaskId"].ToString()));

            this.LblMsg.Text = oCat.TaskName;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = TXT_PAGETITLE;
        this.LblPageTitle.Text = TXT_PAGETITLE;

        if (Page.IsPostBack == false)
        {
            //	First time initialisation.

            if (Request.QueryString["ProjectId"] == null)
                Response.Redirect("ProjectMenu.aspx", true);

            if (Request.QueryString["TaskId"] == null)
                Response.Redirect("TaskMenu.aspx?ProjectId=" + Request.QueryString["ProjectId"].ToString(), true);

            ViewState["ProjectId"] = Request.QueryString["ProjectId"].ToString();
            ViewState["TaskId"] = Request.QueryString["TaskId"].ToString();

            int ProjectId = Convert.ToInt32(ViewState["ProjectId"].ToString());
            int TaskId = Convert.ToInt32(ViewState["TaskId"].ToString());

            ClassProject oPrj = new ClassProject(ProjectId);
            ClassTask oTsk = new ClassTask(TaskId);

            this.LblProject.Text = oPrj.ProjectName;
            this.TxtTaskName.Text = oTsk.TaskName;
            this.TxtCostCentre.Text = oTsk.CostCentre;
            this.DdlProductive.SelectedValue = (oTsk.IsProductive == true) ? "1" : "0";
            this.DdlActive.SelectedValue = (oTsk.Active == true) ? "1" : "0";
            this.TxtReferenceRegEx.Text = oTsk.ReferenceRegEx;
            this.TxtDescription.Text = oTsk.Description;
            this.DdlValidationType.SelectedValue = oTsk.ValidationType.ToString();

            this.TxtTaskName.Focus();
        }
    }
Exemple #10
0
    public DataSet GetTasksForProject(string UsrNam, string UsrPwd, Int32 ProjectId, Boolean bActiveOnly)
    {
        DataSet oDs = null;

        try
        {
            Int32 UserId = GetUserId(UsrNam, UsrPwd);

            if (UserId > 0)
            {
                ClassTask oTsk = new ClassTask();

                oDs = oTsk.ShowTasksForProject(ProjectId, bActiveOnly);
            }
        }

        catch (Exception ex)
        {
            Log.LogMsg(ex.Message);
        }

        return oDs;
    }
    private void ShowTasks()
    {
        this.DdlTasks.Enabled = false;

        if (this.ddlProjects.Items.Count > 0)
        {
            ClassTask oTsk = new ClassTask();
            DataSet oDs = oTsk.ShowTasksForProject(Convert.ToInt32(this.ddlProjects.SelectedValue), true);

            if (oDs != null)
            {
                if (oDs.Tables.Count > 0)
                {
                    if (oDs.Tables[0].Rows.Count > 0)
                    {
                        //	We have some tasks.

                        this.DdlTasks.Enabled = true;

                        this.DdlTasks.DataSource = oDs;
                        this.DdlTasks.DataTextField = "TaskName";
                        this.DdlTasks.DataValueField = "TaskId";
                        this.DdlTasks.DataBind();

                        ShowJobs(0);
                    }
                }
            }
        }
    }
        public ActionResult Create(ClassTask classTask)
        {
            string userId   = User.Identity.GetUserId();
            var    teacher  = db.Teachers.Find(userId);
            var    currTime = DateTime.Now;

            if (!ModelState.IsValid)
            {
                var enrollList   = new List <SelectListItem>();
                var enrollsQuery = (from e in teacher.enrollments
                                    orderby e.grade, e.@group ascending
                                    select e);
                foreach (var m in enrollsQuery)
                {
                    enrollList.Add(new SelectListItem {
                        Value = (m.Id).ToString(), Text = m.grade + m.group
                    });
                }

                ViewBag.streamlist     = enrollList;
                TempData["classesNum"] = teacher.enrollments.Count();
                return(View(classTask));
            }
            if (classTask.dueDate < DateTime.Today)
            {
                ModelState.AddModelError("dueDate", "Due date cannot be past date.");
                var enrollList   = new List <SelectListItem>();
                var enrollsQuery = (from e in teacher.enrollments
                                    orderby e.grade, e.@group ascending
                                    select e);
                foreach (var m in enrollsQuery)
                {
                    enrollList.Add(new SelectListItem {
                        Value = (m.Id).ToString(), Text = m.grade + m.group
                    });
                }

                ViewBag.streamlist     = enrollList;
                TempData["classesNum"] = teacher.enrollments.Count();
                return(View(classTask));
            }
            var x = DateTime.Compare(DateTime.Now, classTask.dueTime);

            if (classTask.dueDate == DateTime.Today && x > 0)
            {
                ModelState.AddModelError("dueTime", "Time cannot be past time.");
                var enrollList   = new List <SelectListItem>();
                var enrollsQuery = (from e in teacher.enrollments
                                    orderby e.grade, e.@group ascending
                                    select e);
                foreach (var m in enrollsQuery)
                {
                    enrollList.Add(new SelectListItem {
                        Value = (m.Id).ToString(), Text = m.grade + m.group
                    });
                }

                ViewBag.streamlist     = enrollList;
                TempData["classesNum"] = teacher.enrollments.Count();
                return(View(classTask));
            }
            if (ModelState.IsValid)
            {
                if (classTask.file != null)
                {
                    var           fileName      = Path.GetFileName(classTask.file.FileName);
                    ClassTaskFile classTaskFile = new ClassTaskFile()
                    {
                        FileName  = fileName,
                        Extension = Path.GetExtension(fileName),
                        Id        = classTask.Id,
                        ClassTask = classTask
                    };
                    classTask.ClassTaskFile = classTaskFile;
                }

                classTask.Teacher = teacher;
                long enrId  = Convert.ToInt64(classTask.enrollId);
                var  Enroll = teacher.enrollments.ToList().Find(p => p.Id == enrId);
                classTask.postDate   = DateTime.Now;
                classTask.Enrollment = Enroll;
                db.ClassTasks.Add(classTask);
                db.SaveChanges();
                if (classTask.file != null)
                {
                    var fileName = Path.GetFileName(classTask.file.FileName);
                    var path     = Path.Combine(Server.MapPath("~/App_Data/ClassTaskFiles/"), classTask.ClassTaskFile.Id + fileName);
                    classTask.file.SaveAs(path);
                }
                return(RedirectToAction("Index"));
            }

            return(View(classTask));
        }