回复 3楼 谢成新
public partial class Sys_BranchDetail : TowinCore.BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
if(this.Request["option"]!=null)
{
if (this.Request["option"] == "add")
{
}
else
{
this.BindBranchInfo();
}
}
}
}
private void BindBranchInfo()
{
string strsql = "select tb_branchId, tb_branchName,effective from t_Branch where tb_branchId= '" + this.Request["cCode"].ToString() + "'";
DataTable dt = Db.GetDataTable(strsql);
this.TBX_Branchcode.Text = dt.Rows[0]["tb_branchId"].ToString();
this.TBX_Branchname.Text=dt.Rows[0]["tb_branchName"].ToString();
this.DDL_effective.SelectedValue = dt.Rows[0]["effective"].ToString();
}
protected void Btn_Save_Click(object sender, EventArgs e) //保存部门信息
{
if (this.TBX_Branchname.Text == "")
{
Response.Write("<script language=javascript>alert('您还没有填写部门名称!')</script>");
}
else
{
string str = "";
if (this.Request["option"].ToString() == "add")
{
str = "insert into t_Branch(tb_branchId,tb_branchName,effective) values('" +TBX_Branchcode.Text+ "','" + this.TBX_Branchname.Text + "','" + this.DDL_effective.SelectedValue+ "')";
}
else
{
str = "update t_Branch set tb_branchName='" + this.TBX_Branchname.Text + "' where tb_branchId='"+this.Request["cCode"].ToString()+"'";
}
TowinCore.Db.ExecuteSQL(str);
Cls_Message.ShowPageMessage("操作成功!", this.Page);
}
}
protected void Btn_Cancel_Click(object sender, EventArgs e)
{
//取消操作
this.TBX_Branchcode.Text = "";
this.TBX_Branchname.Text = "";
Response.Write("<script>if(confirm(\"确定取消操作?\")==true){window.close();}</script>");
}
}