public LoginController(MainFrame mainFrame, LoginScreen screen)
 {
     this._screen = screen;
     _dbc = DatabaseController.Instance;
     this.MainFrame = mainFrame;
 }
 public RemoveProductController(RemoveProductScreen screen, ProductModel product)
 {
     _dbc = DatabaseController.Instance;
     this._screen = screen;
     this._product = product;
     screen.productNameLabel.Text = product.Name;
 }
 public InventoryEditController(InventoryEdit screen, ProductModel product, InventoryScreen inventoryScreen)
 {
     _dbc = DatabaseController.Instance;
     this._product = product;
     this._screen = screen;
     this._inventoryScreen = inventoryScreen;
     FillWithProductInfo();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Rellena la página con el contenido pasado durante la navegación. Cualquier estado guardado se
 /// proporciona también al crear de nuevo una página a partir de una sesión anterior.
 /// </summary>
 /// <param name="sender">
 /// El origen del evento; suele ser <see cref="NavigationHelper"/>
 /// </param>
 /// <param name="e">Datos de evento que proporcionan tanto el parámetro de navegación pasado a
 /// <see cref="Frame.Navigate(Type, Object)"/> cuando se solicitó inicialmente esta página y
 /// un diccionario del estado mantenido por esta página durante una sesión
 /// anterior. El estado será null la primera vez que se visite una página.</param>
 /// <summary>
 /// Mantiene el estado asociado con esta página en caso de que se suspenda la aplicación o
 /// se descarte la página de la memoria caché de navegación.  Los valores deben cumplir los requisitos
 /// de serialización de <see cref="SuspensionManager.SessionState"/>.
 /// </summary>
 /// <param name="sender">El origen del evento; suele ser <see cref="NavigationHelper"/></param>
 /// <param name="e">Datos de evento que proporcionan un diccionario vacío para rellenar con
 /// un estado serializable.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     string type = e.Parameter as string;
     FoodList foods = null;
     DatabaseController dbController = new DatabaseController();
     foods=dbController.searchFood(type);
     foodController = new ListFoodController(foods);
     this.DataContext = foodController;
 }
 public EditProductController(EditProductScreen screen, ProductModel productModel)
 {
     this._screen = screen;
     _dbc = DatabaseController.Instance;
     this._productModel = productModel;
     _currentImagePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) +
                        @"\Resources\" + productModel.ImageFileName;
     _isNewImage = false;
     FillComboBox();
     FillTextBoxes();
 }
Ejemplo n.º 6
0
        public Journey()
        {
            InitializeComponent();
            DataBinder binder = new DataBinder();
            DatabaseController controller = new DatabaseController();

            binder.bindComboBox<Class>(cmbClass, controller.get<Class>("SELECT * FROM class"), "id", "name");
            binder.bindComboBox<Airport>(cmbTo, controller.get<Airport>("SELECT id, CONCAT(name, ' (', id, ')') as name FROM airport"), "id", "name");
            binder.bindComboBox<Airport>(cmbFrom, controller.get<Airport>("SELECT id, CONCAT(name, ' (', id, ')') as name FROM airport"), "id", "name");
            binder.bindComboBox<Airline>(cmbAirline, controller.get<Airline>("SELECT id, name FROM airline"), "id", "name");
        }
 public EditProductController(EditProductScreen screen, ProductModel productModel)
 {
     this._screen = screen;
     _dbc = DatabaseController.Instance;
     this._productModel = productModel;
     _currentImagePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                         @"\Kantoor Inrichting\Afbeeldingen producten\" + productModel.ImageFileName;
     _isNewImage = false;
     FillComboBox();
     FillTextBoxes();
 }
        public CategoryManagerController()
        {
            Dbc = DatabaseController.Instance;
            catman = new CategoryManager(this);
            catman.ShowDialog();
            

            if (catman.DialogResult == DialogResult.OK)
            {
                //update database
            }
        }
