private void paintFrm() { try { string strSql = String.Format("select CountryName,CountryDes,townName from tbCountry"); DataTable dtCountry = null; CDBConnection.getDataTable(ref dtCountry, strSql, "btCountry"); this.lsvCountry.Items.Clear(); for (int i = 0; i < dtCountry.Rows.Count; i++) { this.lsvCountry.Items.Add(dtCountry.Rows[i]["countryName"].ToString()); this.lsvCountry.Items[i].SubItems.Add(dtCountry.Rows[i]["townName"].ToString()); this.lsvCountry.Items[i].SubItems.Add(dtCountry.Rows[i]["countryDes"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//»æÖƵ¥Î»Ê÷ public bool paintTrVDep(System.Windows.Forms.TreeView trvDep) { 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(); 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++) { 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++) { trvDep.Nodes[i].Nodes[j].Nodes.Add(dtDep.Rows[z]["depShortName"].ToString()); } } } return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } }
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()); } }
//*******************数据库操作区***************** #region "数据库查询" /// <summary> /// 已审 /// </summary> /// <param name="strWellNo">监测站编号</param> /// <param name="strUserName">操作员名称</param> private void paintReport(string strWellNo, string strUserName) { 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 = ""; //监测站统计sql1******************************sql语句 string strSql = String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo and tbSal.wellNo='{2}' order by time", strFrom, strTo, strWellNo); strTitle = "单位购水统计表"; if (strWellNo.Trim() == "") { if (strUserName.Trim() == "") { //无查询条件sql2 strSql = String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo order by time", strFrom, strTo); } else { //操作员统计sql3***** strSql = String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo and tbSal.salPer='{2}' order by time", strFrom, strTo, strUserName); strTitle = "操作员售水统计表"; } } //************************************** //统计合计 DataTable dt = null; CDBConnection.getDataTable(ref dt, strSql, "tbSalWater"); double iSalAmount = 0, iSalMony = 0; for (int i = 0; i < dt.Rows.Count; i++) { iSalAmount = iSalAmount + Convert.ToDouble(dt.Rows[i]["Field5"]); iSalMony = iSalMony + Convert.ToDouble(dt.Rows[i]["Field4"]); } DataRow dr = dt.NewRow(); dr["Field1"] = "合计"; dr["Field4"] = iSalMony.ToString(); dr["Field5"] = iSalAmount.ToString(); dt.Rows.Add(dr); //************************ //报表显示 string strTime = 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 = strTime; toTitle = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTitle"]; if (strTitle != "") { 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(); } crpPrintObj.SetDataSource(dt); this.crpSalWater.ReportSource = crpPrintObj; } 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); } }
private void frmDepEdit_Load(object sender, System.EventArgs e) { try { string strSql = String.Format("select countryName from tbCountry"); DataTable dtCountry = null; CDBConnection.getDataTable(ref dtCountry, strSql, "dtCountry"); this.cmbCountry.Items.Clear(); for (int i = 0; i < dtCountry.Rows.Count; i++) { this.cmbCountry.Items.Add(dtCountry.Rows[i]["countryName"].ToString()); } if (this.cmbCountry.Items.Count > 0) { this.cmbCountry.Text = this.cmbCountry.Items[0].ToString(); } else { this.cmbCountry.Text = ""; } this.cmbHangYe.Items.Clear(); strSql = "select hangYeName from tbHangYe"; DataTable dtHangYe = null; CDBConnection.getDataTable(ref dtHangYe, strSql, "HangYe"); for (int i = 0; i < dtHangYe.Rows.Count; i++) { this.cmbHangYe.Items.Add(dtHangYe.Rows[i]["HangYeName"].ToString()); } if (this.cmbHangYe.Items.Count > 0) { this.cmbHangYe.Text = this.cmbHangYe.Items[0].ToString(); } else { this.cmbHangYe.Text = ""; } if (this.m_bEdit == false) { this.cmbCountry.Text = this.m_strCountryName; } else { strSql = String.Format("select depShortName,depName,CountryName,HangYeName,ContactPer,ContactTel,address,des from tbDep where depShortName='{0}'", this.m_strDepShortName.Trim()); DataTable dtDep = null; if (CDBConnection.getDataTable(ref dtDep, strSql, "dep") == false) { return; } if (dtDep.Rows.Count > 0) { this.txtDepShortName.Text = dtDep.Rows[0]["depShortName"].ToString(); this.txtDepShortName.ReadOnly = true; this.txtDepName.Text = dtDep.Rows[0]["depName"].ToString(); this.txtAddress.Text = dtDep.Rows[0]["address"].ToString(); this.txtContactPer.Text = dtDep.Rows[0]["ContactPer"].ToString(); this.txtContactTel.Text = dtDep.Rows[0]["ContactTel"].ToString(); this.txtDes.Text = dtDep.Rows[0]["des"].ToString(); this.cmbHangYe.Text = dtDep.Rows[0]["HangYeName"].ToString(); this.cmbCountry.Text = dtDep.Rows[0]["CountryName"].ToString(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void lswUserInfo_Click(object sender, System.EventArgs e) { try { if (lswUserInfo.SelectedItems.Count == 0) { return; } if (checkSelectedItem() == false) { //判断是否同权限 //return; } for (int z = 0; z < this.tvwMenuInfo.Nodes.Count; z++) { this.tvwMenuInfo.Nodes[z].Checked = false; CheckAllChildNodes(this.tvwMenuInfo.Nodes[z], false); } string strUserID = this.lswUserInfo.SelectedItems[0].Text.Trim(); string strSql = String.Format("select ltrim(rtrim(menuName)) as menuName from userMenu where userID='{0}'", strUserID); DataTable dtUserMenu = new DataTable(); CDBConnection.getDataTable(ref dtUserMenu, strSql, "userMenu"); for (int i = 0; i < this.tvwMenuInfo.Nodes.Count; i++) { for (int x = 0; x < dtUserMenu.Rows.Count; x++) { if (this.tvwMenuInfo.Nodes[i].Text.Trim() == dtUserMenu.Rows[x][0].ToString().Trim()) { this.tvwMenuInfo.Nodes[i].Checked = true; break; } else { this.tvwMenuInfo.Nodes[i].Checked = false; } } for (int j = 0; j < this.tvwMenuInfo.Nodes[i].Nodes.Count; j++) { for (int y = 0; y < dtUserMenu.Rows.Count; y++) { if (this.tvwMenuInfo.Nodes[i].Nodes[j].Text.Trim() == dtUserMenu.Rows[y][0].ToString().Trim()) { this.tvwMenuInfo.Nodes[i].Nodes[j].Checked = true; break; } else { this.tvwMenuInfo.Nodes[i].Nodes[j].Checked = false; } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }