private void Button_Click(object sender, RoutedEventArgs e) { adminmenu adminmenuobj = new adminmenu(); adminmenuobj.Show(); this.Close(); }
private void Button_Click(object sender, RoutedEventArgs e) { SqlConnection sqlConnection = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Sayan\Documents\erfanrestudb.mdf; Integrated Security = True; Connect Timeout = 30"); sqlConnection.Open(); string sql = "select * from adminss where (adminusername='******' and adminpassword='******')"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); if (dataTable.Rows.Count == 1) { adminmenu adminmenuobj = new adminmenu(); adminmenuobj.Show(); this.Close(); } else { MessageBox.Show("Wrong username or password"); } }
private void Button_Click(object sender, RoutedEventArgs e) { string newnumber = ""; bool flag = true; bool flagz = true; bool flag1 = true; bool flag2 = true; bool flag3 = true; bool flag4 = true; string errormasage = ""; if (c2.Text.Trim() != "") { if (!allmethods.emailcheck(c2.Text.Trim())) { flag = false; errormasage += "The email format is not corect "; } } if (c1.Text.Trim() != "") { if (!allmethods.phonechecker(c1.Text.Trim(), out newnumber)) { flag1 = false; errormasage += "The phone number format is not corect "; } } if (c4.Password.Trim() != c5.Password.Trim()) { flag2 = false; errormasage += "paswords do not match"; } if (c6.Text.Trim() != "") { char[] komaki = c6.Text.Trim().ToLower().ToCharArray(); try { flag4 = false; for (int i = 0; i < komaki.Length; i++) { if (komaki[i] == 'a' && komaki[i + 1] == 'd' && komaki[i + 2] == 'm' && komaki[i + 3] == 'i' && komaki[i + 4] == 'n') { flag4 = true; break; } } if (flag4 == false) { errormasage += "this user name is not corect"; } } catch (Exception) { } } SqlConnection sqlConnection = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Sayan\Documents\erfanrestudb.mdf; Integrated Security = True; Connect Timeout = 30"); sqlConnection.Open(); string sql = "select * from adminss"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); string res = string.Join(Environment.NewLine, dataTable.Rows.OfType <DataRow>().Select(x => string.Join(" ; ", x.ItemArray))); if (flag == false || flag1 == false || flag2 == false || flag3 == false || flag4 == false) { MessageBox.Show(errormasage); } else { SqlCommand sqlCommand; if (c.Text.Trim() != "") { sql = "update adminss set name = '" + c.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c2.Text.Trim() != "") { sql = "update adminss set email = '" + c2.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c1.Text.Trim() != "") { sql = "update adminss set phone = '" + newnumber + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c3.Text.Trim() != "") { sql = "update adminss set image = '" + c3.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c4.Password.Trim() != "") { sql = "update adminss set adminpassword = '******' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c6.Text.Trim() != "") { char[] komaki = c6.Text.Trim().ToLower().ToCharArray(); flagz = false; try { for (int i = 0; i < komaki.Length; i++) { if (komaki[i] == 'a' && komaki[i + 1] == 'd' && komaki[i + 2] == 'm' && komaki[i + 3] == 'i' && komaki[i + 4] == 'n') { flagz = true; break; } } } catch (Exception) { } if (flagz == true) { sql = "update adminss set adminusername = '******' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } } MessageBox.Show("Done!!"); adminmenu adminmenuobj = new adminmenu(); adminmenuobj.Show(); this.Close(); } }
private void Button_Click(object sender, RoutedEventArgs e) { bool flag = true; bool flag1 = true; bool flag2 = true; bool flag3 = true; bool flag4 = true; string errormasage = ""; if (!c.Text.All(Char.IsLetter)) { flag = false; errormasage = "your name is not in coorect format "; } SqlConnection sqlConnection = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Sayan\Documents\erfanrestudb.mdf; Integrated Security = True; Connect Timeout = 30"); sqlConnection.Open(); string sql = "select * from restu"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection); DataTable dataTable = new DataTable(); sqlDataAdapter.Fill(dataTable); string res = string.Join(Environment.NewLine, dataTable.Rows.OfType <DataRow>().Select(x => string.Join(" ; ", x.ItemArray))); if (flag == false || flag1 == false || flag2 == false || flag3 == false || flag4 == false) { MessageBox.Show(errormasage); } else { SqlCommand sqlCommand; if (c.Text.Trim() != "") { sql = "update restu set nameandfamily = '" + c.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c2.Text.Trim() != "") { sql = "update restu set kind = '" + c2.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c1.Text.Trim() != "") { sql = "update restu set block = '" + c1.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c3.Text.Trim() != "") { sql = "update restu set menuimage = '" + c3.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } if (c4.Text.Trim() != "") { sql = "update restu set addres = '" + c4.Text.Trim() + "' where Id = 1"; sqlCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection); sqlDataAdapter.InsertCommand.ExecuteNonQuery(); } MessageBox.Show("Done!!"); adminmenu adminmenuobj = new adminmenu(); adminmenuobj.Show(); this.Close(); } }