protected void buttonDeleteComment_OnClick(object sender, EventArgs e) { if (gridDevicesED.SelectedDataKey != null) { try { Database.Interface.open(); Database.Device.delete_comment((Guid)gridDeviceHistory.SelectedDataKey.Value); Database.Device device = new Database.Device(); device.select_all_where_ID((Guid)gridDevicesED.SelectedDataKey.Value); gridDeviceHistory.DataSource = device.select_all_comments(); gridDeviceHistory.DataBind(); gridDeviceInfo.DataSource = device.select_all_comments(); gridDeviceInfo.DataBind(); Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Historie kommentar slettet"); } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } } else { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Du må velge en kommentar for sletting først"); } }
protected void gridDevicesAllED_OnSelectedIndexChanged(object sender, EventArgs e) { try { Database.Interface.open(); Database.Device device = new Database.Device(); if (!device.select_all_where_ID((Guid)gridDevicesAllED.SelectedDataKey.Value)) { Utils.displayStatus(ref labelStatusAll, Color.Red, "Enhet ikke funnet"); return; } labelDeviceInfo.Text = "Historie for enhet " + device.SerialNumber; gridDeviceInfo.DataSource = device.select_all_comments(); gridDeviceInfo.DataBind(); panelDeviceInfo.Visible = true; } catch (Exception ex) { Utils.displayStatus(ref labelStatusAll, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void buttonAddComment_OnClick(object sender, EventArgs e) { if (String.IsNullOrEmpty(tbAddComment.Text)) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Kommentarfeltet kan ikke være tomt"); return; } try { Database.Interface.open(); Database.Device.insert_comment((Guid)gridDevicesED.SelectedDataKey.Value, tbAddComment.Text); Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Historie kommentar lagt til"); tbAddComment.Text = ""; Database.Device device = new Database.Device(); device.select_all_where_ID((Guid)gridDevicesED.SelectedDataKey.Value); gridDeviceHistory.DataSource = device.select_all_comments(); gridDeviceHistory.DataBind(); gridDeviceInfo.DataSource = device.select_all_comments(); gridDeviceInfo.DataBind(); } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void gridDeviceHistory_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { Database.Interface.open(); Database.Device.delete_comment((Guid)gridDeviceHistory.DataKeys[e.RowIndex].Values[0]); Database.Device device = new Database.Device(); device.select_all_where_ID((Guid)gridDevicesED.SelectedDataKey.Value); gridDeviceHistory.DataSource = device.select_all_comments(); gridDeviceHistory.DataBind(); gridDeviceInfo.DataSource = device.select_all_comments(); gridDeviceInfo.DataBind(); Utils.displayStatus(ref labelStatusEdit, Color.SeaGreen, "Historie kommentar slettet"); } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
public int RegDevice(DateTime extraditionDate) { var device = new Device(); device.ExtraditionDate = extraditionDate; device.Id = Devicelist.Count + 1; Devicelist.Add(device); return device.Id; }
protected void gridDevicesED_OnSelectedIndexChanged(object sender, EventArgs e) { try { Database.Interface.open(); Database.Device device = new Database.Device(); if (!device.select_all_where_ID((Guid)gridDevicesED.SelectedDataKey.Value)) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Enhet ikke funnet"); return; } ddCategoriesEdit.SelectedValue = device.DeviceCategoryID.ToString(); ddTypesEdit.SelectedValue = device.DeviceTypeID.ToString(); ddAccountED.SelectedValue = device.AccountID.ToString(); tbSerialnumberED.Text = device.SerialNumber; ddStatusED.SelectedValue = device.Status; ddOwnershipED.SelectedValue = device.Ownership; tbCommentED.Text = device.Comment; if (device.ReceivedNew != DateTime.MinValue) { calReceivedNewED.SelectedDate = device.ReceivedNew; } gridDeviceHistory.DataSource = device.select_all_comments(); gridDeviceHistory.DataBind(); Database.DeviceCategory cat = new Database.DeviceCategory(); if (!cat.select_all_where_name("Detektor")) { Utils.displayStatus(ref labelStatusEdit, Color.Red, "Enhet 'Detektor' ikke funnet"); return; } if (ddCategoriesED.SelectedValue == cat.ID.ToString()) { ddCategoriesEdit.Enabled = false; ddTypesEdit.Enabled = false; } else { ddCategoriesEdit.Enabled = true; ddTypesEdit.Enabled = true; } panelDeviceED.Visible = true; } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void buttonCreateCD_OnClick(object sender, EventArgs e) { if (ddCategoriesCD.SelectedValue == Guid.Empty.ToString() || ddTypesCD.SelectedValue == Guid.Empty.ToString() || String.IsNullOrEmpty(ddStatusCD.Text) || ddOwnershipCD.SelectedValue == Guid.Empty.ToString()) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Mangler informasjon"); return; } try { Database.Interface.open(); Database.Device device = new Database.Device( new Guid(ddAccountCD.SelectedValue), new Guid(ddCategoriesCD.SelectedValue), new Guid(ddTypesCD.SelectedValue), tbSerialnumberCD.Text, ddStatusCD.SelectedValue, ddOwnershipCD.SelectedValue, "", String.IsNullOrEmpty(tbReceivedNewCD.Text) ? DateTime.MinValue : DateTime.Parse(tbReceivedNewCD.Text)); if (device.insert_with_ID(Guid.NewGuid())) { Utils.displayStatus(ref labelStatusCreate, Color.SeaGreen, "Enhet opprettet"); } else { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Oppretting av enhet feilet"); } tbSerialnumberCD.Text = ""; gridDevicesED.DataBind(); gridDevicesAllED.DataBind(); } catch (Exception ex) { Utils.displayStatus(ref labelStatusCreate, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
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(); } }
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(); } }