コード例 #1
0
ファイル: Ringtest.aspx.cs プロジェクト: bytting/Lorakon
    protected void ddDetector_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        labelStatusSelectDetector.Text = "";

        buttonDetectorContinue.Enabled = true;
        if (ddDetector.SelectedValue == Guid.Empty.ToString())
        {
            buttonDetectorContinue.Enabled = false;
            labelDetectorInfo.Text         = "";
            return;
        }

        try
        {
            Database.Interface.open();
            Database.RingtestReport report = new Database.RingtestReport();
            if (report.select_all_where_accountID_detectorID_ringtestID(
                    new Guid(hiddenAccountID.Value),
                    new Guid(ddDetector.SelectedValue),
                    new Guid(hiddenRingtestID.Value)))
            {
                labelDetectorInfo.Text  = Lang.Evaluated + ": " + (report.Evaluated ? "Ja" : "Nei");
                labelDetectorInfo.Text += "<br>Godkjent: " + (report.Approved ? "Ja" : "Nei");
                if (report.ContactID != Guid.Empty)
                {
                    Database.Contact contact = new Database.Contact();
                    contact.select_all_by_ID(report.ContactID);
                    labelDetectorInfo.Text += "<br>" + Lang.Contact + ": " + contact.Name + "   [" + (contact.Status == "Active" ? "Aktiv" : "Inaktiv") + "]";

                    if (contact.Status != "Active")
                    {
                        buttonDetectorContinue.Enabled = false;
                    }
                }
                else
                {
                    labelDetectorInfo.Text += "<br>" + Lang.Contact + ": " + Lang.None;
                }
            }
            else
            {
                labelDetectorInfo.Text = Lang.NoReportForDetector + ".<br>" + Lang.PressContinueForNewReport;
            }
        }
        catch (Exception ex)
        {
            Utils.reportStatus(ref labelStatusSelectDetector, Color.Red, "Ringtest.ddDetector_OnSelectedIndexChanged: " + ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
コード例 #2
0
ファイル: Course.aspx.cs プロジェクト: bytting/Lorakon
    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();
        }
    }
