Exemple #1
0
    protected void buttonCreateBox_OnClick(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(tbKNumber.Text) ||
            String.IsNullOrEmpty(tbExternID.Text) ||
            String.IsNullOrEmpty(tbRefDate.Text) ||
            String.IsNullOrEmpty(tbRefValue.Text) ||
            String.IsNullOrEmpty(tbUncertainty.Text) ||
            String.IsNullOrEmpty(tbWeight.Text))
        {
            Utils.displayStatus(ref labelStatusCreate, Color.Red, "Mangler informasjon");
            return;
        }

        try
        {
            Database.Interface.open();

            Database.RingtestBox box = new Database.RingtestBox(
                tbKNumber.Text,
                tbExternID.Text,
                DateTime.Parse(tbRefDate.Text),
                Convert.ToSingle(tbRefValue.Text),
                Convert.ToSingle(tbUncertainty.Text),
                Convert.ToSingle(tbWeight.Text),
                ddStatusAss.SelectedValue,
                tbComment.Text);

            if (box.insert_with_ID_KNumber(Guid.NewGuid(), tbKNumber.Text))
            {
                Utils.displayStatus(ref labelStatusCreate, Color.SeaGreen, "Ringtestboks '" + tbKNumber.Text + "' opprettet");
            }
            else
            {
                Utils.displayStatus(ref labelStatusCreate, Color.Red, "Oppretting av ringtestboks feilet");
            }

            updateBoxes();

            tbKNumber.Text            = "";
            tbExternID.Text           = "";
            tbRefDate.Text            = "";
            tbRefValue.Text           = "";
            tbUncertainty.Text        = "";
            tbWeight.Text             = "";
            ddStatusAss.SelectedIndex = 0;
            tbComment.Text            = "";
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusCreate, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
Exemple #2
0
    protected void gridBoxes_OnUpdateCommand(object sender, GridViewUpdateEventArgs e)
    {
        TextBox      KNumber     = (TextBox)gridBoxes.Rows[e.RowIndex].Cells[0].Controls[0];
        TextBox      ExternID    = (TextBox)gridBoxes.Rows[e.RowIndex].Cells[1].Controls[0];
        TextBox      RefDate     = gridBoxes.Rows[e.RowIndex].Cells[2].FindControl("tbGridRefDate") as TextBox;
        TextBox      RefValue    = (TextBox)gridBoxes.Rows[e.RowIndex].Cells[3].FindControl("tbRefValue");
        TextBox      Uncertainty = (TextBox)gridBoxes.Rows[e.RowIndex].Cells[4].FindControl("tbGridUncertainty");
        TextBox      Weight      = (TextBox)gridBoxes.Rows[e.RowIndex].Cells[5].FindControl("tbWeight");
        DropDownList Status      = gridBoxes.Rows[e.RowIndex].Cells[6].FindControl("ddGridStatus") as DropDownList;
        TextBox      Comment     = (TextBox)gridBoxes.Rows[e.RowIndex].Cells[7].Controls[0];

        if (String.IsNullOrEmpty(KNumber.Text) ||
            String.IsNullOrEmpty(ExternID.Text) ||
            String.IsNullOrEmpty(RefDate.Text) ||
            String.IsNullOrEmpty(RefValue.Text) ||
            String.IsNullOrEmpty(Uncertainty.Text) ||
            String.IsNullOrEmpty(Weight.Text))
        {
            Utils.displayStatus(ref labelStatusCreate, Color.Red, "Mangler informasjon");
            return;
        }

        try
        {
            Database.Interface.open();

            Database.RingtestBox box = new Database.RingtestBox();
            if (!box.select_all_where_ID((Guid)gridBoxes.DataKeys[e.RowIndex].Values[0]))
            {
                Utils.displayStatus(ref labelStatusCreate, Color.Red, "Ringtestboks ikke funnet");
                return;
            }

            box.KNumber     = KNumber.Text;
            box.ExternID    = ExternID.Text;
            box.RefDate     = DateTime.Parse(RefDate.Text);
            box.RefValue    = Convert.ToSingle(RefValue.Text);
            box.Uncertainty = Convert.ToSingle(Uncertainty.Text);
            box.Weight      = Convert.ToSingle(Weight.Text);
            box.Status      = Status.SelectedValue;
            box.Comment     = Comment.Text;

            if (box.update_all_by_ID())
            {
                Utils.displayStatus(ref labelStatusCreate, Color.SeaGreen, "Ringtestboks oppdatert");
            }
            else
            {
                Utils.displayStatus(ref labelStatusCreate, Color.Red, "Oppdatering av ringtestboks feilet");
            }

            gridBoxes.EditIndex = -1;
            updateBoxes();
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusCreate, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }
    }
Exemple #3
0
    protected void graphResults_OnRenderGraph(ZedGraph.Web.ZedGraphWeb z, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        if (hiddenAccountID.Value == null || hiddenAccountID.Value == Guid.Empty.ToString())
        {
            return;
        }

        DataSet   dataSet = null;
        GraphPane myPane  = masterPane[0];

        myPane.Border.Color     = Color.White;
        myPane.Title.Text       = Lang.OurRingtestResults;;
        myPane.XAxis.Title.Text = Lang.Years;
        myPane.YAxis.Title.Text = "%"; // Lang.ErrorPercent;

        Database.RingtestBox box = new Database.RingtestBox();

        try
        {
            Database.Interface.open();
            dataSet = Database.RingtestReport.select_Year_Error_CalculatedUncertainty_RingtestBoxID_MCAType_ActivityRef_where_AccountID(new Guid(hiddenAccountID.Value));

            PointPairList list  = new PointPairList();
            PointPairList eList = new PointPairList();
            PointPairList bList = new PointPairList();

            double maxYear = DateTime.Now.Year;
            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                Guid boxID = (Guid)dataSet.Tables[0].Rows[i][3];
                box.select_all_where_ID(boxID);

                double year        = Convert.ToDouble(dataSet.Tables[0].Rows[i][0]);
                double error       = Convert.ToDouble(dataSet.Tables[0].Rows[i][1]);
                double uncertainty = Convert.ToDouble(dataSet.Tables[0].Rows[i][2]);
                string MCAType     = dataSet.Tables[0].Rows[i][4].ToString();
                if (MCAType.ToLower() != "serie10")
                {
                    double activity = Convert.ToDouble(dataSet.Tables[0].Rows[i][5]);
                    uncertainty = (uncertainty / activity) * 100.0;
                }

                if (year > maxYear)
                {
                    maxYear = year;
                }

                list.Add(year, error);
                eList.Add(year, error + uncertainty, error - uncertainty);
                bList.Add(year, box.Uncertainty, -box.Uncertainty);
            }

            myPane.YAxis.Scale.Max           = 11.0f;
            myPane.YAxis.Scale.Min           = -11.0f;
            myPane.XAxis.Scale.Max           = maxYear + 1;
            myPane.XAxis.Scale.Min           = maxYear - 10;
            myPane.XAxis.Scale.MinorStep     = 1.0;
            myPane.XAxis.Scale.MajorStep     = 1.0;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;
            myPane.Legend.IsVisible          = true;

            LineItem curve = myPane.AddCurve(Lang.Reported_result, list, Color.White, SymbolType.Circle);
            curve.Line.IsVisible = false;
            curve.Symbol.Fill    = new Fill(Color.IndianRed);
            curve.Symbol.Size    = 6;

            ErrorBarItem errBar = myPane.AddErrorBar(Lang.CalculatedUncertainty, eList, Color.Red);
            errBar.Bar.PenWidth = 1;

            ErrorBarItem boxBar = myPane.AddErrorBar(Lang.RingtestBoxUncertainty, bList, Color.LightGray);
            boxBar.Bar.PenWidth         = 12;
            boxBar.Bar.Symbol.IsVisible = false;

            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, Color.White), 45.0F);

            const double offset = 0.1;

            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                PointPair pt = curve.Points[i];

                if (pt.Y >= myPane.YAxis.Scale.Min && pt.Y <= myPane.YAxis.Scale.Max)
                {
                    TextObj text = new TextObj(pt.Y.ToString("f2"), pt.X + offset, pt.Y, CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
                    text.FontSpec.Size             = 6;
                    text.ZOrder                    = ZOrder.A_InFront;
                    text.FontSpec.Border.IsVisible = false;
                    text.FontSpec.Fill.IsVisible   = false;
                    //text.FontSpec.Angle = 90;
                    myPane.GraphObjList.Add(text);

                    //g.DrawLine(pen, new Point((int)(pt.X + 10), (int)pt.Y), new Point((int)(pt.X - 10), (int)pt.Y));
                }
            }

            myPane.YAxis.Scale.MaxGrace = 0.2;
        }
        catch (Exception ex)
        {
            Utils.reportStatus(ref labelStatus, Color.Red, "Ringtest.graphResults_OnRenderGraph: " + ex.Message);
            return;
        }
        finally
        {
            Database.Interface.close();
        }

        masterPane.AxisChange(g);
    }
Exemple #4
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();
        }
    }