Пример #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();
            }
        }
Пример #2
0
        private void ButtonConfirm_Click(object sender, EventArgs e)
        {
            SubscriberHome   get  = new SubscriberHome();
            MainControlClass get1 = new MainControlClass();
            Home             get3 = new Home();

            con.Open();
            SqlCommand    cmd = new SqlCommand("Select magazineID from MagazineInfo where [publisher]='" + publisher + "' AND Issue#='" + issueNo + "' ", con);
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                magID = dr.GetValue(0).ToString();
                break;
            }
            con.Close();

            List <string> linesData = File.ReadAllLines(get1.tempCustomerIDLoc).ToList();

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

            if (comboBoxNoOfMonths.SelectedIndex == 0)
            {
                con.Open();
                SqlCommand cmdr0 = new SqlCommand("Insert Into Subscription values('" + get1.CustomerID + "','" + Int32.Parse(magID) + "','" + DateTime.Now.ToString("M-d-yyyy") + "','" + DateTime.Now.AddDays(30).ToString("M-d-yyyy") + "')", con);
                cmdr0.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Subscription Success!");
                MainControlClass.showControl(get3, Content);
            }

            else if (comboBoxNoOfMonths.SelectedIndex == 1)
            {
                con.Open();
                SqlCommand cmdr1 = new SqlCommand("Insert Into Subscription values('" + get1.CustomerID + "','" + Int32.Parse(magID) + "','" + DateTime.Now.ToString("M-d-yyyy") + "','" + DateTime.Now.AddDays(60).ToString("M-d-yyyy") + "')", con);
                cmdr1.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Subscription Success!");
                MainControlClass.showControl(get3, Content);
            }


            else if (comboBoxNoOfMonths.SelectedIndex == 2)
            {
                con.Open();
                SqlCommand cmdr2 = new SqlCommand("Insert Into Subscription values('" + get1.CustomerID + "','" + Int32.Parse(magID) + "','" + DateTime.Now.ToString("M-d-yyyy") + "','" + DateTime.Now.AddDays(90).ToString("M-d-yyyy") + "')", con);
                cmdr2.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Subscription Success!");
                MainControlClass.showControl(get3, Content);
            }


            else if (comboBoxNoOfMonths.SelectedIndex == 3)
            {
                con.Open();
                SqlCommand cmdr3 = new SqlCommand("Insert Into Subscription values('" + get1.CustomerID + "','" + Int32.Parse(magID) + "','" + DateTime.Now.ToString("M-d-yyyy") + "','" + DateTime.Now.AddDays(120).ToString("M-d-yyyy") + "')", con);
                cmdr3.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Subscription Success!");
                MainControlClass.showControl(get3, Content);
            }

            else if (comboBoxNoOfMonths.SelectedIndex == 4)
            {
                con.Open();
                SqlCommand cmdr4 = new SqlCommand("Insert Into Subscription values('" + get1.CustomerID + "','" + Int32.Parse(magID) + "','" + DateTime.Now.ToString("M-d-yyyy") + "','" + DateTime.Now.AddDays(150).ToString("M-d-yyyy") + "')", con);
                cmdr4.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Subscription Success!");
                MainControlClass.showControl(get3, Content);
            }

            else if (comboBoxNoOfMonths.SelectedIndex == 5)
            {
                con.Open();
                SqlCommand cmdr5 = new SqlCommand("Insert Into Subscription values('" + get1.CustomerID + "','" + Int32.Parse(magID) + "','" + DateTime.Now.ToString("M-d-yyyy") + "','" + DateTime.Now.AddDays(180).ToString("M-d-yyyy") + "')", con);
                cmdr5.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Subscription Success!");
                MainControlClass.showControl(get3, Content);
            }

            else
            {
                MessageBox.Show("Select how many months to subscribe");
            }
        }