コード例 #3
0
ファイル: Course.aspx.cs プロジェクト: bytting/Lorakon
    protected void cbCourseActorBit_OnCheckChanged(object sender, EventArgs e)
    {
        if (gridCourse.SelectedDataKey == null)
        {
            Utils.displayStatus(ref labelStatus, Color.Red, Lang.No_courses_selected);
            clearAllActorBits();
            return;
        }

        Guid courseID = (Guid)gridCourse.SelectedDataKey.Value;

        try
        {
            Database.Interface.open();

            for (int i = 0; i < gridCourseActors.Rows.Count; i++)
            {
                Database.Contact contact = new Database.Contact();
                contact.select_all_by_ID((Guid)gridCourseActors.DataKeys[i][0]);
                CheckBox cb = (CheckBox)gridCourseActors.Rows[i].FindControl("cbCourseActorBit");

                if (cb.Checked)
                {
                    contact.link_with_courseID(courseID);
                }
                else
                {
                    contact.unlink_with_courseID(courseID);
                }

                Utils.displayStatus(ref labelStatus, Color.SeaGreen, Resources.Localization.StatusCourseUpdated);
            }
        }
        catch (Exception ex)
        {
            Utils.reportStatus(ref labelStatus, Color.Red, "Course.cbCourseActorBit_OnCheckChanged: " + ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
コード例 #4
0
ファイル: Account.aspx.cs プロジェクト: bytting/Lorakon
    protected void ddActors_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddActors.SelectedValue == Guid.Empty.ToString())
        {
            textBoxNameUpd.Text    = "";
            textBoxEmailUpd.Text   = "";
            textBoxPhoneUpd.Text   = "";
            textBoxMobileUpd.Text  = "";
            ddStatus.SelectedIndex = -1;
            return;
        }

        try
        {
            Database.Interface.open();
            Database.Contact contact = new Database.Contact();
            if (!contact.select_all_by_ID(new Guid(ddActors.SelectedValue)))
            {
                Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.ddActors_OnSelectedIndexChanged: Contact not found");
                return;
            }

            textBoxNameUpd.Text    = contact.Name;
            textBoxEmailUpd.Text   = contact.Email;
            textBoxPhoneUpd.Text   = contact.Phone;
            textBoxMobileUpd.Text  = contact.Mobile;
            ddStatus.SelectedValue = contact.Status;
        }
        catch (Exception ex)
        {
            Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.ddActors_OnSelectedIndexChanged: " + ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
コード例 #5
0
ファイル: Account.aspx.cs プロジェクト: bytting/Lorakon
    protected void buttonUpdateActor_OnClick(object sender, EventArgs e)
    {
        if (ddActors.SelectedValue == Guid.Empty.ToString())
        {
            return;
        }

        if (String.IsNullOrEmpty(textBoxNameUpd.Text) || String.IsNullOrEmpty(textBoxEmailUpd.Text))
        {
            Utils.displayStatus(ref labelStatusActors, Color.Red, Resources.Localization.MissingInformation);
            return;
        }

        if (!Utils.isValidEmail(textBoxEmailUpd.Text))
        {
            Utils.displayStatus(ref labelStatusActors, Color.Red, Lang.Email_invalid_address);
            return;
        }

        try
        {
            Database.Interface.open();

            Database.Contact contact = new Database.Contact();
            if (!contact.select_all_by_ID(new Guid(ddActors.SelectedValue)))
            {
                Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.buttonUpdateActor_OnClick: Contact not found");
                return;
            }

            if (ddStatus.SelectedValue != "Active")
            {
                Database.Interface.open();

                Database.Interface.command.Parameters.Clear();
                Database.Interface.command.CommandText = @"
SELECT COUNT(Contact.ID) 
FROM Contact, Course, Contact_Course 
WHERE Course.bitCompleted = 0     
    AND Contact.ID = Contact_Course.ContactID 
    AND Course.ID = Contact_Course.CourseID AND Contact.ID = @contactID";
                Database.Interface.command.CommandType = CommandType.Text;
                Database.Interface.command.Parameters.AddWithValue("@contactID", contact.ID);
                int count = (int)Database.Interface.command.ExecuteScalar();
                if (count > 0)
                {
                    Utils.displayStatus(ref labelStatusActors, Color.Red, "Kan ikke deaktivere. Den interne brukeren er oppmeldt til en eller flere kurs");
                    return;
                }
                Database.Interface.command.Parameters.Clear();

                Database.Interface.command.CommandText = @"
SELECT COUNT(RingtestReport.ID) 
FROM RingtestReport
WHERE RingtestReport.bitApproved = 0 
    AND RingtestReport.ContactID = @contactID";
                Database.Interface.command.CommandType = CommandType.Text;
                Database.Interface.command.Parameters.AddWithValue("@contactID", contact.ID);
                count = (int)Database.Interface.command.ExecuteScalar();
                if (count > 0)
                {
                    Utils.displayStatus(ref labelStatusActors, Color.Red, "Kan ikke deaktivere. Den interne brukeren har en eller flere ringtest rapporter");
                    return;
                }
                Database.Interface.command.Parameters.Clear();
            }

            contact.Name   = textBoxNameUpd.Text;
            contact.Email  = textBoxEmailUpd.Text;
            contact.Phone  = String.IsNullOrEmpty(textBoxPhoneUpd.Text) ? "" : textBoxPhoneUpd.Text;
            contact.Mobile = String.IsNullOrEmpty(textBoxMobileUpd.Text) ? "" : textBoxMobileUpd.Text;
            contact.Status = ddStatus.SelectedValue;

            if (!contact.update_all_by_ID())
            {
                Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.buttonUpdateActor_OnClick: Update contact failed");
                return;
            }

            Utils.displayStatus(ref labelStatusActors, Color.SeaGreen, Lang.Contact + " '" + textBoxNameUpd.Text + "' " + Lang.updated);

            textBoxNameUpd.Text    = "";
            textBoxEmailUpd.Text   = "";
            textBoxPhoneUpd.Text   = "";
            textBoxMobileUpd.Text  = "";
            ddStatus.SelectedIndex = -1;

            ddActors.DataBind();
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusActors, Color.Red, "Actors.buttonUpdateActor_OnClick: " + ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }