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";
        }
    }
}

相关文章:

  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2022-01-20
  • 2021-07-21
  • 2021-11-23
  • 2022-03-09
  • 2022-12-23
相关资源
相似解决方案