.Nettiers事件: Insert,Update,Load || Edit.aspx || 不用WEB层【原创】

public partial class EditDefault : System.Web.UI.Page
{
    CustomersService customersService 
= new CustomersService();
    
    
protected void Page_Load(object sender, EventArgs e)
    {
        
if (!IsPostBack)
        {
            
string customerID = Request.Params["CustomerId"].ToString();
            
if(customerID!="")
            {
                Customers customers 
= customersService.GetByCustomerId(customerID);
                dataCustomerId.Text 
= customers.CustomerId;
                dataCompanyName.Text 
= customers.CompanyName;
                dataContactName.Text 
= customers.ContactName;
                dataCustomerPs.Text 
= customers.CustomerPs;
                
//.
                dataCustomerId.ReadOnly = true;
                
this.Label1.Text = "";
            }
            
        }
    }

    
protected void UpdateButton_Click(object sender, EventArgs e)
    {
        
string customerID = Request.Params["CustomerId"].ToString();
        Customers customers 
= customersService.GetByCustomerId(customerID);
        customers.CustomerId 
= dataCustomerId.Text;
        customers.CompanyName 
= dataCompanyName.Text;
        customers.ContactName 
= dataContactName.Text;

        
bool isok = customersService.Update(customers);  //更新一条
        if (isok)
        {
            
this.Label1.Text = "succeed";
        }
        
else
        {
            
this.Label1.Text = "failed";
        }
    }
    
protected void InsertButton_Click(object sender, EventArgs e)
    {
        Customers customers 
= new Customers();
        customers.CustomerId 
= dataCustomerId.Text;
        customers.CompanyName 
= dataCompanyName.Text;
        customers.ContactName 
= dataContactName.Text;
        
bool isok = customersService.Insert(customers);         //更新一条
        if (isok)
        {
            
this.Label1.Text = "succeed";
        }
        
else
        {
            
this.Label1.Text = "failed";
        }
    }
}
posted @ 2008-08-27 21:17  KiNg.JiOnG  阅读(528)  评论(0编辑  收藏  举报
查看博客访问人数(点击):