Ejemplo n.º 1
0
        public static void RegistrPerson(string LoginUser, string Pass, string Fio, string Phone, string Email, string Gender, string Position, int Rol)
        {
            //Таблица Persona
            RegistraciaEntities2 registraciaEntities = new RegistraciaEntities2();
            Persona user = new Persona
            {
                LoginReg  = LoginUser,
                ParolReg  = Pass,
                Imia      = Fio,
                Telefon   = Phone,
                Pochta    = Email,
                Pol       = Gender,
                Dolzhnost = Position,
                CodRol    = Rol
            };

            registraciaEntities.Persona.Add(user);
            registraciaEntities.SaveChanges();

            //Таблица Polzovatel
            Polzovatel autUser = new Polzovatel()
            {
                LoginVhod = user.LoginReg,
                ParolVhod = user.ParolReg,
                CodPerson = user.CodPerson
            };

            registraciaEntities.Polzovatel.Add(autUser);
            registraciaEntities.SaveChanges();
        }
Ejemplo n.º 2
0
        private void delete_Click(object sender, RoutedEventArgs e)
        {
            //Получение данных
            string loginUser = loginText.Text;

            //Удаление
            RegistraciaEntities2 registraciaEntities2 = new RegistraciaEntities2();
            Persona persona = registraciaEntities2.Persona.Where(b => b.LoginReg == loginUser).FirstOrDefault();

            registraciaEntities2.Persona.Remove(persona);
            Polzovatel polzovatel = registraciaEntities2.Polzovatel.Where(b => b.LoginVhod == loginUser).FirstOrDefault();

            registraciaEntities2.Polzovatel.Remove(polzovatel);
            registraciaEntities2.SaveChanges();

            MessageBox.Show("Удаление прошло успешно!");

            //Очистка поля
            loginText.Clear();
        }