.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;
                
// .Nettiers事件: Insert,Update,Load || Edit.aspx || 不用WEB层【原创】.
                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 " ;
        }
    }
}

你可能感兴趣的:(update)