Exemplo n.º 1
0
        private void ButtonSearch_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Data Source=DESKTOP-D2ICRPB;Initial Catalog=eMagazine;Integrated Security=True");

            con.Open();
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "Select publisher from MagazineInfo where [publisher]='" + textBoxSearch.Text + "'";
            cmd.Connection  = con;
            SqlDataReader rd = cmd.ExecuteReader();

            while (rd.Read())
            {
                if (rd[0].ToString().Trim() == textBoxSearch.Text)
                {
                    q = 1;
                    break;
                }
            }
            if (q == 1)
            {
                MagazineFound ts = new MagazineFound();
                ts.MagazineFound_Load(textBoxSearch.Text);
                MainControlClass.showControl(ts, Content);
            }
            else
            {
            }
            con.Close();
        }
Exemplo n.º 2
0
        private void ButtonSubscribe3_Click(object sender, EventArgs e)
        {
            Subscribe get = new Subscribe();

            get.Subscribe_Load(3, PublisherName);
            MainControlClass.showControl(get, Content);
        }
Exemplo n.º 3
0
        private void BunifuFlatButton3_Click(object sender, EventArgs e)
        {
            sidePanel.Height = bunifuFlatButton3.Height;
            sidePanel.Top    = bunifuFlatButton3.Top;
            SelectMagazineRead get = new SelectMagazineRead();

            MainControlClass.showControl(get, Content);
        }
Exemplo n.º 4
0
        private void BunifuFlatButton2_Click(object sender, EventArgs e)
        {
            sidePanel.Height = bunifuFlatButton2.Height;
            sidePanel.Top    = bunifuFlatButton2.Top;
            Browse gs = new Browse();

            MainControlClass.showControl(gs, Content);
        }
Exemplo n.º 5
0
        private void BunifuFlatButton1_Click(object sender, EventArgs e)
        {
            sidePanel.Height = bunifuFlatButton1.Height;
            sidePanel.Top    = bunifuFlatButton1.Top;
            Home get = new Home();

            MainControlClass.showControl(get, Content);
        }
Exemplo n.º 6
0
        public SubscriberHome()
        {
            InitializeComponent();
            sidePanel.Height = bunifuFlatButton1.Height;
            sidePanel.Top    = bunifuFlatButton1.Top;
            Home get = new Home();

            MainControlClass.showControl(get, Content);
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
0
        public LogIn()
        {
            MainControlClass get1      = new MainControlClass();
            List <string>    linesData = File.ReadAllLines(get1.tempCustomerIDLoc).ToList();

            foreach (var line in linesData)
            {
                string[] entries = line.Split(',');
                linesData.Remove(line);
                break;
            }
            File.WriteAllLines(get1.tempCustomerIDLoc, linesData);
            InitializeComponent();
        }
Exemplo n.º 9
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");
            }
        }
Exemplo n.º 10
0
        private void MagazineFound_Load(object sender, EventArgs e)
        {
            MainControlClass get1      = new MainControlClass();
            List <string>    linesData = File.ReadAllLines(get1.tempCustomerIDLoc).ToList();

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

            con.Open();
            SqlCommand cmd = new SqlCommand("Select magazineID from Subscription where dateEnded > @dateNow AND customerID = @costomerID AND magazineID =@magID", con);

            cmd.Parameters.Add("@dateNow", DateTime.Now);
            cmd.Parameters.Add("@costomerID", get1.CustomerID);
            cmd.Parameters.Add("@magID", magazine1);
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                if (Convert.ToInt32(dr[0].ToString().Trim()) == magazine1)
                {
                    buttonSubscribe1.Text    = "Subscribed";
                    buttonSubscribe1.Enabled = false;
                }
                break;
            }
            con.Close();

            con.Open();
            SqlCommand cmd2 = new SqlCommand("Select magazineID from Subscription where dateEnded > @dateNow AND customerID = @costomerID AND magazineID =@magID", con);

            cmd2.Parameters.Add("@dateNow", DateTime.Now);
            cmd2.Parameters.Add("@costomerID", get1.CustomerID);
            cmd2.Parameters.Add("@magID", magazine2);
            SqlDataReader dr2 = cmd2.ExecuteReader();

            while (dr2.Read())
            {
                if (Convert.ToInt32(dr2[0].ToString().Trim()) == magazine2)
                {
                    buttonSubscribe2.Text    = "Subscribed";
                    buttonSubscribe2.Enabled = false;
                }
                break;
            }
            con.Close();

            con.Open();
            SqlCommand cmd3 = new SqlCommand("Select magazineID from Subscription where dateEnded > @dateNow AND customerID = @costomerID AND magazineID =@magID", con);

            cmd3.Parameters.Add("@dateNow", DateTime.Now);
            cmd3.Parameters.Add("@costomerID", get1.CustomerID);
            cmd3.Parameters.Add("@magID", magazine3);
            SqlDataReader dr3 = cmd3.ExecuteReader();

            while (dr3.Read())
            {
                if (Convert.ToInt32(dr3[0].ToString().Trim()) == magazine3)
                {
                    buttonSubscribe3.Text    = "Subscribed";
                    buttonSubscribe3.Enabled = false;
                }
                break;
            }
            con.Close();
        }