private void setRoundTableNames(ref TournamentMainRoundTable roundTable)
        {
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                Player player;

                string strPlayer1Name = "N/A";
                string strPlayer2Name = "N/A";

                if (roundTable.Player1Id > 0)
                {
                    player         = conn.Get <Player>(roundTable.Player1Id);
                    strPlayer1Name = player.Name;
                }

                if (roundTable.Player2Id > 0)
                {
                    player         = conn.Get <Player>(roundTable.Player2Id);
                    strPlayer2Name = player.Name;
                }

                roundTable.Player1Name = strPlayer1Name;
                roundTable.Player2Name = strPlayer2Name;
                roundTable.TableName   = string.Format("{0} vs {1}", strPlayer1Name, strPlayer2Name);
            }
        }
示例#2
0
 public Bill GetBillByID(int billID)
 {
     using (var db = new SQLite.SQLiteConnection(DBPath))
     {
         return(db.Get <Bill>(billID));
     }
 }
示例#3
0
 public Category GetCategoryByID(int categoryID)
 {
     using (var db = new SQLite.SQLiteConnection(DBPath))
     {
         return(db.Get <Category>(categoryID));
     }
 }
示例#4
0
        partial void LearnButtonClick(Foundation.NSObject sender)
        {
            LearnButton.Hidden = true;
            LetterPattern letter;

            using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
            {
                letter = db.Get <LetterPattern>(p => p.ID == "L");
            }

            var matrix = ConvertStringToArray(letter.Pattern, 60);

            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int a = 0; a < matrix.GetLength(1); a++)
                {
                    if (currentMatrix[i, a] == 1 && matrix[i, a] < 50)
                    {
                        matrix[i, a]++;
                    }
                    else if (matrix[i, a] > -50)
                    {
                        matrix[i, a]--;
                    }
                }
            }

            using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
            {
                db.Update(new LetterPattern()
                {
                    ID = "L", Pattern = ConvertArrayToString(matrix)
                });
            }
        }
示例#5
0
 public CheckInOut GetActiveCheckInOut(string date, int personId)
 {
     try
     {
         return database.Get<CheckInOut>(i => i.PersonId == personId && i.EndTime == null);
     }
     catch (Exception e)
     {
         Debug.WriteLine($"error getting checkinout object: {e.Message}");
     }
     return null;
 }
示例#6
0
        //Opening an existing player
        public Players_AddEdit(int Id)
        {
            InitializeComponent();
            openPlayer = new Player();

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                conn.CreateTable <Player>();
                openPlayer = conn.Get <Player>(Id);

                nameEntry.Text         = openPlayer.Name;
                emailEntry.Text        = openPlayer.Email;
                activeSwitch.IsToggled = openPlayer.Active;
            }
        }
示例#7
0
        public static void AddWage(string groupName, int id)
        {
            double wage;

            using (var db = new SQLite.SQLiteConnection(CreateDB.GetDataBasePath, true))
            {
                List <CreateDB.TableGroup> dataGroup = new List <CreateDB.TableGroup>();
                double AllSalarySub = 0;
                var    tableGroup   = from s in db.Table <CreateDB.TableGroup>()
                                      where s.Name_group == groupName
                                      select s;
                var tableDepartment = db.Get <CreateDB.TableDepartment>(id);
                tableGroup.ToList().ForEach(item => dataGroup.Add(item));
                var querySub = db.Query <CreateDB.Show>("select b.name, d.name_group, b.Date, b.wage" +
                                                        " from TableDepartment as a, TableSubordination as c, TableDepartment as b, TableGroup as d" +
                                                        " where  c.chief_id = a.id" +
                                                        " and c.department_id = b.id" +
                                                        " and a.group_id = d.id" +
                                                        " and c.chief_id =" + id);

                querySub.ToList().ForEach((x) => AllSalarySub += x.Wage);
                double percent;
                switch (dataGroup[0].Id)
                {
                case 1:
                    percent = GetYear(tableDepartment.Date, DateTime.Now) * dataGroup[0].Percent > 0.30 ? 0.30 : GetYear(tableDepartment.Date, DateTime.Now) * dataGroup[0].Percent;
                    break;

                case 2:
                    percent = GetYear(tableDepartment.Date, DateTime.Now) * dataGroup[0].Percent > 0.40 ? 0.40 : GetYear(tableDepartment.Date, DateTime.Now) * dataGroup[0].Percent;
                    break;

                case 3:
                    percent = GetYear(tableDepartment.Date, DateTime.Now) * dataGroup[0].Percent > 0.35 ? 0.35 : GetYear(tableDepartment.Date, DateTime.Now) * dataGroup[0].Percent;
                    break;

                default:
                    percent = 0;
                    break;
                }

                wage = dataGroup[0].Rate + percent * dataGroup[0].Rate + AllSalarySub * dataGroup[0].Percent_worker;
                db.Execute("update TableDepartment set wage =" + Convert.ToInt32(wage) + " where id = " + id);
                db.Dispose();
            }
        }
