private void AddUser()
        {
            string LastMessage;

            try
            {
                IHP_ZAM_USERS addtuser = new IHP_ZAM_USERS()
                {
                    ID_IHP_ZAM_USERS = GetNextNumer(10),
                    ID_UZYTKOWNIK    = 0,
                    LOGIN            = _user,
                    HASLO            = PasswordManager.Encrypt(_password),
                    NAZWISKO_IMIE    = _nazwauser,
                    AKTYWNY          = 0,
                    RESET_HASLA      = 0
                };
                if (checkData(addtuser))
                {
                    context.IHP_ZAM_USERS.Add(addtuser);
                    context.SaveChanges();
                }

                //    ObservlstUsersSl.Add(addtuser);
                Clear();
                Refresh();
            }

            catch (Exception ex)
            {
                LastMessage = ex.ToString();
                LogManager.WriteLogMessage(LogManager.LogType.Error, LastMessage);
                throw ex;
            }
        }
Пример #2
0
        public IHP_ZAM_USERS DoLogin(string login, string password)
        {
            IHP_ZAM_USERS res;

            password = PasswordManager.Encrypt(password);
            try
            {
                res = context.IHP_ZAM_USERS?.FirstOrDefault(x => x.LOGIN == login && x.HASLO == password);
                if (res != null)
                {
                    CreateIfMissing(login);
                }
            }

            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        LogManager.WriteLogMessage(LogManager.LogType.Error, String.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage));
                    }
                }
                throw;
            }
            return(res);
        }
Пример #3
0
 private void txtPassword_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
 {
     if (currentUser == null)
     {
         currentUser = new IHP_ZAM_USERS();
     }
     currentUser.HASLO = PasswordManager.Encrypt(txtPassword.Text);
 }
        private void  AktRec(IHP_ZAM_USERS_EX Item)
        {
            IHP_ZAM_USERS it = context.IHP_ZAM_USERS?.FirstOrDefault(w => w.ID_IHP_ZAM_USERS == Item.ID_IHP_ZAM_USERS);

            if (it != null)
            {
                if (Item.REJWAGAEX == false)
                {
                    Item.REJWAGA = 0;
                }
                if (Item.REJWAGAEX == true)
                {
                    Item.REJWAGA = 1;
                }

                if (Item.USLUGAEX == false)
                {
                    Item.USLUGA = 0;
                }
                if (Item.USLUGAEX == true)
                {
                    Item.USLUGA = 1;
                }

                if (Item.KIEROWCYEX == false)
                {
                    Item.KIEROWCY = 0;
                }
                if (Item.KIEROWCYEX == true)
                {
                    Item.KIEROWCY = 1;
                }

                if (Item.KARTOTEKIEX == false)
                {
                    Item.KARTOTEKI = 0;
                }
                if (Item.KARTOTEKIEX == true)
                {
                    Item.KARTOTEKI = 1;
                }

                if (Item.POJAZDYEX == false)
                {
                    Item.POJAZDY = 0;
                }
                if (Item.POJAZDYEX == true)
                {
                    Item.POJAZDY = 1;
                }

                if (Item.KONTRAHENTEX == false)
                {
                    Item.KONTRAHENT = 0;
                }
                if (Item.KONTRAHENTEX == true)
                {
                    Item.KONTRAHENT = 1;
                }

                if (Item.DANEFIRMYEX == false)
                {
                    Item.DANEFIRMY = 0;
                }
                if (Item.DANEFIRMYEX == true)
                {
                    Item.DANEFIRMY = 1;
                }
                if (_ischangepass)
                {
                    it.HASLO = PasswordManager.Encrypt(Password);
                }
                //   it.LOGIN = Item.LOGIN;
                //    it.ID_UZYTKOWNIK = Item.ID_UZYTKOWNIK;
                it.KARTOTEKI   = Item.KARTOTEKI;
                it.KIEROWCY    = Item.KIEROWCY;
                it.KONTRAHENT  = Item.KONTRAHENT;
                it.POJAZDY     = Item.POJAZDY;
                it.REJWAGA     = Item.REJWAGA;
                it.RESET_HASLA = Item.RESET_HASLA;
                it.USLUGA      = Item.USLUGA;
                it.DANEFIRMY   = Item.DANEFIRMY;
                it.AKTYWNY     = Item.AKTYWNY;
                context.SaveChanges();
            }
        }