private void picLogo_Click(object sender, EventArgs e)
        {
            frmHomePage frmHome = new frmHomePage();

            frmHome.Show();
            this.Hide();
        }
コード例 #2
0
        private void LoginForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmHomePage frm = new frmHomePage();

            frm.Show();
        }
        private void listOrders()
        {
            con = new SqlConnection("Data Source=DESKTOP-ECU28KQ\\SQLEXPRESS;Initial Catalog=OOP2;Integrated Security=True");
            da  = new SqlDataAdapter();
            try
            {
                con.Open();
                dt               = new DataTable();
                dall             = new DataSet();
                cmd              = new SqlCommand("Select Prd.ID, Prd.Name, Prd.Price, Book.Author, Book.Publisher, Book.Page, Prd.pType, Prd.Image From dbo.Book AS Book, dbo.Product AS Prd Where Book.ID = Prd.ID", con);
                da.SelectCommand = cmd;
                cmd.ExecuteNonQuery();
                try
                {
                    da.Fill(dall, "Book");
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot open connection!");
                }
                cmd = new SqlCommand("Select Prd.ID, Prd.Name, Prd.Price, Maga.Issue, Maga.Type, Prd.Image, Prd.pType From dbo.Magazine AS Maga, dbo.Product AS Prd Where Maga.ID = Prd.ID", con);
                da.SelectCommand = cmd;
                cmd.ExecuteNonQuery();
                try
                {
                    da.Fill(dall, "Magazine");
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot open connection !");
                }
                cmd = new SqlCommand("Select Prd.ID, Prd.Name, Prd.Price, Music.Singer, Music.Type, Prd.Image, Prd.pType From dbo.MusicCD AS Music, dbo.Product AS Prd Where Music.ID = Prd.ID", con);
                da.SelectCommand = cmd;
                cmd.ExecuteNonQuery();
                try
                {
                    da.Fill(dall, "MusicCD");
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot open connection !");
                }
                dt.Reset();
                cmd = new SqlCommand("Select * From Orders Where CustomerID = '" + login.Cart.CustomerID + "'", con);
                da.SelectCommand = cmd;
                cmd.ExecuteNonQuery();
                da.Fill(dt);
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("Herhangi bir aktif siparişiniz bulunmamaktadır." + Environment.NewLine + "Anasayfaya yönlendirileceksiniz.", "Sipariş Bilgisi",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    frmHomePage frmHome = new frmHomePage();
                    this.Hide();
                    frmHome.Show();
                }
                else if (dt.Rows[0].ItemArray[1].ToString() == login.Cart.CustomerID.ToString())
                {
                    string[] products   = dt.Rows[0].ItemArray[2].ToString().Split(';');
                    string[] quantities = dt.Rows[0].ItemArray[3].ToString().Split(';');
                    string[] ptype      = dt.Rows[0].ItemArray[4].ToString().Split(';');
                    double   total      = 0;
                    orderNO           = dt.Rows[0].ItemArray[0].ToString();
                    lblPrdName1.Text  = "";
                    lblPrdPrice1.Text = "";
                    for (int i = 0; i < products.Length; i++)
                    {
                        lblPrdNo1.Text    = "# " + orderNO.ToString();
                        btnRemove.Visible = true;
                        lblDurum.Visible  = true;

                        if (ptype[i].ToString() == "B")
                        {
                            for (int j = 0; j < dall.Tables["Book"].Rows.Count; j++)
                            {
                                if (dall.Tables["Book"].Rows[j].ItemArray[0].ToString() == products[i])
                                {
                                    lblPrdName1.Text += dall.Tables["Book"].Rows[j].ItemArray[1].ToString() + " - " + quantities[i] + " adet" + Environment.NewLine;
                                    total            += double.Parse(dall.Tables["Book"].Rows[j].ItemArray[2].ToString()) * double.Parse(quantities[i]);
                                }
                            }
                        }
                        else if (ptype[i].ToString() == "M")
                        {
                            for (int k = 0; k < dall.Tables["Magazine"].Rows.Count; k++)
                            {
                                if (dall.Tables["Magazine"].Rows[k].ItemArray[0].ToString() == products[i])
                                {
                                    lblPrdName1.Text += dall.Tables["Magazine"].Rows[k].ItemArray[1].ToString() + " - " + quantities[i] + " adet" + Environment.NewLine;
                                    total            += double.Parse(dall.Tables["Magazine"].Rows[k].ItemArray[2].ToString()) * double.Parse(quantities[i]);
                                }
                            }
                        }
                        else if (ptype[i].ToString() == "C")
                        {
                            for (int l = 0; l < dall.Tables["MusicCD"].Rows.Count; l++)
                            {
                                if (dall.Tables["MusicCD"].Rows[l].ItemArray[0].ToString() == products[i])
                                {
                                    lblPrdName1.Text += dall.Tables["MusicCD"].Rows[l].ItemArray[1].ToString() + " - " + quantities[i] + " adet" + Environment.NewLine;
                                    total            += double.Parse(dall.Tables["MusicCD"].Rows[l].ItemArray[2].ToString()) * double.Parse(quantities[i]);
                                }
                            }
                        }
                    }
                    lblPrdPrice1.Text = total.ToString("0.00") + " TL";
                }
                con.Close();
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
            }
        }
        private void btnLogOut_Click(object sender, EventArgs e)
        {
            DialogResult logout = MessageBox.Show("Sistemden çıkış yapmak istediğinize emin misiniz?", "Çıkış",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (logout == DialogResult.Yes)
            {
                string products   = "";
                string quantities = "";
                string ptype      = "";
                for (int i = 0; i < login.Cart.ItemsToPurchase.Count; i++)
                {
                    products   += ((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product.ID;
                    quantities += ((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Quantity;
                    if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is Book)
                    {
                        ptype += "B";
                    }
                    else if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is Magazine)
                    {
                        ptype += "M";
                    }
                    else if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is MusicCD)
                    {
                        ptype += "C";
                    }
                    if (!(i == login.Cart.ItemsToPurchase.Count - 1))
                    {
                        products   += ";";
                        quantities += ";";
                        ptype      += ";";
                    }
                }
                try
                {
                    SqlConnection con = new SqlConnection("Data Source=DESKTOP-ECU28KQ\\SQLEXPRESS;Initial Catalog=OOP2;Integrated Security=True");
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                        string     ekleme_komutu = "UPDATE Cart SET Products = @Products, Quantities = @Quantities, pType = @pType WHERE CustomerID = @CustomerID";
                        SqlCommand ekleme        = new SqlCommand(ekleme_komutu, con);
                        ekleme.Parameters.AddWithValue("@CustomerID", login.Cart.CustomerID.ToString());
                        ekleme.Parameters.AddWithValue("@Products", products);
                        ekleme.Parameters.AddWithValue("@Quantities", quantities);
                        ekleme.Parameters.AddWithValue("@pType", ptype);
                        ekleme.ExecuteNonQuery();
                        con.Close();
                    }
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message.ToString());
                }
                login.Kadi  = null;
                login.Sifre = null;
                login.Cart.ItemsToPurchase.Clear();
                frmHomePage frmHome = new frmHomePage();
                frmHome.Show();
                this.Hide();
            }
        }
