예제 #1
0
        private void LoadAll()
        {
            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Default"].ConnectionString;

            using (SqlConnection _con = new SqlConnection(connectionString))
            {
                string queryStatement = "SELECT * FROM [GROCERYBAMA1].[dbo].[payment] where username = @username";

                using (SqlCommand _cmd = new SqlCommand(queryStatement, _con))
                {
                    //MessageBox.Show(Globals.Persistent_Current.username);
                    _cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = Globals.Persistent_Current.username;
                    DataTable tb = new DataTable();

                    SqlDataAdapter _dap = new SqlDataAdapter(_cmd);

                    _con.Open();
                    _dap.Fill(tb);
                    _con.Close();
                    foreach (DataRow dr in tb.Rows)
                    {
                        PAYMENT addUser = new PAYMENT();
                        addUser.username       = dr["username"].ToString();
                        addUser.payment_name   = dr["payment_name"].ToString();
                        addUser.routing_number = dr["routing_number"].ToString();
                        addUser.account_number = dr["account_number"].ToString();
                        payments.Add(addUser);
                    }
                }
            }
        }
예제 #2
0
        private void LoadAll()
        {
            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Default"].ConnectionString;

            using (SqlConnection _con = new SqlConnection(connectionString))
            {
                string queryStatement = "SELECT * FROM [GROCERYBAMA1].[dbo].[payment] where username = @username";

                using (SqlCommand _cmd = new SqlCommand(queryStatement, _con))
                {
                    //MessageBox.Show(Globals.Persistent_Current.username);
                    _cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = Globals.Persistent_Current.username;
                    DataTable tb = new DataTable();

                    SqlDataAdapter _dap = new SqlDataAdapter(_cmd);

                    _con.Open();
                    _dap.Fill(tb);
                    _con.Close();
                    foreach (DataRow dr in tb.Rows)
                    {
                        PAYMENT addUser = new PAYMENT();
                        addUser.username       = dr["username"].ToString();
                        addUser.payment_name   = dr["payment_name"].ToString();
                        addUser.routing_number = dr["routing_number"].ToString();
                        addUser.account_number = dr["account_number"].ToString();
                        payments.Add(addUser);
                    }
                }
                queryStatement = "SELECT * FROM [GROCERYBAMA1].[dbo].[orderr]";

                using (SqlCommand _cmd = new SqlCommand(queryStatement, _con))
                {
                    //MessageBox.Show(Globals.Persistent_Current.username);
                    _cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = Globals.Persistent_Current.username;
                    DataTable tb = new DataTable();

                    SqlDataAdapter _dap = new SqlDataAdapter(_cmd);

                    _con.Open();
                    _dap.Fill(tb);
                    _con.Close();
                    foreach (DataRow dr in tb.Rows)
                    {
                        int temp_id;
                        temp_id = Int32.Parse(dr["order_id"].ToString());
                        order_ids.Add(temp_id);
                    }
                }
                queryStatement = "SELECT * FROM [GROCERYBAMA1].[dbo].[user] where user_type = 'deliverer'";
                using (SqlCommand _cmd = new SqlCommand(queryStatement, _con))
                {
                    DataTable tb = new DataTable();

                    SqlDataAdapter _dap = new SqlDataAdapter(_cmd);

                    _con.Open();
                    _dap.Fill(tb);
                    _con.Close();
                    foreach (DataRow dr in tb.Rows)
                    {
                        USER addUser = new USER();
                        addUser.first_name = dr["first_name"].ToString();
                        addUser.last_name  = dr["last_name"].ToString();
                        addUser.email      = dr["email"].ToString();
                        addUser.password   = dr["password"].ToString();
                        addUser.username   = dr["username"].ToString();
                        addUser.user_type  = dr["user_type"].ToString();
                        deliverers.Add(addUser);
                    }
                }
            }
            foreach (var item in payments)
            {
                comboPaymentType.Items.Add(item.payment_name);
            }
            double totalPrice = 0;

            foreach (var item in Globals.cart)
            {
                totalPrice += item.quantity * item.listed_price;
                totalItems += item.quantity;
            }
            textTotalPrice.Text = totalPrice.ToString();
        }