Ejemplo n.º 9
0
        public List <CommitFileHirarhicalData> GetBranchFiles(int projectId, int branchId)
        {
            var result = new List <CommitFileHirarhicalData>();

            using (var context = new DatabaseController(Context, Configuration))
            {
                var getProject = context.GetBranchFiles(projectId, branchId);
                if (getProject != null)
                {
                    result = context.GetFileHirarchy(getProject);
                }
            }
            return(result);
        }
Ejemplo n.º 10
0
        public static Account FindByName(string name)
        {
            var    account = new Account();
            var    key     = new SqlParameter("?TITLE", name);
            string sql     = DatabaseController.GenerateSelectStatement(TABLE_NAME, key);

            DataTable dataTable = DatabaseController.ExecuteSelectQuery(sql, key);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                account.SetPropertiesFromDataRow(dataRow);
            }
            return(account);
        }
Ejemplo n.º 11
0
 public void WriteToPlayerStats()
 {
     if (allowWriteToPlayerStats)
     {
         PlayerManager.mainPlayer.playerClassID = selectedCharacter;
         PlayerManager.mainPlayer.playerName    = playerName;
         DatabaseController.updatePlayer(PlayerManager.mainPlayer);
         PlayerPrefs.SetInt(LoadGame.PLAYED_BEFORE, 1);
     }
     else
     {
         Debug.Log("Pick character and player name befor continuing.");
     }
 }
Ejemplo n.º 12
0
        public IActionResult WorkItems(int projectId, int boardId)
        {
            var currentUser = this.User;
            var id          = currentUser.Claims.ElementAt(1);

            using (var context = new DatabaseController(Context, Configuration))
            {
                var currentId = int.Parse(id.Value);
                ViewData["ProjectId"] = projectId;
                ViewData["Name"]      = context.GetUsername(currentId);
                ViewData["BoardId"]   = boardId;
            }
            return(View());
        }
Ejemplo n.º 13
0
    public static void CalculateElo(int winnerID, int loserID)
    {
        int WinnerElo = DatabaseController.GetElo(winnerID);
        int LoserElo  = DatabaseController.GetElo(loserID);

        float expectedScoreA = 1 / (1 + Mathf.Pow(10, (LoserElo - WinnerElo) / mod));
        float expectedScoreB = 1 / (1 + Mathf.Pow(10, (WinnerElo - LoserElo) / mod));

        int winnerNewElo = CalculationOfElo(WinnerElo, K, pointsPerWin, expectedScoreA);
        int loserNewElo  = CalculationOfElo(LoserElo, K, pointsPerLoss, expectedScoreB);

        DatabaseController.SetElo(winnerID, winnerNewElo);
        DatabaseController.SetElo(loserID, loserNewElo);
    }
Ejemplo n.º 14
0
        internal static List <LoanProduct> GetList()
        {
            string    sqlCommandText = string.Format("SELECT * FROM {0}", TABLE_NAME);
            DataTable dataTable      = DatabaseController.ExecuteSelectQuery(sqlCommandText);
            var       result         = new List <LoanProduct>();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var lp = new LoanProduct();
                lp.SetPropertiesFromDataRow(dataRow);
                result.Add(lp);
            }
            return(result);
        }
Ejemplo n.º 15
0
        //public ActionResult Index(string componentCategory, string searchString)
        public ActionResult Index(ItemViewModel model)
        {
            ViewBag.Message = "Index Page!";
            DatabaseController db = new DatabaseController();
            //var allItems = db.FindItems(componentCategory, searchString);
            var allItems = db.GetItems();

            ItemViewModel items = new ItemViewModel()
            {
                Items = allItems
            };

            return(View(items));
        }
Ejemplo n.º 16
0
        public MainMenu()
        {
            InitializeComponent();
            // If there is no database, run these.
            DatabaseController.AddThemesForTheFirstRun();
            DatabaseController.AddFloorsForFirstRun();

            representativeList = new List <Representative>();
            representativeList = DatabaseController.representativeList;
            SetBackground(DatabaseController.getLastSubTheme());

            this.mv = new MainView(this);
            mv.Hide();
        }
Ejemplo n.º 17
0
        public Result Create()
        {
            Action createRecord = () =>
            {
                var sqlParameter = new List <SqlParameter>();
                sqlParameter.Add(new SqlParameter("?Description", Description));

                var sql = DatabaseController.GenerateInsertStatement(TABLE_NAME, sqlParameter);
                ID = DatabaseController.ExecuteInsertQuery(sql,
                                                           sqlParameter.ToArray());
            };

            return(ActionController.InvokeAction(createRecord));
        }
Ejemplo n.º 18
0
        public static List <LoanCharge> GetList()
        {
            string    sqlCommandText = string.Format("SELECT * FROM {0}", TableName);
            DataTable dataTable      = DatabaseController.ExecuteSelectQuery(sqlCommandText);
            var       list           = new List <LoanCharge>();

            foreach (DataRow row in dataTable.Rows)
            {
                var item = new LoanCharge();
                item.SetPropertiesFromDataRow(row);
                list.Add(item);
            }
            return(list);
        }
Ejemplo n.º 19
0
        public AssociatedWorkItemMessages WorkItemAddMessage([FromBody] IncomingWorkItemMessage request)
        {
            var result      = default(AssociatedWorkItemMessages);
            var currentUser = this.User;
            var id          = int.Parse(currentUser.Claims.ElementAt(1).Value);

            using (var context = new DatabaseController(Context, Configuration))
            {
                result = context.AddNewWorkItemMessage(request, id);
                result.Message.AssociatedWorkItemMessages = null;
                result.Message.Sender = context.GetUserAccount(result.Message.SenderId);
            }
            return(result);
        }
Ejemplo n.º 20
0
        public List <OutgoingWorkItemSimple> UnassociatedChangelogItems(int projectId)
        {
            var result = new List <OutgoingWorkItemSimple>();

            using (var context = new DatabaseController(Context, Configuration))
            {
                result = context.GetEmptyChangelogWorktItems(projectId).Select(y => new OutgoingWorkItemSimple {
                    Id               = y.Id,
                    Name             = string.IsNullOrEmpty(y.Title) ? "" : y.Title,
                    WorkItemTypeName = y.WorkItemType == null ? "" : y.WorkItemType.TypeName
                }).ToList();
            }
            return(result);
        }
Ejemplo n.º 21
0
        public static List <Account> GetListGeneralAccount()
        {
            string    sqlCommandText = string.Format("SELECT * FROM {0} WHERE AccountType = 'General'", TABLE_NAME);
            DataTable dataTable      = DatabaseController.ExecuteSelectQuery(sqlCommandText);
            var       result         = new List <Account>();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var item = new Account();
                item.SetPropertiesFromDataRow(dataRow);
                result.Add(item);
            }
            return(result);
        }
        public IViewComponentResult Invoke(int projectId)
        {
            var user = Request.HttpContext.User.Claims.ElementAt(1);
            var Id   = int.Parse(user.Value);

            using (var context = new DatabaseController(Context, Configuration))
            {
                var projects = context.GetUserProjects(Id);
                var current  = projects.FirstOrDefault(x => x.Id == projectId);
                ViewData["Projects"]      = projects;
                ViewData["SelectedIndex"] = projects.IndexOf(current);
            }
            return(View());
        }
Ejemplo n.º 23
0
 public static void intialize(TestContext tc)
 {
     DatabaseController.getInstance().removeTable(tableName.ToString());
     DatabaseController.getInstance().addTable(tableName.ToString());
     Word.setScoringHandler(new ScoringHandler("../../ScoringHandlerDaoTests.xml"));
     testWords = new List <Word>(new Word[] { new Word("Daddy"), new Word("Mom"), new Word("Dnow"), new Word("Grandpa") });
     using (var testDao = new WordDAO())
     {
         foreach (Word word in testWords)
         {
             testDao.save(word, tableName.ToString());
         }
     }
 }
