예제 #1
0
 //
 //
 //
 public void fillchbox()
 {
     db = new TableContext();
     cbPicFilter.DataSource    = db.Statuses.ToList <Statuses>();
     cbPicFilter.ValueMember   = "Status";
     cbPicFilter.DisplayMember = "Status";
 }
예제 #2
0
        public FormPicture(Pictures picture)
        {
            this.picture = picture;

            InitializeComponent();
            tabCon = new TableContext();
            //tabCon.Genres.Load();
            //tabCon.Authors.Load();
            //tabCon.Status.Load();



            if (picture == null)
            {
                bAdd.Click  += bClick_Add;
                bDel.Visible = false;
                this.Text    = "Добавление автора";
            }
            else
            {
                str                    = picture.InventoryNumber;
                tbInvNum.Text          = picture.InventoryNumber;
                tbName.Text            = picture.Name;
                dTPYearOfWriting.Value = picture.Year;
                tbPrice.Text           = picture.Cost.ToString();
                bAdd.Click            += bClick_Edit;
                this.Text              = "Редактирование жанра";
                bAdd.Text              = "Изменить";
            }
        }
예제 #3
0
        public FormUser(Users user)
        {
            this.user = user;
            str       = "";
            InitializeComponent();
            tabCon = new TableContext();

            if (user == null)
            {
                bAdd.Click  += bAdd_Click_Add;
                bDel.Visible = false;
                this.Text    = "Добавление пользователя";
            }
            else
            {
                tbLogin.Text    = user.Login;
                tbPassword.Text = user.Password;
                tbPassReap.Text = user.Password;
                tbSurname.Text  = user.Surname;
                tbName.Text     = user.FirstName;
                tbLastName.Text = user.LastName;

                bAdd.Click += bAdd_Click_Edit;
                this.Text   = "Редактирование пользователя";
                bAdd.Text   = "Изменить";
            }
        }
예제 #4
0
 //
 //Поиск Экспозиций
 //
 private void bExpSbros_Click(object sender, EventArgs e)
 {
     tbExpFilter.Text  = null;
     tbExpFilter2.Text = null;
     db = new TableContext();
     db.Expositions.Load();
     dGVExpositionList.DataSource = db.Expositions.Local.ToBindingList();
 }
예제 #5
0
 public FormPictureList(Expositions expositions)
 {
     this.expos = expositions;
     InitializeComponent();
     db = new TableContext();
     db.Pictures.Include("Status").Load();
     dGVPictures.DataSource = db.Pictures.Local.ToBindingList();
 }
예제 #6
0
        private void bAutSbros_Click(object sender, EventArgs e)
        {
            tbAutFilter.Text = null;

            TabCon = new TableContext();
            TabCon.Authors.Load();
            dGVAvtorList.DataSource = TabCon.Authors.Local.ToBindingList();
        }
예제 #7
0
        private void bGenSbros_Click(object sender, EventArgs e)
        {
            tbGenFilter.Text  = null;
            tbGenFilter2.Text = null;

            TabCon = new TableContext();
            TabCon.Genres.Load();
            dGVGenreList.DataSource = TabCon.Genres.Local.ToBindingList();
        }
예제 #8
0
        //
        //Сброс поиска пользователей
        //
        private void bUsrSbros_Click(object sender, EventArgs e)
        {
            tbUsrFilter.Text  = null;
            tbUsrFilter2.Text = null;
            tbUsrFilter3.Text = null;
            cbUsrFilter.Text  = null;

            db = new TableContext();
            db.Users.Include("Position").Load();
            dGVUserList.DataSource = db.Users.Local.ToBindingList();
        }
예제 #9
0
        //
        //Сброс поиска картин
        //
        private void bPicSbros_Click(object sender, EventArgs e)
        {
            tbPicFilter.Text  = null;
            tbPicFilter2.Text = null;
            dtPicker.Value    = new DateTime(1753, 01, 01);
            cbPicFilter.Text  = null;

            db = new TableContext();
            db.Pictures.Include("Status").Load();
            dGVPicturesList.DataSource = db.Pictures.Local.ToBindingList();
        }
