public bool SetObjectValueByFiledName(CommonPara para) { using (SQLTransaction trans = new SQLTransaction(para)) { CommonBusiness business = new CommonBusiness(); bool result = business.SetObjectValueByFiledName(para, trans, para.ObjectID, para.FieldName, para.Value); if (result) { trans.Commit(); } return(result); } }
private void MainForm_Load(object sender, EventArgs e) { try { var updater = Updater.Instance; updater.Error += updater_Error; updater.UpdatesFound += updater_UpdatesFound; updater.NoUpdatesFound += updater_NoUpdatesFound; updater.MinmumVersionRequired += updater_OnUpdaterOnMinmumVersionRequired; updater.BeginCheckUpdateInProcess(); } catch (Exception exception) { CommonLogHelper.GetInstance("LogError").Error(@"自动更新过程出错", exception); } try { _para = Parameter.ReadCfg(); } catch (Exception exception) { CommonLogHelper.GetInstance("LogError").Error(@"读取系统参数过程出错", exception); MessageBox.Show(@"读取系统参数过程出错", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (_para.StationGrade.Contains("省级")) { //采集器设置ToolStripMenuItem.Visible = false; 台站选择ToolStripMenuItem.Visible = true; try { _para.StationProList = new List <StationPara>(); string conn = $"Data Source={_para.SqlServerPara.SqlIp};Initial Catalog={_para.SqlServerPara.SqlDb};User ID={_para.SqlServerPara.SqlUser};Password={_para.SqlServerPara.SqlPwd};"; RadarDataClassesDataContext radarDataContext = new RadarDataClassesDataContext(conn); var stations = (from s in radarDataContext.StationParaTable select s).Distinct().ToList(); foreach (StationPara station in stations.Select(s => new StationPara { StationId = s.StationID, StationName = s.StationName, Slong = s.Slong, Slat = s.Slat })) { _para.StationProList.Add(station); } foreach (ToolStripMenuItem stationToolStripMenuItem in stations.Select(station => new ToolStripMenuItem { Name = "stationToolStripMenuItem", Text = station.StationName, Tag = station.StationID })) { stationToolStripMenuItem.Click += StationToolStripMenuItem_Click; 台站选择ToolStripMenuItem.DropDownItems.Add(stationToolStripMenuItem); StationToolStripMenuItem_Click(stationToolStripMenuItem, e); } } catch (Exception exception) { CommonLogHelper.GetInstance("LogError").Error(@"加载站点信息出错", exception); MessageBox.Show(@"加载站点信息出错", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //采集器设置ToolStripMenuItem.Visible = true; 台站选择ToolStripMenuItem.Visible = false; _smcForm = new StatusMonitorControlForm { MdiParent = this, WindowState = FormWindowState.Maximized, Para = _para, StationId = _para.StationInfo.StationId, }; _smcForm.Show(); } _tmr.Start(); }
private void 系统设置ToolStripMenuItem_Click(object sender, EventArgs e) { string staitongrad = _para.StationGrade; using (SettingForm setForm = new SettingForm()) { var result = setForm.ShowDialog(); if (result == DialogResult.OK) { _para = Parameter.ReadCfg(); if (!_para.StationGrade.Equals(staitongrad)) { foreach (Form mdiChild in MdiChildren) { ((StatusMonitorControlForm)mdiChild).CanClose = true; mdiChild.Close(); } if (_para.StationGrade.Contains("省级")) { //采集器设置ToolStripMenuItem.Visible = false; 台站选择ToolStripMenuItem.Visible = true; 台站选择ToolStripMenuItem.DropDownItems.Clear(); try { _para.StationProList = new List <StationPara>(); string conn = $"Data Source={_para.SqlServerPara.SqlIp};Initial Catalog={_para.SqlServerPara.SqlDb};User ID={_para.SqlServerPara.SqlUser};Password={_para.SqlServerPara.SqlPwd};"; RadarDataClassesDataContext radarDataContext = new RadarDataClassesDataContext(conn); var stations = (from s in radarDataContext.StationParaTable select s).Distinct().ToList(); foreach (StationPara station in stations.Select(s => new StationPara { StationId = s.StationID, StationName = s.StationName, Slong = s.Slong, Slat = s.Slat })) { _para.StationProList.Add(station); } foreach (ToolStripMenuItem stationToolStripMenuItem in stations.Select(station => new ToolStripMenuItem { Name = "stationToolStripMenuItem", Text = station.StationName, Tag = station.StationID })) { stationToolStripMenuItem.Click += StationToolStripMenuItem_Click; 台站选择ToolStripMenuItem.DropDownItems.Add(stationToolStripMenuItem); StationToolStripMenuItem_Click(stationToolStripMenuItem, e); } } catch (Exception exception) { CommonLogHelper.GetInstance("LogError").Error(@"加载站点信息出错", exception); MessageBox.Show(@"加载站点信息出错", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //采集器设置ToolStripMenuItem.Visible = true; 台站选择ToolStripMenuItem.Visible = false; _smcForm = new StatusMonitorControlForm { MdiParent = this, WindowState = FormWindowState.Maximized, Para = _para, StationId = _para.StationInfo.StationId }; _smcForm.Show(); } } } } }
public DataLineFormPro(CommonPara para) { InitializeComponent(); _synchContext = SynchronizationContext.Current; _para = para; }
private void btnEnter_Click(object sender, EventArgs e) { for (int i = 0; i < dgvStationList.RowCount; i++) { if (dgvStationList[0, dgvStationList.CurrentCell.RowIndex].Value != null && dgvStationList[0, dgvStationList.CurrentCell.RowIndex].Value.ToString() != string.Empty) { if (dgvStationList[1, dgvStationList.CurrentCell.RowIndex].Value == null || dgvStationList[1, dgvStationList.CurrentCell.RowIndex].Value.ToString() == string.Empty) { MessageBox.Show(@"站号必须输入", @"警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } try { _para = new CommonPara { StationGrade = cmbGrade.SelectedItem.ToString(), UpdateDataIntl = (int)(nUdIntl.Value), SerialPortPara = { PortName = cmbSerialPort.SelectedItem.ToString(), BaudRate = int.Parse(cmbBaudRate.SelectedItem.ToString()), DataBits = int.Parse(cmbDataBits.SelectedItem.ToString()), StopBits = cmbStopBit.SelectedItem.ToString(), CheckBit = cmbCheckBit.SelectedItem.ToString() }, SqlServerPara = { SqlIp = tbSqlIp.Text, SqlDb = tbDataBase.Text, SqlUser = tbUser.Text, SqlPwd = tbPassword.Text }, }; if (_para.StationGrade.Contains("台站")) { if (dgvStationList[1, 0].Value != null && dgvStationList[1, 0].Value.ToString() != string.Empty) { StationPara station = new StationPara { StationId = dgvStationList[1, 0].Value.ToString(), StationName = dgvStationList[2, 0].Value.ToString(), Slong = dgvStationList[3, 0].Value.ToString(), Slat = dgvStationList[4, 0].Value.ToString() }; _para.StationInfo = station; } else { MessageBox.Show(@"请配置台站信息", @"注意", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { string conn = $"Data Source={_para.SqlServerPara.SqlIp};Initial Catalog={_para.SqlServerPara.SqlDb};User ID={_para.SqlServerPara.SqlUser};Password={_para.SqlServerPara.SqlPwd};"; DataBaseOperate.StationParaTable stationInfo = new DataBaseOperate.StationParaTable { ID = Guid.NewGuid(), StationID = _para.StationInfo.StationId, StationName = _para.StationInfo.StationName, Slong = _para.StationInfo.Slong, Slat = _para.StationInfo.Slat }; DataBaseHelper dbHelper = new DataBaseHelper(conn); dbHelper.StationParaInsertorUpdate(stationInfo); dbHelper.SaveChanges(); } catch (Exception exception) { MessageBox.Show(@"保存台站信息到远程数据库出错:" + Environment.NewLine + exception.Message, @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Parameter.WriteCfg(_para); Close(); } catch (Exception exception) { CommonLogHelper.GetInstance("LogError").Error(@"保存参数文件出错", exception); MessageBox.Show(@"保存参数文件出错", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void SettingForm_Load(object sender, EventArgs e) { try { string[] ports = SerialPort.GetPortNames(); Array.Sort(ports); cmbSerialPort.Items.AddRange(ports); } catch (Exception exception) { CommonLogHelper.GetInstance("LogError").Error(@"加载本机串口号出错", exception); MessageBox.Show(@"加载本机串口号出错", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { _para = Parameter.ReadCfg(); cmbSerialPort.SelectedItem = _para.SerialPortPara.PortName; cmbBaudRate.SelectedItem = _para.SerialPortPara.BaudRate.ToString(CultureInfo.InvariantCulture); cmbDataBits.SelectedItem = _para.SerialPortPara.DataBits.ToString(CultureInfo.InvariantCulture); cmbStopBit.SelectedItem = _para.SerialPortPara.StopBits.ToString(CultureInfo.InvariantCulture); cmbCheckBit.SelectedItem = _para.SerialPortPara.CheckBit; tbSqlIp.Text = _para.SqlServerPara.SqlIp; tbDataBase.Text = _para.SqlServerPara.SqlDb; tbUser.Text = _para.SqlServerPara.SqlUser; tbPassword.Text = _para.SqlServerPara.SqlPwd; nUdIntl.Value = _para.UpdateDataIntl; cmbGrade.SelectedItem = _para.StationGrade; //if (para.StationGrade.Contains("省级")) //{ // dgvStationList.ReadOnly = true; // dgvStationList.RowCount = para.StationList.Count; // for (int i = 0; i < dgvStationList.RowCount; i++) // { // dgvStationList[0, i].Value = (i + 1).ToString(CultureInfo.InvariantCulture); // dgvStationList[1, i].Value = para.StationList[i].StationId; // dgvStationList[2, i].Value = para.StationList[i].StationName; // dgvStationList[3, i].Value = para.StationList[i].Slong; // dgvStationList[4, i].Value = para.StationList[i].Slat; // } //} //else //{ // dgvStationList.ReadOnly = false; // dgvStationList.RowCount = 1; // dgvStationList[0, 0].Value = "1"; // dgvStationList[1, 0].Value = para.StationList[0].StationId; // dgvStationList[2, 0].Value = para.StationList[0].StationName; // dgvStationList[3, 0].Value = para.StationList[0].Slong; // dgvStationList[4, 0].Value = para.StationList[0].Slat; //} } catch (Exception exception) { CommonLogHelper.GetInstance("LogError").Error(@"读取参数文件出错", exception); MessageBox.Show(@"读取参数文件出错", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }