protected void btnsubmit_Click(object sender, EventArgs e)
 {
     try
     {
         var user = new Member()
         {
             member_fullname = txtfullname.Text,
             member_mail     = txtemail.Text,
             member_password = Encryptor.MD5Hash(txtpassword.Text),
             member_phone    = txtphone.Text,
             member_username = txtusername.Text,
             member_status   = 1, ///Active
             member_type     = Convert.ToInt16(ddltype.SelectedValue.ToString())
         };
         if (data.CheckRegister(user.member_fullname, user.member_mail, user.member_phone))
         {
             msg.Text      = "Add Fail. Username or email or phone exists. Let try again!";
             msg.ForeColor = System.Drawing.Color.Red;
         }
         else
         {
             data.AddNewUser(user);
             msg.Text      = "Add success!";
             msg.ForeColor = System.Drawing.Color.Green;
             ReloadPage();
         }
     }
     catch (Exception ex)
     {
         msg.Text      = "Add Fail. Erorr: " + ex.Message + ". Let try again!";
         msg.ForeColor = System.Drawing.Color.Red;
     }
 }
예제 #2
0
 protected void btnregister_Click(object sender, EventArgs e)
 {
     try
     {
         var user = new Member()
         {
             member_fullname = txtfullname.Text,
             member_mail     = txtemail.Text,
             member_password = Encryptor.MD5Hash(txtpassword.Text),
             member_phone    = txtphone.Text,
             member_username = txtusername.Text,
             member_status   = 1, ///Active
             member_type     = 0  ///user
         };
         if (data.CheckRegister(user.member_fullname, user.member_mail, user.member_phone))
         {
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Thông báo", "alert('Sign up fail! Username or email or phone exists!')", true);
         }
         else
         {
             data.AddNewUser(user);
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Thông báo", "alert('Sign up successful! Let login right now!')", true);
         }
     }
     catch (Exception)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Thông báo", "alert('Sign up fail! Let try again')", true);
     }
 }