/*protected void RunPersonInfoChanged(IPersonInfo pInfo)
        {
            if (OnPersonInfoChanged != null)
                PropertyChanged(this, new PersonInfoEventArgs(new PersonInfoView()));
        }*/

        public void Row_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            PropertyInfo[] propInfos;

            DataGridRow row = sender as DataGridRow;
            PersonInfoModel outputPersonInfo = (row.Item as PersonInfoModel);
            List<PersonPaymentsModel> outputPP;
            using (DataBaseConnector dbService = new DataBaseConnector())
            {
                List<IPersonPayments> inputPP = dbService.GetPersonPaymentRecords(t => t.PersonUUID == outputPersonInfo.UUID);
                if (inputPP.Count > 0)
                {
                    outputPP = new List<PersonPaymentsModel>();
                    foreach (var item in inputPP)
                    {
                        PersonPaymentsModel newpp = new PersonPaymentsModel();
                        propInfos = typeof(IPersonPayments).GetProperties();
                        foreach (var curPropt in propInfos)
                        {
                            curPropt.SetValue(newpp, curPropt.GetValue(item));
                        }
                        outputPP.Add(newpp);
                    }
                    outputPersonInfo.Payments = new ObservableCollection<PersonPaymentsModel>(outputPP);
                }
            }
            PersonInfoView hbDetailed = new PersonInfoView(outputPersonInfo);
            hbDetailed.ParentListView = this;
            //hbDetailed.Owner = this;
            hbDetailed.Show();
        }
 public void GetAllRooms()
 {
     using (DataBaseConnector dbService = new DataBaseConnector())
     {
         if (RoomList != null)
         {
             RoomList = dbService.GetAllRecords<IRoom>();
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompletionController"/> class.
 /// </summary>
 protected CompletionController()
 {
     _signInController = SignInController.GetInstance();
     _topArtistsCache  = new Dictionary <string, List <string> >();
     _topPlacesCache   = new Dictionary <string, List <string> >();
     _topSongsCache    = new Dictionary <string, List <string> >();
     _topGeneresCache  = new Dictionary <string, List <string> >();
     _yearsList        = new List <string>
     {
         "1900 - 1940",
         "1940 - 1960",
         "1960 - 1980",
         "1980 - 2000",
         "2000 - 2018"
     };
     conn = DataBaseConnector.GetInstance();
 }
 private void FullFillDBWithRooms()
 {
     IRoom room = new RoomDBModel();;
     using (DataBaseConnector dbService = new DataBaseConnector())
     {
         for (int i = 0; i < 3; i++)
         {
             for (int j = 0; j < 12; j++)
             {
                 room.UUID = Guid.NewGuid().ToString();
                 room.RoomNumber = (i + 1) + "-" + (j + 1);
                 dbService.HandleRoomsTable(room, null, RecordActions.Inserted);
             }
         }
         dbService.SaveChanges();
     }
 }
Beispiel #5
0
        public static Song GetSongFromSongName(string songName, DataBaseConnector conn)
        {
            MySqlCommand command = new MySqlCommand();

            command.Connection  = conn.Connection;
            command.CommandText = "select id_song from songs where lower(song_name) = \"" + songName.ToLower() + "\"";
            List <string> result = conn.ExecuteOneColumnCommand(command);

            if (result.Count <= 0)
            {
                return(null);
            }

            Song song = new Song(songName, result[0]);

            return(song);
        }
Beispiel #6
0
        public static Genre GetGenreFromGenreName(string genreName, DataBaseConnector conn)
        {
            MySqlCommand command = new MySqlCommand();

            command.Connection  = conn.Connection;
            command.CommandText = "select id_genre from genres where lower(genere_name) = \"" + genreName.ToLower() + "\"";
            List <string> result = conn.ExecuteOneColumnCommand(command);

            if (result.Count <= 0)
            {
                return(null);
            }

            Genre genreObject = new Genre(genreName, int.Parse(result[0]));

            return(genreObject);
        }
Beispiel #7
0
        public static Place GetPlaceFromPlaceId(int placeId, DataBaseConnector conn)
        {
            MySqlCommand command = new MySqlCommand();

            command.Connection  = conn.Connection;
            command.CommandText = "select area_name from area where id_area = " + placeId;
            List <string> result = conn.ExecuteOneColumnCommand(command);

            if (result.Count <= 0)
            {
                return(null);
            }

            Place place = new Place(placeId, result[0]);

            return(place);
        }
Beispiel #8
0
    // Use this for initialization
    IEnumerator Start()
    {
        yield return(StartCoroutine(DataBaseConnector.SelectPlayerInfo()));

        yield return(StartCoroutine(DataBaseConnector.SelectItems(this)));

        yield return(StartCoroutine(DataBaseConnector.SelectPurchasedItems(this)));

        yield return(StartCoroutine(DataBaseConnector.SelectLoadouts(this)));

        showingItemList = allItemList;

        UpdatePlayerInfo();
        RefreshShop();
        RefreshLoadouts(0);

        btn_loadoutRename.onClick.AddListener(OpenLoadoutRename);
        btn_loadoutSave.onClick.AddListener(OnLoadoutSynchronize);
    }
Beispiel #9
0
    public IEnumerator TryToBuyItem(ShopItem s)
    {
        if (Money >= s.item.Price && Level >= s.item.Level)
        {
            //SQL transaction
            Debug.Log("start");
            yield return(StartCoroutine(DataBaseConnector.BuyItem(s.item)));

            s.item.IsBought = true;
            panelInfo.SetButtonAction(s);

            Money -= s.item.Price;
            //
        }
        else
        {
            Debug.Log("not enough money or level");
        }
    }
        public void getRents()
        {
            /*
             * SELECT *
             * FROM Products
             *    where UserId<>'245875698' AND type='Nadlan' AND RentDateFrom > #3/1/1996# AND RentDateTo < #3/1/2019#  AND Condition='New' AND Bundle=true AND Purpose='loan'
             */

            string          query  = "Select * From Products INNER JOIN Rents ON Products.ProductID = Rents.ProductID where Renter = '" + Router.root.loginView1.getUserEmail() + "'";
            OleDbDataReader result = DataBaseConnector.sql(query);

            productsToDisplay = new List <ProductListingModel>();
            if (!result.Read())
            {
                MessageBox.Show("no Results found please try again.");
                return;
            }
            do
            {
                //string value=(string)result.GetValue(0).ToString();
                email       = result.GetString(0);
                productId   = result.GetValue(1).ToString();
                purpose     = result.GetValue(2).ToString();
                from        = result.GetValue(3).ToString();
                to          = result.GetString(4);
                price       = result.GetValue(5).ToString();
                addons      = result.GetString(6);
                deposite    = result.GetValue(7).ToString();
                condition   = result.GetString(8);
                description = result.GetString(9);
                category    = result.GetString(10);
                composition = result.GetValue(12).ToString();

                ProductListingModel product = new ProductListingModel(productId, description, composition, condition, category, purpose, from, to, price, addons);
                productsToDisplay.Add(product);
            }while (result.Read());



            // Router.root.showRents1.populateListingView(productsToDisplay, this.category);

            Router.navigate("DASHBOARD", "SHOWRENTS");
        }
 private void AddButton_OnClick(object sender, RoutedEventArgs e)
 {
     if (AllIsGood())
     {
         DataBaseConnector.NonQueryCommand(
             $"INSERT Clients(name, surname, phone, email, genderID) " +
             $"VALUES ((N'{Name.Text}'), (N'{Surname.Text}'), (N'{Phone.Text}'), (N'{Email.Text}'), (N'{Gender.SelectedIndex}'))");
         MessageBox.Show("Client added successfully", "Success", MessageBoxButton.OK);
         Name.Text            = "";
         Surname.Text         = "";
         Phone.Text           = "";
         Email.Text           = "";
         Gender.SelectedIndex = 0;
     }
     else
     {
         MessageBox.Show("Check spelling", "ERROR", MessageBoxButton.OK);
     }
 }
Beispiel #12
0
        private void FullFillDBWithFurniture()
        {
            IRoomFurniture roomfurn;
            List<IRoom> rooms = new List<IRoom>();

            using (DataBaseConnector dbService = new DataBaseConnector())
            {

                rooms = dbService.GetAllRecords<IRoom>();
                foreach ( var room in rooms)
                {

                    roomfurn = new RoomFurnitureDBModel();
                    roomfurn.UUID = Guid.NewGuid().ToString();
                    roomfurn.RoomUUID = room.UUID;
                    roomfurn.FurnitureUnit = "Кровать";
                    roomfurn.Quantity = 2;
                    dbService.HandleRoomFurnituresTable(roomfurn,null,RecordActions.Inserted);

                    roomfurn.UUID = Guid.NewGuid().ToString();
                    roomfurn.FurnitureUnit = "Стул";
                    roomfurn.Quantity = 2;
                    dbService.HandleRoomFurnituresTable(roomfurn, null, RecordActions.Inserted);

                    roomfurn.UUID = Guid.NewGuid().ToString();
                    roomfurn.FurnitureUnit = "Стол";
                    roomfurn.Quantity = 1;
                    dbService.HandleRoomFurnituresTable(roomfurn, null, RecordActions.Inserted);

                    roomfurn.UUID = Guid.NewGuid().ToString();
                    roomfurn.FurnitureUnit = "Шкаф";
                    roomfurn.Quantity = 2;
                    dbService.HandleRoomFurnituresTable(roomfurn, null, RecordActions.Inserted);

                    roomfurn.UUID = Guid.NewGuid().ToString();
                    roomfurn.FurnitureUnit = "Полочка";
                    roomfurn.Quantity = 3;
                    dbService.HandleRoomFurnituresTable(roomfurn, null, RecordActions.Inserted);
                }
                dbService.SaveChanges();
            }
        }
Beispiel #13
0
        private void ClientForm_OnLoaded(object sender, RoutedEventArgs e)
        {
            Clients = new List <Client>();
            // ORM-3 заполнение коллекции
            try
            {
                SqlDataReader reader = DataBaseConnector.GetReader(
                    "SELECT C.id, C.name, surname, email, phone, COALESCE(genderId,'-'), COALESCE(G.description, '-') FROM Clients C LEFT JOIN Genders G ON C.GenderID = G.Id");
                while (reader.Read())
                {
                    Clients.Add(
                        new Client()
                    {
                        Id                = reader.GetInt32(0),
                        Name              = reader.GetString(1),
                        Surname           = reader.GetString(2),
                        Email             = reader.GetString(3),
                        Phone             = reader.GetString(4),
                        GenderId          = (reader.GetValue(5) == DBNull.Value) ? 0 : reader.GetInt32(5),
                        GenderDescription = reader.GetString(6)
                    }
                        );
                }
                reader.Close();  // С незакрытым reader блокируется connection
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Close();
            }

            DataTable dataTable = DataBaseConnector.GetDataTable("SELECT id, name FROM Genders");

            Genders = new List <string>();
            foreach (DataRow row in dataTable.Rows)
            {
                Genders.Add(row.ItemArray[1].ToString());
            }

            ShowClient();
        }
Beispiel #14
0
    public IEnumerator MailCheck()
    {
        validation.MailChecked = false;

        string mail = text_regMail.text;

        if (String.IsNullOrEmpty(mail))
        {
            ShowWarning(
                text_regMail.gameObject.transform,
                "Enter email field!");
            //ShowMessage("Enter email field!");
            yield break;
        }

        if (!regexMail.IsMatch(mail))
        {
            ShowWarning(
                text_regMail.gameObject.transform,
                "Entered mail is not valid");
            //ShowMessage("Entered mail is not valid");
            yield break;
        }

        yield return(StartCoroutine(DataBaseConnector.MailExist(mail, validation)));

        if (validation.MailExist)
        {
            ShowWarning(
                text_regMail.gameObject.transform,
                "This mail is already exist");
            //ShowMessage("This mail is already exist");
        }
        else
        {
            HideWarning(text_regMail.gameObject.transform);
            validation.MailChecked = true;
        }
    }
Beispiel #15
0
        public static Artist GetArtistFromArtistId(string artistId, DataBaseConnector conn)
        {
            MySqlCommand command = new MySqlCommand();

            command.Connection  = conn.Connection;
            command.CommandText = "select * from artists where id_artist = \"" + artistId + "\" limit 1";
            List <Dictionary <string, string> > result = conn.ExecuteCommand(command);

            if (result.Count == 0)
            {
                return(null);
            }

            Artist artist = new Artist();

            artist.Name  = result[0]["artist_name"];
            artist.Id    = result[0]["id_artist"];
            artist.Day   = result[0]["begin_date_day"];
            artist.Month = result[0]["begin_date_month"];
            artist.Year  = result[0]["begin_date_year"];
            return(artist);
        }
        public void SettleButton_Click(object sender, RoutedEventArgs e)
        {
            if (sender.GetType() != typeof(DataGrid))
            {
                MessageBox.Show("Невозможно определить список");
                return;
            }
            var dg = sender as DataGrid;
            if (dg == null)
            {
                MessageBox.Show("Невозможно определить список");
                return;
            }
            else
            {
                var toSettleList = dg.Items.OfType<SettledListModel>();
                int count = 0;

                using (DataBaseConnector dbService = new DataBaseConnector())
                {
                    ObservableCollection<SettledListModel> settledAllListForChecks = new ObservableCollection<SettledListModel>();
                    if (ms!=null)
                    {
                        ms.Position = 0;
                        settledAllListForChecks = (ObservableCollection<SettledListModel>)oldSettleAllListKeeper.Deserialize(ms);
                    }
                    bool savef = false;
                    foreach (var row in toSettleList)
                    {
                        if (String.IsNullOrEmpty(row.RoomNumber))
                        {
                            MessageBox.Show("Укажите комнату");
                            MakeDataGridRowFocused(dg, count);
                            return;
                        }

                        string newRoomUUID = "";
                        try
                        {
                            newRoomUUID = RoomList.Where(t => t.RoomNumber == row.RoomNumber).First().UUID;
                        }
                        catch(NullReferenceException nullEx)
                        {
                            MessageBox.Show("Такого номера команты нет в базе данных");
                            return;
                        }

                        if (String.IsNullOrEmpty(row.RoomUUID)==false && row.RoomUUID != newRoomUUID)
                            row.ViewModelStatus = RecordActions.Updated;
                        else if (String.IsNullOrEmpty(row.RoomUUID))
                            row.ViewModelStatus = RecordActions.Inserted;
                        //checks
                        if (row.ViewModelStatus == RecordActions.Inserted || row.ViewModelStatus == RecordActions.Updated)
                        {
                            SettledListModel tempSettle = settledAllListForChecks.Where(t => t.UUID == row.UUID).FirstOrDefault();
                            if (tempSettle != null)
                                tempSettle = row;
                            else
                                settledAllListForChecks.Add(row);

                            if (settledAllListForChecks.Where(t => t.RoomNumber == row.RoomNumber).Count() > 4)
                            {
                                MessageBox.Show("В комнате " + row.RoomNumber + " теперь больше четырех человек");
                                MakeDataGridRowFocused(dg, count);
                                return;
                            }
                            string roomSex = settledAllListForChecks.Where(t => t.RoomNumber == row.RoomNumber && t.PersonUUID != row.PersonUUID).Select(t => t.Sex).Distinct().ElementAtOrDefault(0);
                            if (String.IsNullOrEmpty(roomSex)==false && roomSex!=row.Sex)
                            {
                                MessageBox.Show("В одной команте не могут быть жители разного пола");
                                MakeDataGridRowFocused(dg, count);
                                return;
                            }
                            if (settledAllListForChecks.Where(t => t.PersonUUID == row.PersonUUID).Count() > 1)
                            {
                                MessageBox.Show("Человек селится больше, чем в одну комнату");
                                MakeDataGridRowFocused(dg, count);
                                return;
                            }
                            row.SettledDate = DateTime.Now;
                            if (String.IsNullOrEmpty(row.UUID))
                                row.UUID = Guid.NewGuid().ToString();
                            row.RoomUUID = newRoomUUID;
                            dbService.HandleSettledListTable(row, t => (t.UUID == row.UUID), row.ViewModelStatus);
                            List<IPersonInfo> persons = dbService.GetPersonRecords(t=>t.UUID==row.PersonUUID);
                            if (persons!=null)
                            {
                                IPersonInfo person = persons[0];
                                person.RoomUUID = row.RoomUUID;
                                dbService.HandlePersonInfoTable(person,t=>t.UUID==person.UUID,RecordActions.Updated);
                            }
                            else
                            {
                                MessageBox.Show("Невозможно найти человека");
                                return;
                            }
                            savef = true;
                        }
                        count++;
                    }
                    if (savef)
                    {
                        //MessageBox.Show("Saved");
                        int result = dbService.SaveChanges();
                        if (result > 0)
                        {
                            ms.Position = 0;
                            settledAllList = settledAllListForChecks;
                            oldSettleAllListKeeper.Serialize(ms, settledAllList);
                            if (OnSettledListViewModelChanged != null)
                                OnSettledListViewModelChanged(this, new EventArgs());
                        }
                        else
                            MessageBox.Show("Люди не заселены");
                    }
                }
            }
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            PersonInfoModel pInfo = (PersonInfoModel)this.DataContext;

            using (DataBaseConnector dbService = new DataBaseConnector())
            {
                dbService.HandlePersonInfoTable(pInfo, t => (t.UUID == pInfo.UUID), RecordActions.Deleted);
                if (pInfo.Payments != null && pInfo.Payments.Count > 0)
                {
                    foreach (var payment in pInfo.Payments)
                    {
                        dbService.HandlePersonPaymentsTable(payment, t => (t.UUID == payment.UUID), RecordActions.Deleted);
                    }
                    if (removedPayments.Count > 0)
                    {
                        foreach (var payment in removedPayments)
                        {
                            dbService.HandlePersonPaymentsTable(payment, t => (t.UUID == payment.UUID), RecordActions.Deleted);
                        }
                        removedPayments = new List<PersonPaymentsModel>();
                    }
                }
                int result = dbService.SaveChanges();
                if (result > 0)
                {
                    if (ParentListView!=null)
                        ParentListView.UpdatePersonList(pInfo, RecordActions.Deleted);
                    this.Close();
                }
            }
        }
        public UserDetailsRepository(DataBaseConnector dataBaseConnector)

        {
            _dataBaseConnector = dataBaseConnector;
        }
 public IEnumerable <Crop> GetAllWeeds()
 {
     return(DataBaseConnector.GetAllWeeds());
 }
 public IEnumerable <TrialType> GetTrialTypes()
 {
     return(DataBaseConnector.GetTrialTypes());
 }
Beispiel #21
0
 /// <summary>
 /// Constructeur
 /// </summary>
 public AuthenticationController()
 {
     //Construction du connecteur à la base de données
     model = new DataBaseConnector("db_pictionnary", "172.16.30.244", "pictionnary", ".Etml-");
     model.Connect();
 }
Beispiel #22
0
 public DAOChofer()
 {
     this.connector = DataBaseConnector.getInstance();
 }
        public void UnSettleButton_Click(object sender, RoutedEventArgs e)
        {
            if (sender.GetType() != typeof(DataGrid))
            {
                MessageBox.Show("Невозможно определить список");
                return;
            }
            var dg = sender as DataGrid;
            if (dg == null)
            {
                MessageBox.Show("Невозможно определить список");
                return;
            }
            else
            {
                var toUnSettleList = dg.Items.OfType<SettledListModel>();
                int count = 0;

                using (DataBaseConnector dbService = new DataBaseConnector())
                {
                    ObservableCollection<SettledListModel> settledAllListForChecks = new ObservableCollection<SettledListModel>();
                    if (ms != null)
                    {
                        ms.Position = 0;
                        settledAllListForChecks = (ObservableCollection<SettledListModel>)oldSettleAllListKeeper.Deserialize(ms);
                    }
                    bool savef = false;
                    foreach (var row in toUnSettleList)
                    {
                        if (String.IsNullOrEmpty(row.RoomUUID) == false)
                            row.ViewModelStatus = RecordActions.Deleted;

                        //checks
                        if (row.ViewModelStatus == RecordActions.Deleted)
                        {
                            SettledListModel tempSettle = settledAllListForChecks.Where(t => t.UUID == row.UUID).FirstOrDefault();
                            if (tempSettle != null)
                                tempSettle = row;
                            else
                            {
                                MessageBox.Show("Нельзя выселить. Неопредленная запись");
                                MakeDataGridRowFocused(dg, count);
                                return;
                            }
                            if (String.IsNullOrEmpty(row.UUID))
                            {
                                MessageBox.Show("Нельзя выселить. Неопредленная запись");
                                MakeDataGridRowFocused(dg, count);
                                return;
                            }
                            row.RoomNumber = "";
                            row.SettledDate = DateTime.MinValue;
                            row.RoomUUID = "";
                            dbService.HandleSettledListTable(row, t => (t.UUID == row.UUID), RecordActions.Deleted);
                            settledAllListForChecks.Remove(row);
                            savef = true;
                        }
                        count++;
                    }
                    if (savef)
                    {
                        //MessageBox.Show("Saved");
                        int result = dbService.SaveChanges();
                        if (result > 0)
                        {
                            ms.Position = 0;
                            settledAllList = settledAllListForChecks;
                            oldSettleAllListKeeper.Serialize(ms, settledAllList);
                            if (OnSettledListViewModelChanged != null)
                                OnSettledListViewModelChanged(this, new EventArgs());
                        }
                        else
                            MessageBox.Show("Люди не выселены");
                    }
                }
            }
        }
 //public void RefreshButton_Click(object sender, RoutedEventArgs e)
 public void RefreshButton_Click()
 {
     using (DataBaseConnector dbService = new DataBaseConnector())
     {
         List<ISettledList> tempSettledList = new List<ISettledList>();
         List<IRoom> tempRoomList = new List<IRoom>();
         foreach (var dbPer in Habitants)
         {
             bool foundf = false;
             tempSettledList = dbService.GetSettledListRecords(t => t.PersonUUID == dbPer.UUID).ToList();
             if (tempSettledList.Count > 0)
             {
                 string roomUUID = tempSettledList[0].RoomUUID;
                 tempRoomList = dbService.GetRoomRecords(t => t.UUID == roomUUID).ToList();
                 if (tempRoomList.Count > 0)
                 {
                     dbPer.RoomNumber = tempRoomList[0].RoomNumber;
                     dbPer.SettledDate = tempSettledList[0].SettledDate;
                     foundf = true;
                 }
             }
             if (foundf==false)
             {
                 dbPer.RoomNumber = "";
                 dbPer.SettledDate = DateTime.MinValue;
             }
         }
     }
 }
        public void InsertRowIntoManager(List<IPersonInfo> pInfoList)
        {
            SettledListModel settle;
            PropertyInfo[] propInfos;

            if (pInfoList != null)
            {
                using (DataBaseConnector dbService = new DataBaseConnector())
                {
                    propInfos = typeof(ISettledList).GetProperties();
                    foreach (var pInfo in pInfoList)
                    {
                        if (settledAllList==null)
                        {
                            settledAllList = new ObservableCollection<SettledListModel>();
                            List<ISettledList>  tempSettleList = dbService.GetAllRecords<ISettledList>();
                            foreach (var setUnit in tempSettleList)
                            {
                                settle = new SettledListModel();
                                foreach (var curPropt in propInfos)
                                {
                                    curPropt.SetValue(settle, curPropt.GetValue(setUnit));
                                }
                                /*IPersonInfo pi = dbService.GetPersonRecords(t=>t.UUID==settle.PersonUUID).First();
                                if (pi!=null)
                                {
                                    settle.FirstName = pi.FirstName;
                                    settle.LastName = pi.LastName;
                                    settle.Sex = pi.Sex;
                                }*/
                                IRoom room = dbService.GetRoomRecords(t => t.UUID == settle.RoomUUID).First();
                                if (room!=null)
                                {
                                    settle.RoomNumber = room.RoomNumber;
                                }
                                settledAllList.Add(settle);
                            }
                            if (oldSettleAllListKeeper == null)
                                oldSettleAllListKeeper = new BinaryFormatter();
                            if (ms == null)
                                ms = new MemoryStream();
                            else
                                ms.Position = 0;
                            oldSettleAllListKeeper.Serialize(ms, settledAllList);
                        }
                        List<SettledListModel> curSettleList = settledAllList.Where(t => t.PersonUUID == pInfo.UUID).ToList<SettledListModel>();
                        if (curSettleList.Count > 1)
                        {
                            MessageBox.Show("Невозможно добавить строку в менеджер поселения");
                        }
                        else
                        {

                            if (curSettleList.Count == 1)
                            {
                                settle = curSettleList[0];
                                settle.FirstName = pInfo.FirstName;
                                settle.LastName = pInfo.LastName;
                                settle.Sex = pInfo.Sex;
                            }
                            else
                            {
                                settle = new SettledListModel();
                                settle.UUID = Guid.NewGuid().ToString();
                                settle.PersonUUID = pInfo.UUID;
                                settle.FirstName = pInfo.FirstName;
                                settle.LastName = pInfo.LastName;
                                settle.Sex = pInfo.Sex;
                            }
                            ManagerList.Add(settle);
                        }
                    }
                }
            }
        }
Beispiel #26
0
        private void LoginWin_onKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                //FullFillDBWithRooms();
                //FullFillDBWithFurniture();
                try
                {
                    using (DataBaseConnector dbService = new DataBaseConnector(5))
                    {
                        PersonInfoModel viewPerson;
                        IRoom dbRoom;
                        List<IRoom> tempRoomList = new List<IRoom>();
                        PersonInfoListView hb = new PersonInfoListView();
                        ObservableCollection<PersonInfoModel> viewPersons = new ObservableCollection<PersonInfoModel>();

                        List<IPersonInfo> dbPersons = dbService.GetAllRecords<IPersonInfo>();
                        List<IRoom> dbRoomList = dbService.GetAllRecords<IRoom>();

                        PropertyInfo[] propInfos = typeof(IPersonInfo).GetProperties();
                        foreach (var dbPer in dbPersons)
                        {
                            viewPerson = new PersonInfoModel();
                            foreach (var curPropt in propInfos)
                            {
                                curPropt.SetValue(viewPerson, curPropt.GetValue(dbPer));
                            }
                            tempRoomList = dbRoomList.Where(t => t.UUID == viewPerson.RoomUUID).ToList();
                            if (tempRoomList.Count>0)
                            {
                                dbRoom = tempRoomList[0];
                                viewPerson.RoomNumber = dbRoom.RoomNumber;
                            }
                            viewPersons.Add(viewPerson);
                        }
                        PersonInfoListViewModel hbViewModel = new PersonInfoListViewModel(viewPersons);
                        hb.NewButton.Click += hbViewModel.NewButton_Click;
                        hb.ManagerButton.Click += hbViewModel.ManagerButton_Click;
                        hb.SchemeButton.Click += hbViewModel.SchemeButton_Click;
                        hb.Redirect_HabitantsGridRow_DoubleClick += hbViewModel.Row_DoubleClick;
                        hb.Redirect_HabitantsGridRow_MouseLeftButtonDown += hbViewModel.Row_MouseLeftButtonDown;
                        hb.DataContext = hbViewModel;
                        hb.Show();
                    }
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    this.Close();
                }
            }
        }
Beispiel #27
0
 public DAOFacturacion()
 {
     this.db = DataBaseConnector.getInstance();
 }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            PersonInfoModel pInfo = (PersonInfoModel)this.DataContext;

            if (String.IsNullOrEmpty(pInfo.FirstName))
            {
                MessageBox.Show("Укажите имя");
                return;
            }
            if (String.IsNullOrEmpty(pInfo.LastName))
            {
                MessageBox.Show("Укажите фамилию");
                return;
            }
            if (String.IsNullOrEmpty(pInfo.Sex))
            {
                MessageBox.Show("Укажите пол");
                return;
            }
            using (DataBaseConnector dbService = new DataBaseConnector())
            {
                bool savef = false;
                if (pInfo != null && pInfo.ViewModelStatus == RecordActions.Inserted)
                {
                    pInfo.UUID = Guid.NewGuid().ToString();
                    dbService.HandlePersonInfoTable(pInfo, null, RecordActions.Inserted);
                    savef = true;
                }
                else if (pInfo != null && pInfo.ViewModelStatus == RecordActions.Updated)
                {
                    dbService.HandlePersonInfoTable(pInfo, t => (t.UUID == pInfo.UUID), RecordActions.Updated);
                    savef = true;
                }
                if (pInfo.Payments != null && pInfo.Payments.Count > 0)
                {

                    foreach (var payment in pInfo.Payments)
                    {
                        if (String.IsNullOrEmpty(payment.PersonUUID) == true)
                        {
                            payment.PersonUUID = pInfo.UUID;
                            payment.UUID = Guid.NewGuid().ToString();
                            payment.ViewModelStatus = RecordActions.Inserted;
                        }
                        if (payment.ViewModelStatus == RecordActions.Inserted)
                            dbService.HandlePersonPaymentsTable(payment, null, RecordActions.Inserted);
                        else if (payment.ViewModelStatus == RecordActions.Updated)
                            dbService.HandlePersonPaymentsTable(payment, t => (t.UUID == payment.UUID), RecordActions.Updated);
                    }
                    if (removedPayments.Count>0)
                    {
                        foreach (var payment in removedPayments)
                        {
                            if (String.IsNullOrEmpty(payment.UUID) == false)
                            {
                                dbService.HandlePersonPaymentsTable(payment, t => (t.UUID == payment.UUID), RecordActions.Deleted);
                            }
                        }
                        removedPayments = new List<PersonPaymentsModel>();
                    }
                    savef = true;
                }
                if (savef==true)
                {
                    int result = dbService.SaveChanges();
                    if (result > 0)
                    {
                        if (ParentListView != null)
                            ParentListView.UpdatePersonList(pInfo, pInfo.ViewModelStatus);
                        InitialOperations();
                        ms.Position = 0;
                        oldContextKeeper.Serialize(ms, pInfo);
                    }
                }
            }
        }
