Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            informsysEntities context = new informsysEntities();
            Admins            admins  = context.Admins.Where(p => p.username == user.Text).FirstOrDefault();

            if (admins != null && admins.passwords == password.Text)
            {
                this.Close();
                adminMain adminMain = new adminMain();
                adminMain.Show();
            }
            else
            {
                atten.Visible = true;
            }
        }
Пример #2
0
        private void adminDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                informsysEntities context = new informsysEntities();
                Admins            admins  = context.Admins.Find(adminDataGridView.Rows[e.RowIndex].Cells[0].Value);

                if (admins != null)
                {
                    if (!(String.IsNullOrEmpty(adminDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString())) && !(String.IsNullOrEmpty(adminDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString())))
                    {
                        warning1.Visible            = false;
                        admins.username             = adminDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
                        admins.passwords            = adminDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString();
                        context.Entry(admins).State = EntityState.Modified;
                        context.SaveChanges();

                        this.adminsTableAdapter.Fill(this.informsysDataSet.Admins);
                    }
                    else
                    {
                        warning1.Visible = true;
                    }
                }
                else
                {
                    MessageBox.Show("Такого пользователя не сущетвует");
                }
            }

            if (e.ColumnIndex == 4)
            {
                informsysEntities context     = new informsysEntities();
                Admins            deliteadmin = context.Admins.Find(adminDataGridView.Rows[e.RowIndex].Cells[0].Value);

                context.Admins.Remove(deliteadmin);
                context.SaveChanges();

                this.adminsTableAdapter.Fill(this.informsysDataSet.Admins);
            }
        }