//This Method Attach object of type Obligations to the context.

        public void UpdateObligations(Obligations obligation)
        {
            var context = new CashierSystemEntities();

            context.Obligations.Attach(obligation);

            context.SaveChanges();
        }
        //This Mehtod get all obligations and returns  list of type Obligations.

        public List <Obligations> GetObligations()
        {
            var contex = new CashierSystemEntities();

            var obligation = contex.Obligations.ToList();

            return(obligation);
        }
        //This Method Attach object of type Client to the context.

        public void UpdateClient(Client client)
        {
            var context = new CashierSystemEntities();

            context.Client.Attach(client);

            context.SaveChanges();
        }
Esempio n. 4
0
        //This Method Attach object of type Cashier to the context.

        public void UpdateCashier(Cashier cashier)
        {
            var context = new CashierSystemEntities();

            context.Cashier.Attach(cashier);

            context.SaveChanges();
        }
        //This Mehtod get all clients and returns  list of type Client.

        public List <Client> GetClients()
        {
            var context = new CashierSystemEntities();

            var client = context.Client.ToList();

            return(client);
        }
Esempio n. 6
0
        //This Mehtod get all cahiers and returns  list of type Cashier.

        public List <Cashier> GetCashier()
        {
            var context = new CashierSystemEntities();

            var cashier = context.Cashier.ToList();


            return(cashier);
        }
        //This Method add object of type Obligations to the table Obligations.

        public Obligations AddObligations(Obligations obligation)
        {
            var context = new CashierSystemEntities();

            context.Obligations.Add(obligation);

            context.SaveChanges();

            return(obligation);
        }
        //This Method add object of type Client to the table Client.

        public Client AddClient(Client client)
        {
            var context = new CashierSystemEntities();

            context.Client.Add(client);

            context.SaveChanges();

            return(client);
        }
Esempio n. 9
0
        //This Method add object of type Cashier to the table Cashier.


        public void AddCashier(string FirstName, string LastName, string userName, string Pass)
        {
            var context = new CashierSystemEntities();

            var include = context.Cashier.Include("CashierClientTable").Where(x => x.cashier_user_name == userName);


            Cashier newCashier = context.Cashier.Add
                                 (
                new Cashier
            {
                cashier_first_name = FirstName,
                cashier_last_name  = LastName,
                cashier_user_name  = userName,
                cashier_password   = Pass
            }
                                 );



            context.SaveChanges();
        }
Esempio n. 10
0
        private void ConfirmButtonReg_Click(object sender, EventArgs e)
        {
            var context = new CashierSystemEntities();

            /******************************************************************************************
            **                           Getting  values in registration form                        **
            ******************************************************************************************/

            // Get value in registration form – text field first name.
            var FirstNameReg = NameCashierRegField.Text.ToString();

            // Get value in registration form – text field last name.
            var LastNameReg = LnameCashierRegField.Text.ToString();

            // Get value in registration form – text field user name.
            var UserNameReg = UserNameCashierRegField.Text.ToString();

            // Get value in registration form – text field password.
            var PassReg = PasswordCashierRegField.Text.ToString();

            // Get value in registration form – text field confirm password.
            var PassConfig = ConfirmPassCashierRegFiedl.Text.ToString();

            /******************************************************************************************
            **                                   Getting data model                                  **
            ******************************************************************************************/

            // Object newCashier of type CashierRepository.
            CashierRepository newCashier = new CashierRepository();

            // Get only user name from table Cashier.
            var onlyUserName = context.Cashier.FirstOrDefault(un => un.cashier_user_name == UserNameReg);

            /******************************************************************************************
            **                                Registration proccessing                               **
            ******************************************************************************************/

            // Check if any field is empty.
            if (FirstNameReg.Length == 0 || LastNameReg.Length == 0 || UserNameReg.Length == 0 || PassReg.Length == 0 || PassConfig.Length == 0)
            {
                // If there is empty field, it shows message.
                MessageBox.Show("Не сте въвели някое от полетата!");
            }
            else
            {
                // Check password and confirm password match.
                if (PassReg.Equals(PassConfig))
                {
                    // Check is user exist
                    if (onlyUserName != null)
                    {
                        // Return message that user exists
                        MessageBox.Show("Съществува такъв потребител ! Сменете потребителското име");
                    }
                    else
                    {
                        // Add to table new cashier
                        newCashier.AddCashier(FirstNameReg, LastNameReg, UserNameReg, PassReg);

                        // Clear all fields
                        NameCashierRegField.Text        = "";
                        LnameCashierRegField.Text       = "";
                        UserNameCashierRegField.Text    = "";
                        PasswordCashierRegField.Text    = "";
                        ConfirmPassCashierRegFiedl.Text = "";

                        // Confirmed record
                        MessageBox.Show("Успешен запис !");
                    }
                }
                else
                {
                    // If there is no matching of confirm pass and pass, shows message.
                    MessageBox.Show("Паролите не съвпадат !");
                }
            }
        }
Esempio n. 11
0
        private void SignUserButton_Click(object sender, EventArgs e)
        {
            // Create object of type ClientRepository
            ClientRepository client = new ClientRepository();

            // Create Data base context
            var context = new CashierSystemEntities();

            /******************************************************************************************
            **                                   Get field values                                    **
            ******************************************************************************************/
            // Get values of first name field
            var FirstNameClientField = SignUserFirstNameField.Text.ToString();

            // Get values of Last name field
            var LastNameClientField = SignUserLastNameField.Text.ToString();

            // Get values of Egn field
            var EgnClientEgnField = SignUserEgnField.Text.ToString();

            /******************************************************************************************
            **                                   Processing EGN                                      **
            ******************************************************************************************/

            // Cast from string to int
            int EgnInt = int.Parse(EgnClientEgnField);

            var EgnCheck = context.Client.FirstOrDefault(egn => egn.client_egn == EgnInt);

            /******************************************************************************************
            **                      Get from the model generated client number                       **
            ******************************************************************************************/



            /******************************************************************************************
            **                                   Interact with DB                                    **
            ******************************************************************************************/

            // Check if there is empty field.
            if (FirstNameClientField.Length == 0 || LastNameClientField.Length == 0 || EgnClientEgnField.Length == 0)
            {
                // Thie message shows when fields are empty
                MessageBox.Show("Не сте въвели някое от поле !");
            }
            else if (EgnCheck != null)
            {
                // This message shows when there is Client with such EGN.
                MessageBox.Show("Не може да има човек със същото ЕГН !");
            }
            else
            {
                client.AddClient(
                    new Client
                {
                    // Record first name in DB
                    client_first_name = FirstNameClientField,

                    //Record Last name in DB
                    client_last_name = LastNameClientField,

                    // Record Egn in DB
                    client_egn = EgnInt
                });
                var ClientNumber = context.Client.FirstOrDefault(c => c.client_egn == EgnInt).client_serial_number;

                //Clear all fields
                SignUserFirstNameField.Text = "";
                SignUserLastNameField.Text  = "";
                SignUserEgnField.Text       = "";

                GenClientNSignUser.Text = ClientNumber.ToString();

                MessageBox.Show("Успешен запис !");
            }
        }