Ejemplo n.º 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Logic lo = new Logic();
        Taskk t = new Taskk();
        t.Title = tasktitle.Value;
        t.Description = taskdesc.Value;
        t.IsComplete = false;

        //DateTime.Parse(Calendar1.SelectedDate)
        if (tasktitle.Value.Length == 0 || taskdesc.Value.Length == 0)
        {
            Label lb = new Label();
            lb.Text = "Empty Fields Are Not Allowed";
            Panel1.CssClass = "divError";
            icon.CssClass = "img";
            icon.ImageUrl = "~/assets/icons/error3.png";
            icon.Visible = true;
            PlaceHolder1.Controls.Add(lb);
        }
        else if (tasktitle.Value.Length != 0 && taskdesc.Value.Length != 0)
        {
            if (Calendar1.SelectedDate != null)
            {
                t.DateCreated = (DateTime)Calendar1.SelectedDate;
                bool resp1 = lo.CreateTask(t);
                int last = lo.GetLastTaskID();
                PersonTask pt = new PersonTask();
                string u = Session["username"].ToString();
                Person pp = lo.GetPerson(u);
                pt.PersonId = pp.Id; //lo.GetPersonID("ay");
                pt.TaskkId = last;
                bool resp2 = lo.CreatePersonTask(pt);
                if (resp1 == true && resp2 == true)
                {
                    Label lb = new Label();
                    lb.Text = "New Task Added Successfully";
                    Panel1.CssClass = "divSuccess";
                    icon.CssClass = "img";
                    icon.ImageUrl = "~/assets/icons/success3.png";
                    icon.Visible = true;
                    PlaceHolder1.Controls.Add(lb);
                }
                else if (resp1 != true || resp2 != true)
                {
                    Label lb = new Label();
                    lb.Text = "New Task Could Not Be Added";
                    Panel1.CssClass = "divError";
                    icon.CssClass = "img";
                    icon.ImageUrl = "~/assets/icons/error3.png";
                    icon.Visible = true;
                    PlaceHolder1.Controls.Add(lb);
                }
            }
            else if (Calendar1.SelectedDate == null)
            {

                Label lb = new Label();
                lb.Text = "No Date Selected";
                Panel1.CssClass = "divError";
                icon.CssClass = "img";
                icon.ImageUrl = "~/assets/icons/error3.png";
                icon.Visible = true;
                PlaceHolder1.Controls.Add(lb);
            }
        }
    }