Exemple #1
0
    protected void ddCourses_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddCourses.SelectedValue == Guid.Empty.ToString())
        {
            textBoxCourseTitleUpd.Text        = "";
            textBoxCourseDescriptionUpd.Text  = "";
            textBoxCourseCommentUpd.Text      = "";
            checkBoxCourseCompleteUpd.Checked = false;
            lbMembers.Items.Clear();
            return;
        }

        try
        {
            Database.Interface.open();

            Database.Course course = new Database.Course();
            if (!course.select_all_where_ID(new Guid(ddCourses.SelectedValue)))
            {
                Utils.displayStatus(ref labelStatusCreate, Color.Red, "Kurs '" + ddCourses.SelectedItem.Text + "' ikke funnet");
                return;
            }

            textBoxCourseTitleUpd.Text        = course.Title;
            textBoxCourseDescriptionUpd.Text  = course.Description;
            textBoxCourseCommentUpd.Text      = course.Comment;
            checkBoxCourseCompleteUpd.Checked = course.Completed;

            Database.Contact contact     = new Database.Contact();
            Database.Account account     = new Database.Account();
            string           accountName = "";
            List <Guid>      idList      = new List <Guid>();
            Database.Contact.select_ID_from_courseID(new Guid(ddCourses.SelectedValue), ref idList);
            lbMembers.Items.Clear();
            foreach (Guid id in idList)
            {
                contact.select_all_by_ID(id);
                account.select_String_where_ID(contact.AccountID, "vchName", ref accountName);
                lbMembers.Items.Add(new ListItem(contact.Name + " fra " + accountName + " [" + (contact.Status == "Active" ? "Aktiv" : "Inaktiv") + "]"));
            }
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
Exemple #2
0
    protected void buttonUpdateCourse_OnClick(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(textBoxCourseTitleUpd.Text) || ddCourses.SelectedValue == Guid.Empty.ToString())
        {
            Utils.displayStatus(ref labelStatusEdit, Color.Red, "Mangler informasjon");
            return;
        }

        try
        {
            Database.Interface.open();

            Database.Course course = new Database.Course();
            if (!course.select_all_where_ID(new Guid(ddCourses.SelectedValue)))
            {
                Utils.displayStatus(ref labelStatusEdit, Color.Red, "Kurs '" + ddCourses.SelectedItem.Text + "' ikke funnet");
                return;
            }

            course.Title       = textBoxCourseTitleUpd.Text;
            course.Description = textBoxCourseDescriptionUpd.Text;
            course.Comment     = textBoxCourseCommentUpd.Text;
            course.Completed   = checkBoxCourseCompleteUpd.Checked;

            if (!course.update_all_by_ID())
            {
                Utils.displayStatus(ref labelStatusEdit, Color.Red, "Oppdatering av kurs feilet");
                return;
            }

            Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Kurs '" + textBoxCourseTitleUpd.Text + "' oppdatert");

            textBoxCourseTitleUpd.Text        = "";
            textBoxCourseDescriptionUpd.Text  = "";
            textBoxCourseCommentUpd.Text      = "";
            checkBoxCourseCompleteUpd.Checked = false;
            lbMembers.Items.Clear();

            ddCourses.DataBind();
            gridShowCourses.DataBind();
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }