Exemplo n.º 1
0
        private void ButtonLogIn_Click(object sender, EventArgs e)
        {
            if (textBoxUsername.Text == "Username:"******"Password:"******"Enter your Username or Password");
            }

            else
            {
                con.Open();
                SqlCommand    cmd = new SqlCommand("Select password From CustomerInfo where username='******'", con);
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (dr[0].ToString().Trim() == textBoxPassword.Text)
                    {
                        q = 1;
                        break;
                    }
                }
                con.Close();

                if (q == 1)
                {
                    MainControlClass get1      = new MainControlClass();
                    List <string>    linesData = File.ReadAllLines(get1.tempCustomerIDLoc).ToList();
                    con.Open();
                    SqlCommand    cmdr = new SqlCommand("select customerID from CustomerInfo where username='******'", con);
                    SqlDataReader drr  = cmdr.ExecuteReader();
                    while (drr.Read())
                    {
                        customerID = drr[0].ToString();
                        linesData.Add(customerID);
                        File.WriteAllLines(get1.tempCustomerIDLoc, linesData);
                    }
                    con.Close();

                    foreach (var line in linesData)
                    {
                        string[] entries = line.Split(',');
                        get1.CustomerID = entries[0];
                        break;
                    }

                    SubscriberHome get = new SubscriberHome();
                    get.SubscriberHome_Load(textBoxUsername.Text);
                    get.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Incorrect Username or Password");
                }
                con.Close();
            }
        }