Beispiel #1
0
        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 customers where (email='" + userbox.Text.Trim() + "' or nationalid='" + userbox.Text.Trim() + "' and password='******')";
            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 (dataTable.Rows.Count == 1)
            {
                string[] id = res.Split(';');
                allmethods.signinid = int.Parse(id[0]);
                customermenu customermenuobj = new customermenu();
                customermenuobj.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Wrong username or password");
            }
        }
Beispiel #2
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            customermenu customermenuobj = new customermenu();

            customermenuobj.Show();
            this.Close();
        }
        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";
            }


            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 customers";
            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 customers set name = '" + c.Text.Trim() + "' where Id = " + allmethods.signinid;
                    sqlCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand.ExecuteNonQuery();
                }
                if (c2.Text.Trim() != "")
                {
                    sql        = "update customers set email = '" + c2.Text.Trim() + "' where Id = " + allmethods.signinid;
                    sqlCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand.ExecuteNonQuery();
                }
                if (c1.Text.Trim() != "")
                {
                    sql        = "update customers set phone = '" + newnumber + "' where Id = " + allmethods.signinid;
                    sqlCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand.ExecuteNonQuery();
                }
                if (c3.Text.Trim() != "")
                {
                    sql        = "update customers set image = '" + c3.Text.Trim() + "' where Id = " + allmethods.signinid;
                    sqlCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand.ExecuteNonQuery();
                }
                if (c4.Password.Trim() != "")
                {
                    sql        = "update customers set password = '******' where Id = " + allmethods.signinid;
                    sqlCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand = new SqlCommand(sql, sqlConnection);
                    sqlDataAdapter.InsertCommand.ExecuteNonQuery();
                }

                MessageBox.Show("Done!!");
                customermenu customermenuobj = new customermenu();
                customermenuobj.Show();
                this.Close();
            }
        }