private void save_Click(object sender, EventArgs e) { if (Model.SignalType.ToValue((string)comboBox1.SelectedItem) != -1) { this.m_channel.SignalType = Model.SignalType.ToValue((string)comboBox1.SelectedItem); } else { this.m_channel.SignalType = null; } if (Model.MeasurementType.ToValue((string)comboBox2.SelectedItem) != "") { this.m_channel.MeasurementType = Model.MeasurementType.ToValue((string)comboBox2.SelectedItem); } else { this.m_channel.MeasurementType = ""; } this.m_channel.MeterID = (comboDevice.SelectedItem as dynamic).Value; using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider)) { (new GSF.Data.Model.TableOperations <PQio.Model.Channel>(connection)).UpdateRecord(this.m_channel); GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity> dataSensitivityTbl = new GSF.Data.Model.TableOperations <PQio.Model.DataSensitivity>(connection); PQio.Model.DataSensitivity dataSensitivity; if (this.m_channel.AssetID != null) { if (dataSensitivityTbl.QueryRecordCountWhere("Event = {0} AND Asset = {1}", this.m_evt.ID, this.m_channel.AssetID) > 0) { dataSensitivity = dataSensitivityTbl.QueryRecordsWhere("Event = {0} AND Asset = {1}", this.m_evt.ID, this.m_channel.AssetID).First(); } else { dataSensitivity = new Model.DataSensitivity() { Event = this.m_evt.ID, Asset = (int)this.m_channel.AssetID } }; dataSensitivity.DataSensitivityCode = Model.DataSensitivityCode.ToValue((string)comboBox3.SelectedItem); dataSensitivity.Note = DataSensitivityNoteText.Text; dataSensitivityTbl.AddNewOrUpdateRecord(dataSensitivity); } } this.Close(); }
private void SaveField() { if (this.alreadySavedFlag) { return; } this.alreadySavedFlag = true; string activeTab = tabControl1.SelectedTab.Text; Control[] ctrls = tabControl1.SelectedTab.Controls.Find("listView1-" + activeTab, false); ListView list = (ListView)ctrls[0]; ctrls = tabControl1.SelectedTab.Controls.Find("editkey", false); TextBox txtkey = (TextBox)ctrls[0]; ctrls = tabControl1.SelectedTab.Controls.Find("editvalue", false); TextBox txtvalue = (TextBox)ctrls[0]; ctrls = tabControl1.SelectedTab.Controls.Find("editType", false); ComboBox txtType = (ComboBox)ctrls[0]; int index = (int)list.SelectedItems[0].Tag; using (AdoDataConnection connection = new AdoDataConnection(connectionstring, dataprovider)) { GSF.Data.Model.TableOperations <PQio.Model.CustomField> customFldTbl = new GSF.Data.Model.TableOperations <PQio.Model.CustomField>(connection); PQio.Model.CustomField fld; if (index == -1) { fld = new Model.CustomField(); fld.domain = activeTab; fld.AssetID = (int)this.m_channel.AssetID; fld.EventID = (int)this.m_evt.ID; } else { fld = customFldTbl.QueryRecordWhere("ID = {0}", index); } if (txtvalue.Text == "" && index != -1) { DialogResult confirm = System.Windows.Forms.MessageBox.Show("This will delete the MetaDataTag " + fld.key, "Warning", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning); if (confirm == DialogResult.OK) { customFldTbl.DeleteRecord(fld); HideTextEditor(); this.UpdateCustomFields(); return; } } fld.key = txtkey.Text; fld.Value = txtvalue.Text; fld.Type = TextToType(txtType.Text); customFldTbl.AddNewOrUpdateRecord(fld); HideTextEditor(); this.UpdateCustomFields(); } }
private void button2_Click(object sender, EventArgs e) { using (AdoDataConnection connection = new AdoDataConnection("systemSettings")) { GSF.Data.Model.TableOperations <PQds.Model.Event> evtTable = new GSF.Data.Model.TableOperations <PQds.Model.Event>(connection); PQds.Model.Event evt = evtTable.QueryRecordWhere("ID = {0}", m_Event.ID); evt.Name = faultIDTxtBox.Text; evt.EventTime = timeTxtBox.Value; if (peakITxtBox.Text != "") { try { if (!(Convert.ToDouble(peakITxtBox.Text) == 0)) { evt.PeakCurrent = Convert.ToDouble(peakITxtBox.Text); } } catch { MessageBox.Show("Peak Current has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (peakVTxtBox.Text != "") { try { if (!(Convert.ToDouble(peakVTxtBox.Text) == 0)) { evt.PeakVoltage = Convert.ToDouble(peakVTxtBox.Text); } } catch { MessageBox.Show("Peak Voltage has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (preITxtBox.Text != "") { try { if (!(Convert.ToDouble(preITxtBox.Text) == 0)) { evt.PreEventCurrent = Convert.ToDouble(preITxtBox.Text); } } catch { MessageBox.Show("Pre-Event Current has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (preVTxtBox.Text != "") { try { if (!(Convert.ToDouble(preVTxtBox.Text) == 0)) { evt.PreEventVoltage = Convert.ToDouble(preVTxtBox.Text); } } catch { MessageBox.Show("Pre-Event Voltage has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (I2tTxtBox.Text != "") { try { if (!(Convert.ToDouble(I2tTxtBox.Text) == 0)) { evt.FaultI2T = Convert.ToDouble(I2tTxtBox.Text); } } catch { MessageBox.Show("Fault I2(t) has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (maxVaTxtBox.Text != "") { try { if (!(Convert.ToDouble(maxVaTxtBox.Text) == 0)) { evt.MaxVA = Convert.ToDouble(maxVaTxtBox.Text); } } catch { MessageBox.Show("Phase A Voltage Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (maxVbTxtBox.Text != "") { try { if (!(Convert.ToDouble(maxVbTxtBox.Text) == 0)) { evt.MaxVB = Convert.ToDouble(maxVbTxtBox.Text); } } catch { MessageBox.Show("Phase B Voltage Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (maxVcTxtBox.Text != "") { try { if (!(Convert.ToDouble(maxVcTxtBox.Text) == 0)) { evt.MaxVC = Convert.ToDouble(maxVcTxtBox.Text); } } catch { MessageBox.Show("Phase C Voltage Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (minVaTxtBox.Text != "") { try { if (!(Convert.ToDouble(minVaTxtBox.Text) == 0)) { evt.MinVA = Convert.ToDouble(minVaTxtBox.Text); } } catch { MessageBox.Show("Phase A Voltage Minimum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (minVbTxtBox.Text != "") { try { if (!(Convert.ToDouble(minVbTxtBox.Text) == 0)) { evt.MinVB = Convert.ToDouble(minVbTxtBox.Text); } } catch { MessageBox.Show("Phase B Voltage Minimum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (minVcTxtBox.Text != "") { try { if (!(Convert.ToDouble(minVcTxtBox.Text) == 0)) { evt.MinVC = Convert.ToDouble(minVcTxtBox.Text); } } catch { MessageBox.Show("Phase C Voltage Minimum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (maxIaTxtBox.Text != "") { try { if (!(Convert.ToDouble(maxIaTxtBox.Text) == 0)) { evt.MaxIA = Convert.ToDouble(maxIaTxtBox.Text); } } catch { MessageBox.Show("Phase A Current Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (maxIbTxtBox.Text != "") { try { if (!(Convert.ToDouble(maxIbTxtBox.Text) == 0)) { evt.MaxIB = Convert.ToDouble(maxIbTxtBox.Text); } } catch { MessageBox.Show("Phase B Current Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (maxIcTxtBox.Text != "") { try { if (!(Convert.ToDouble(maxIcTxtBox.Text) == 0)) { evt.MaxIC = Convert.ToDouble(maxIcTxtBox.Text); } } catch { MessageBox.Show("Phase C Current Maximum has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (durationTxtBox.Text != "") { try { if (!(Convert.ToDouble(durationTxtBox.Text) == 0)) { evt.Duration = Convert.ToDouble(durationTxtBox.Text); } } catch { MessageBox.Show("Event duration has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (distanceTxtBox.Text != "") { try { if (!(Convert.ToDouble(distanceTxtBox.Text) == 0)) { evt.DistanceToFault = Convert.ToDouble(distanceTxtBox.Text); } } catch { MessageBox.Show("Distance to Fault has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // Update Data from Comboboxes if ((string)FltTypeCombo.SelectedItem == "") { evt.FaultType = null; } else { evt.FaultType = Model.FaultType.ToValue((string)FltTypeCombo.SelectedItem); } if ((string)evtTypeCombo.SelectedItem == "") { evt.EventType = null; } else { evt.EventType = Model.EventType.ToValue((string)evtTypeCombo.SelectedItem); } if ((string)evtCauseCombo.SelectedItem == "") { evt.FaultCause = null; } else { evt.FaultCause = Model.FaultCause.ToValue((string)evtCauseCombo.SelectedItem); } evtTable.AddNewOrUpdateRecord(evt); } this.Close(); }
private void button2_Click(object sender, EventArgs e) { m_Asset.AssetKey = AssetNameTxtBox.Text; if (NomfTxtBox.Text.Trim() != "") { try { if (!(Convert.ToDouble(NomfTxtBox.Text) == 0)) { if (Convert.ToDouble(NomfTxtBox.Text) > 0) { m_Asset.NominalFrequency = Convert.ToDouble(NomfTxtBox.Text); } else { throw new ArgumentOutOfRangeException(); } } } catch { MessageBox.Show("Nominal Frequency has to be a positive number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (NomVTxtBox.Text.Trim() != "") { try { if (!(Convert.ToDouble(NomVTxtBox.Text) == 0)) { m_Asset.NominalVoltage = Convert.ToDouble(NomVTxtBox.Text); } } catch { MessageBox.Show("Nominal Voltage has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (lenTxtBox.Text.Trim() != "") { try { if (!(Convert.ToDouble(lenTxtBox.Text) == 0)) { m_Asset.Length = Convert.ToDouble(lenTxtBox.Text); } } catch { MessageBox.Show("Length has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (XFTxtBox.Text.Trim() != "") { try { if (!(Convert.ToDouble(XFTxtBox.Text) == 0)) { m_Asset.UpstreamXFMR = Convert.ToDouble(XFTxtBox.Text); } } catch { MessageBox.Show("Upstream XF Size has to be a Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } using (AdoDataConnection connection = new AdoDataConnection("systemSettings")) { GSF.Data.Model.TableOperations <PQds.Model.Asset> assetTable = new GSF.Data.Model.TableOperations <PQds.Model.Asset>(connection); assetTable.AddNewOrUpdateRecord(m_Asset); } this.Close(); }
private void SaveBtn_Click(object sender, EventArgs e) { using (AdoDataConnection connection = new AdoDataConnection("systemSettings")) { GSF.Data.Model.TableOperations <PQds.Model.Meter> deviceTable = new GSF.Data.Model.TableOperations <PQds.Model.Meter>(connection); PQds.Model.Meter device = deviceTable.QueryRecordWhere("ID = {0}", m_device.ID); if (device is null) { device = new PQds.Model.Meter(); } device.DeviceName = NameTxtBox.Text; device.DeviceAlias = AliasTxtBox.Text; device.DeviceLocation = LocationTxtBox.Text; device.DeviceLocationAlias = LocationAliasTxtBox.Text; if (LatTxtBox.Text != "") { try { if (!(Convert.ToDouble(LatTxtBox.Text) == 0)) { device.Latitude = Convert.ToDouble(LatTxtBox.Text); } } catch { MessageBox.Show("Latitude has to be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (LongTxtBox.Text != "") { try { if (!(Convert.ToDouble(LongTxtBox.Text) == 0)) { device.Longitude = Convert.ToDouble(LongTxtBox.Text); } } catch { MessageBox.Show("Longitude has to be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } device.AccountAlias = ActAliasTxtBox.Text; device.AccountName = ActTxtBox.Text; device.Owner = OwnerTxtBox.Text; if (XFRTxtBox.Text != "") { try { if (!(Convert.ToDouble(XFRTxtBox.Text) == 0)) { device.DistanceToXFR = Convert.ToDouble(XFRTxtBox.Text); } } catch { MessageBox.Show("Distance to XFMR has to be a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if ((string)connBox.SelectedItem == "") { device.ConnectionType = null; } else { device.ConnectionType = Model.ConnectionType.ToValue((string)connBox.SelectedItem); } deviceTable.AddNewOrUpdateRecord(device); } this.Close(); }