Beispiel #29
0
 public DAOListado()
 {
     this.db = DataBaseConnector.getInstance();
 }
Beispiel #30
0
        public SalaryDetailsRepository(DataBaseConnector dataBaseConnector)

        {
            _dataBaseConnector = dataBaseConnector;
        }
Beispiel #31
0
        public static User GetUserFromEmailAndPassword(string email, string password, DataBaseConnector conn)
        {
            MySqlCommand getUser = UserQueryBank.GetSimpleUserQuery(conn.Connection);

            getUser.Parameters["@email"].Value    = email;
            getUser.Parameters["@password"].Value = password;
            List <Dictionary <string, string> > result = conn.ExecuteCommand(getUser);

            if (result.Count == 0)
            {
                return(null);
            }

            User user = new User();
            Dictionary <string, string> userAsDictionary = result[0];

            user.Id        = int.Parse(userAsDictionary["id_user"]);
            user.FirstName = userAsDictionary["first_name"];
            user.LastName  = userAsDictionary["last_name"];
            user.Email     = userAsDictionary["email"];
            user.PlaceId   = int.Parse(userAsDictionary["id_area"]);
            user.GenreId   = int.Parse(userAsDictionary["id_favorite_genre"]);
            user.Year      = int.Parse(userAsDictionary["birthday_year"]);
            user.Day       = int.Parse(userAsDictionary["birthday_day"]);
            user.Month     = int.Parse(userAsDictionary["birthday_month"]);

            MySqlCommand getSongs = UserQueryBank.GetUserSongsQuery(conn.Connection);

            getSongs.Parameters["@userId"].Value = user.Id;
            List <string> songs = conn.ExecuteOneColumnCommand(getSongs);

            user.Songs = songs;

            MySqlCommand getArtists = UserQueryBank.GetUserArtistsQuery(conn.Connection);

            getArtists.Parameters["@userId"].Value = user.Id;
            List <string> artists = conn.ExecuteOneColumnCommand(getArtists);

            foreach (string artist in artists)
            {
                user.AddArtist(int.Parse(artist));
            }

            return(user);
        }
