private void LoadUserSelectionTable() { try { string sqlText = "select 线路名 from 自选线路代码表 "; DataTable dt = null; try { dt = InnerFileOperator.Query(sqlText); } catch (Exception ex) { MessageBox.Show("查询自选线路失败:" + ex.Message); } if (dt != null && dt.Rows.Count > 0) { foreach (var row in dt.AsEnumerable()) { lstselectedLineName.Items.Add(row["线路名"].ToString()); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void cbxLineName_SelectedIndexChanged(object sender, EventArgs e) { if (cbxLineName.SelectedItem != null) { string cmdStr = string.Format("select 线路编号 from 线路代码表 where PWMIS原始线路名='{0}'", cbxLineName.SelectedItem.ToString()); object lineCode = InnerFileOperator.ExecuteScalar(cmdStr); if (lineCode != null) { _lineCode = lineCode.ToString(); } } }
/// <summary> /// 通过线路名获取线路编码 /// </summary> /// <param name="name"></param> /// <returns></returns> private string GetLineCodeByName(string name) { string cmdStr = string.Format("select 线路编号 from 线路代码表 where 线路代码='{0}'", name); object lineCode = InnerFileOperator.ExecuteScalar(cmdStr); if (lineCode != null) { return(lineCode.ToString()); } return(""); }
private void LoadLineData() { DataTable dt = InnerFileOperator.Query("select LineName,LineCode from line"); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { if (!Lines.ContainsKey(dt.Rows[i]["LineName"].ToString())) { Lines.Add(dt.Rows[i]["LineName"].ToString(), dt.Rows[i]["LineCode"].ToString()); } } } }
/// <summary> /// 根据cit文件头部部分数据初始化长短链集合 /// </summary> /// <param name="lineCode">线路编码</param> /// <param name="kmInc">增减里程</param> /// <param name="dir">上下行</param> public LongChainTable(string lineCode, int kmInc, int dir) { string dirDesc = "上行"; switch (dir) { case 1: dirDesc = "上行"; break; case 2: dirDesc = "下行"; break; case 3: dirDesc = "单线"; break; } switch (dir) { case 1: dirDesc = "上"; break; case 2: dirDesc = "下"; break; case 3: dirDesc = "单"; break; } string sql = "select * from 长短链 where 线编号='" + lineCode + "' and 行别='" + dirDesc + "' order by 公里 "; if (kmInc == 1) { sql += "desc"; } DataTable dt = InnerFileOperator.Query(sql); if (dt != null && dt.Rows.Count > 0) { _chains = new List <LongChain>(); for (int i = 0; i < dt.Rows.Count; i++) { LongChain chain = new LongChain(); chain.Dir = dir; chain.LineCode = lineCode; chain.Km = float.Parse(dt.Rows[i]["公里"].ToString()); chain.ExtraLength = float.Parse(dt.Rows[i]["米数"].ToString()); _chains.Add(chain); } } }
/// <summary> /// 加载线路代码和名称 /// </summary> private void LoadLineCodeAndName() { if (_dtLineCodeAndName != null && _dtLineCodeAndName.Rows.Count > 0) { _dtLineCodeAndName.Rows.Clear(); } //获取线路编号和线路名e try { string cmdText = "select 自定义线路编号, 线路名 from 自定义线路代码表"; _dtLineCodeAndName = InnerFileOperator.Query(cmdText); } catch (Exception ex) { MyLogger.LogError("查询线路数据失败", ex); MessageBox.Show(ex.Message); } }
private void UpdateUserSelectionTable() { // delete all the data in 自选线路代码表 // add the items in list box into 自选线路代码表 try { string sqlText = "delete from 自选线路代码表 "; InnerFileOperator.ExcuteSql(sqlText); foreach (string str in lstselectedLineName.Items) { sqlText = "insert into 自选线路代码表 (线路名) values('" + str + "')"; InnerFileOperator.ExcuteSql(sqlText); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LoadAccountData(string tableName, string sqlWhereText, string displayFiled) { dgvAccountInfo.DataSource = null; dgvAccountInfo.Rows.Clear(); dgvAccountInfo.Columns.Clear(); string dir = string.Empty; switch (_maker.WaveformDataList[0].CitFile.iDir) { case 1: dir = "上"; break; case 2: dir = "下"; break; case 3: dir = "单"; break; default: dir = "上"; break; } if (string.IsNullOrEmpty(_maker.WaveformDataList[0].LineCode)) { throw new ArgumentException("找不到线路编号为:" + _maker.WaveformDataList[0].CitFile.sTrackCode + "的对应编号"); } string sqlText = "select " + displayFiled + " from " + tableName + " where 线编号='" + _maker.WaveformDataList[0].LineCode + "' and 行别='" + dir + "' " + sqlWhereText; try { DataTable dt = InnerFileOperator.Query(sqlText); dgvAccountInfo.DataSource = dt; } catch (Exception) { dgvAccountInfo.DataSource = null; } }
private void StandardConfig_Load(object sender, EventArgs e) { try { dataGridView1.AutoGenerateColumns = false; dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.GreenYellow; string cmd = String.Format("select speed,class,type,VALUESTANDARD,VALUEDIY,STANDARDTYPE from 大值国家标准表 where STANDARDTYPE = {0}", 0); DataTable dt = InnerFileOperator.Query(cmd); dtStandardValue = ConvertToTable(dt); dataGridView1.DataSource = dtStandardValue; //dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Aqua; //DgvRowColor(dataGridView1); } catch (Exception ex) { MyLogger.LogError("读取数据错误", ex); MessageBox.Show("错误:" + ex.Message); } }
/// <summary> /// 点击确定按钮,保存数据 /// </summary> /// <param name="sender">确定按钮</param> /// <param name="e">触发参数</param> private void btnOk_Click(object sender, EventArgs e) { try { _configData.ServerConfig = _networkControl.ServerConfig; _configData.MeterageRadius = _commonControl.MeterageRadius; _configData.MediaPath = _commonControl.MediaPath; _configData.SignRadius = _commonControl.SignRadius; _configData.AutoScrollVelocity = _commonControl.AutoScrollVelocity; _configData.WaveConfigs = _waveDisplayControl.WaveConfigs; if (_standard.StandardChangedList != null && _standard.StandardChangedList.Count > 0) { foreach (var item in _standard.StandardChangedList) { string cmd = String.Format("update 大值国家标准表 set VALUEDIY={0} where speed = {1} and class = {2} and type = '{3}' and STANDARDTYPE = {4}", item.StdValue, item.Speed, item.StdClass, item.StdParam, item.stdType); InnerFileOperator.ExcuteSql(cmd); } } //for (int i = 0; i < _standardControl.dtStandardValue.Rows.Count; i++) //{ // string cmd = String.Format("update 大值国家标准表 set VALUEDIY={0},VALUESTANDARD={1} where ID = {2}", // _standardControl.dtStandardValue.Rows[i][5].ToString(), // _standardControl.dtStandardValue.Rows[i][4].ToString(), // _standardControl.dtStandardValue.Rows[i][0].ToString()); // InnerFileOperator.ExcuteSql(cmd); //} ConfigManger.SaveConfigData(_configData); } catch (Exception ex) { MyLogger.logger.Error("保存配置失败:" + ex.Message + ",堆栈:" + ex.StackTrace); MessageBox.Show("错误:" + ex.Message); } finally { this.Close(); } }
private void LoadLineName() { cbxLineName.Items.Clear(); InnerFileOperator.CheckAndCreateTable("自选线路代码表", "CREATE TABLE 自选线路代码表(线路名 TEXT(255))"); DataTable dt = null; try { dt = InnerFileOperator.Query("select 线路名 from 自选线路代码表"); } catch (Exception ex) { MessageBox.Show("查询线路失败:" + ex.Message); } if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { cbxLineName.Items.Add(dt.Rows[i][0].ToString()); } } }
/// <summary> /// 查询标准表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQurey_Click(object sender, EventArgs e) { //DataTable d1 = getTable(); //DataTable d2 = ConvertToTable(d1); SetTextBoxEnable(false); string cmd = String.Format("select * from 大值国家标准表 where CLASS = {0} and SPEED = {1} and STANDARDTYPE = {2}", _defectLevel, _speedClass, _standerdType); //string cmd = String.Format("select speed,class,type,VALUESTANDARD from 大值国家标准表 where STANDARDTYPE = {0}", _standerdType); try { dtStandardValue = InnerFileOperator.Query(cmd); //DataTable dt = ConvertToTable(dtStandardValue); } catch (Exception ex) { MessageBox.Show(ex.Message); dtStandardValue = null; } //0,ID //1,速度值 //2,等级 //3,类型 //4,标准值 //5,自定义值 if (dtStandardValue != null && dtStandardValue.Rows.Count > 0) { for (int i = 0; i < dtStandardValue.Rows.Count; i++) { for (int j = 0; j < _txtStandardList.Count; j++) { if (_txtStandardList[j].Name.Substring(8).Equals(dtStandardValue.Rows[i][3].ToString())) { double standardValue = double.Parse(string.IsNullOrEmpty(dtStandardValue.Rows[i][4].ToString()) == true ? "0" : dtStandardValue.Rows[i][4].ToString()); double customValue = double.Parse(string.IsNullOrEmpty(dtStandardValue.Rows[i][5].ToString()) == true ? "0" : dtStandardValue.Rows[i][5].ToString()); _txtStandardList[j].Text = standardValue.ToString(); if (customValue == 0) { //把textbox设为enable if (standardValue >= 0) { _txtCustomList[j].Text = (standardValue - 1).ToString(); } else { _txtCustomList[j].Text = (standardValue + 1).ToString(); } } else { _txtCustomList[j].Text = customValue.ToString(); } if (ckbSenior.Checked && cbxStanderdType.SelectedIndex == 1) { _txtCustomList[j].Enabled = true; } _txtCustomList[j].Enabled = true; } } } } }
private void LoadLineData() { DataTable dt = InnerFileOperator.Query("select LineName,LineCode from line"); _citCreater = new CitCreater(dt); }
/// <summary> /// 选择切割单位事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbxSplitUnit_SelectedIndexChanged(object sender, EventArgs e) { dgvBoundary.Rows.Clear(); int length = 2; switch (cbxSplitUnit.SelectedIndex) { case 0: length = 2; break; case 1: length = 5; break; case 2: length = 7; break; case 3: length = 9; break; } string dir = "上"; switch (_maker.WaveformDataList[0].CitFile.iDir) { case 1: { dir = "上"; break; } case 2: { dir = "下"; break; } case 3: { dir = "单"; break; } } string sql = "select IIf(" + length.ToString() + "=2,(select distinct bureauname from dw b where b.bureaucode=a.sunitid)," + "(select distinct unitname from dw b where b.unitid=a.sunitid)) as unitname,a.sstartmile,a.sendmile from " + "(SELECT left(unitid," + length.ToString() + ") as sunitid,min(startmile) as sstartmile,max(endmile) as sendmile " + "FROM Gj where lineid='" + _maker.WaveformDataList[0].LineCode + "' and linedirname='" + dir + "' " + "group by left(unitid," + length.ToString() + ")) a"; DataTable dt = null; try { dt = InnerFileOperator.Query(sql); } catch (Exception ex) { MyLogger.LogError("查询IIF数据失败", ex); MessageBox.Show("查询数据失败:" + ex.Message); } if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { dgvBoundary.Rows.Add(dt.Rows[i].ItemArray); } } }