示例#8
0
        //Update the SQL table after all the adjustments are made
        public void UpdateRoundTable()
        {
            if (TournamentMainRoundTable.Id == 0 || _recursiveLvl > 1)
            {
                return;
            }

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                TournamentMainRoundTable roundTable = conn.Get <TournamentMainRoundTable>(TournamentMainRoundTable.Id);

                roundTable.Player1Score  = TournamentMainRoundTable.Player1Score;
                roundTable.Player1Winner = TournamentMainRoundTable.Player1Winner;
                roundTable.Player2Score  = TournamentMainRoundTable.Player2Score;
                roundTable.Player2Winner = TournamentMainRoundTable.Player2Winner;

                conn.Update(roundTable);
            }
        }
示例#9
0
        partial void RecognizeButtonClick(Foundation.NSObject sender)
        {
            currentMatrix = SimplifyImage((int)DrawHolder.Frame.Width, (int)DrawHolder.Frame.Height, 10, DrawHolder.AllPoints);
            int[,] matrix;
            using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
            {
                //db.Insert(new LetterPattern() { ID = "L", Pattern = ConvertArrayToString(currentMatrix) });
                LetterPattern letter = db.Get <LetterPattern>(p => p.ID == "L");
                matrix = ConvertStringToArray(letter.Pattern, 60);
            }

            neuron        = new Neuron(60, 60, currentMatrix);
            neuron.weight = matrix;
            neuron.mul_w();
            neuron.Sum();

            TextLabel.Text = neuron.Rez() ? "L" : "";

            LearnButton.Hidden = false;
        }
示例#10
0
 public static void Delete <T>(T[] items) where T : IHasId, new()
 {
     using (var db = new SQLite.SQLiteConnection(SqliteDbPath))
     {
         lock (lck)
         {
             db.CreateTable <T>();
             db.BeginTransaction();
             foreach (var item in items)
             {
                 var d = db.Get <T>(item.Id);
                 if (d != null)
                 {
                     File.AppendAllLines("d:\\a.txt", new [] { item.Id });
                     db.Delete(d);
                 }
             }
             db.Commit();
         }
     }
 }
示例#11
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.FilePath))
     {
         var appointments = conn.Query <Appointment>("select * from Appointment where uId=?", uid);
         List <XamForms.Controls.SpecialDate> specialDates = new List <XamForms.Controls.SpecialDate>
         {
         };
         List <DateTime> d = new List <DateTime>
         {
         };
         foreach (Appointment a in appointments)
         {
             if (a.aptDate > DateTime.Now)
             {
                 Doctor doc = conn.Get <Doctor>(a.dId);
                 specialDates.Add(
                     new XamForms.Controls.SpecialDate(a.aptDate)
                 {
                     Selectable        = true,
                     BackgroundPattern = new XamForms.Controls.BackgroundPattern(1)
                     {
                         Pattern = new List <XamForms.Controls.Pattern>
                         {
                             new XamForms.Controls.Pattern {
                                 WidthPercent = 1f, HightPercent = 0.4f, Color = Color.Transparent
                             },
                             new XamForms.Controls.Pattern {
                                 WidthPercent = 1f, HightPercent = 0.6f, Color = Color.CornflowerBlue, Text = doc.dName, TextColor = Color.Black, TextSize = 11, TextAlign = XamForms.Controls.TextAlign.Middle
                             },
                         }
                     }
                 });
             }
             MyCal.SpecialDates = specialDates;
         }
     }
 }
示例#12
0
        // Processing

        private void ProcessRequest(object sender, ConfirmationRequest request)
        {
            try
            {
                using (var db = new SQLite.SQLiteConnection(AppState.State.Instance.DbPath))
                {
                    if (request.UserId == AppState.State.Instance.UserDetails.UserId)
                    {
                        throw new ConfirmationException("Nemùžete potvrzovat vlastní požadavky");
                    }

                    var r = db.Table <Model.User>();
                    var l = db.Get <Model.User>(request.UserId);

                    var targetUser = db.Find <Model.User>(request.UserId);
                    if (targetUser == null)
                    {
                        throw new ConfirmationException("Vaše zaøízení tohoto uživatele nerozpoznalo. Jeho požadavek nelze potvrdit.");
                    }

                    string dialogText;
                    if (request.Type == ConfirmationType.Challenge)
                    {
                        var challenge = AppState.State.Instance.Challenges.FirstOrDefault((c) => c.Id == request.TargetId);
                        if (challenge == null)
                        {
                            throw new ConfirmationException("Neznámá zkouška");
                        }

                        dialogText = $"Uživatel { targetUser.Name} žádá o potvrzení zkoušky { challenge.Names[0].Name}. Potvrdit?";
                    }
                    else
                    {
                        ChallengeTask task = null;

                        foreach (var challenge in AppState.State.Instance.Challenges)
                        {
                            if ((task = challenge.BasicTasks.FirstOrDefault((t) => t.Id == request.TargetId)) != null)
                            {
                                break;
                            }

                            if ((task = challenge.ExtraTasks.FirstOrDefault((t) => t.Id == request.TargetId)) != null)
                            {
                                break;
                            }
                        }

                        if (task == null)
                        {
                            throw new ConfirmationException("Neznámý úkol");
                        }

                        dialogText = $"Uživatel { targetUser.Name} žádá o potvrzení úkolu { task.Name}. Potvrdit?";
                    }

                    new AlertDialog.Builder(this)
                    .SetTitle("Požadavek od uživatele")
                    .SetMessage(dialogText)
                    .SetPositiveButton("Ano", (o, e) => GenerateConfirmation(request))
                    .SetNegativeButton("Ne", CancelAction)
                    .Create()
                    .Show();
                }
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this)
                .SetMessage("Pøi ovìøování došlo k chybì: " + e.Message)
                .SetNeutralButton("Ok", (o, ev) =>
                {
                    SetResult(Android.App.Result.Canceled);
                    Finish();
                })
                .Create()
                .Show();
            }
        }
示例#13
0
 public Income Get(int id)
 {
     return(_connection.Get <Income>(id));
 }