Beispiel #32
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="connector">Коннектор базы данных</param>
 /// <param name="output">Класс вывода</param>
 public DataBase(DataBaseConnector connector, DataBaseOutput output)
 {
     this.connector = connector;
     this.output    = output;
 }
Beispiel #33
0
 public DAORoles()
 {
     this.connector = DataBaseConnector.getInstance();
 }
 public DataTable getAllCars()
 {
     DataBaseConnector db = DataBaseConnector.getInstance();
     return db.select_query("SELECT AUTOS.Patente,MODELOS.Description,TURNOS.Descripcion,PERSONAS.Apellido,PERSONAS.Nombre FROM FSOCIETY.Autos AUTOS LEFT JOIN FSOCIETY.Modelos MODELOS ON AUTOS.IdModelo = MODELOS.Id LEFT JOIN FSOCIETY.Turnos TURNOS ON AUTOS.IdTurno = TURNOS.Id LEFT JOIN FSOCIETY.Personas PERSONAS ON AUTOS.IdChofer = PERSONAS.Id"); 
 }
Beispiel #35
0
 public DAORendicionViaje()
 {
     this.connector = DataBaseConnector.getInstance();
 }
 public IEnumerable <TopResult> GetTopResults()
 {
     return(DataBaseConnector.GetTopResults());
 }
 public QuestionDataService(DataBaseConnector dbc)
 {
     _dbc = dbc;
     _db  = _dbc.getDBInstance();
 }
Beispiel #38
0
 public PlayerDataService(DataBaseConnector dbc)
 {
     _dbc = dbc;
     _db  = _dbc.getDBInstance();
 }
 public LevelSuccessTimeService(DataBaseConnector dbc)
 {
     _dbc = dbc;
     _db  = _dbc.getDBInstance();
 }
Beispiel #40
0
        public void doSearch()
        {
            /*
             * SELECT *
             *  FROM Products
             *      where UserId<>'245875698' AND type='Nadlan' AND RentDateFrom > #3/1/1996# AND RentDateTo < #3/1/2019#  AND Condition='New' AND Bundle=true AND Purpose='loan'
             */
            string query = "Select * From Products INNER JOIN " + this.category + " ON Products.ProductID=" + this.category + ".ProductID Where Products.category='" + this.category + "' ";

            query += "AND Products.RentDateFrom <= #" + this.from + "# ";
            query += "AND Products.RentDateTo >= #" + this.to + "# ";

            /*if (this.userID.Length > 0)
             * {
             *  query += "AND UserId<>'" + this.userID + "' ";
             * }*/
            if (this.purpose != null)
            {
                query += "AND Products.Purpose='" + this.purpose + "' ";
            }
            if (this.condition != null)
            {
                query += "AND Products.Condition='" + this.condition + "' ";
            }

            /*
             * if (this.composition != null)
             * {
             *  Boolean isBundel = this.composition.Equals("Bundle");
             *  query += "AND Products.Bundle=" + isBundel + " ";
             * }
             */
            OleDbDataReader result = DataBaseConnector.sql(query);                // temp for example

            if (!result.HasRows)
            {
                MessageBox.Show("No Results Found! \n Please Try again");
                return;
            }


            productsToDisplay = new List <ProductListingModel>();
            result.Read();
            do
            {
                //string value=(string)result.GetValue(0).ToString();
                email       = result.GetString(0);
                productId   = result.GetValue(1).ToString();
                purpose     = result.GetValue(2).ToString();
                from        = result.GetValue(3).ToString();
                to          = result.GetString(4);
                price       = result.GetValue(5).ToString();
                addons      = result.GetString(6);
                deposite    = result.GetValue(7).ToString();
                condition   = result.GetString(8);
                description = result.GetString(9);
                category    = result.GetString(10);
                composition = result.GetValue(12).ToString();
                // breed = result.GetValue(13).ToString();
                // age = result.GetValue(14).ToString();
                // sex = result.GetString(15);
                ProductListingModel         product = new ProductListingModel(productId, description, composition, condition, category, purpose, from, to, price, addons);
                Dictionary <string, string> props   = new Dictionary <string, string>();
                populateProps(result, props);
                product.props = props;


                productsToDisplay.Add(product);
            }while (result.Read());


            /*
             * else if (this.category.Equals("Nadlan"))
             * {
             *  productsToDisplay = new List<ProductListingModel>();
             *  result.Read();
             *  do
             *  {
             *      //string value=(string)result.GetValue(0).ToString();
             *      email = result.GetString(0);
             *      productId = result.GetValue(1).ToString();
             *      purpose = result.GetValue(2).ToString();
             *      from = result.GetValue(3).ToString();
             *      to = result.GetString(4);
             *      price = result.GetValue(5).ToString();
             *      addons = result.GetString(6);
             *      deposite = result.GetValue(7).ToString();
             *      condition = result.GetString(8);
             *      description = result.GetString(9);
             *      category = result.GetString(10);
             *      composition = result.GetValue(12).ToString();
             *      breed = result.GetValue(13).ToString();
             *      age = result.GetValue(14).ToString();
             *      sex = result.GetString(15);
             *      ProductListingModel pets = new Pets(productId, description, composition, condition, category, purpose, from, to, sex, age, breed);
             *      productsToDisplay.Add(pets);
             *  }
             *  while (result.Read());
             * }
             * else if (this.category.Equals("Vehicle"))
             * {
             *  productsToDisplay = new List<ProductListingModel>();
             *  result.Read();
             *  do
             *  {
             *      //string value=(string)result.GetValue(0).ToString();
             *      email = result.GetString(0);
             *      productId = result.GetValue(1).ToString();
             *      purpose = result.GetValue(2).ToString();
             *      from = result.GetValue(3).ToString();
             *      to = result.GetString(4);
             *      price = result.GetValue(5).ToString();
             *      addons = result.GetString(6);
             *      deposite = result.GetValue(7).ToString();
             *      condition = result.GetString(8);
             *      description = result.GetString(9);
             *      category = result.GetString(10);
             *      composition = result.GetValue(12).ToString();
             *      breed = result.GetValue(13).ToString();
             *      age = result.GetValue(14).ToString();
             *      sex = result.GetString(15);
             *      ProductListingModel pets = new Pets(productId, description, composition, condition, category, purpose, from, to, sex, age, breed);
             *      productsToDisplay.Add(pets);
             *  }
             *  while (result.Read());
             * }
             * else if (this.category.Equals("SecondHand"))
             * {
             *  productsToDisplay = new List<ProductListingModel>();
             *  result.Read();
             *  do
             *  {
             *      //string value=(string)result.GetValue(0).ToString();
             *      email = result.GetString(0);
             *      productId = result.GetValue(1).ToString();
             *      purpose = result.GetValue(2).ToString();
             *      from = result.GetValue(3).ToString();
             *      to = result.GetString(4);
             *      price = result.GetValue(5).ToString();
             *      addons = result.GetString(6);
             *      deposite = result.GetValue(7).ToString();
             *      condition = result.GetString(8);
             *      description = result.GetString(9);
             *      category = result.GetString(10);
             *      composition = result.GetValue(12).ToString();
             *      breed = result.GetValue(13).ToString();
             *      age = result.GetValue(14).ToString();
             *      sex = result.GetString(15);
             *      ProductListingModel pets = new Pets(productId, description, composition, condition, category, purpose, from, to, sex, age, breed);
             *      productsToDisplay.Add(pets);
             *  }
             *  while (result.Read());
             * }
             */
            // 1) go back to the point where you had the filtered product list

            // 2) once you get the OleDbDataReader result for products table you need to map it into objects


            // 3) meanwhile we'll use a mockup:

            /*    // our goal is to create a list of products models
             *  ProductListingModel productMock1 = new ProductListingModel("PET1", this.composition, this.condition, this.category, this.purpose, this.from, this.to);
             *  ProductListingModel productMock2 = new ProductListingModel("PET2", this.composition, this.condition, this.category, this.purpose, this.from, this.to);
             *  ProductListingModel productMock3 = new ProductListingModel("PET3", this.composition, this.condition, this.category, this.purpose, this.from, this.to);
             *  ProductListingModel productMock4 = new ProductListingModel("PET4", this.composition, this.condition, this.category, this.purpose, this.from, this.to);
             */
            // do it with a for loop :)

            /*
             * productsToDisplay.Add((ProductListingModel)pets);
             * productsToDisplay.Add(productMock2);
             * productsToDisplay.Add(productMock3);
             * productsToDisplay.Add(productMock4);
             */
            Router.root.listingView.cleanPanel();
            Router.root.listingView.populateListingView(productsToDisplay, this.category);

            Router.navigate("SEARCH", "RENT_LISTING");



            /*DataTable table= result.GetSchemaTable();
             * while (result.Read())
             * {
             *  string companyCode = reader.GetValue(0).ToString();
             *  string agentId = reader.GetString(1);
             *  string firstName = reader.GetString(2);
             *  string lastName = reader.GetString(3);
             *  string nameSuffix = reader.GetString(4);
             *  string corporateName = reader.GetString(5);
             *  string entityType = reader.GetString(6);
             *  string obfSSN = reader.GetString(7);
             *  string obfFEIN = reader.GetString(8);
             *  string dummyIndicator = reader.GetString(9);
             *  // Insert code to process data.
             * }*/
        }
 public DaoViajes()
 {
     this.db = DataBaseConnector.getInstance();
 }