예제 #1
0
        private void declineButton_Click(object sender, EventArgs e)
        {
            using (var db = new MyDbContext())
            {
                Videocard toShow = db.Videocards.SingleOrDefault(v => v.Id == videoId);

                if (toShow == null)
                {
                    // TODO:
                    // Add not found error
                    return;
                }

                videoNameTextBox.Text   = toShow.Name;
                videomemoryTextBox.Text = toShow.VideoMemory.ToString();
            }

            acceptButton.Visible  = false;
            declineButton.Visible = false;
            editButton.Visible    = true;

            videoNameTextBox.ReadOnly   = true;
            videomemoryTextBox.ReadOnly = true;

            return;
        }
예제 #2
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            using (var db = new MyDbContext())
            {
                string videoName   = videoNameTextBox.Text;
                string videomemory = videomemoryTextBox.Text;

                // Eror processing. If string is not a num - return
                try
                {
                    Convert.ToInt32(videomemory);
                }
                catch
                {
                    return;
                }

                Videocard editing = db.Videocards.SingleOrDefault(v => v.Id == videoId);

                if (videoName == "")
                {
                    // TODO:
                    // Add error (empty)
                }

                if (videomemory == "")
                {
                    // TODO:
                    // Add error (empty)
                }

                editing.Name        = videoName;
                editing.VideoMemory = Convert.ToInt32(videomemory);

                db.SaveChanges();
            }

            acceptButton.Visible  = false;
            declineButton.Visible = false;
            editButton.Visible    = true;

            videoNameTextBox.ReadOnly   = true;
            videomemoryTextBox.ReadOnly = true;

            return;
        }
예제 #3
0
        private void addButton_Click(object sender, EventArgs e)
        {
            using (var db = new MyDbContext())
            {
                string videocardName     = videoNameTextBox.Text;
                string stringVideomemory = videomemoryTextBox.Text;
                int    videomemory;

                // Eror processing. If string is not a num - return
                try
                {
                    videomemory = Convert.ToInt32(stringVideomemory);
                }
                catch
                {
                    return;
                }

                if (videocardName == "")
                {
                    // TODO:
                    // Add error
                }

                if (videomemoryTextBox.Text == null)
                {
                    // TODO:
                    // Add error
                }

                var newVideocard = new Videocard()
                {
                    Name        = videocardName,
                    VideoMemory = videomemory
                };

                db.Videocards.Add(newVideocard);
                db.SaveChanges();
            }

            this.Close();
        }
예제 #4
0
        private void yesButton_Click(object sender, EventArgs e)
        {
            using (var db = new MyDbContext())
            {
                Videocard toDelete = db.Videocards.SingleOrDefault(v => v.Id == videoId);

                if (toDelete == null)
                {
                    // TODO:
                    // Add not found error
                    return;
                }

                db.Videocards.Remove(toDelete);
                db.SaveChanges();
            }

            this.Close();

            return;
        }
예제 #5
0
        public AdminMoreVideoInfoForm(int id)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterParent;

            videoId = id;

            using (var db = new MyDbContext())
            {
                Videocard toShow = db.Videocards.SingleOrDefault(v => v.Id == videoId);

                if (toShow == null)
                {
                    // TODO:
                    // Add not found error
                    return;
                }

                videoNameTextBox.Text   = toShow.Name;
                videomemoryTextBox.Text = toShow.VideoMemory.ToString();
            }

            return;
        }