?? addclient.ascx.cs
字號(hào):
?using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class control_addclient : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.bindtogridview();
}
//if (Convert.ToString(Session["username"]) == "")
//{
// Response.Write("<script language=javascript>alert('請(qǐng)登錄');location='../login.aspx'</script>");
// return;
//}
}
protected void btnaddclient_Click(object sender, EventArgs e)
{
string txtclientnum = this.txtclientnun.Text.ToString();
string txtclientname = this.txtclientname.Text.ToString();
string txtconpeople = this.txtconpeople.Text.ToString();
string txtphoto= this.txtphoto.Text.ToString();
string txtaddress = this.txtaddress.Text.ToString();
SqlConnection strcon = DB.createConnection();
//new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
strcon.Open();
SqlCommand scd = new SqlCommand("insert into client(客戶(hù)編號(hào),客戶(hù)名稱(chēng),聯(lián)系人,聯(lián)系電話(huà),聯(lián)系地址)values('" + txtclientnum + "','" + txtclientname + "','" + txtconpeople + "','" + txtphoto + "','" + txtaddress + "')", strcon);
scd.ExecuteNonQuery();
strcon.Close();
Response.Write("<script language=javascript>alert('您已經(jīng)添加成功');location='addclient.aspx'</script>");
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void bindtogridview()
{
SqlConnection con = DB.createConnection();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from client", con);
DataSet ds = new DataSet();
sda.Fill(ds, "client");
this.GridView1.DataKeyNames = new string[] {"客戶(hù)編號(hào)"};
this.GridView1.DataSource = ds.Tables["client"];
this.GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
this.bindtogridview();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -