Ejemplo n.º 1
0
        internal bool updateUser(User user)
        {
            using (OleDbConnection sqlConn = new OleDbConnection(database))
            {
                try
                {
                    sqlConn.Open();
                    String insert = "UPDATE [USERS] " +
                                    "SET [first_name] = @firstName," +
                                    "[last_name] = @lastName," +
                                    "[address] = @address," +
                                    "[city] = @city," +
                                    "[state] = @state," +
                                    "[zip_code] = @zipCode," +
                                    "[email] = @email " +
                                    "WHERE ([user_id] = @userId)";

                    OleDbCommand cmd = new OleDbCommand(insert, sqlConn);

                    cmd.Parameters.Add("firstName", OleDbType.VarChar, 255).Value = user.getFirstName();
                    cmd.Parameters.Add("lastName", OleDbType.VarChar, 255).Value  = user.getLastName();
                    cmd.Parameters.Add("address", OleDbType.VarChar, 255).Value   = user.getAddress();
                    cmd.Parameters.Add("city", OleDbType.VarChar, 255).Value      = user.getCity();
                    cmd.Parameters.Add("state", OleDbType.VarChar, 255).Value     = user.getState();
                    cmd.Parameters.Add("zipCode", OleDbType.VarChar, 255).Value   = user.getZipCode();
                    cmd.Parameters.Add("email", OleDbType.VarChar, 255).Value     = user.getEamil();
                    cmd.Parameters.Add("userId", OleDbType.Integer).Value         = user.getId();

                    int rows = cmd.ExecuteNonQuery();

                    if (rows == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (OleDbException ex)
                {
                    return(false);
                }
                finally
                {
                    sqlConn.Close();
                }
            }
        }
Ejemplo n.º 2
0
        internal List <PaymentInformation> getUserPaymentInfo(User user)
        {
            List <PaymentInformation> userPaymentInfo = new List <PaymentInformation>();

            using (OleDbConnection sqlconn = new OleDbConnection(database))
            {
                try
                {
                    sqlconn.Open();
                    String       select = "SELECT * FROM [PAYMENT_INFORMATION] WHERE [user_id] = @userId";
                    OleDbCommand cmd    = new OleDbCommand(select, sqlconn);

                    cmd.Parameters.Add("userId", OleDbType.Integer).Value = user.getId();
                    OleDbDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int      paymentInformationId = (int)reader["payment_information_id"];
                        int      userId           = (int)reader["user_id"];
                        String   creditCartType   = reader["credit_card_type"].ToString();
                        String   creditCardNumber = reader["credit_card_number"].ToString();
                        String   cardCity         = reader["card_city"].ToString();
                        String   cardState        = reader["card_state"].ToString();
                        DateTime cardExpDate      = DateTime.Parse(reader["card_exp_date"].ToString());
                        String   securityCode     = reader["security_code"].ToString();

                        PaymentInformation paymentInfo = new PaymentInformation(paymentInformationId, user, creditCartType,
                                                                                creditCardNumber, cardCity, cardState, cardExpDate, securityCode);
                        userPaymentInfo.Add(paymentInfo);
                    }
                    return(userPaymentInfo);
                }
                catch (OleDbException ex)
                {
                    userPaymentInfo = null;
                    return(userPaymentInfo);
                }
                finally
                {
                    sqlconn.Close();
                }
            }
        }
        internal List<PaymentInformation> getUserPaymentInfo(User user)
        {
            List<PaymentInformation> userPaymentInfo = new List<PaymentInformation>();
            using (OleDbConnection sqlconn = new OleDbConnection(database))
            {
                try
                {
                    sqlconn.Open();
                    String select = "SELECT * FROM [PAYMENT_INFORMATION] WHERE [user_id] = @userId";
                    OleDbCommand cmd = new OleDbCommand(select, sqlconn);

                    cmd.Parameters.Add("userId", OleDbType.Integer).Value = user.getId();
                    OleDbDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int paymentInformationId = (int) reader["payment_information_id"];
                        int userId = (int)reader["user_id"];
                        String creditCartType = reader["credit_card_type"].ToString();
                        String creditCardNumber = reader["credit_card_number"].ToString();
                        String cardCity = reader["card_city"].ToString();
                        String cardState = reader["card_state"].ToString();
                        DateTime cardExpDate = DateTime.Parse(reader["card_exp_date"].ToString());
                        String securityCode = reader["security_code"].ToString();

                        PaymentInformation paymentInfo = new PaymentInformation(paymentInformationId, user, creditCartType,
                            creditCardNumber, cardCity, cardState, cardExpDate, securityCode);
                        userPaymentInfo.Add(paymentInfo);
                    }
                    return userPaymentInfo;
                }
                catch(OleDbException ex)
                {
                    userPaymentInfo = null;
                    return userPaymentInfo;
                }
                finally
                {
                    sqlconn.Close();
                }
            }
        }
Ejemplo n.º 4
0
        internal bool updateUser(User user)
        {
            using (OleDbConnection sqlConn = new OleDbConnection(database))
            {
                try
                {
                    sqlConn.Open();
                    String insert = "UPDATE [USERS] " +
                        "SET [first_name] = @firstName," +
                        "[last_name] = @lastName," +
                        "[address] = @address," +
                        "[city] = @city," +
                        "[state] = @state," +
                        "[zip_code] = @zipCode," +
                        "[email] = @email " +
                        "WHERE ([user_id] = @userId)";

                    OleDbCommand cmd = new OleDbCommand(insert, sqlConn);

                    cmd.Parameters.Add("firstName", OleDbType.VarChar, 255).Value = user.getFirstName();
                    cmd.Parameters.Add("lastName", OleDbType.VarChar, 255).Value = user.getLastName();
                    cmd.Parameters.Add("address", OleDbType.VarChar, 255).Value = user.getAddress();
                    cmd.Parameters.Add("city", OleDbType.VarChar, 255).Value = user.getCity();
                    cmd.Parameters.Add("state", OleDbType.VarChar, 255).Value = user.getState();
                    cmd.Parameters.Add("zipCode", OleDbType.VarChar, 255).Value = user.getZipCode();
                    cmd.Parameters.Add("email", OleDbType.VarChar, 255).Value = user.getEamil();
                    cmd.Parameters.Add("userId", OleDbType.Integer).Value = user.getId();

                    int rows = cmd.ExecuteNonQuery();

                    if (rows == 1)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }

                }
                catch (OleDbException ex)
                {
                    return false;
                }
                finally
                {
                    sqlConn.Close();
                }

            }
        }
 private void populatePage(User user)
 {
     lblUserId.Text = user.getId().ToString();
     txtUsername.Text = user.getUsername();
     txtFirstName.Text = user.getFirstName();
     txtLastName.Text = user.getLastName();
     txtEmail.Text = user.getEamil();
     txtAddress.Text = user.getAddress();
     txtCity.Text = user.getCity();
     txtState.Text = user.getState();
     txtZipCode.Text = user.getZipCode();
 }