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

📄 companyedit.aspx.cs

📁 ASP.NET编写的眼镜行分销系统的程序.
💻 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 NewGlassBook;
namespace NewGlassBook
{
	public class CompanyEdit : MyPage
	{
		protected System.Web.UI.WebControls.Label lblWarning;
		protected NewGlassBook.MyTextBox aZip;
		protected NewGlassBook.MyTextBox aAddress;
		protected NewGlassBook.MyTextBox aFax;
		protected NewGlassBook.MyTextBox aTel;
		protected NewGlassBook.MyTextBox aContact;
		protected NewGlassBook.MyTextBox aCompanyName;
		protected NewGlassBook.MyTextBox aID;
		protected System.Web.UI.WebControls.DropDownList astorecode;		
		protected NewGlassBook.MyButton dbtn_cancel;
		protected NewGlassBook.MyButton dbtn_ok;
		protected System.Web.UI.WebControls.TextBox did;
		protected string strID;//公司的编号
		Record r=new Record();//访问数据库
		DataSet dsStore;
		private void Page_Load(object sender, System.EventArgs e)
		{			
			if(!Page.IsPostBack)
			{
				dsStore=r.GetData("store","select * from store where storecode not like '_f%'");
				astorecodebind();//将仓库信息绑定到dropdownlist
				initData();//在文本框中显示公司的信息
			}
		}
		private void astorecodebind()
		{
			DataSet ds=r.GetData("tblName","select * from store where storecode not like '_f%'");
			astorecode.DataSource=ds;
			astorecode.DataTextField="storename";
			astorecode.DataValueField="storecode";
			astorecode.DataBind();			
		}
		private void initData()
		{
			DataSet ds;
			string strSql;
			strID=Request.QueryString["id"].ToString();//得到公司的ID
			did.Text=strID;
			strSql="select *,a.id as bid from company a where a.id='"+strID+"'";
			ds=r.GetData("a_b",strSql);
			aID.Text=ds.Tables["a_b"].Rows[0]["ID"].ToString();
			aCompanyName.Text=ds.Tables["a_b"].Rows[0]["CompanyName"].ToString();
			aContact.Text=ds.Tables["a_b"].Rows[0]["Contact"].ToString();
			aTel.Text=ds.Tables["a_b"].Rows[0]["Tel"].ToString();
			aFax.Text=ds.Tables["a_b"].Rows[0]["Fax"].ToString();
			aAddress.Text=ds.Tables["a_b"].Rows[0]["Address"].ToString();
			aZip.Text=ds.Tables["a_b"].Rows[0]["Zip"].ToString();			
			astorecode.SelectedIndex=GetSelectedIndex(ds.Tables["a_b"].Rows[0]["storecode"].ToString());			
		}
		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			InitializeComponent();
			base.OnInit(e);
		}
		private void InitializeComponent()
		{    
			this.dbtn_ok.Click += new System.EventHandler(this.dbtn_ok_Click);
			this.dbtn_cancel.Click += new System.EventHandler(this.dbtn_cancel_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
		

		public int GetSelectedIndex(String strID)
		{
			int i=0;
			if(strID!=null)
			{
				foreach(DataRow Store in dsStore.Tables["store"].Rows)
				{
					if(strID.Trim()==Store["storecode"].ToString().Trim())
					{
						break;
					}
					i=i+1;
				}
			}	
			return i;
		}

		private void dbtn_ok_Click(object sender, System.EventArgs e)
		{			
			if(r.RequestUpdate("company",Request)==1)//更新表
			{
				Response.Write("<script lannguage='javascript'>window.close();</script>");
				Response.Write("<script lannguage='javascript'>window.opener.location.href='CompanyAdmin.aspx';</script>");
			}
			else
			{
				lblWarning.Text=r.ErrMsg;
			}
		}

		private void dbtn_cancel_Click(object sender, System.EventArgs e)
		{
			Response.Write("<script lannguage='javascript'>window.close();</script>");
		}
	}
}

⌨️ 快捷键说明

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