using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//using NewGlassBook;
namespace NewGlassBook
{
///
/// Summary description for employee.
///
public class AddCompany : MyPage
{
protected NewGlassBook.MyButton dbtnreset;
protected System.Web.UI.WebControls.DropDownList astorecode;
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.Label lblWarning;
protected NewGlassBook.MyButton dbtnOk;
Record r=new Record();
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
astorecodebind();//绑定仓库
dbtnOk.Attributes["onClick"]="return subcompanyValid();";
aID.Text=gen();//设置公司ID号
}
}
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();
ListItem a=new ListItem();
a.Text="请选择公司主仓库";
a.Value="";
astorecode.Items.Insert(0,a);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.dbtnOk.Click += new System.EventHandler(this.dbtnOk_Click);
this.dbtnreset.Click += new System.EventHandler(this.dbtnreset_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dbtnreset_Click(object sender, System.EventArgs e)
{
ClearTextBox();
lblWarning.Text="";
}
private void dbtnOk_Click(object sender, System.EventArgs e)
{
if(r.RequestInsert("company",Request)==1)
{
lblWarning.Text=aCompanyName.Text+"公司信息添加成功!";
ClearTextBox();
aID.Text=gen();
}
else
{
lblWarning.Text=r.ErrMsg;
}
}
string gen()//产生公司编号的函数
{
DataSet ds=r.GetData("fxs","select top 1 id from company where id not like 'f%' order by id desc");
string strID=ds.Tables["fxs"].Rows[0]["id"].ToString();
int intTmp=Int32.Parse(strID);
intTmp++;
string l="";
for(int i=0;i {
l=l+"0";
}
strID=l+intTmp.ToString();
return strID;
}
}
}