Ejemplo n.º 24
0
        public OutgoingJsonData MakeBoardPublic([FromBody] IncomingPublicBoardRequest request)
        {
            var result = string.Empty;

            using (var context = new DatabaseController(Context, Configuration))
            {
                var domain = Request.Host.Host;

                result = context.ChangeProjectBoardStatus(request, domain);
            }
            return(new OutgoingJsonData {
                Data = result
            });
        }
Ejemplo n.º 25
0
        public IActionResult SprintBacklogs(int projectId, int boardId)
        {
            var currentUser = this.User;
            var id          = currentUser.Claims.ElementAt(1);

            using (var context = new DatabaseController(Context, Configuration))
            {
                ViewData["Projects"]      = context.GetUserProjects(int.Parse(id.Value));
                ViewData["ProjectId"]     = projectId;
                ViewData["WorkItemTypes"] = context.GetAllWorkItemTypes();
                ViewData["ProjectName"]   = context.GetProjectName(projectId);
            }
            return(View());
        }
Ejemplo n.º 26
0
        private void EditDeviceType(object sender, RoutedEventArgs e)
        {
            DeviceType d = (DeviceType)this.dg_DeviceTypesList.SelectedItem;

            AddDeviceTypeView adt = new AddDeviceTypeView(this, d);

            if (adt.ShowDialog() == true)
            {
                DatabaseController.EditDeviceType(adt.NewDeviceType);
                UpdateDeviceListView();
                UpdateDeviceTypeListView();
                UpdateLogbookView();
            }
        }
        public IActionResult EditChangelog(int projectId, int changelog)
        {
            var currentUser = this.User;
            var id          = currentUser.Claims.ElementAt(1);
            var currentId   = int.Parse(id.Value);

            using (var context = new DatabaseController(Context, Configuration))
            {
                ViewData["ProjectId"] = projectId;
                ViewData["Name"]      = context.GetUsername(currentId);
                ViewData["Changelog"] = context.GetSpecificChangelog(changelog);
            }
            return(View());
        }
Ejemplo n.º 28
0
        public static List <ForwardedBalanceOld> GetListByYear(int year)
        {
            const string sql       = "SELECT * FROM `ForwardedBalances` WHERE ForwardedYear = ?ForwardedYear";
            DataTable    dataTable = DatabaseController.ExecuteSelectQuery(sql, new SqlParameter("?ForwardedYear", year));
            var          result    = new List <ForwardedBalanceOld>();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var fb = new ForwardedBalanceOld();
                fb.SetPropertiesFromDataRow(dataRow);
                result.Add(fb);
            }
            return(result);
        }
Ejemplo n.º 29
0
        public IActionResult AddNewAccount()
        {
            var currentUser   = this.User;
            var currentUserId = currentUser.Claims.ElementAt(1);

            using (var context = new DatabaseController(Context, Configuration))
            {
                ViewData["Projects"] = context.GetUserProjects(int.Parse(currentUserId.Value));


                ViewData["Relationships"] = context.GetProjectRelationships();
            }
            return(View());
        }
Ejemplo n.º 30
0
        public static List <Account> GetListOfLoanReceivables()
        {
            var          loanAccounts = new List <Account>();
            const string sp           = "sp_list_loan_receivables";
            var          dataTable    = DatabaseController.ExecuteStoredProcedure(sp);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var loanAccount = new Account();
                loanAccount.SetPropertiesFromDataRow(dataRow);
                loanAccounts.Add(loanAccount);
            }
            return(loanAccounts);
        }
