Esempio n. 1
0
    protected void buttonAddComment_OnClick(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(tbComment.Text))
        {
            Utils.displayStatus(ref labelStatusReport, Color.Red, "Du må skrive inn en kommentar først");
            return;
        }

        try
        {
            Database.Interface.open();
            Database.RingtestReport report = new Database.RingtestReport();
            if (!report.select_all_where_ID(new Guid(hiddenRingtestReportID.Value)))
            {
                Utils.reportStatus(ref labelStatusReport, Color.Red, "Ringtest.buttonAddComment_OnClick: Report not found");
                return;
            }

            report.add_comment(ddCurrentActor.SelectedItem.Text, tbComment.Text);
            gridComments.DataSource = Database.RingtestReport.get_comments(report.ID);
            gridComments.DataBind();
            tbComment.Text = "";
            Utils.displayStatus(ref labelStatusReport, Color.SeaGreen, "Kommentar oppdatert");
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusReport, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
Esempio n. 2
0
    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();
        }
    }
Esempio n. 3
0
    protected void buttonUpdateED_OnClick(object sender, EventArgs e)
    {
        if (ddCategoriesED.SelectedValue == Guid.Empty.ToString() ||
            ddTypesED.SelectedValue == Guid.Empty.ToString() ||
            String.IsNullOrEmpty(ddStatusED.Text) ||
            ddOwnershipED.SelectedValue == Guid.Empty.ToString())
        {
            Utils.displayStatus(ref labelStatusCreate, Color.Red, "Mangler informasjon");
            return;
        }

        try
        {
            Database.Interface.open();

            Database.Device device = new Database.Device();
            device.select_all_where_ID((Guid)gridDevicesED.SelectedDataKey.Value);
            if (device.AccountID.ToString() != ddAccountED.SelectedValue)
            {
                Database.Ringtest ringtest = new Database.Ringtest();
                if (ringtest.select_all_where_year(DateTime.Now.Year))
                {
                    Database.RingtestReport report = new Database.RingtestReport();
                    if (report.select_all_where_ringtestID_AccountID_DetectorID_approved(ringtest.ID, device.AccountID, device.ID, false))
                    {
                        Utils.displayStatus(ref labelStatusEdit, Color.Red, "Oppdatering avbrutt. Kan ikke oppdatere innehaver fordi enheten har en aktiv ringtestrapport");
                        return;
                    }
                }
            }
            device.DeviceCategoryID = new Guid(ddCategoriesEdit.SelectedValue);
            device.DeviceTypeID     = new Guid(ddTypesEdit.SelectedValue);
            device.AccountID        = new Guid(ddAccountED.SelectedValue);
            device.SerialNumber     = tbSerialnumberED.Text;
            device.Status           = ddStatusED.SelectedValue;
            device.Ownership        = ddOwnershipED.SelectedValue;
            device.Comment          = tbCommentED.Text;
            device.ReceivedNew      = String.IsNullOrEmpty(tbReceivedNewED.Text) ? DateTime.MinValue : DateTime.Parse(tbReceivedNewED.Text);

            if (device.update_by_ID())
            {
                Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Enhet oppdatert");
            }
            else
            {
                Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Oppdatering av enhet feilet");
            }

            gridDevicesED.SelectedIndex = -1;
            gridDevicesED.DataBind();
            gridDevicesAllED.DataBind();
            panelDeviceED.Visible = false;
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
Esempio n. 4
0
    protected void buttonRingtestReportUpdate_OnClick(object sender, EventArgs e)
    {
        if (ddCurrentActor.SelectedValue == Guid.Empty.ToString())
        {
            Utils.displayStatus(ref labelStatusReport, Color.Red, Lang.You_must_select_contact_for_this_report);
            return;
        }

        if (String.IsNullOrEmpty(tbMeasureDate.Text) || String.IsNullOrEmpty(tbRefDate.Text) || String.IsNullOrEmpty(tbActivityRef.Text))
        {
            Utils.displayStatus(ref labelStatusReport, Color.Red, Lang.Missing_fields);
            return;
        }

        DateTime measureDate = DateTime.Now;
        DateTime refDate     = DateTime.Now;

        try
        {
            measureDate = Convert.ToDateTime(tbMeasureDate.Text);
            refDate     = Convert.ToDateTime(tbRefDate.Text);
        }
        catch (Exception except)
        {
            Utils.displayStatus(ref labelStatusReport, Color.Red, Lang.Invalid_date_fields);
            return;
        }

        try
        {
            Database.Interface.open();
            Database.RingtestReport report = new Database.RingtestReport();
            if (!report.select_all_where_ID(new Guid(hiddenRingtestReportID.Value)))
            {
                Utils.reportStatus(ref labelStatusReport, Color.Red, "Ringtest.buttonRingtestReportUpdate_OnClick: Report not found");
                return;
            }

            if (report.Approved)
            {
                Utils.displayStatus(ref labelStatusReport, Color.Red, Lang.Update_failed_report_approved);
                return;
            }

            if (cbWantEvaluation.Checked)
            {
                if (ddMCAType.SelectedValue == "Inspector1000")
                {
                    if (ddCurrentActor.SelectedIndex == -1 || String.IsNullOrEmpty(tbGeometryFactor.Text) || String.IsNullOrEmpty(tbActivityRef.Text) ||
                        String.IsNullOrEmpty(tbAvgLivetimeSample.Text) || String.IsNullOrEmpty(tbUncertainty.Text))
                    {
                        Utils.displayStatus(ref labelStatusReport, Color.Red, Lang.Cannot_evaluate_missing_fields);
                        return;
                    }
                }
                else
                {
                    if (ddCurrentActor.SelectedIndex == -1 || String.IsNullOrEmpty(tbBackground.Text) || String.IsNullOrEmpty(tbIntegralBackground.Text) ||
                        String.IsNullOrEmpty(tbCountingBackground.Text) || String.IsNullOrEmpty(tbGeometryFactor.Text) || String.IsNullOrEmpty(tbActivity.Text) ||
                        String.IsNullOrEmpty(tbActivityRef.Text) || String.IsNullOrEmpty(tbAvgIntegralSample.Text) || String.IsNullOrEmpty(tbAvgLivetimeSample.Text))
                    {
                        Utils.displayStatus(ref labelStatusReport, Color.Red, Lang.Cannot_evaluate_missing_fields);
                        return;
                    }
                }
            }

            try
            {
                if (ddCurrentActor.SelectedIndex == -1)
                {
                    report.ContactID = Guid.Empty;
                }
                else
                {
                    report.ContactID = new Guid(ddCurrentActor.SelectedValue);
                }
                report.MCAType              = ddMCAType.SelectedValue;
                report.Background           = String.IsNullOrEmpty(tbBackground.Text) ? float.MinValue : Convert.ToSingle(tbBackground.Text);
                report.IntegralBackground   = String.IsNullOrEmpty(tbIntegralBackground.Text) ? int.MinValue : Convert.ToInt32(tbIntegralBackground.Text);
                report.CountingBackground   = String.IsNullOrEmpty(tbCountingBackground.Text) ? int.MinValue : Convert.ToInt32(tbCountingBackground.Text);
                report.GeometryFactor       = String.IsNullOrEmpty(tbGeometryFactor.Text) ? float.MinValue : Convert.ToSingle(tbGeometryFactor.Text);
                report.Activity             = String.IsNullOrEmpty(tbActivity.Text) ? float.MinValue : Convert.ToSingle(tbActivity.Text);
                report.ActivityRef          = String.IsNullOrEmpty(tbActivityRef.Text) ? float.MinValue : Convert.ToSingle(tbActivityRef.Text);
                report.Uncertainty          = String.IsNullOrEmpty(tbUncertainty.Text) ? float.MinValue : Convert.ToSingle(tbUncertainty.Text);
                report.AvgIntegralSample    = String.IsNullOrEmpty(tbAvgIntegralSample.Text) ? float.MinValue : Convert.ToSingle(tbAvgIntegralSample.Text);
                report.AvgLivetimeSample    = String.IsNullOrEmpty(tbAvgLivetimeSample.Text) ? float.MinValue : Convert.ToSingle(tbAvgLivetimeSample.Text);
                report.RefDate              = refDate;
                calRefDate.SelectedDate     = report.RefDate;
                report.MeasureDate          = measureDate;
                calMeasureDate.SelectedDate = report.MeasureDate;
                report.WantEvaluation       = cbWantEvaluation.Checked;
                report.AnswerByEmail        = cbAnswerByEmail.Checked;
            }
            catch (Exception except2)
            {
                Utils.displayStatus(ref labelStatusReport, Color.Red, Lang.Invalid_fields);
                return;
            }

            if (!report.update_all_by_ID())
            {
                Utils.reportStatus(ref labelStatusReport, Color.Red, "Ringtest.buttonRingtestReportUpdate_OnClick: Update report failed");
                return;
            }

            Utils.displayStatus(ref labelStatusReport, Color.SeaGreen, Lang.Report_updated);
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusReport, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }

        //ddDetector_OnSelectedIndexChanged(sender, e);
    }
Esempio n. 5
0
    protected void buttonDetectorContinue_OnClick(object sender, EventArgs e)
    {
        if (ddDetector.SelectedValue == Guid.Empty.ToString())
        {
            Utils.displayStatus(ref labelStatusSelectDetector, Color.Red, Lang.NoDetectorSelected);
            return;
        }

        try
        {
            Database.Ringtest       ringtest = new Database.Ringtest();
            Database.RingtestReport report   = new Database.RingtestReport();
            Database.RingtestBox    box      = new Database.RingtestBox();

            Database.Interface.open();

            if (!ringtest.select_all_where_year(DateTime.Now.Year))
            {
                Utils.reportStatus(ref labelStatusSelectDetector, Color.Red, "Ringtest.buttonDetectorContinue_OnClick: No ringtest found for year " + DateTime.Now.Year.ToString());
                return;
            }

            if (!report.select_all_where_accountID_detectorID_ringtestID(
                    new Guid(hiddenAccountID.Value),
                    new Guid(ddDetector.SelectedValue),
                    ringtest.ID))
            {
                report.AccountID     = new Guid(hiddenAccountID.Value);
                report.DetectorID    = new Guid(ddDetector.SelectedValue);
                report.RingtestID    = ringtest.ID;
                report.RingtestBoxID = new Guid(hiddenRingtestBoxID.Value);
                report.AnswerByEmail = false;
                report.MeasureDate   = SqlDateTime.MinValue.Value;
                report.RefDate       = SqlDateTime.MinValue.Value;

                if (!report.insert_with_ID(Guid.NewGuid()))
                {
                    Utils.reportStatus(ref labelStatusSelectDetector, Color.Red, "Ringtest.buttonDetectorContinue_OnClick: Insert new report failed");
                    return;
                }
            }

            if (!box.select_all_where_ID(report.RingtestBoxID))
            {
                Utils.reportStatus(ref labelStatusSelectDetector, Color.Red, "Ringtest.buttonDetectorContinue_OnClick: Ringtestbox not found");
                return;
            }

            hiddenRingtestReportID.Value = report.ID.ToString();

            multiViewRingtest.SetActiveView(viewRingtestReport);

            Database.Device detector = new Database.Device();
            if (!detector.select_all_where_ID(report.DetectorID))
            {
                Utils.reportStatus(ref labelStatusReport, Color.Red, "Ringtest.buttonDetectorContinue_OnClick: Detector not found");
                return;
            }
            labelReportDetector.Text = detector.SerialNumber;

            if (report.ContactID == Guid.Empty)
            {
                ddCurrentActor.SelectedIndex = -1;
            }
            else
            {
                ddCurrentActor.SelectedValue = report.ContactID.ToString();
            }
            ddMCAType.SelectedValue = report.MCAType;
            labelBoxWeight.Text     = Utils.roundOff(box.Weight, 1) + "g (" + box.KNumber + ")";
            //calMeasureDate.SelectedDate = report.MeasureDate;
            tbBackground.Text         = Utils.roundOff(report.Background, 2);
            tbIntegralBackground.Text = Utils.intToString(report.IntegralBackground);
            tbCountingBackground.Text = Utils.intToString(report.CountingBackground);
            tbGeometryFactor.Text     = Utils.roundOff(report.GeometryFactor, 2);
            tbActivity.Text           = Utils.roundOff(report.Activity, 1);
            tbActivityRef.Text        = Utils.roundOff(report.ActivityRef, 1);
            tbUncertainty.Text        = Utils.roundOff(report.Uncertainty, 1);
            tbAvgIntegralSample.Text  = Utils.roundOff(report.AvgIntegralSample, 1);
            tbAvgLivetimeSample.Text  = Utils.roundOff(report.AvgLivetimeSample, 1);
            //calRefDate.SelectedDate = report.RefDate;
            cbWantEvaluation.Checked = report.WantEvaluation;
            cbAnswerByEmail.Checked  = report.AnswerByEmail;
            cbEvaluated.Checked      = report.Evaluated;
            cbApproved.Checked       = report.Approved;
            gridComments.DataSource  = Database.RingtestReport.get_comments(report.ID);
            gridComments.DataBind();

            if (report.MeasureDate != SqlDateTime.MinValue.Value)
            {
                calMeasureDate.SelectedDate = report.MeasureDate;
            }

            if (report.RefDate != SqlDateTime.MinValue.Value)
            {
                calRefDate.SelectedDate = report.RefDate;
            }

            if (report.Approved)
            {
                ddCurrentActor.Enabled             = false;
                ddMCAType.Enabled                  = false;
                tbMeasureDate.Enabled              = false;
                tbBackground.ReadOnly              = true;
                tbIntegralBackground.ReadOnly      = true;
                tbCountingBackground.ReadOnly      = true;
                tbGeometryFactor.ReadOnly          = true;
                tbActivity.ReadOnly                = true;
                tbActivityRef.ReadOnly             = true;
                tbUncertainty.ReadOnly             = true;
                tbAvgIntegralSample.ReadOnly       = true;
                tbAvgLivetimeSample.ReadOnly       = true;
                tbRefDate.Enabled                  = false;
                cbWantEvaluation.Enabled           = false;
                cbAnswerByEmail.Enabled            = false;
                buttonRingtestReportUpdate.Enabled = false;
            }
            else
            {
                ddCurrentActor.Enabled             = true;
                ddMCAType.Enabled                  = true;
                tbMeasureDate.Enabled              = true;
                tbBackground.ReadOnly              = false;
                tbIntegralBackground.ReadOnly      = false;
                tbCountingBackground.ReadOnly      = false;
                tbGeometryFactor.ReadOnly          = false;
                tbActivity.ReadOnly                = false;
                tbActivityRef.ReadOnly             = false;
                tbUncertainty.ReadOnly             = false;
                tbAvgIntegralSample.ReadOnly       = false;
                tbAvgLivetimeSample.ReadOnly       = false;
                tbRefDate.Enabled                  = true;
                cbWantEvaluation.Enabled           = true;
                cbAnswerByEmail.Enabled            = true;
                buttonRingtestReportUpdate.Enabled = true;
            }

            if (ddMCAType.SelectedValue == "Inspector1000")
            {
                tbIntegralBackground.Visible    = false;
                labelIntegralBackground.Visible = false;
                tbCountingBackground.Visible    = false;
                labelCountingBackground.Visible = false;
                tbBackground.Visible            = false;
                labelBackground.Visible         = false;
                tbAvgIntegralSample.Visible     = false;
                labelAvgIntegralSample.Visible  = false;
                tbActivity.Visible       = false;
                labelActivity.Visible    = false;
                labelGeometryFactor.Text = Lang.Efficiency;
                labelUncertainty.Text    = Lang.Uncertainty_insp1000;
            }
            else
            {
                tbIntegralBackground.Visible    = true;
                labelIntegralBackground.Visible = true;
                tbCountingBackground.Visible    = true;
                labelCountingBackground.Visible = true;
                tbBackground.Visible            = true;
                labelBackground.Visible         = true;
                tbAvgIntegralSample.Visible     = true;
                labelAvgIntegralSample.Visible  = true;
                tbActivity.Visible       = true;
                labelActivity.Visible    = true;
                labelGeometryFactor.Text = Lang.GeometryFactor;
                labelUncertainty.Text    = Lang.Uncertainty_serie10;
            }
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusSelectDetector, Color.Red, "Ringtest.buttonDetectorContinue_OnClick: " + ex.Message);
            Utils.displayStatus(ref labelStatusReport, Color.Red, "Ringtest.buttonDetectorContinue_OnClick: " + ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }