Esempio n. 1
0
        async void Auth()
        {
            var wait = new WaitForm {
                Status = Texts.Authorization, OwnerForm = this
            };

            wait.Show();
            Anonym();
            foreach (var item in db.Admins)
            {
                if (item.login.Equals(SecurityLogin) && item.password.Equals(SecurityPassword))
                {
                    var person     = db.TypePersons.FirstOrDefault(x => x.Id == item.type);
                    var personname = db.Admins.FirstOrDefault(x => x.id == item.id);

                    Menu men = new TizimNuuz.Menu(personname.FIO, person.Type, person.Id);

                    men.ShowDialog();
                }
                else if (ktbLogin.Text == null || ktbLogin.Text == "" || ktbPassword.Text == null || ktbPassword.Text == "")
                {
                    MessageBox.Show(Texts.FieldIsEmpty);
                }
                else
                {
                    MessageBox.Show(Texts.FailedToAuthenticateToServer);
                }
            }
            wait.Close();
            wait.Dispose();
        }
Esempio n. 2
0
        async void button1_Click(object sender, EventArgs e)
        {
            var wait = new WaitForm {
                Status = Texts.Searching, OwnerForm = this
            };

            wait.Show();
            typePersonBindingSource.DataSource = db.TypePersons.ToList();

            switch ((int)cmbsearch.SelectedIndex)
            {
            case 0:
            {
                BindingSource bs     = new BindingSource();
                List <Admin>  admins = db.Admins.ToList();

                bs.DataSource            = admins;
                dataGridView1.DataSource = bs.DataSource;


                #region MyRegion


                //foreach (var item in admins)
                //{


                //    item.TypePerson.Type = db.TypePersons.FirstOrDefault(x => x.Id == item.id).Type;
                //    dataGridView1.Columns["TypePerson"].DataPropertyName = item.TypePerson.Type;



                //}
                // dataGridView1.Columns.Remove(dataGridView1.Columns["type"]);


                //foreach (DataGridViewColumn item in dataGridView1.Columns)
                //{

                //    item.ValueType = typeof(string);



                //}
                //  DataColumn dv = new DataColumn("Type");

                //dataGridView1.Columns["type"].Visible = false;
                //dataGridView1.Columns["TypePerson"].Visible = false;
                //DataGridViewComboBoxColumn cmbCol = new DataGridViewComboBoxColumn();
                //cmbCol.HeaderText = "Type";
                //cmbCol.Name = "typePerson";
                //cmbCol.Items.Add("True");
                //cmbCol.DataSource = db.TypePersons.ToList();
                //cmbCol.ValueMember = "id";
                //cmbCol.DisplayMember = "type";
                //dataGridView1.Columns.Add(cmbCol);
                //  dataGridView1.Columns["myComboColumn"].DisplayIndex = "at any index that you want";

                //foreach (DataGridViewRow row in dataView.Rows)
                //{
                //    row.Cells["myComboColumn"].Value = row.Cells["yourColumn"].Value;
                //}



                //((DataGridViewComboBoxColumn)dataGridView1.Columns["type"]).DataSource = db.TypePersons.ToList();
                //((DataGridViewComboBoxColumn)dataGridView1.Columns["type"]).DisplayMember = "id";
                //((DataGridViewComboBoxColumn)dataGridView1.Columns["type"]).ValueMember = "type";
                #endregion
                break;
            }

            case 1:
            {
                BindingSource bs = new BindingSource();
                bs.DataSource            = db.TeachersUZMUs.ToList();
                dataGridView1.DataSource = bs.DataSource; break;
            }

            case 2:
            {
                BindingSource bs = new BindingSource();
                bs.DataSource            = db.EduCoursesLists.ToList();
                dataGridView1.DataSource = bs.DataSource; break;
            }

            case 3:
            {
                BindingSource bs = new BindingSource();
                bs.DataSource = db.TypePersons.ToList();

                dataGridView1.DataSource = bs.DataSource; break;
            }

            default:
                break;
            }
            wait.Close();
            wait.Dispose();
        }