コード例 #1
0
        private void btnReturnToCust_Click(object sender, EventArgs e)
        {
            this.Hide();
            CustomerPage cp = new CustomerPage();

            cp.Show();
        }
コード例 #2
0
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            try
            {
                //capture current date and delivery type
                DateTime      orderDate = DateTime.Now;
                SqlConnection con       = new SqlConnection("Data Source=cstnt.tstc.edu;Initial Catalog=inew2330fa20;Persist Security Info=True;User ID=group4bfa202330;Password=1938274");
                con.Open();
                string payment = "";
                int    theCustomerID;

                if (rdoCheck.Checked == true)
                {
                    payment = "CHECK";
                }
                if (rdoCash.Checked == true)
                {
                    payment = "CASH";
                }
                if (rdoCreditCard.Checked == true)
                {
                    payment             = "CREDIT";
                    grpCardInfo.Enabled = true;
                }

                theCustomerID = int.Parse(CustomerPage.newCustomer.id.ToString());

                SqlCommand cmd = new SqlCommand("insert into group4bfa202330.OrderTable values('" + orderDate + "','" + theCustomerID + "','" + lblBalance.Text + "','" + payment + "')", con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Order Submitted!");


                List <item> itemList = new List <item>();
                item        newItem  = new item();

                foreach (int product in ToolsAndAccessories.cart)
                {
                    SqlCommand com = new SqlCommand("update group4bfa202330.Product set QtyInStock = QtyInStock - 1 where ProductID ='" + product + "'", con);
                    com.ExecuteNonQuery();
                }

                ToolsAndAccessories.cart.Clear();
                ToolsAndAccessories.vc.lstOrderSummary.Items.Clear();
                ToolsAndAccessories.vc.lblTotal.Text = "";
                ToolsAndAccessories.total            = 0;

                con.Close();

                this.Close();
                CustomerPage cp = new CustomerPage();
                cp.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection  con = new SqlConnection("Data Source=cstnt.tstc.edu;Initial Catalog=inew2330fa20;Persist Security Info=True;User ID=group4bfa202330;Password=1938274");
                SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM group4bfa202330.LoginInfo WHERE User_Name = '" + txtUserName.Text + "' and User_Password = '******' ", con);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    //MessageBox.Show("Login successfully");

                    if (Hardware_Shop.User.userName == "Customer" && txtUserName.Text == "employee")
                    {
                        MessageBox.Show("Login successfully");

                        this.Hide();

                        CustomerPage cp = new CustomerPage();
                        cp.Show();
                    }
                    else if (Hardware_Shop.User.userName == "Manager" && txtUserName.Text == "manager")
                    {
                        MessageBox.Show("Login successfully");

                        this.Hide();

                        Add_Product_And_Picture addProductPicture = new Add_Product_And_Picture();
                        addProductPicture.Show();
                    }
                    else if (Hardware_Shop.User.userName == "Supervisor" && txtUserName.Text == "supervisor")
                    {
                        MessageBox.Show("Login successfully");

                        this.Hide();

                        EmployeePage ep = new EmployeePage();
                        ep.Show();
                    }
                    else
                    {
                        MessageBox.Show("Wrong password or user ID");
                    }
                }
                else
                {
                    MessageBox.Show("Wrong password or user ID");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }