⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_dqcy.aspx.cs

📁 毕业设计时做的,一个管理关于污染管理的, 源代码,呵呵 想想当时还真厉害,可以实现污染检测
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using gyit.Data;
using System.Configuration;
using System.Data.SqlClient;

namespace itcrm.jxcManager
{
	/// <summary>
	/// t_dqcy 的摘要说明。
	/// </summary>
	public class t_dqcy : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox txtRemark;
		protected System.Web.UI.WebControls.DropDownList ddlDq;
		protected System.Web.UI.WebControls.DropDownList ddlHy;
		protected System.Web.UI.WebControls.DropDownList ddlBz;
		protected System.Web.UI.WebControls.Button btnAdd;
		protected System.Web.UI.WebControls.Button btnClear;
		protected System.Web.UI.WebControls.TextBox txtDqcy_ID;
		protected System.Web.UI.WebControls.TextBox txtPlaceID;
		protected System.Web.UI.WebControls.TextBox txtPlace;
		protected System.Web.UI.WebControls.TextBox txtTime;
		protected System.Web.UI.WebControls.TextBox txtThg;
		protected System.Web.UI.WebControls.TextBox txtTspg;
		protected System.Web.UI.WebControls.TextBox txtBound;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Button btnReturn;
		DBOperator db;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator3;
	    string vid;
		private void Page_Load(object sender, System.EventArgs e)
		{
			 vid=Page.Request["id"];
			
			db =DBOperator.CreateObject((string)ConfigurationSettings.AppSettings["DSN"]);
			if(!Page.IsPostBack)
			{
				
				BindDdlDq();
				BindDdlBz();
				BindDdlHy();
				if(vid!=null)
				{
					QueryEdit(vid);
					txtDqcy_ID.Enabled=false;
					
				}
				else{Refresh();}
			}
			
		}
		

/// <summary>
/// 绑定下拉框
/// </summary>
		private void BindDdlDq()
		{
			string strSql="select dq_ID,dq_Name from tb_dq";
			DataSet ds=null;
			db.Open();
			ds=db.exeSqlForDataSet(strSql);
			db.Close();
			if(ds!=null)
			{
				ddlDq.DataSource=ds;
				ddlDq.DataTextField=ds.Tables[0].Columns["dq_Name"].ToString();
				ddlDq.DataValueField=ds.Tables[0].Columns["dq_ID"].ToString();
				ddlDq.DataBind();
				ds.Dispose();
				ddlDq.Dispose();
			}
			 
			
			
		}
		private void BindDdlBz()
		{
			string strSql="select bz_ID,BM from tb_gwrbz";
			DataSet ds=null;
			db.Open();
			ds=db.exeSqlForDataSet(strSql);
			db.Close();
			if(ds!=null)
			{
				ddlBz.DataSource=ds;
				ddlBz.DataTextField=ds.Tables[0].Columns["BM"].ToString();
				ddlBz.DataValueField=ds.Tables[0].Columns["bz_ID"].ToString();
				ddlBz.DataBind();
				ds.Dispose();
				ddlBz.Dispose();
			}
		}
/// <summary>
/// 绑定地区
/// </summary>
		private void BindDdlHy()
		{   
			string strSql="select hy_ID,hy_Name from tb_hy";
			DataSet ds=null;
			db.Open();
			ds=db.exeSqlForDataSet(strSql);
			db.Close();
			if(ds!=null)  
			{
				ddlHy.DataSource=ds;
				ddlHy.DataTextField=ds.Tables[0].Columns["hy_Name"].ToString();
				ddlHy.DataValueField=ds.Tables[0].Columns["hy_ID"].ToString();
				ddlHy.DataBind();
				ds.Dispose();
				ddlHy.Dispose();
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
			this.btnReturn.Click += new System.EventHandler(this.btnReturn_Click);
			this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

/// <summary>
///  增 加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			
				string[] strPara =new string[14];
				object[] strValues=new object[14];

				strPara[0]="@Dqcy_ID";
				strPara[1]="@dq_ID";
				strPara[2]="@dq_Name";
				strPara[3]="@PlaceID";
				strPara[4]="@hy_ID";
                strPara[5]="@hy_Name";
				strPara[6]="@bz_ID";
				strPara[7]="@BM";
				strPara[8]="@Place";               
				strPara[9]="@Time";
				strPara[10]="@Value";
				strPara[11]="@Thg";
				strPara[12]="@Tspg";
				strPara[13]="@Remark";
				

				strValues[0]=txtDqcy_ID.Text;
				strValues[1]=ddlDq.SelectedItem.Value;
				strValues[2]=ddlDq.SelectedItem.Text;
				strValues[3]=txtPlaceID.Text;
				strValues[4]=ddlHy.SelectedItem.Value;
				strValues[5]=ddlHy.SelectedItem.Text;
				strValues[6]=ddlBz.SelectedItem.Value;
				strValues[7]=ddlBz.SelectedItem.Text;
				strValues[8]=txtPlace.Text;
				strValues[9]=txtTime.Text;
				strValues[10]=txtBound.Text;
				strValues[11]=txtThg.Text;
				strValues[12]=txtTspg.Text;
				strValues[13]=txtRemark.Text;
			
			
				try
				{
					if(txtDqcy_ID.Text!="")
					{
						if(txtPlaceID.Text!="")
						{
							if(txtBound.Text!="")
							{
								if(vid!=null)
								{
									db.Open();
									db.exeProc("Update_t_dqcy",strPara,strValues);
									db.Close();
									Page.RegisterStartupScript("script","<script>alert('修改记录成功!')</script>");
								}
								else		
								{
										db.Open();
										db.exeProc("Add_t_dqcy",strPara,strValues);
										db.Close();
										Page.RegisterStartupScript("script","<script>alert('增加记录成功!')</script>");
									    btnClear_Click(sender,e);
									    Refresh();
								}
							}
							else{Page.RegisterStartupScript("script","<script>alert('汞含量范围不能为空!')</script>");}
						}
						else{Page.RegisterStartupScript("script","<script>alert('地点编号不能为空!')</script>");}
						
					}
					else{Page.RegisterStartupScript("script","<script>alert('采样编号不能为空!')</script>");}
					
					}
					
				catch(System.Exception ee)
				{
					
			       Page.RegisterStartupScript("script","<script>alert('"+ee.Message+"')</script>");
				}
		}
/// <summary>
/// 清除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
		private void btnClear_Click(object sender, System.EventArgs e)
		{
			//txtDqcy_ID.Text="";
			txtPlaceID.Text="";
			txtPlace.Text="";
			//txtTime.Text="";
			txtBound.Text="";
			txtThg.Text="";
			txtTspg.Text="";
			txtRemark.Text="";
		}


/// <summary>
/// 返 回
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
		private void btnReturn_Click(object sender, System.EventArgs e)
		{
			Page.Response.Redirect("t_dqcyAdd.aspx");
		
		}
/// <summary>
///  编辑
/// </summary>
/// <param name="who"></param>
		private void QueryEdit(string who)
		{
			string strSql="select * from t_dqcy where dqcy_ID='"+who+"'";
			DataSet ds=new DataSet();
			DataRow row=null;
			db.Open();
			ds=db.exeSqlForDataSet(strSql);
			db.Close();
			row=ds.Tables[0].Rows[0];
			if(row!=null)
			{
				txtDqcy_ID.Text=row["Dqcy_ID"].ToString();
				ddlDq.SelectedItem.Value=row["dq_ID"].ToString();
				txtPlaceID.Text=row["PlaceID"].ToString();
				ddlHy.SelectedItem.Value=row["hy_ID"].ToString();
				ddlBz.SelectedItem.Value=row["bz_ID"].ToString();
				txtPlace.Text=row["Place"].ToString();
				txtTime.Text=row["Time"].ToString();
				txtBound.Text=row["Value"].ToString();
				txtThg.Text=row["Thg"].ToString();
				txtTspg.Text=row["Tspg"].ToString();
				txtRemark.Text=row["Remark"].ToString();
				ds.Dispose();
			}

		}
		/// <summary>
		/// 自动获得编号
		/// </summary>
		private void Refresh()
		{
			
           txtTime.Text=System.DateTime.Now.ToShortDateString();
			string strSql="select dqcy_ID from t_dqcy order by ID";
			DataSet ds=null;
			db.Open();
			ds=db.exeSqlForDataSet(strSql);
			db.Close();
			int count=ds.Tables[0].Rows.Count;
			if(count==0)
			{  
				txtDqcy_ID.Text="300001";     
			}
			else
			{
				
				count=ds.Tables[0].Rows.Count;
				DataRow row=ds.Tables[0].Rows[count-1];
				int len=row["dqcy_ID"].ToString().Length;
				string str=(row["dqcy_ID"].ToString()).Substring(len-2,1);
				if(str=="0")
				{
					string str1=(row["dqcy_ID"].ToString()).Substring(0,len-1);
					string str2=(row["dqcy_ID"].ToString()).Substring(len-1,1);
					int ID=Convert.ToInt32(str2)+1;
					string Value=str1+ID.ToString();
					txtDqcy_ID.Text=Value;
				}
				else
				{
					string str1=(row["dqcy_ID"].ToString()).Substring(0,len-2);
					string str2=(row["dqcy_ID"].ToString()).Substring(len-2,2);					
					int ID=Convert.ToInt32(str2)+1;
					string Value=str1+ID.ToString();
					txtDqcy_ID.Text=Value;  
				}
			}
		}  		

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -