コード例 #1
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["lrbdConnectionString"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("SELECT * FROM CustomerMaster WHERE username='******'", connection);
            SqlDataReader reader = command.ExecuteReader();
            
            //while (reader.Read())
            //{
                if (reader.Read())
                {
                    ErrorMessage.Text = reader["username"].ToString() + " User already exist";
                }
                else
                {                   
                    Lrbd.BusinessEntity.CustomerBase objcu = new Lrbd.BusinessEntity.CustomerBase();                    
                    objcu.username = UserName.Text;
                    objcu.password = Password.Text;
                    objcu.name = Name.Text;
                    objcu.email = Email.Text;
                    objcu.phone = Phone.Text;
                    Lrbd.Business.Customer objcustomer = new Lrbd.Business.Customer();
                    objcustomer.CreateCustomer(objcu);

                    Response.Redirect("Login.aspx");
                }
                
            //}
                connection.Close();

            
            //ErrorMessage.Text = result.Errors.FirstOrDefault();
            
        }
コード例 #2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Lrbd.Business.Customer objcu = new Lrbd.Business.Customer();
     Lrbd.BusinessEntity.CustomerBase objcust = new Lrbd.BusinessEntity.CustomerBase();
     objcust.username = Username.Text;
     objcust.password = Password.Text;
     objcust.name = Name.Text;
     objcust.email = Email.Text;
     objcust.phone = Phone.Text;
     objcu.CreateCustomer(objcust);
     
     Response.Redirect("Customerlisting.aspx");
 }