Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string Texti, UN;

            Texti = richTextBox1.Text;
            UN    = Main.ControlID.UserName;

            var context = new Films_dbEntities();


            using (Films_dbEntities db = new Films_dbEntities())
            {
                var user = db.Users.Where(x => x.Name.Equals(UN)).FirstOrDefault();

                var t = new Feedback //Make sure you have a table called test in DB
                {
                    UserID   = user.ID,
                    Text     = Texti,
                    UserName = UN
                };


                context.Feedbacks.Add(t);
                context.SaveChanges();

                this.Hide();
            }
        }
Exemplo n.º 2
0
        private void Upload_Click(object sender, EventArgs e)
        {
            string Nm, PSW;

            Nm  = NameField.Text;
            PSW = PswField.Text;


            using (Films_dbEntities db = new Films_dbEntities())
            {
                var user = db.Users.Where(x => x.Name.Equals(Nm) && x.Password.Equals(PSW)).FirstOrDefault();

                if (user != null)
                {
                    MessageBox.Show("Sign In Succesfully");

                    this.Hide();


                    Main.ControlID.UserName = Nm;

                    var form2 = new Main();
                    form2.Closed += (s, args) => this.Close();
                    form2.Show();
                }
                else
                {
                    MessageBox.Show("password or Email is incorrect");
                    NameField.ResetText();
                    PswField.ResetText();
                }
            }
        }
Exemplo n.º 3
0
        public Main()
        {
            InitializeComponent();
            loadTable();
            dataGridView.Columns[0].Visible      = false;
            dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView.AllowUserToOrderColumns = true;
            var context = new Films_dbEntities();


            var posts = context.Users
                        .Where(p => p.Admin == 1);

            var query = posts.ToList();


            foreach (var nm in query)
            {
                if (!string.Equals(ControlID.UserName, nm.Name))
                {
                    Delete.Visible       = false;
                    Insert.Visible       = false;
                    FeedBacks.Visible    = false;
                    UpdateButton.Visible = false;

                    dataGridView.ReadOnly = true;
                }
                else
                {
                    Delete.Visible   = true;
                    Insert.Visible   = true;
                    FeedBack.Visible = false;
                }
            }
        }
Exemplo n.º 4
0
 public void loadData()
 {
     using (Films_dbEntities db = new Films_dbEntities())
     {
         var films = db.Films.Where(x => x.Name.Equals(NameObj)).FirstOrDefault();
         if (films != null)
         {
             NameField.Text  = NameObj;
             MarkField.Text  = films.Mark;
             GenreField.Text = films.Genre;
         }
     }
 }
Exemplo n.º 5
0
        public void Delete_Click1(object sender, EventArgs e)
        {
            var Context      = new Films_dbEntities();
            var itemToRemove = Context.Films.SingleOrDefault(x => x.Name == RowName);

            if (itemToRemove != null)
            {
                Context.Films.Remove(itemToRemove);
                Context.SaveChanges();


                loadTable();
                MessageBox.Show(RowName + "is deleted");
            }
        }
Exemplo n.º 6
0
        private void Upload_Click(object sender, EventArgs e)
        {
            using (Films_dbEntities db = new Films_dbEntities())
            {
                var result = db.Films.SingleOrDefault(b => b.Name == NameObj);
                if (result != null)
                {
                    result.Name  = NameField.Text;
                    result.Mark  = MarkField.Text;
                    result.Genre = GenreField.Text;
                    db.SaveChanges();

                    MessageBox.Show("Film " + NameField.Text + " is Updated");
                    this.Hide();
                }
            }
        }
        private void Upload_Click(object sender, EventArgs e)
        {
            string NM, PSW;

            NM  = NameField.Text;
            PSW = PswField.Text;

            if (NM.Length < 6 || PSW.Length < 6)
            {
                MessageBox.Show("Name and Pasword should contain minimum 6 letter");
            }
            else
            {
                using (Films_dbEntities db = new Films_dbEntities())
                {
                    var user = db.Users.Where(x => x.Name.Equals(NM)).FirstOrDefault();
                    if (user == null)
                    {
                        MessageBox.Show("Registration Was Succesfully");

                        this.Hide();


                        var t = new User
                        {
                            Name     = NM,
                            Password = PSW
                        };

                        db.Users.Add(t);
                        db.SaveChanges();

                        var g = new Thread(() => Application.Run(new LogIn()));
                        g.Start();
                        this.Close();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Same name already exist");
                        NameField.ResetText();
                        PswField.ResetText();
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void Upload_Click(object sender, EventArgs e)
        {
            Main   mn = new Main();
            string NM, Gnr;

            NM  = NameField.Text;
            Gnr = GenreField.Text;

            String Mrk;

            Mrk = MarkField.Text;

            var context = new Films_dbEntities();

            var t = new Film //Make sure you have a table called test in DB
            {
                Name  = NM,
                Mark  = Mrk,
                Genre = Gnr
            };

            context.Films.Add(t);
            context.SaveChanges();


            NameField.ResetText();
            GenreField.ResetText();
            MarkField.ResetText();

            var form = new Main();

            form.Refresh();

            mn.loadTable();

            MessageBox.Show("Film " + NM + " is added");
        }
Exemplo n.º 9
0
        public void loadTable()
        {
            using (Films_dbEntities db = new Films_dbEntities())
            {
                var result = from Films in db.Films
                             select Films;


                dataGridView.DataSource = result.OrderBy(x => x.ID).Skip(5 * page).Take(5).ToList();

                int Count = result.ToList().Count();
                PageCount = Count / 5;

                if (Count % 5 > 0)
                {
                    PageCount = PageCount + 1;
                }

                PageLabel.Text = page + 1 + "/" + PageCount;
            }

            //var result = Get();
            //List<Film> FilmList = result.ToList();
        }
Exemplo n.º 10
0
        public static IQueryable <Feedback> Get()
        {
            var context1 = new Films_dbEntities();

            return(context1.Feedbacks);
        }