protected void btnSignUp_Click(object sender, EventArgs e) { string myDatabase = "datasource=localhost;port=3306;username=root;password=root"; try { if (txtPassword.Text != txtConfirmPassword.Text) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show(); $('.alert-danger').html('Sorry password do not match'); })</script>"); } else if (txtFirstName.Text == "" || txtLastName.Text == "" || txtPhoneNumber.Text == "" || txtUserName.Text == "" || txtEmailAddress.Text == "" || txtPassword.Text == "" || txtConfirmPassword.Text == "") { Page.ClientScript.RegisterClientScriptBlock( this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show();" + " $('.alert-danger').html('Please Fill Mandatory Fields'); })</script>"); } else { MySqlConnection Mycon1 = new MySqlConnection(myDatabase); MySqlCommand selectCommand = new MySqlCommand("select * from EntrepreneurialTechnology.User where username='******';", Mycon1); Mycon1.Open(); MySqlDataAdapter DataAdapter = new MySqlDataAdapter(selectCommand); DataSet MyDataSet = new DataSet(); DataAdapter.Fill(MyDataSet); int i = MyDataSet.Tables[0].Rows.Count; if (i > 0) { Page.ClientScript.RegisterClientScriptBlock( this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show(); $('.alert-danger').html('Duplicate username '); })</script>"); MyDataSet.Clear(); } else { MySqlConnection Mycon2 = new MySqlConnection(myDatabase); MySqlCommand InsertCommand = new MySqlCommand("insert into EntrepreneurialTechnology.User (FirstName, LastName, PhoneNumber, username, EmailAddress, Password)values('" + txtFirstName.Text + "','" + txtLastName.Text + "','" + txtPhoneNumber.Text + "','" + txtUserName.Text + "','" + txtEmailAddress.Text + "',aes_encrypt('" + txtPassword.Text + "','secret1'));", Mycon2); MySqlDataReader MyReaderToInsert; Mycon2.Open(); MyReaderToInsert = InsertCommand.ExecuteReader(); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-success').show(); $('.alert-success').html('Saved succesfully..'); })</script>"); while (MyReaderToInsert.Read()) { } } } } catch (Exception ex) { Response.Write(ex.Message); } }
protected void btnSaveAppointment_Click(object sender, EventArgs e) { if (DDService.SelectedItem.Text == DDService.Items[0].Text) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show(); $('.alert-danger').html('Sorry Select the service'); })</script>"); } else if (DDHairstylist.SelectedItem.Text == DDHairstylist.Items[0].Text) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show(); $('.alert-danger').html('Sorry Select the Hairstylist'); })</script>"); } else if (txtSelectDate.Text == "") { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show(); $('.alert-danger').html('Sorry Select the Date'); })</script>"); } else if (DDTime.SelectedItem.ToString() == "") { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show(); $('.alert-danger').html('Sorry Select the Time'); })</script>"); } else { MySqlConnection Mycon = new MySqlConnection(myDatabase); MySqlCommand selectCommand = new MySqlCommand("select * from EntrepreneurialTechnology.Appointment where Time='" + DDTime.SelectedItem.Text + "'and Date='" + txtSelectDate.Text + "'and Stylist='" + DDHairstylist.SelectedItem + "';", Mycon); Mycon.Open(); MySqlDataAdapter DataAdapter = new MySqlDataAdapter(selectCommand); DataSet MyDataSet = new DataSet(); DataAdapter.Fill(MyDataSet); int i = MyDataSet.Tables[0].Rows.Count; if (i > 0) { Page.ClientScript.RegisterClientScriptBlock( this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-danger').show(); $('.alert-danger').html('Sorry This Time has been recieved'); })</script>"); MyDataSet.Clear(); } else { MySqlConnection Mycon1 = new MySqlConnection(myDatabase); Mycon1.Open(); MySqlCommand InsertCommand = new MySqlCommand("insert into EntrepreneurialTechnology.Appointment (FirstName, LastName, username, PhoneNumber, Service, Stylist, Date, Time)values('" + txtFirstName.Text + "','" + txtLastName.Text + "','" + txtUserName.Text + "','" + txtPhoneNumber.Text + "','" + DDService.SelectedItem.Text + "','" + DDHairstylist.SelectedItem.Text + "','" + txtSelectDate.Text + "','" + DDTime.SelectedItem.Text + "');", Mycon1); MySqlDataReader MyReaderToInsert; MyReaderToInsert = InsertCommand.ExecuteReader(); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>$(document).ready(function(){ $('.alert-success').show(); $('.alert-success').html('Saved succesfully..'); })</script>"); while (MyReaderToInsert.Read()) { } } } }