예제 #10
0
 //ДОБАВИТЬ пользователя
 public static bool UserAdd(Users usr, TableContext tableContext)
 {
     try
     {
         tableContext.Users.Add(usr);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #11
0
 //ДОБАВИТЬ КАРТИНУ
 public static bool PictureAdd(Pictures pic, TableContext tableContext)
 {
     try
     {
         tableContext.Pictures.Add(pic);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #12
0
 //ДОБАВИТЬ Автора
 public static bool AuthorAdd(Authors aut, TableContext tableContext)
 {
     try
     {
         tableContext.Authors.Add(aut);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #13
0
 //ДОБАВИТЬ  Выставку
 public static bool ExpositionAdd(Expositions exp, TableContext tableContext)
 {
     try
     {
         tableContext.Expositions.Add(exp);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #14
0
 //ДОБАВИТЬ ЖАНР
 public static bool GenreAdd(Genres gen, TableContext tableContext)
 {
     try
     {
         tableContext.Genres.Add(gen);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #15
0
 //Пользователи
 public static bool UsersNR(string Log)
 {
     try
     {
         TableContext tableContext = new TableContext();
         if (tableContext.Users.Where(c => c.Login == Log).FirstOrDefault() == null)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #16
0
 //Картины
 public static bool PictureNR(string InNum)
 {
     try
     {
         TableContext tableContext = new TableContext();
         if (tableContext.Pictures.Where(c => c.InventoryNumber == InNum).FirstOrDefault() == null)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #17
0
 //Экспозиции
 public static bool ExpositionsNR(string name)
 {
     try
     {
         TableContext tableContext = new TableContext();
         if (tableContext.Expositions.Where(c => c.Name == name).FirstOrDefault() == null)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #18
0
 //РЕДАКТИРОВАТЬ ЖАНР
 public static bool GenreEdit(Genres genreEdit, Genres genreEditor, TableContext tableContext)
 {
     try
     {
         if (genreEdit != genreEditor)
         {
             genreEdit = genreEditor;
         }
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #19
0
 //УДАЛИТЬ Выставку
 public static bool ExpositionDel(Expositions exposition, TableContext tableContext)
 {
     try
     {
         if (exposition != null)
         {
             tableContext.Expositions.Remove(exposition);
             tableContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #20
0
 //УДАЛИТЬ Автора
 public static bool AuthorDel(Authors author, TableContext tableContext)
 {
     try
     {
         if (author != null)
         {
             tableContext.Authors.Remove(author);
             tableContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #21
0
 //РЕДАКТИРОВАТЬ Автора
 public static bool AuthorEdit(Authors authorEdit, Authors authorEditor, TableContext tableContext)
 {
     try
     {
         if (authorEdit != authorEditor)
         {
             authorEdit = authorEditor;
         }
         tableContext.Entry(authorEdit).State = EntityState.Modified;
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #22
0
 //ДОБАВИТЬ Cвязь Экспозиция - выставка
 public static bool ExpToPicAdd(int expId, int picId, TableContext tableContext)
 {
     try
     {
         ExpToPic expToPic = new ExpToPic
         {
             IdExp = expId,
             IdPic = picId
         };
         tableContext.ExpToPics.Add(expToPic);
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #23
0
 public static bool Session(Users sess)
 {
     try
     {
         TableContext TabCon = new TableContext();
         Users        usr    = TabCon.Users.Where(c => c.Login == sess.Login).FirstOrDefault();
         if (usr.Password.Equals(sess.Password))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #24
0
 public FormGenreList(Users sess)
 {
     this.sess = sess;
     TabCon    = new TableContext();
     InitializeComponent();
     if (DBFunction.Session(sess))
     {
         TabCon.Genres.Load();
         dGVGenreList.DataSource = TabCon.Genres.Local.ToBindingList();
         bDel.Visible            = false;
     }
     else
     {
         MessageBox.Show("Ай-ай");
         FormAutorization formAuth = new FormAutorization();
         formAuth.Show();
         formAuth.Closed += (s, Args) => this.Close();
         this.Hide();
     }
 }
예제 #25
0
        //УДАЛИТЬ ЖАНР
        public static bool GenreDel(Genres genre, TableContext tableContext)
        //public static bool GenreDel(int id)
        {
            try
            {
                //TableContext tableContext = new TableContext();

                if (genre != null)
                {
                    tableContext.Genres.Remove(genre);
                    tableContext.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                MessageBox.Show("Потеряно соеденение с сервером.");
                return(false);
            }
        }
예제 #26
0
 //АВТОРИЗАЦИЯ
 public static Users Auth(string login, string password)
 {
     try
     {
         TableContext TabCon = new TableContext();
         Users        User   = TabCon.Users.Include("Position").Where(c => c.Login == login).FirstOrDefault();
         if (User.Password.Equals(password))
         {
             return(User);
         }
         else
         {
             MessageBox.Show("Проверьте правильность Логина/Пароля");
             return(null);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Проверьте соединение с сервером.");
         return(null);
     }
 }
예제 #27
0
        //УДАЛИТЬ ПОЛЬЗОВАТЕЛЯ
        public static bool DelExpToPic(int idExp, int idPic, TableContext tableContext)
        //public static bool GenreDel(int id)
        {
            try
            {
                //TableContext tableContext = new TableContext();

                if (idExp != 0 && idPic != 0)
                {
                    ExpToPic expToPic = tableContext.ExpToPics.Where(c => c.IdExp == idExp).Where(c => c.IdPic == idPic).FirstOrDefault();
                    tableContext.ExpToPics.Remove(expToPic);
                    tableContext.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка удаления.");
                return(false);
            }
        }
예제 #28
0
 public static bool ExpositionEdit(Expositions expEdit, Expositions expEditor, TableContext tableContext)
 {
     try
     {
         if (expEdit != expEditor)
         {
             expEdit = expEditor;
         }
         tableContext.Entry(expEdit).State = EntityState.Modified;
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }
예제 #29
0
        public FormMain(Users sess)
        {
            this.sess = sess;
            InitializeComponent();

            if (DBFunction.Session(sess))
            {
                db = new TableContext();

                fillchbox();
                bPicSbros_Click(null, null);

                dtPicker.Format       = DateTimePickerFormat.Custom;
                dtPicker.CustomFormat = "yyyy";
                dtPicker.ShowUpDown   = true;

                switch (sess.Position.Position)
                {
                case "Администратор":
                    db.Pictures.Include("Status").Load();
                    dGVPicturesList.DataSource = db.Pictures.Local.ToBindingList();
                    dGVPicturesList.Columns[4].DefaultCellStyle.Format = "yyyy";
                    db.Expositions.Load();
                    dGVExpositionList.DataSource = db.Expositions.Local.ToBindingList();
                    CbExposition_Refresh();
                    cbExposition_SelectionChangeCommitted(null, null);
                    db.Users.Include("Position").Load();
                    db.Users.Load();
                    dGVUserList.DataSource = db.Users.Local.ToBindingList();
                    break;

                case "Реставратор":
                    db.Pictures.Include("Status").Load();
                    dGVPicturesList.DataSource = db.Pictures.Local.ToBindingList();
                    dGVPicturesList.Columns[4].DefaultCellStyle.Format = "yyyy";

                    tabControl3.TabPages.Remove(tabPageExpToPic);
                    tabControl3.TabPages.Remove(tabPageExp);
                    tabControl3.TabPages.Remove(tabPageUser);
                    bGenre.Visible = false;
                    break;

                case "Помошник администратора":
                    db.Pictures.Include("Status").Load();
                    dGVPicturesList.DataSource = db.Pictures.Local.ToBindingList();
                    dGVPicturesList.Columns[4].DefaultCellStyle.Format = "yyyy";
                    db.Expositions.Load();
                    dGVExpositionList.DataSource = db.Expositions.Local.ToBindingList();
                    CbExposition_Refresh();
                    cbExposition_SelectionChangeCommitted(null, null);
                    break;

                case "Директор":
                    db.Pictures.Include("Status").Load();
                    dGVPicturesList.DataSource = db.Pictures.Local.ToBindingList();
                    dGVPicturesList.Columns[4].DefaultCellStyle.Format = "yyyy";
                    tabControl3.TabPages.Remove(tabPageExpToPic);
                    tabControl3.TabPages.Remove(tabPageExp);
                    tabControl3.TabPages.Remove(tabPageUser);
                    bGenre.Visible = false;
                    break;

                default:
                    Console.WriteLine("Ой-ой");
                    break;
                }
            }
            else
            {
                MessageBox.Show("Ай-ай");
                FormAutorization formAuth = new FormAutorization();
                formAuth.Show();
                formAuth.Closed += (s, Args) => this.Close();
                this.Hide();
            }
        }
예제 #30
0
 //РЕДАКТИРОВАТЬ КАРТИНУ
 public static bool PicturesEdit(Pictures picturesEdit, Pictures picturesEditor, TableContext tableContext)
 {
     try
     {
         if (picturesEdit != picturesEditor)
         {
             picturesEdit = picturesEditor;
         }
         tableContext.Entry(picturesEdit).State = EntityState.Modified;
         tableContext.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Потеряно соеденение с сервером.");
         return(false);
     }
 }