Ejemplo n.º 31
0
        public Result Update()
        {
            Action updateRecord = () =>
            {
                var key           = _paramKey;
                var sqlParameters = Parameters;
                var sql           = DatabaseController.GenerateUpdateStatement(_tableName, Parameters,
                                                                               _paramKey);
                sqlParameters.Add(key);
                DatabaseController.ExecuteNonQuery(sql, sqlParameters.ToArray());
            };

            return(ActionController.InvokeAction(updateRecord));
        }
Ejemplo n.º 32
0
        public MapsController(DatabaseController databaseController)
        {
            DatabaseController = databaseController;

            //Initialize();

            Pins = new ObservableCollection <PinItem>();

            DatabaseController.CreateTable <PinItem>();
            foreach (var PinItem in DatabaseController.Table <PinItem>())
            {
                Pins.Add(PinItem);
            }
        }
        private void btnCreateClick(object sender, EventArgs e)
        {
            //inpute validation
            bool   invalid = false;
            string name    = tbxName.Text;

            if (string.IsNullOrEmpty(name))
            {
                lblAssignmentName.ForeColor = Color.Red;
                invalid = true;
            }
            if (cbxCategory.SelectedIndex == -1)
            {
                lblCategory.ForeColor = Color.Red;
                invalid = true;
            }
            if (dtDate.Value == null)
            {
                lblDueDate.ForeColor = Color.Red;
                invalid = true;
            }

            if (invalid)
            {
                return;
            }

            string   cat  = cbxCategory.SelectedItem.ToString();
            DateTime date = dtDate.Value;

            Task newTask = new Task(name.Trim(), date, cat, Mediator.CurrentUser.UserID);

            //create the task in the database
            (bool result, string error, Task task_returned) = DatabaseController.GetDBController().WriteTask(newTask, Mediator.AuthCookie);

            if (result == false)
            {
                MessageBox.Show(error, "Task creation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                MessageBox.Show(string.Format("Your task {0} has been created!", name), "Task creation succeeded", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //add the task to the observable collection
                ObservableCollections.ObservableTaskCollection.Add(new SelectableTaskDecorator(task_returned));

                Hide();
            }
        }
        public IActionResult Commits(int id)
        {
            using (var context = new DatabaseController(Context, Configuration))
            {
                ViewData["ProjectId"]   = id;
                ViewData["ProjectName"] = context.GetProjectName(id);
            }
            using (var context = new WorkItemsContext(Context, Configuration))
                ViewData["WorkItemTypes"] = context.GetAllWorkItemTypes();


            ViewData["IsEmpty"] = true;
            return(View());
        }
Ejemplo n.º 35
0
        private void AddNewProduct(object sender, EventArgs e)
        {
            DatabaseController db      = new DatabaseController();
            string             expTime = "0";

            if (ShowAddForm.Controls[9].Text != string.Empty && ShowAddForm.Controls[8].Text != string.Empty && ShowAddForm.Controls[7].Text != string.Empty)
            {
                //Converts Einddatum to amount of days and then into a string
                expTime = (new DateTime(int.Parse(ShowAddForm.Controls[9].Text), int.Parse(ShowAddForm.Controls[8].Text), int.Parse(ShowAddForm.Controls[7].Text)) - DateTime.Today).Days.ToString();
            }

            //if the exp date is unknown (days till expiring is 0 or elss than 0), the product will get the general exp date from its given category.
            if (int.Parse(expTime) <= 0)
            {
                expTime = Categories.First(c => ShowAddForm.Controls[11].Text.Equals(c.Name)).GeneralDaysToExpire.ToString();
            }

            //First inserts the product into the table with all products in our database
            string sql = "INSERT INTO product (ID, Name, Expiration_time, Description, Category) VALUES (@val0, @val1, @val2, @val3, @val4)";

            db.NonQuery(sql,
                        ShowAddForm.Controls[1].Text, //the ID
                        ShowAddForm.Controls[3].Text, //The name
                        expTime,                      //The expiration time
                        ShowAddForm.Controls[5].Text, //The description
                        ShowAddForm.Controls[11].Text //The category
                        );
            //Then inserts it into the food table of the client
            sql = "INSERT INTO food (Add_date, Product) VALUES (@val0, @val1)";
            db.NonQuery(sql,
                        DateTime.Today.ToString("yyyy-MM-dd"),
                        ShowAddForm.Controls[1].Text
                        );
            //Addform gets emptied again
            ShowAddForm.Controls[1].Text = "";
            ShowAddForm.Controls[3].Text = "";
            ShowAddForm.Controls[5].Text = "";
            (ShowAddForm.Controls[7] as ComboBox).SelectedItem  = null;
            (ShowAddForm.Controls[8] as ComboBox).SelectedItem  = null;
            (ShowAddForm.Controls[9] as ComboBox).SelectedItem  = null;
            (ShowAddForm.Controls[11] as ComboBox).SelectedItem = null;
            DataManager.Instance.GetData();
            Products        = DataManager.Instance.Products;
            Categories      = DataManager.Instance.Categories;
            ProductsInHouse = DataManager.Instance.ProductsInHouse;
            FillExistingProductView();
            ShowAddForm.Hide();
            ViewExistingProduct.Show();
        }
Ejemplo n.º 36
0
        public IActionResult Index(int projectId)
        {
            var currentUser = this.User;
            var id          = currentUser.Claims.ElementAt(1);

            using (var context = new DatabaseController(Context, Configuration))
            {
                ViewData["Projects"] = context.GetUserProjects(int.Parse(id.Value));

                ViewData["Relationships"]    = context.GetProjectRelationships();
                ViewData["Branches"]         = context.GetBranchesForProject(projectId);
                ViewData["DefaultIteration"] = context.GetProjectDefautIteration(projectId);
            }
            return(View());
        }
Ejemplo n.º 37
0
        public static bool DeleteRecord(Record record, int requestingUserId)
        {
            if (!DatabaseController.RecordExists(record))
            {
                return(false);
            }
            if (record.User.Id != requestingUserId)
            {
                return(false);
            }
            var command = "delete from records where id = " + record.Id;

            DatabaseController.ExecuteCommand(command);
            return(true);
        }
Ejemplo n.º 38
0
        public Result Update()
        {
            Action updateRecord = () =>
            {
                var key = new SqlParameter("?ID", ID);

                List <SqlParameter> sqlParameters = SqlParameters;
                string sql = DatabaseController.GenerateUpdateStatement(TABLE_NAME, sqlParameters, key);

                sqlParameters.Add(key);
                DatabaseController.ExecuteNonQuery(sql, sqlParameters.ToArray());
            };

            return(ActionController.InvokeAction(updateRecord));
        }
Ejemplo n.º 39
0
        public AddFlights()
        {
            InitializeComponent();

            controller = new DatabaseController();
            DataBinder binder = new DataBinder();

            flightCollection = new ObservableCollection<Flight>();
            gridFlights.ItemsSource = flightCollection;

            string queryJourney =
                "SELECT J.id, A1.name as 'from_airport_id', A2.name as 'to_airport_id' FROM journey J LEFT JOIN airport A1 ON J.from_airport_id = A1.id LEFT JOIN airport A2 ON J.to_airport_id = A2.id";
            journey = controller.get<Journey_>(queryJourney);

            journeyList = controller.get<Journey_>("SELECT * FROM journey");
            binder.bindComboBox<Journey_>(cmbJourney, journeyList, "id");
            flightList = controller.get<Flight>("SELECT * FROM flight");
            binder.bindComboBox<Flight>(cmbFlight, flightList, "id");
        }
 public AddNewProductController(AddNewProductScreen screen)
 {
     this._screen = screen;
     _dbc = DatabaseController.Instance;
     FillComboBox();
 }
 public ChangeCategoryNameController(ChangeCategoryName screen)
 {
     dbc = DatabaseController.Instance;
     this.screen = screen;
 }