Beispiel #1
0
            public static List <InsuranceType> GetTypes()
            {
                List <InsuranceType> insuranceTypes = new List <InsuranceType>();

                using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME,
                                                            GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD))
                {
                    if (db.Open())
                    {
                        ListCategoryStatement stmt = new ListCategoryStatement();
                        stmt.Prepare(db.connection);

                        using (var reader = db.ExecutePreparedStatementReader(stmt, IsolationLevel.ReadCommitted))
                        {
                            if (reader != null && reader.HasRows)
                            {
                                int    id;
                                string category;

                                while (reader.Read())
                                {
                                    id       = reader.GetInt32(0);
                                    category = reader.GetString(1);

                                    insuranceTypes.Add(new InsuranceType(id, category));
                                }
                            }
                        }
                    }
                }

                return(insuranceTypes);
            }
        // TODO: Update database (rating)
        private void Rate(object sender, RoutedEventArgs e)
        {
            // Update with int chosenRating
            using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME,
                                                        GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD))
            {
                if (db.Open())
                {
                    // select the provider first
                    IPreparedStatement provStmt = new GetProviderIDStatement(providerName);
                    provStmt.Prepare(db.connection);
                    using (var reader = db.ExecutePreparedStatementReader(provStmt))
                    {
                        if (reader != null && reader.HasRows)
                        {
                            reader.Read();
                            providerID = reader.GetInt32(0);
                        }
                    }

                    // now rate the provider
                    int userID = GlobalVariables.User.Id;
                    IPreparedStatement stmt = new VendorRatingStatement(userID, providerID, chosenRating);
                    stmt.Prepare(db.connection);

                    db.ExecutePreparedStatementNonQuery(stmt);
                }
            }

            Window.Current.Close();
        }
Beispiel #3
0
        private void Send(object sender, RoutedEventArgs e)
        {
            string question = questionBox.Text;

            using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME,
                                                        GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD))
            {
                if (db.Open())
                {
                    int ID = GlobalVariables.User.Id;

                    IPreparedStatement stmt = new CreateFragenStatement(question, ID);
                    stmt.Prepare(db.connection);
                    db.ExecutePreparedStatementNonQuery(stmt);

                    StatusMessage.Text = "New question was send, you will soon get an answer :-)";
                }
            }
        }
        // TODO: Update database
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            username  = UsernameBox.Text;
            password  = pwBox.Password;
            birthday  = DateBox.Date.Date;
            residence = AddressBox.Text;

            using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME,
                                                        GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD))
            {
                if (db.Open())
                {
                    IPreparedStatement stmt = new CreateUserStatement(username, password, birthday, residence);
                    stmt.Prepare(db.connection);

                    db.ExecutePreparedStatementNonQuery(stmt);
                }
                else
                {
                }
            }
        }
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME,
                                                        GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD))
            {
                if (db.Open())
                {
                    //TODO: pass user data to stmt
                    IPreparedStatement stmt = new UpdateUserStatement("Max Mustermann", "Password123", DateTime.UtcNow, "Wolfsburg");
                    stmt.Prepare(db.connection);

                    if (db.ExecutePreparedStatementNonQuery(stmt) == 1)
                    {
                        //TODO: print success
                    }
                    else
                    {
                        //TODO: print error
                    }
                }
            }
        }
Beispiel #6
0
            public List <Insurance> GetInsurances(int type)
            {
                List <Insurance> insurances = new List <Insurance>();

                using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME, GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD))
                {
                    if (db.Open())
                    {
                        ListProductStatement stmt = new ListProductStatement(type);
                        stmt.Prepare(db.connection);

                        using (var reader = db.ExecutePreparedStatementReader(stmt))
                        {
                            if (reader != null && reader.HasRows)
                            {
                                SqlParser parser = new SqlParser();
                                insurances = parser.ReadFromReader(reader);
                            }
                        }
                    }
                }

                return(insurances);
            }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string username = userInput.Text;
            string password = pwInput.Text;


            //if (username.Equals("user") && password.Equals("pw"))
            //{
            //    GlobalVariables.User.Name = username;
            //    GlobalVariables.User.Birthday = new DateTime(1997, 11, 22);
            //    GlobalVariables.User.Address = "1150 Wien";

            //    this.Frame.Navigate(typeof(ChooseOption));
            //}
            //else if (username.Equals("admin") && password.Equals("pw"))
            //{
            //    //this.Frame
            //}
            //else if (username.Equals("provider") && password.Equals("pw"))
            //{

            //}
            //else if (username.Equals("adviser") && password.Equals("pw"))
            //{

            //}
            //else
            //{
            //    allertMessage.Text = "Wrong Username or Password";
            //}

            using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME,
                                                        GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD))
            {
                if (db.Open())
                {
                    IPreparedStatement stmt = new LoginUserStatement(username, password);
                    stmt.Prepare(db.connection);

                    using (var reader = db.ExecutePreparedStatementReader(stmt))
                    {
                        if (reader != null && reader.HasRows)
                        {
                            reader.Read();
                            int      id           = reader.GetInt32(0);
                            string   name         = reader.GetString(1);
                            DateTime birthday     = reader.GetDateTime(2);
                            string   residence    = reader.GetString(3);
                            bool     isConsultant = reader.GetBoolean(4);
                            bool     isAdmin      = reader.GetBoolean(5);

                            if (!isAdmin && !isConsultant)
                            {
                                GlobalVariables.User.Name     = name;
                                GlobalVariables.User.Birthday = birthday;
                                GlobalVariables.User.Address  = residence;
                                GlobalVariables.User.Id       = id;

                                this.Frame.Navigate(typeof(ChooseOption));
                            }
                            else if (isAdmin)
                            {
                                this.Frame.Navigate(typeof(ChooseOptionAdm));
                            }
                            else if (isConsultant)
                            {
                                this.Frame.Navigate(typeof(ChooseOptionAdv));
                            }
                        }
                        else
                        {
                            allertMessage.Text = "Wrong Username or Password";
                        }
                    }
                }
                else
                {
                    allertMessage.Text = "Wrong Username or Password";
                }
            }
        }