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 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()); } }
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 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 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()); } }
//判断该节点是否有效 private bool checkSelectedItem() { string strUID = this.lswUserInfo.SelectedItems[0].Text.Trim(); string strSql = String.Format("select parentManager from tbUsers where userID='{0}'", strUID); string strParentManager = CDBConnection.ExecuteScalar(strSql); if (strParentManager.Trim() != "") { string strInfo = String.Format("该操作员的权限与操作员{0}相同!", strParentManager.Trim()); MessageBox.Show(strInfo); selectItem(strParentManager); return(false); } else { return(true); } }
private void button1_Click(object sender, System.EventArgs e) { int w_wid = int.Parse(txtWellNo.Text.Trim()); string strSql = String.Format("select count(*) from tbw_WellInfo where WellID='{0}'", txtWellNo.Text.Trim()); string strCountE = CDBConnection.ExecuteScalar(strSql); bool isedit = m_bEdit; if (strCountE.Trim() != "0") { isedit = true; } else { isedit = false; } frmAdvancedInfo f = new frmAdvancedInfo(isedit, w_wid, this.txtWellName.Text.Trim()); f.ShowDialog(); }
private string getWellNo() { string strSql = "select tbNo from tbDel where tbName='tbWell'"; string strWellNo = CDBConnection.ExecuteScalar(strSql); if (strWellNo.Trim() != "") { return(strWellNo); } else { strSql = "select count(*) from tbWell"; int iCount = 0; iCount = Convert.ToInt32(CDBConnection.ExecuteScalar(strSql)); iCount = iCount + 1; strWellNo = cStr(iCount.ToString()); return(strWellNo); } }
private void frmAdd_Load(object sender, System.EventArgs e) { try { iniCmbManagers(); if (this.m_bEdit == true) { this.txtUserID.ReadOnly = true; string strSql = String.Format("select userName,userPwd,parentManager from tbUsers where userID='{0}'", this.m_strUserID.Trim()); DataTable dt = new DataTable(); CDBConnection.getDataTable(ref dt, strSql, "tbUsers"); this.txtUserID.Text = this.m_strUserID; this.txtUserName.Text = dt.Rows[0]["userName"].ToString(); this.txtUserPwd.Text = dt.Rows[0]["userPwd"].ToString(); this.txtPwdCer.Text = this.txtUserPwd.Text; this.cmbManagers.Text = dt.Rows[0]["parentManager"].ToString().Trim(); if (this.cmbManagers.Text.Trim() != "") { this.chkPower.Checked = true; } this.chkPower.Enabled = false; this.cmbManagers.Enabled = false; strSql = String.Format("select userName from tbUsers where parentManager='{0}'", this.txtUserName.Text.Trim()); string strUName = CDBConnection.ExecuteScalar(strSql).Trim(); if (strUName != "") { this.txtUserName.ReadOnly = true; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void frmSysSet_Load(object sender, System.EventArgs e) { try { string strSql = String.Format("select val from tbInfo where des='{0}'", "报警下限"); this.txtWarnLevel.Text = CDBConnection.ExecuteScalar(strSql); XmlDocument xDoc = new XmlDocument(); xDoc.Load("Info.xml"); XmlNode xNode = xDoc.DocumentElement.SelectSingleNode("./interval"); string strInterval = xNode.InnerText.Trim(); int iInter = Convert.ToInt32(Math.Round(Convert.ToDouble(strInterval), 0)); double dInter = Math.Round(iInter / 60.00, 2); this.txtInterval.Text = dInter.ToString(); this.m_xDoc = xDoc; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnDel_Click(object sender, System.EventArgs e) { try { if (this.lsvUsers.SelectedItems.Count == 0) { MessageBox.Show("请选中要删除的用户!"); return; } string strParentManager = this.lsvUsers.SelectedItems[0].SubItems[1].Text; string strSql = String.Format("select userName from tbUsers where parentManager='{0}'", strParentManager); string strUserName = CDBConnection.ExecuteScalar(strSql); if (strUserName.Trim() != "") { string strInfo = String.Format("操作员:{0}已应用其操作权限不能将其删除!", strUserName); MessageBox.Show(strInfo); return; } SqlConnection sCon = new SqlConnection(BengZhan.CDBConnection.m_strCon); sCon.Open(); strSql = String.Format("delete from tbUsers where userID='{0}'", this.lsvUsers.SelectedItems[0].Text.Trim()); SqlCommand sCmd = new SqlCommand(); sCmd.Connection = sCon; sCmd.CommandText = strSql; sCmd.ExecuteNonQuery(); sCon.Close(); strSql = String.Format("delete from userMenu where userId='{0}'", this.lsvUsers.SelectedItems[0].Text.Trim()); this.paintFrm(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnSave_Click(object sender, System.EventArgs e) { try { if (this.m_bEdit) { DialogResult result = MessageBox.Show(this, "警告:修改站点信息将对实时监测和报表统计造成影响是否继续?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); if (result != DialogResult.Yes) { return; } else { } } if (this.chkJTS.Checked) { if (!this.paintPrice()) { return; } } if (this.txtPrice.Text.Trim() == "") { MessageBox.Show("水价不能为空!"); return; } if (this.txtWatNo.Text.Trim() == "") { MessageBox.Show("请填入控制器编号。"); return; } try { double dPrice = double.Parse(this.txtPrice.Text.Trim()); } catch { MessageBox.Show("水价不是有效数字!"); return; } string strSqlE = string.Format("select count(*) from tbWell where watchNo='{0}' and not wellNo='{1}'", this.txtWatNo.Text.Trim(), this.txtWellNo.Text.Trim()); string strCount = BengZhan.CDBConnection.ExecuteScalar(strSqlE); if (strCount.Trim() != "0") { MessageBox.Show("该控制器编号已录入!"); return; } if (this.txtWellName.Text.Trim() == "") { MessageBox.Show("请填入监测站名称!"); return; } if (this.txtGprsNo.Text.Trim() == "") { MessageBox.Show("请输入GPRS号!"); return; } if (this.txtAddress.Text.Trim() == "") { MessageBox.Show("请输入设备地址!"); return; } if (this.txtGprsNo.Text.Trim().Length != 11) { MessageBox.Show("GPRS号长度有误!"); return; } string strSql = String.Format("select count(*) from tbWell where wellName='{0}' and not wellNo='{1}'", this.txtWellName.Text.Trim(), this.txtWellNo.Text.Trim()); string strCountE = CDBConnection.ExecuteScalar(strSql); if (strCountE.Trim() != "0") { MessageBox.Show("该监测站名称已录入!"); return; } strSql = String.Format("select count(*) from tbWell where gprsNo='{0}' and not wellNo='{1}'", this.txtGprsNo.Text.Trim(), this.txtWellNo.Text.Trim()); strCount = CDBConnection.ExecuteScalar(strSql); if (strCount != "0") { MessageBox.Show("该GPRS号已存在!"); return; } string strWatchType = ""; strSql = String.Format("select watchType from tbWell where wellNo='{0}'", this.txtWellNo.Text.Trim()); strWatchType = BengZhan.CDBConnection.ExecuteScalar(strSql); strSql = String.Format("delete from tbWell where wellNo='{0}'", this.txtWellNo.Text.Trim()); CDBConnection.ExecuteSql(strSql); string strX = ""; if (this.txtX.Text.Trim() == "") { strX = "null"; } else { try { double dX = Convert.ToDouble(this.txtX.Text.Trim()); strX = dX.ToString(); } catch (Exception ex) { MessageBox.Show("你所填入的x坐标不是有效数字!"); return; } } string strY = ""; if (this.txtY.Text.Trim() == "") { strY = "null"; } else { try { double dY = Convert.ToDouble(this.txtY.Text.Trim()); strY = dY.ToString(); } catch (Exception ex) { MessageBox.Show("你所填入的x坐标不是有效数字!"); return; } } //地址十六进制 string strAddress = this.txtAddress.Text.Trim(); int iAddress = Convert.ToInt32(strAddress, 16); strAddress = iAddress.ToString(); strSql = String.Format("insert into tbWell(wellNo,wellName,depName,gprsNo,watAddress,wellDes,x,y,ICNo,watchType) values('{0}','{1}','{2}','{3}','{4}','{5}',{6},{7},'{8}','{9}')", this.txtWellNo.Text.Trim(), this.txtWellName.Text.Trim(), this.txtDepShortName.Text.Trim(), this.txtGprsNo.Text.Trim(), strAddress, this.txtDes.Text.Trim(), strX, strY, this.txtICNo.Text.Trim(), strWatchType); CDBConnection.ExecuteSql(strSql); strSql = String.Format("delete from tbDel where tbName='{0}' and tbNo='{1}'", "tbWell", this.txtWellNo.Text.Trim()); CDBConnection.ExecuteSql(strSql); strSql = string.Format("update tbWell set iniAmount='{0}',watchNo='{1}',xi='{2}',warnAmount='{3}',price1='{5}' where wellNo='{4}'", this.txtIniAmount.Text.Trim(), this.txtWatNo.Text.Trim(), this.txtXi.Text.Trim(), this.txtWarnLevel.Text.Trim(), this.txtWellNo.Text.Trim(), this.txtPrice.Text.Trim()); BengZhan.CDBConnection.ExecuteSql(strSql); if (this.chkJTS.Checked) { strSql = string.Format("update tbWell set bjt='true' where wellNo='{0}'", this.txtWellNo.Text.Trim()); BengZhan.CDBConnection.ExecuteSql(strSql); this.saveJTPrice(); } this.m_bInserted = true; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void frmBengZhanEdit_Load(object sender, System.EventArgs e) { try { if (this.m_bEdit == false) { //生成监测站编号 string strSql = "select tbNo from tbDel where tbName='tbWell'"; string strWellNo = CDBConnection.ExecuteScalar(strSql); if (strWellNo.Trim() != "") { this.txtWellNo.Text = strWellNo; } else { strSql = "select count(*) from tbWell"; int iCount = 0; iCount = Convert.ToInt32(CDBConnection.ExecuteScalar(strSql)); iCount = iCount + 1; strWellNo = cStr(iCount.ToString()); this.txtWellNo.Text = strWellNo; } this.txtDepShortName.Text = this.m_strDepName; } else { string strSql = String.Format("select wellNo,wellName,depName,gprsNo,watAddress,wellDes,ICNo,iniAmount,watchNo,xi,warnAmount,price1,x,y from tbWell where wellNo='{0}'", this.m_strWellNo); DataTable dtWell = null; CDBConnection.getDataTable(ref dtWell, strSql, "tbWell"); this.txtWellNo.Text = dtWell.Rows[0]["wellNo"].ToString(); this.txtWellName.Text = dtWell.Rows[0]["wellName"].ToString(); string strAddress = dtWell.Rows[0]["watAddress"].ToString(); int iAddress = Convert.ToInt32(strAddress); strAddress = iAddress.ToString("x"); this.txtAddress.Text = strAddress; this.txtDes.Text = dtWell.Rows[0]["wellDes"].ToString(); this.txtGprsNo.Text = dtWell.Rows[0]["gprsNo"].ToString(); this.txtDepShortName.Text = dtWell.Rows[0]["depName"].ToString(); this.txtICNo.Text = dtWell.Rows[0]["ICNo"].ToString(); this.txtIniAmount.Text = dtWell.Rows[0]["iniAmount"].ToString().Trim(); this.txtWatNo.Text = dtWell.Rows[0]["watchNo"].ToString().Trim(); this.txtWarnLevel.Text = dtWell.Rows[0]["warnAmount"].ToString().Trim(); this.txtXi.Text = dtWell.Rows[0]["xi"].ToString().Trim(); this.txtX.Text = dtWell.Rows[0]["x"].ToString().Trim(); this.txtY.Text = dtWell.Rows[0]["y"].ToString().Trim(); this.txtPrice.Text = dtWell.Rows[0]["price1"].ToString().Trim(); } paintJTPrice(); addCmbPrice(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnDel_Click(object sender, System.EventArgs e) { try { if (MessageBox.Show("删除操作可能对数据统计造成影响,是否继续?", "删除", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } //return; if (this.lsvWell.SelectedItems.Count == 0) { MessageBox.Show("请选中要删除的监测站!"); return; } string strWellNo = this.lsvWell.SelectedItems[0].Text.Trim(); string strSql = String.Format("select count(*) from (select * from tbWellAmount where wellNo='{0}' union select * from tbWellAmount where wellNo='{0}') temp", strWellNo); string strCount = CDBConnection.ExecuteScalar(strSql); // if(strCount!="") // { // int iCount=Convert.ToInt32(strCount); // if(iCount>0) // { // if(MessageBox.Show("流量信息表中已有该监测站的信息,继续操作将造成历史记录混乱,是否继续?","删除",MessageBoxButtons.OKCancel)!=DialogResult.OK) // { // return; // } // // } // } strSql = String.Format("select count(*) from tbSal where wellNo='{0}'", strWellNo); strCount = CDBConnection.ExecuteScalar(strSql); // if(strCount!="") // { // int iCount=Convert.ToInt32(strCount); // if(iCount>0) // { // if(MessageBox.Show("售水历史记录表中已有该监测站的信息,继续操作将造成历史记录混乱,是否继续?","删除",MessageBoxButtons.OKCancel)!=DialogResult.OK) // { // return; // } // // } // } strSql = String.Format("delete from tbWell where wellNo='{0}'", strWellNo); CDBConnection.ExecuteSql(strSql); strSql = String.Format("delete from tbw_WellInfo where WellID='{0}'", strWellNo); CDBConnection.ExecuteSql(strSql); // strSql = String.Format("insert into tbDel(tbNo,tbName) values('{0}','{1}')", strWellNo, "tbWell"); CDBConnection.ExecuteSql(strSql); this.paintFrm(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//绘制图表 public bool PaintFrm(string strWellNo) { try { string strFrom = String.Format("{0}-{1}-{2}", this.dtFrom.Value.Year.ToString(), this.dtFrom.Value.Month.ToString(), this.dtFrom.Value.Day.ToString()); string strTo = String.Format("{0}-{1}-{2}", this.dtTo.Value.Year.ToString(), this.dtTo.Value.Month.ToString(), this.dtTo.Value.Day.ToString()); string strSql = String.Format("select depName from tbWell where wellNo='{0}'", strWellNo); string strDepName = CDBConnection.ExecuteScalar(strSql); this.lblInfo.Text = String.Format("水井编号:{0} 单位名称:{3} 日期:{1} 至 {2}", strWellNo, strFrom, strTo, strDepName); DataTable dtLine1 = new DataTable(); DataTable dtLine2 = new DataTable(); if (this.m_strDrawLine1Sql != "") { //查询第一条线的sql语句 strSql = this.m_strDrawLine1Sql; DataTable dt = new DataTable(); CDBConnection.getDataTable(ref dt, strSql, "tbData"); dtLine1 = dt; } if (this.m_strDrawLine2Sql != "") { //查询第二条线的sql语句 strSql = this.m_strDrawLine2Sql; DataTable dt = new DataTable(); CDBConnection.getDataTable(ref dt, strSql, "tbData"); dtLine2 = dt; } ZedGraph.Demo.DateAxisSampleDemo demo = new ZedGraph.Demo.DateAxisSampleDemo(); demo.m_dtLine1 = dtLine1; demo.m_strTitle = ""; demo.m_dtLine2 = dtLine2; //第一条线名称 demo.m_strLine1Name = this.m_strColTitle1; //第二条线名称 demo.m_strLine2Name = this.m_strColTitle2; if (strFrom != strTo) { //绘图 demo.m_strState = "month"; } else { //绘图 demo.m_strState = "Day"; } demo.initialDateAxis(); if (demo == null) { return(false); } this.tabChart.TabPages[0].Controls.Clear(); this.tabChart.TabPages[0].Controls.Add(this.lblInfo); this.tabChart.TabPages[0].Controls.Add(demo.ZedGraphControl); //demo.ZedGraphControl.Top=this.label1.Top+this.label1.Height; demo.ZedGraphControl.Top = 10; demo.ZedGraphControl.Left = 10; demo.ZedGraphControl.Width = tabChart.Width - 20; demo.ZedGraphControl.Height = tabChart.Height - 40; demo.ZedGraphControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; //this.Text = TitlePrefix + demo.Title; //descriptionBox.Text = demo.Description; // tell the control to rescale itself demo.ZedGraphControl.AxisChange(); // redraw the entire form this.Invalidate(); return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }