/// <summary> /// 更新低料预警图表 /// </summary> public void UpdateMaterialWarningChart(string programName) { if (programName == string.Empty) { return; } CDBConnection.SQL = "SELECT Address,QTY-UsedQTY AS QTY FROM TB_QMS_ProgramList WHERE Code='" + programName + "'"; DataTable dtStack = CDBConnection._GetDTInfo(CDBConnection.SQL); foreach (DataRow drQty in dtStack.Rows) { string stackNO = drQty[0].ToString(); if (stackNO.Trim() == string.Empty) { continue; } VBarItem item; if (this.chartWarning.GetAt(stackNO, out item)) { item.Value = int.Parse(drQty[1].ToString()); this.chartWarning.ModifyAt(stackNO, item); } } RedrawWarningChart(); }
private void frmWellMana_Load(object sender, System.EventArgs e) { try { this.txtWellNo.Text = this.m_strWellNo; string strSql = String.Format("select depName from tbWell where wellNo='{0}'", this.m_strWellNo); string strDepName = CDBConnection.ExecuteScalar(strSql); this.txtDepName.Text = strDepName; strSql = String.Format("select gprsNo from tbWell where wellNo='{0}'", this.m_strWellNo); string strGprsNo = CDBConnection.ExecuteScalar(strSql); strSql = String.Format("select watAddress from tbWell where wellNo='{0}'", this.m_strWellNo); string strAddress = CDBConnection.ExecuteScalar(strSql); this.m_strAddress = strAddress; if (strGprsNo.Trim() == "" || strGprsNo == null) { this.Close(); } this.m_strGprsNo = strGprsNo; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void LoadStationInfo() { try { string strSql=string.Format("select * from tbw_WellInfo where WellID='{0}'",m_sID.ToString()); DataTable dtWell=null; CDBConnection.getDataTable(ref dtWell,strSql,"tbw_WellInfo"); b=double.Parse(dtWell.Rows[0]["BaseW"].ToString()); m=double.Parse(dtWell.Rows[0]["BPm"].ToString()); i=double.Parse(dtWell.Rows[0]["ZPi"].ToString()); w=double.Parse(dtWell.Rows[0]["middleW"].ToString()); m_Type=int.Parse(dtWell.Rows[0]["DataType"].ToString()); if(m_Type==0) { labType.Text="明渠均匀流"; this.groupBox1.Visible=true; groupBox2.Visible=false; } else { labType.Text="巴歇尔量水槽"; this.groupBox2.Visible=true; groupBox1.Visible=false; } labBase.Text=b.ToString(); labTop.Text=dtWell.Rows[0]["TopW"].ToString(); labM.Text=m.ToString(); labI.Text=i.ToString(); labMidW.Text=w.ToString(); } catch { } }
// private bool paintTrvWell() { try { this.trv.Nodes.Clear(); tools.CPaintForm.paintWell(this.cmbCountry.Text, this.trv); this.trv.Nodes.Add("所有操作员"); string strSql = "select userName from tbUsers"; DataTable dt = null; CDBConnection.getDataTable(ref dt, strSql, "tbUsers"); for (int i = 0; i < dt.Rows.Count; i++) { this.trv.Nodes[1].Nodes.Add(dt.Rows[i]["userName"].ToString()); } return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }
private void LoadWellInfo() { try { string strSql = String.Format("select * from tbw_WellInfo where WellID='{0}'", this.m_wellID); DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbw_WellInfo"); int dataType = int.Parse(dtWell.Rows[0]["DataType"].ToString()); if (dataType == 0) { cmdType.Text = "明渠均匀流"; this.txtBaseW.Text = dtWell.Rows[0]["BaseW"].ToString(); this.txtTopW.Text = dtWell.Rows[0]["TopW"].ToString(); this.txtZPi.Text = dtWell.Rows[0]["ZPi"].ToString(); this.txtBPm.Text = dtWell.Rows[0]["BPm"].ToString(); this.groupBox2.Visible = false; this.groupBox1.Visible = true; } else { cmdType.Text = "巴歇尔量水槽"; this.txtmiddleW.Text = dtWell.Rows[0]["middleW"].ToString(); this.groupBox1.Visible = false; this.groupBox2.Visible = true; } } catch { } }
private void btnDel_Click(object sender, System.EventArgs e) { try { if (this.lsvTown.SelectedItems.Count == 0) { MessageBox.Show("请选中要删除的县!"); return; } string strSql = String.Format("select count(*) from tbCountry where townName='{0}'", this.lsvTown.SelectedItems[0].SubItems[0].Text.Trim()); string strCount = CDBConnection.ExecuteScalar(strSql); if (strCount.Trim() != "0") { MessageBox.Show("该县以下已录入乡镇信息不能删除!"); return; } string strTownName = this.lsvTown.SelectedItems[0].Text.Trim(); strSql = String.Format("delete from tbTown where townName='{0}'", strTownName); CDBConnection.ExecuteSql(strSql); this.paintFrm(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void LoadTr() { try { string strSql = string.Format("select * from tbCountry"); DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbCountry"); txtZhan.Text = dtWell.Rows[0]["countryName"].ToString(); strSql = string.Format("select distinct depName from tbWell"); CDBConnection.getDataTable(ref dtWell, strSql, "tbdepName"); for (int z = 0; z < dtWell.Rows.Count; z++) { TreeNode tn = new TreeNode(dtWell.Rows[z]["depName"].ToString()); trvWel.Nodes.Add(tn); } strSql = string.Format("select wellName,depName from tbWell"); CDBConnection.getDataTable(ref dtWell, strSql, "tbwellName"); for (int i = 0; i < dtWell.Rows.Count; i++) { for (int j = 0; j < trvWel.Nodes.Count; j++) { if (dtWell.Rows[i]["depName"].ToString().Trim() == trvWel.Nodes[j].Text) { TreeNode tn = new TreeNode(dtWell.Rows[i]["wellName"].ToString()); trvWel.Nodes[j].Nodes.Add(tn); } } } } catch { } }
//单位 private void paintDep() { try { string strSql = ""; if (this.cmbCountry.Text.Trim() == "") { strSql = String.Format("select depShortName from tbDep"); } else { strSql = String.Format("select depShortName from tbDep where CountryName='{0}'", this.cmbCountry.Text.Trim()); } DataTable dtDep = null; CDBConnection.getDataTable(ref dtDep, strSql, "tbDep"); this.trvDep.Nodes.Clear(); this.trvDep.Nodes.Add("用水单位列表"); for (int i = 0; i < dtDep.Rows.Count; i++) { this.trvDep.Nodes[0].Nodes.Add(dtDep.Rows[i]["depShortName"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnSet_Click(object sender, System.EventArgs e) { try { if (this.txtInterval.Text.Trim() == "") { MessageBox.Show("请填写时间间隔!"); return; } if (this.txtWarnLevel.Text.Trim() == "") { MessageBox.Show("请填写报警下限!"); return; } double dWarn = Convert.ToDouble(this.txtWarnLevel.Text.Trim()); string strSql = String.Format("update tbInfo set val='{0}' where des='{1}'", dWarn.ToString(), "报警下限"); CDBConnection.ExecuteSql(strSql); double dInter = Convert.ToDouble(this.txtInterval.Text); double iInter = Convert.ToDouble(dInter * 60); this.m_xDoc.DocumentElement.SelectSingleNode("./interval").InnerText = iInter.ToString(); this.m_xDoc.Save("Info.xml"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//填充treeview private void paintTvwDep() { try { string strSql = "select townName from tbTown"; DataTable dtTown = null; CDBConnection.getDataTable(ref dtTown, strSql, "tbTown"); for (int i = 0; i < dtTown.Rows.Count; i++) { string strTownName = dtTown.Rows[i]["townName"].ToString(); this.trvDep.Nodes.Add(dtTown.Rows[i]["townName"].ToString()); DataTable dtCountry = null; strSql = String.Format("select countryName from tbCountry where townName='{0}'", strTownName); CDBConnection.getDataTable(ref dtCountry, strSql, "tbCountry"); for (int j = 0; j < dtCountry.Rows.Count; j++) { this.trvDep.Nodes[i].Nodes.Add(dtCountry.Rows[j]["countryName"].ToString()); string strCountryName = dtCountry.Rows[j]["countryName"].ToString(); strSql = String.Format("select depShortName from tbDep where countryName='{0}'", strCountryName); DataTable dtDep = null; CDBConnection.getDataTable(ref dtDep, strSql, "dtDep"); for (int z = 0; z < dtDep.Rows.Count; z++) { this.trvDep.Nodes[i].Nodes[j].Nodes.Add(dtDep.Rows[z]["depShortName"].ToString()); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void GetMaterialList(ref QueryMessage msg) { if (programName == string.Empty) { return; } CDBConnection.SQL = "SELECT Address,CompoentNO, QTY-UsedQTY AS QTY FROM TB_QMS_ProgramList WHERE Code='" + programName + "'"; DataTable dtStack = CDBConnection._GetDTInfo(CDBConnection.SQL); foreach (DataRow drQty in dtStack.Rows) { string stackNO = drQty[0].ToString(); if (stackNO.Trim() == string.Empty) { continue; } QueryMessage.QueryItem item = new QueryMessage.QueryItem(stackNO, drQty[1].ToString()); try { item.QTY = Int32.Parse(drQty[2].ToString()); } catch (Exception) { item.QTY = 0; } msg.items.Add(item); } }
private void btnDel_Click(object sender, System.EventArgs e) { try { if (this.lsvCountry.SelectedItems.Count == 0) { MessageBox.Show("请选中要删除的管理局!"); return; } string strCountryName = this.lsvCountry.SelectedItems[0].Text.Trim(); // string strSql = String.Format("select count(*) from tbDep where countryName='{0}'", strCountryName); string strCount = CDBConnection.ExecuteScalar(strSql); if (strCount != "0") { MessageBox.Show("该管理局以下已录入管理处,请先将其下的管理处信息删除!"); return; } strSql = String.Format("delete from tbCountry where countryName='{0}'", strCountryName); CDBConnection.ExecuteSql(strSql); this.paintFrm(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private bool iniCmbManagers() { try { string strSql = String.Format("select userName from tbUsers"); DataTable dt = null; CDBConnection.getDataTable(ref dt, strSql, "tbUsers"); if (dt == null) { return(false); } this.cmbManagers.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { string strManagerName = dt.Rows[i]["userName"].ToString(); this.cmbManagers.Items.Add(strManagerName); } return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }
private void ReadDatas() { try { string strSql = ""; switch (m_strSelNodeType) { case "zhan": strSql = string.Format("select * from tbw_waterDatas where name='{0}' and time between '{1}' and '{2}' order by time", trvWel.SelectedNode.Text, dtb.ToString(), dte.ToString()); break; case "country": strSql = string.Format("select * from tbw_waterDatas where name in(select wellName from tbWell where depName='{0}') and time between '{1}' and '{2}'", trvWel.SelectedNode.Text, dtb.ToString(), dte.ToString()); break; default: return; } DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbDatas"); this.dataGrid1.DataSource = dtWell.DefaultView; } catch (Exception ex) { // MessageBox.Show(ex.ToString()); } }
private void button1_Click(object sender, System.EventArgs e) { try { if (this.txtUserID.Text.Trim() == "") { MessageBox.Show("请填写用户ID"); return; } if (this.txtUserName.Text.Trim() == "") { MessageBox.Show("请填写用户名!"); return; } if (this.txtUserPwd.Text.Trim() == "") { MessageBox.Show("请填写用户密码!"); return; } if (this.txtUserPwd.Text.Trim() != this.txtPwdCer.Text.Trim()) { MessageBox.Show("密码与确认密码不同!"); return; } if (this.chkPower.Checked == true) { if (this.cmbManagers.Text.Trim() == "") { MessageBox.Show("请选择具有相同权限的管理员,或去掉应用权限项!"); return; } } else { if (this.cmbManagers.Text.Trim() != "") { MessageBox.Show("请选中应用权限框,或清除所选的管理员!"); return; } } if (this.m_bEdit == false) { //添加用户 this.fInserUsers(); } else { //修改 string strSql = String.Format("delete from tbUsers where userID='{0}'", this.txtUserID.Text.Trim()); CDBConnection.ExecuteSql(strSql); this.fInserUsers(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnSave_Click(object sender, System.EventArgs e) { try { if (this.txtHangYeName.Text.Trim() == "") { MessageBox.Show("行业名称不能为空!"); return; } string strSql = String.Format("select count(*) from tbHangYe where HangYeName='{0}'", this.txtHangYeName.Text.Trim()); string strCount = CDBConnection.ExecuteScalar(strSql); int iCount = Convert.ToInt32(strCount); if (iCount > 0) { MessageBox.Show("该行业名称已存在!"); return; } strSql = String.Format("insert into tbHangYe(HangYeName,HangYeType) values('{0}','{1}')", this.txtHangYeName.Text.Trim(), this.txtHangYeType.Text.Trim()); CDBConnection.ExecuteSql(strSql); this.m_bInserted = true; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnDel_Click(object sender, System.EventArgs e) { try { //MessageBox.Show("因为删除将导致系统错误,所以删除被禁用!"); //return; if (this.lsvDep.SelectedItems.Count <= 0) { MessageBox.Show("请选择要删除的管理处!"); return; } string strDepShortName = this.lsvDep.SelectedItems[0].Text.Trim(); string strSql = String.Format("select count(*) from tbWell where depName ='{0}'", strDepShortName); string strCount = CDBConnection.ExecuteScalar(strSql); if (strCount.Trim() != "0") { MessageBox.Show("该单位下已录入监测站,请先删除其下的站点!"); return; } strSql = String.Format("delete from tbDep where depShortName='{0}'", strDepShortName); CDBConnection.ExecuteSql(strSql); this.paintFrm(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static bool TestConnection(CDBConnection connection, out string message) { message = ""; SqlConnection sqlConn = null; try { sqlConn = new SqlConnection(connection.ConnectionString + string.Format("Connect Timeout={0}", 3)); sqlConn.Open(); } catch (Exception ex) { message = ex.Message; return(false); } finally { if (sqlConn != null) { if (sqlConn.State == ConnectionState.Open) { sqlConn.Close(); } sqlConn.Dispose(); } } return(true); }
private void paintFrm() { try { if (this.trvDep.SelectedNode == null) { return; } else { if (this.trvDep.SelectedNode.Parent == null) { return; } } string strDepName = this.trvDep.SelectedNode.Text.Trim(); string strSql = String.Format("select wellNo,wellName,depName,gprsNo,watAddress,wellDes,x,y,price1,iniAmount,watchNo,xi,warnAmount,bjt from tbWell where depName='{0}' and not gprsNo is null and bSal is null", strDepName); DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbWell"); this.lsvWell.Items.Clear(); for (int i = 0; i < dtWell.Rows.Count; i++) { this.lsvWell.Items.Add(dtWell.Rows[i]["wellNo"].ToString()); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["wellName"].ToString()); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["DepName"].ToString()); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["gprsNo"].ToString()); string strAddress = dtWell.Rows[i]["watAddress"].ToString(); int iAddress = Convert.ToInt32(strAddress); strAddress = iAddress.ToString("x"); this.lsvWell.Items[i].SubItems.Add(strAddress); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["x"].ToString()); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["y"].ToString()); if (dtWell.Rows[i]["bjt"].ToString() == "true") { this.lsvWell.Items[i].SubItems.Add("应用阶梯水价"); } else { this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["price1"].ToString()); } this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["iniAmount"].ToString()); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["watchNo"].ToString().Trim()); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["xi"].ToString()); this.lsvWell.Items[i].SubItems.Add(dtWell.Rows[i]["warnAmount"].ToString().Trim()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private bool saveData(string strWellNo, string strICNo, string strDepName) { string strSql = String.Format("delete from tbIC where icNo='{0}'", strICNo); CDBConnection.ExecuteSql(strSql); strSql = String.Format("insert into tbIC(wellNo,icNo,depName) values('{0}','{1}','{2}')", strWellNo, strICNo, strDepName); CDBConnection.ExecuteSql(strSql); return(true); }
private void frmGLDatas_Load(object sender, System.EventArgs e) { LoadDGtitle(); string strSql = string.Format("select * from tbw_Granulation"); DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbw_Granulation"); this.dataGrid1.DataSource = dtWell.DefaultView; }
public void SetConnection(CDBConnection connection) { if (_connections.FirstOrDefault(c => c.ConnectionString == connection.ConnectionString) == null) { _connections.Add(connection); } _connection = connection; _conn = _connection; }
private void Bgw_DoWork(object sender, DoWorkEventArgs e) { ShowLoading("开始载入工单,请稍后..."); moduleID = CDBConnection._GetModuleID("Program List Registration"); strLbl2 = CDBConnection._GetLabelsTxt(CDBConnection._GetModuleID("上料防错"), 100); strLbl3 = CDBConnection._GetLabelsTxt(CDBConnection._GetModuleID("上料防错"), 101); // 枚举程序名称列表 CDBConnection.SQL = "SELECT DISTINCT Code FROM TB_QMS_ProgramList WHERE ModuleID='" + moduleID + "' AND IsEnable=1"; dtProgramName = CDBConnection._GetGrdInfo(CDBConnection.SQL); }
public frmConnection(CDBConnection Connection) { if (Connection != null) { _Connection = Connection.Clone(); } else { _Connection = new CDBConnection("", ""); } InitializeComponent(); }
private void paintReport(string strWellNo) { //已审 try { string strFrom = String.Format("{0}-{1}-{2}", this.dtpFrom.Value.Year.ToString(), this.dtpFrom.Value.Month.ToString(), this.dtpFrom.Value.Day.ToString()); string strTo = String.Format("{0}-{1}-{2}", this.dtpTo.Value.Year.ToString(), this.dtpTo.Value.Month.ToString(), this.dtpTo.Value.Day.ToString()); string strTitle = String.Format("时间范围:{0}至{1}", strFrom, strTo); string[] strText = new string[7]; strText[0] = "监测站编号"; strText[1] = "单位名称"; strText[2] = "已用水量"; strText[3] = "剩余水量"; strText[4] = "总水量"; strText[5] = "流量"; strText[6] = "上报时间"; printDoc.crpPrint crpPrintObj = new BengZhan.printDoc.crpPrint(); CrystalDecisions.CrystalReports.Engine.TextObject toTitle = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"]; toTitle.Text = strTitle; for (int i = 0; i < 7; i++) { int iNum = i + 1; string strTextTitle = "Text" + iNum.ToString(); CrystalDecisions.CrystalReports.Engine.TextObject to = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle]; to.Text = strText[i].ToString(); } //*************************************************Sql查询部分*************** //wellNo不为空 string strSql = String.Format("select wellNo as Field1,depName as Field2,usedWaterAmount as Field3,leftWaterAmount as Field4,allWaterAmount as Field5,flowWaterAmount as Field6,time as Field7 from tbWellAmount where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and wellNo='{2}' order by time", strFrom, strTo, strWellNo); if (strWellNo.Trim() == "") { //wellNo为空 strSql = String.Format("select wellNo as Field1,depName as Field2,usedWaterAmount as Field3,leftWaterAmount as Field4,allWaterAmount as Field5,flowWaterAmount as Field6,time as Field7 from tbWellAmount where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') order by time", strFrom, strTo); } //**************************************************************************** DataTable dt = null; CDBConnection.getDataTable(ref dt, strSql, "tbWellAmount"); crpPrintObj.SetDataSource(dt); this.crpvWater.ReportSource = crpPrintObj; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnSave_Click(object sender, System.EventArgs e) { try { if (this.txtDepShortName.Text.Trim() == "") { MessageBox.Show("管理处简称不能为空!"); return; } if (this.txtDepName.Text.Trim() == "") { MessageBox.Show("管理处名称不能为空!"); return; } string strSql = ""; if (this.m_bEdit == true) { strSql = String.Format("delete from tbDep where depShortName='{0}'", this.txtDepShortName.Text.Trim()); CDBConnection.ExecuteSql(strSql); } strSql = String.Format("select count(*) from tbDep where depName='{0}'", this.txtDepName.Text.Trim()); string strCount = CDBConnection.ExecuteScalar(strSql); int iCount = Convert.ToInt32(strCount); if (iCount > 0) { MessageBox.Show("该管理处名称已存在!"); return; } strSql = String.Format("select count(*) from tbDep where depShortName='{0}'", this.txtDepShortName.Text.Trim()); strCount = CDBConnection.ExecuteScalar(strSql); if (strCount != "0") { MessageBox.Show("该管理处简称已存在!"); return; } strSql = String.Format("insert into tbDep(DepShortName,depName,countryName,hangYeName,contactPer,contactTel,address,des) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", this.txtDepShortName.Text.Trim(), this.txtDepName.Text.Trim(), this.cmbCountry.Text.Trim(), this.cmbHangYe.Text.Trim(), this.txtContactPer.Text.Trim(), this.txtContactTel.Text.Trim(), this.txtAddress.Text.Trim(), this.txtDes.Text.Trim()); CDBConnection.ExecuteSql(strSql); this.m_bInserted = true; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
void OnDeserialized(StreamingContext context) { _conn = _connection; _precisionDecimals = _precision; if (_connections == null) { _connections = new List <CDBConnection>(); } if (_dimensions == null) { _dimensions = new DimensionSet(); } _dim = _dimensions; }
//±ÃÕ¾ public static void paintWell(string strCountryName, System.Windows.Forms.TreeView trvDep1) { try { string strSql = ""; if (strCountryName.Trim() == "") { strSql = String.Format("select depShortName from tbDep"); } else { strSql = String.Format("select depShortName from tbDep where CountryName='{0}'", strCountryName.Trim()); } strSql = string.Format("select countryName from tbCountry"); DataTable dtCountry = new DataTable(); BengZhan.CDBConnection.getDataTable(ref dtCountry, strSql, "dtCountry"); for (int x = 0; x < dtCountry.Rows.Count; x++) { strCountryName = dtCountry.Rows[x]["countryName"].ToString().Trim(); System.Windows.Forms.TreeNode trvDep = trvDep1.Nodes.Add(strCountryName); strSql = String.Format("select depShortName from tbDep where CountryName='{0}'", strCountryName.Trim()); DataTable dtDep = new DataTable(); CDBConnection.getDataTable(ref dtDep, strSql, "tbDep"); for (int i = 0; i < dtDep.Rows.Count; i++) { int iNIndex = trvDep.Nodes.Add(new System.Windows.Forms.TreeNode(dtDep.Rows[i]["depShortName"].ToString())); string strShortName = dtDep.Rows[i]["depShortName"].ToString().Trim(); strSql = String.Format("select wellNo,wellName from tbWell where depName='{0}' order by wellNo", strShortName); DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbWell"); for (int j = 0; j < dtWell.Rows.Count; j++) { string strNodeText = String.Format("{0}|{1}", dtWell.Rows[j]["wellNo"].ToString(), dtWell.Rows[j]["wellName"].ToString()); trvDep.Nodes[iNIndex].Nodes.Add(strNodeText); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//»æÖƼà²âÕ¾Ê÷ public bool paintTrvWell(System.Windows.Forms.TreeView trvWell) { try { trvWell.Nodes.Clear(); string strSql = "select townName from tbTown"; DataTable dtTown = null; CDBConnection.getDataTable(ref dtTown, strSql, "tbTown"); for (int i = 0; i < dtTown.Rows.Count; i++) { string strTownName = dtTown.Rows[i]["townName"].ToString(); trvWell.Nodes.Add(dtTown.Rows[i]["townName"].ToString()); DataTable dtCountry = null; strSql = String.Format("select countryName from tbCountry where townName='{0}'", strTownName); CDBConnection.getDataTable(ref dtCountry, strSql, "tbCountry"); for (int j = 0; j < dtCountry.Rows.Count; j++) { trvWell.Nodes[i].Nodes.Add(dtCountry.Rows[j]["countryName"].ToString()); string strCountryName = dtCountry.Rows[j]["countryName"].ToString(); strSql = String.Format("select depShortName from tbDep where countryName='{0}'", strCountryName); DataTable dtDep = null; CDBConnection.getDataTable(ref dtDep, strSql, "dtDep"); for (int z = 0; z < dtDep.Rows.Count; z++) { trvWell.Nodes[i].Nodes[j].Nodes.Add(dtDep.Rows[z]["depShortName"].ToString()); strSql = String.Format("select wellNo,wellName from tbWell where depName='{0}'", dtDep.Rows[z]["depShortName"].ToString()); DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbWell"); for (int y = 0; y < dtWell.Rows.Count; y++) { string strWellNo = dtWell.Rows[y]["wellNo"].ToString(); string strWellName = dtWell.Rows[y]["wellName"].ToString(); strWellName = String.Format("{0}|{1}", strWellNo, strWellName); trvWell.Nodes[i].Nodes[j].Nodes[z].Nodes.Add(strWellName); } } } } return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }
public void UpdateMaterialWarningChart(string programName, string stackNO) { CDBConnection.SQL = "SELECT QTY-UsedQTY AS QTY FROM TB_QMS_ProgramList WHERE Code='" + programName + "' AND [Address]='" + stackNO + "'"; DataTable dtList = CDBConnection._GetDTInfo(CDBConnection.SQL); foreach (DataRow dr in dtList.Rows) { VBarItem item; if (this.chartWarning.GetAt(stackNO, out item)) { item.Value = int.Parse(dr[0].ToString()); this.chartWarning.ModifyAt(stackNO, item); } } RedrawWarningChart(); }