Example #1
0
        private void button_GoLogin(object sender, RoutedEventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-PM9NGM3\SQLEXPRESS;Initial Catalog=PMS;Integrated Security=True");

            try
            {
                con.Open();

                string newcon = "select * from UserAuth where UserName='******' and Password ='******'";

                SqlDataAdapter adp = new SqlDataAdapter(newcon, con);
                DataSet        ds  = new DataSet();

                adp.Fill(ds);

                DataTable dt = ds.Tables[0];

                if (dt.Rows.Count >= 1)
                {
                    this.Hide();
                    string UserNam = username.Text.ToString();
                    CarAdd entry   = new CarAdd(UserNam);
                    entry.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Invalid login Credential");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " Something went wrong!");
            }
        }
Example #2
0
        private void button_GoLogin(object sender, RoutedEventArgs e)
        {
            if (username.Text != "" && phoneno.Text != "")
            {
                SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-PM9NGM3\SQLEXPRESS;Initial Catalog=PMS;Integrated Security=True");

                try
                {
                    con.Open();

                    string     newcon = "insert into [GuestAuth] (UserName, PhoneNo) VALUES ('" + username.Text + "','" + phoneno.Text + "')";
                    SqlCommand cmd    = new SqlCommand(newcon, con);

                    int a = Convert.ToInt32(cmd.ExecuteNonQuery());

                    if (a == 1)
                    {
                        //MessageBox.Show("Valid Crediential");

                        this.Hide();
                        string UserNam = username.Text.ToString();
                        CarAdd entry   = new CarAdd(UserNam);
                        entry.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("invalid Crediental");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + " something went wrong!");
                }
                finally
                {
                    con.Close();
                }
            }
            else
            {
                MessageBox.Show("Invalid crediential");
            }
        }