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

📄 productid.aspx.cs

📁 企业管理信息化之财务管理系统
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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 com.unicafe.ui;
using com.unicafe.common;
using com.unicafe.security;

namespace com.ascs.plp.publics
{
	/// <summary>
	/// KC_ProductId 的摘要说明。
	/// </summary>
	public class ProductId : com.unicafe.ui.UnicafePage
	{
		protected System.Web.UI.WebControls.CheckBox CheckBox1;
		protected System.Web.UI.WebControls.CheckBox CheckBox2;
		protected System.Web.UI.WebControls.CheckBox CheckBox3;
		protected System.Web.UI.WebControls.CheckBox CheckBox4;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.TextBox TextBox3;
		protected System.Web.UI.WebControls.TextBox TextBox4;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		protected System.Data.SqlClient.SqlConnection sqlcn_plp;
		protected System.Data.SqlClient.SqlCommand cmd;
		protected System.Data.DataTable dt_CPJBXX;
		protected System.Data.DataView dv_CPJBXX;
		protected System.Data.SqlClient.SqlDataReader dr;
		protected string sql,CPMCStatement,SCCSStatement,CPXHStatement,CPGGStatement,EnableLimit;
		protected System.Web.UI.WebControls.LinkButton LinkButton1;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			this.VerifyPage();
			sqlcn_plp = new SqlConnection (com.unicafe.common.Configuration.GetDBConnectionString());
			cmd = sqlcn_plp.CreateCommand();
			if (!this.IsPostBack)
			{
				try
				{
					ViewState["FormName"] = this.Request.QueryString["FormName"];
					ViewState["ControlName"] = this.Request.QueryString["ControlName"];
				}
				catch
				{
					this.Response.Write("<script language=javascript>window.close();</script>");
					return;
				}
			
				// 给绑定DataGrid控件的SQL语句进行赋值(注意,SQL语句赋值之后不要再修改)
				ViewState["sql"] =	"Select CPDM, CPMC, SCCS, CPXH, CPGG From CPJBXX Where CPDM is Null ";
				string sql = ViewState["sql"].ToString();
			
				//处理DataGrid控件(绑定DataGrid控件 -> 检查是否需要定位 -> 给导航文本赋值)
				if(CommonService.HandleDataGrid(this, sql, DataGrid1, "Data2", Label1, Label2, Label3) == false)
					this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。"); 
			}
			else
			{
				//检查回发的请求操作是否是要进入上页或下页
				if(CommonService.PageNavigate(this, DataGrid1, "Data2", Label1, Label2, Label3) == false)
					this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。");
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.CheckBox1.CheckedChanged += new System.EventHandler(this.CheckBox1_CheckedChanged);
			this.CheckBox2.CheckedChanged += new System.EventHandler(this.CheckBox2_CheckedChanged);
			this.CheckBox3.CheckedChanged += new System.EventHandler(this.CheckBox3_CheckedChanged);
			this.CheckBox4.CheckedChanged += new System.EventHandler(this.CheckBox4_CheckedChanged);
			this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
			this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
			this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
			this.ID = "ProductId";
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		
		
		
		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 查询事件处理函数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void LinkButton1_Click(object sender, System.EventArgs e)
		{
			BindGrid();
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************




		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 与DataGrid1绑定数据
		/// </summary>
		/// *****************************************************************************
		private void BindGrid()
		{
			//根据选择的条件进行查询条件的组合和生成
			sql = "Select CPDM, CPMC, SCCS, CPXH, CPGG From CPJBXX Where CPDM Like '%' ";
			if (CheckBox1.Checked == true && TextBox1.Text.Trim() != "")
			{
				CPMCStatement = "And CPMC Like '%" + TextBox1.Text + "%' ";
			}
			else
			{
				CPMCStatement = "";
			}

			if (CheckBox2.Checked == true && TextBox2.Text.Trim() != "")
			{
				SCCSStatement = "And SCCS Like '%" + TextBox2.Text + "%' ";
			}
			else
			{
				SCCSStatement = "";
			}

			if (CheckBox3.Checked == true && TextBox3.Text.Trim() != "")
			{
				CPXHStatement = "And CPXH Like '%" + TextBox3.Text + "%' ";;
			}
			else
			{
				CPXHStatement = "";
			}

			if (CheckBox4.Checked == true && TextBox4.Text.Trim() != "")
			{
				CPGGStatement = "And CPGG Like '%" + TextBox4.Text + "%' ";
			}
			else
			{
				CPGGStatement = "";
			}

			if(this.Request.QueryString["EnableLimit"] == null || this.Request.QueryString["EnableLimit"] == "T")
			{
				EnableLimit = "And SFSY = '1'";
			}
			else
			{
				EnableLimit = "";
			}

			ViewState["sql"] =	sql + CPMCStatement + SCCSStatement + CPXHStatement + CPGGStatement + EnableLimit;
			sql = ViewState["sql"].ToString();
			
			//处理DataGrid控件(绑定DataGrid控件 -> 给导航文本赋值)
			if(CommonService.ReBindDataGrid(this, sql, DataGrid1, "Data2", Label1, Label2, Label3) == false)
				this.Response.Redirect("../../publics/Error.aspx?errmsg=在处理数据时发生错误。"); 
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************



		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 产品名称复选框状态改变事件处理函数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// *****************************************************************************
		private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
		{
			if (CheckBox1.Checked == true)
			{
				TextBox1.Enabled = true;
			}
			else
			{
				TextBox1.Enabled = false;
			}
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************




				

		/// ******************************************************************
		/// BEIGIN
		/// <summary>
		/// 为数据行添加对鼠标移动的响应代码
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// ******************************************************************
		protected void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if (e.Item.ItemIndex >= 0)
			{
				e.Item.Attributes["onMouseOver"] = "javascript:this.bgColor='LemonChiffon';";
				e.Item.Attributes["onMouseOut"] = "javascript:this.bgColor='white';";
				e.Item.Attributes["onClick"] = "javascript:__doPostBack('DataGrid1:_ctl" +(Convert.ToInt16(e.Item.ItemIndex+3)).ToString() + ":_ctl0','')";
				e.Item.Attributes["style"] = "cursor:hand";
			}
		}
		/// ******************************************************************
		/// END
		/// ******************************************************************





		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 生产厂商复选框状态改变事件处理函数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// *****************************************************************************
		private void CheckBox2_CheckedChanged(object sender, System.EventArgs e)
		{
			if (CheckBox2.Checked == true)
			{
				TextBox2.Enabled = true;
			}
			else
			{
				TextBox2.Enabled = false;
			}
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************


		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 产品型号复选框状态改变事件处理函数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// *****************************************************************************
		private void CheckBox3_CheckedChanged(object sender, System.EventArgs e)
		{
			if (CheckBox3.Checked == true)
			{
				TextBox3.Enabled = true;
			}
			else
			{
				TextBox3.Enabled = false;
			}
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************




		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 产品规格复选框状态改变事件处理函数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// *****************************************************************************
		private void CheckBox4_CheckedChanged(object sender, System.EventArgs e)
		{
			if (CheckBox4.Checked == true)
			{
				TextBox4.Enabled = true;
			}
			else
			{
				TextBox4.Enabled = false;
			}
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************



		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 产品列表选择项改变事件处理函数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// *****************************************************************************
		private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string ReturnForm = ViewState["FormName"].ToString();
			string ReturnControl = ViewState["ControlName"].ToString();
			string sId = DataGrid1.SelectedItem.Cells[1].Text;
			string sScript = "";
			sScript += "<script language=javascript>";
			sScript += "  window.opener." + ReturnForm + "." + ReturnControl + ".value = '" + sId + "';";
			
			if (this.Request.QueryString["Submit"] == "T")
                sScript += "  window.opener." + ReturnForm + "." + ReturnControl + ".value = '" + sId + "';window.opener." + ReturnForm + ".submit();"; 
			
			sScript += "  window.close();";
			sScript += "</script>";
			Response.Write(sScript);
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************

		


		/// *****************************************************************************
		/// BEIGIN
		/// <summary>
		/// 产品列表分页事件处理函数
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void DataGrid1_Page(Object sender, DataGridPageChangedEventArgs e) 
		{
			DataGrid1.CurrentPageIndex = e.NewPageIndex;
			BindGrid();
		}
		/// *****************************************************************************
		/// END
		/// *****************************************************************************


//
//
//		/// *****************************************************************************
//		/// BEIGIN
//		/// <summary>
//		/// 返回事件处理函数
//		/// </summary>
//		/// <param name="sender"></param>
//		/// <param name="e"></param>
//		private void Button2_Click(object sender, System.EventArgs e)
//		{
//			string ReturnForm = ViewState["FormName"].ToString();
//			string ReturnControl = ViewState["ControlName"].ToString();
//			string sId = Text1.Value;
//			string sScript = "";
//			sScript += "<script language=javascript>";
//			sScript += "  window.opener." + ReturnForm + "." + ReturnControl + ".value = '" + sId + "';";
//			sScript += "  window.close();";
//			sScript += "</script>";
//			Response.Write(sScript);
//		}
//		/// *****************************************************************************
//		/// END
//		/// *****************************************************************************

	}
}

⌨️ 快捷键说明

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