コード例 #5
0
        private void btnOdeme_Click(object sender, EventArgs e)
        {
            bool res = false;

            if (radioCC.Checked == true)
            {
                login.Cart.PaymentType = "Credit Card";
                for (int i = 0; i < mtxtCC.Text.Length; i++)
                {
                    if (mtxtCC.Text[i] == ' ')
                    {
                        res = true;
                    }
                }
                if (res)
                {
                    MessageBox.Show("Lütfen geçerli bir kredi kartı numarası giriniz.", "Hatalı Giriş",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    string products   = "";
                    string quantities = "";
                    string ptype      = "";
                    for (int i = 0; i < login.Cart.ItemsToPurchase.Count; i++)
                    {
                        products   += ((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product.ID;
                        quantities += ((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Quantity;
                        if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is Book)
                        {
                            ptype += "B";
                        }
                        else if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is Magazine)
                        {
                            ptype += "M";
                        }
                        else if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is MusicCD)
                        {
                            ptype += "C";
                        }
                        if (!(i == login.Cart.ItemsToPurchase.Count - 1))
                        {
                            products   += ";";
                            quantities += ";";
                            ptype      += ";";
                        }
                    }

                    try
                    {
                        SqlConnection con = new SqlConnection("Data Source=DESKTOP-ECU28KQ\\SQLEXPRESS;Initial Catalog=OOP2;Integrated Security=True");
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                            string     ekleme_komutu = "Insert Into Orders(CustomerID, Products, Quantities, pType) values (@CustomerID, @Products, @Quantities, @pType)";
                            SqlCommand ekleme        = new SqlCommand(ekleme_komutu, con);
                            ekleme.Parameters.AddWithValue("@CustomerID", login.Cart.CustomerID.ToString());
                            ekleme.Parameters.AddWithValue("@Products", products);
                            ekleme.Parameters.AddWithValue("@Quantities", quantities);
                            ekleme.Parameters.AddWithValue("@pType", ptype);
                            ekleme.ExecuteNonQuery();
                            con.Close();

                            string message = login.Cart.placeOrder() + Environment.NewLine;

                            if (cmbInvoice.SelectedItem.ToString() == "Faturamı e-posta adresime yolla")
                            {
                                message += login.Cart.sendInvoicebyEmail(login.Cart.PaymentAmount);
                            }
                            else
                            {
                                message += login.Cart.sendInvoicebySMS(login.Cart.PaymentAmount);
                            }

                            MessageBox.Show(message, "Sipariş Onayı",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception a)
                    {
                        MessageBox.Show(a.Message.ToString());
                    }
                    login.Cart.ItemsToPurchase.Clear();
                    frmHomePage frmHome = new frmHomePage();
                    this.Hide();
                    frmHome.Show();
                }
            }

            if (radioCash.Checked == true)
            {
                login.Cart.PaymentType = "Cash";
                string products   = "";
                string quantities = "";
                string ptype      = "";
                for (int i = 0; i < login.Cart.ItemsToPurchase.Count; i++)
                {
                    products   += ((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product.ID;
                    quantities += ((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Quantity;
                    if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is Book)
                    {
                        ptype += "B";
                    }
                    else if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is Magazine)
                    {
                        ptype += "M";
                    }
                    else if (((ItemToPurchase)(login.Cart.ItemsToPurchase[i])).Product is MusicCD)
                    {
                        ptype += "C";
                    }
                    if (!(i == login.Cart.ItemsToPurchase.Count - 1))
                    {
                        products   += ";";
                        quantities += ";";
                        ptype      += ";";
                    }
                }

                try
                {
                    SqlConnection con = new SqlConnection("Data Source=DESKTOP-ECU28KQ\\SQLEXPRESS;Initial Catalog=OOP2;Integrated Security=True");
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                        string     ekleme_komutu = "Insert Into Orders(CustomerID, Products, Quantities, pType) values (@CustomerID, @Products, @Quantities, @pType)";
                        SqlCommand ekleme        = new SqlCommand(ekleme_komutu, con);
                        ekleme.Parameters.AddWithValue("@CustomerID", login.Cart.CustomerID.ToString());
                        ekleme.Parameters.AddWithValue("@Products", products);
                        ekleme.Parameters.AddWithValue("@Quantities", quantities);
                        ekleme.Parameters.AddWithValue("@pType", ptype);
                        ekleme.ExecuteNonQuery();
                        con.Close();

                        string message = login.Cart.placeOrder() + Environment.NewLine;

                        if (cmbInvoice.SelectedItem.ToString() == "Faturamı e-posta adresime yolla")
                        {
                            message += login.Cart.sendInvoicebyEmail(login.Cart.PaymentAmount);
                        }
                        else
                        {
                            message += login.Cart.sendInvoicebySMS(login.Cart.PaymentAmount);
                        }

                        MessageBox.Show(message, "Sipariş Onayı",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message.ToString());
                }
                login.Cart.ItemsToPurchase.Clear();
                frmHomePage frmHome = new frmHomePage();
                this.Hide();
                frmHome.Show();
            }
        }