示例#14
0
 public T GetItem <T>(int id) where T : new()
 {
     return(database.Get <T>(id));
 }
        private void saveButton_Clicked(object sender, EventArgs e)
        {
            clsPlayerInfo player1 = (clsPlayerInfo)pckPlayer1.SelectedItem;
            clsPlayerInfo player2 = (clsPlayerInfo)pckPlayer2.SelectedItem;


            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                TournamentMainRoundTable tmpOtherTable;
                TournamentMainRoundTable tmpCurrentTable;
                clsPlayerInfo            tmpPlayer;
                int tmpPlayerId;

                for (int i = 1; i <= 2; i++)
                {
                    if (i == 1)
                    {
                        tmpPlayer   = player1;
                        tmpPlayerId = intPlayer1Id;
                    }

                    else
                    {
                        tmpPlayer   = player2;
                        tmpPlayerId = intPlayer2Id;
                    }

                    if (tmpPlayer.PlayerId != tmpPlayerId)
                    {
                        tmpOtherTable   = new TournamentMainRoundTable();
                        tmpCurrentTable = new TournamentMainRoundTable();

                        TournamentMainRoundTable otherTable = conn.Get <TournamentMainRoundTable>(tmpPlayer.TableId);

                        tmpOtherTable.Player1Id   = otherTable.Player1Id;
                        tmpOtherTable.Player1Name = otherTable.Player1Name;
                        tmpOtherTable.Player2Id   = otherTable.Player2Id;
                        tmpOtherTable.Player2Name = otherTable.Player2Name;

                        tmpCurrentTable.Player1Id   = currentTable.Player1Id;
                        tmpCurrentTable.Player1Name = currentTable.Player1Name;
                        tmpCurrentTable.Player2Id   = currentTable.Player2Id;
                        tmpCurrentTable.Player2Name = currentTable.Player2Name;

                        if (otherTable.Player1Id == tmpPlayer.PlayerId)
                        {
                            otherTable.Player1Id   = tmpCurrentTable.Player1Id;
                            otherTable.Player1Name = tmpCurrentTable.Player1Name;
                            otherTable.TableName   = string.Format("{0} vs {1}", otherTable.Player1Name, otherTable.Player2Name);

                            currentTable.Player1Id   = tmpOtherTable.Player1Id;
                            currentTable.Player1Name = tmpOtherTable.Player1Name;
                            currentTable.TableName   = string.Format("{0} vs {1}", currentTable.Player1Name, currentTable.Player2Name);
                        }
                        else if (otherTable.Player2Id == tmpPlayer.PlayerId)
                        {
                            otherTable.Player2Id   = tmpCurrentTable.Player1Id;
                            otherTable.Player2Name = tmpCurrentTable.Player1Name;
                            otherTable.TableName   = string.Format("{0} vs {1}", otherTable.Player1Name, otherTable.Player2Name);

                            currentTable.Player1Id   = tmpOtherTable.Player2Id;
                            currentTable.Player1Name = tmpOtherTable.Player2Name;
                            currentTable.TableName   = string.Format("{0} vs {1}", currentTable.Player1Name, currentTable.Player2Name);
                        }

                        conn.Update(otherTable);
                        conn.Update(currentTable);
                    }
                }

                //if (player1.PlayerId != intPlayer1Id)
                //{
                //    tmpTable = new TournamentMainRoundTable();

                //    TournamentMainRoundTable otherTable = conn.Get<TournamentMainRoundTable>(player1.TableId);

                //    tmpTable = otherTable;

                //    if (otherTable.Player1Id == player1.PlayerId)
                //    {
                //        otherTable.Player1Id = currentTable.Player1Id;
                //        otherTable.Player1Name = currentTable.Player1Name;
                //        otherTable.TableName = string.Format("{0} vs {1}", otherTable.Player1Name, otherTable.Player2Name);

                //        currentTable.Player1Id = tmpTable.Player1Id;
                //        currentTable.Player1Name = tmpTable.Player1Name;
                //        currentTable.TableName = string.Format("{0} vs {1}", currentTable.Player1Name, currentTable.Player2Name);
                //    }
                //    else if (otherTable.Player2Id == player1.PlayerId)
                //    {
                //        otherTable.Player2Id = currentTable.Player1Id;
                //        otherTable.Player2Name = currentTable.Player1Name;
                //        otherTable.TableName = string.Format("{0} vs {1}", otherTable.Player1Name, otherTable.Player2Name);

                //        currentTable.Player1Id = tmpTable.Player2Id;
                //        currentTable.Player1Name = tmpTable.Player2Name;
                //        currentTable.TableName = string.Format("{0} vs {1}", currentTable.Player1Name, currentTable.Player2Name);
                //    }
                //}

                //if (player2.PlayerId != intPlayer2Id)
                //{
                //    tmpTable = new TournamentMainRoundTable();

                //    TournamentMainRoundTable otherTable = conn.Get<TournamentMainRoundTable>(player2.TableId);

                //    tmpTable = otherTable;

                //    if (otherTable.Player1Id == player2.PlayerId)
                //    {
                //        otherTable.Player1Id = currentTable.Player1Id;
                //        otherTable.Player1Name = currentTable.Player1Name;
                //        otherTable.TableName = string.Format("{0} vs {1}", otherTable.Player1Name, otherTable.Player2Name);

                //        currentTable.Player1Id = tmpTable.Player1Id;
                //        currentTable.Player1Name = tmpTable.Player1Name;
                //        currentTable.TableName = string.Format("{0} vs {1}", currentTable.Player1Name, currentTable.Player2Name);
                //    }
                //    else if (otherTable.Player2Id == player2.PlayerId)
                //    {
                //        otherTable.Player2Id = currentTable.Player1Id;
                //        otherTable.Player2Name = currentTable.Player1Name;
                //        otherTable.TableName = string.Format("{0} vs {1}", otherTable.Player1Name, otherTable.Player2Name);

                //        currentTable.Player1Id = tmpTable.Player2Id;
                //        currentTable.Player1Name = tmpTable.Player2Name;
                //        currentTable.TableName = string.Format("{0} vs {1}", currentTable.Player1Name, currentTable.Player2Name);
                //    }
                //}
            }

            Navigation.PopAsync();
        }
示例#16
0
 public Verification GetVerification(int personId)
 {
     return(database.Get <Verification>(i => i.PersonId == personId));
 }
        private void saveButton_Clicked(object sender, EventArgs e)
        {
            clsPlayerInfo player1 = (clsPlayerInfo)pckPlayer1.SelectedItem;
            clsPlayerInfo player2 = (clsPlayerInfo)pckPlayer2.SelectedItem;

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                TournamentMainRoundTable tmpOtherTable;
                TournamentMainRoundTable tmpCurrentTable;
                clsPlayerInfo            tmpPlayer;
                int tmpPlayerId;

                //Go through each Picker set of players
                for (int i = 1; i <= 2; i++)
                {
                    if (i == 1)
                    {
                        tmpPlayer   = player1;
                        tmpPlayerId = intPlayer1Id;
                    }
                    else
                    {
                        tmpPlayer   = player2;
                        tmpPlayerId = intPlayer2Id;
                    }

                    //If the currently selected player is not the same player that was loaded, proceed
                    if (tmpPlayer.PlayerId != tmpPlayerId)
                    {
                        tmpOtherTable   = new TournamentMainRoundTable();
                        tmpCurrentTable = new TournamentMainRoundTable();

                        TournamentMainRoundTable otherTable = conn.Get <TournamentMainRoundTable>(tmpPlayer.TableId);

                        //Ensure we're not swamping player spots within the same table.  If so, can create issues with this logic that there's really no need to code for at this point.
                        if (otherTable.Id != currentTable.Id)
                        {
                            //Set local temp object properties instead of copying the objects themselves, preventing inadvertently changing table data unintentionally
                            tmpOtherTable.Player1Id   = otherTable.Player1Id;
                            tmpOtherTable.Player1Name = otherTable.Player1Name;
                            tmpOtherTable.Player2Id   = otherTable.Player2Id;
                            tmpOtherTable.Player2Name = otherTable.Player2Name;

                            tmpCurrentTable.Player1Id   = currentTable.Player1Id;
                            tmpCurrentTable.Player1Name = currentTable.Player1Name;
                            tmpCurrentTable.Player2Id   = currentTable.Player2Id;
                            tmpCurrentTable.Player2Name = currentTable.Player2Name;

                            //Find player being swapped with on the other tableId, determine if player 1 or 2, keeping in mind if the current table's player is player 1 or 2 already
                            //(that way we can swap a player 1 from one table to a player 2 on another table)
                            if (tmpOtherTable.Player1Id == tmpPlayer.PlayerId)
                            {
                                if (i == 1)
                                {
                                    currentTable.Player1Id   = tmpOtherTable.Player1Id;
                                    currentTable.Player1Name = tmpOtherTable.Player1Name;
                                    otherTable.Player1Id     = tmpCurrentTable.Player1Id;
                                    otherTable.Player1Name   = tmpCurrentTable.Player1Name;
                                }
                                else
                                {
                                    currentTable.Player2Id   = tmpOtherTable.Player1Id;
                                    currentTable.Player2Name = tmpOtherTable.Player1Name;
                                    otherTable.Player1Id     = tmpCurrentTable.Player2Id;
                                    otherTable.Player1Name   = tmpCurrentTable.Player2Name;
                                }
                            }
                            else if (tmpOtherTable.Player2Id == tmpPlayer.PlayerId)
                            {
                                if (i == 1)
                                {
                                    currentTable.Player1Id   = tmpOtherTable.Player2Id;
                                    currentTable.Player1Name = tmpOtherTable.Player2Name;
                                    otherTable.Player2Id     = tmpCurrentTable.Player1Id;
                                    otherTable.Player2Name   = tmpCurrentTable.Player1Name;
                                }
                                else
                                {
                                    currentTable.Player2Id   = tmpOtherTable.Player2Id;
                                    currentTable.Player2Name = tmpOtherTable.Player2Name;
                                    otherTable.Player2Id     = tmpCurrentTable.Player2Id;
                                    otherTable.Player2Name   = tmpCurrentTable.Player2Name;
                                }
                            }

                            //Reset the tables' names
                            currentTable.TableName = string.Format("{0} vs {1}", currentTable.Player1Name, currentTable.Player2Name);
                            otherTable.TableName   = string.Format("{0} vs {1}", otherTable.Player1Name, otherTable.Player2Name);
                        }

                        //Update the tables' information on the database
                        conn.Update(otherTable);
                        conn.Update(currentTable);
                    }
                }
            }

            Navigation.PopAsync();
        }
示例#18
0
 public Subjects GetItem(int id)
 {
     return(database.Get <Subjects>(id));
 }
示例#19
0
 public Expense Get(int id)
 {
     return(_connection.Get <Expense>(id));
 }
示例#20
0
 public FileMeta GetFileMeta(int Id)
 {
     return(db.Get <FileMeta>(Id));
 }
示例#21
0
 public Category Get(int id)
 {
     return(_connection.Get <Category>(id));
 }