Ejemplo n.º 1
0
        public void GetTable()
        {
            this.dataGridView1.Rows.Clear();
            w_client.OperationChangesRef.Person p = new w_client.OperationChangesRef.Person();
            p.tableName = "data_base.persons";
            List <object> list = GetL(p);

            foreach (object person_ in list)
            {
                Person obj = (Person)person_;
                if (obj.WasDel != 1)
                {
                    this.dataGridView1.Rows.Add(obj.ID_person, obj.surname, obj.name, obj.middle_name, "Привилегии");
                }
            }

            this.dataGridView2.Rows.Clear();
            w_client.OperationChangesRef.Group_ g = new w_client.OperationChangesRef.Group_();
            g.tableName = "data_base.groups";
            List <object> gr = GetL(g);

            foreach (object g_ in gr)
            {
                Group_ v = (Group_)g_;
                this.dataGridView2.Rows.Add(v.ID_group, v.name, "Привилегии");
            }
        }
Ejemplo n.º 2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentCell.ColumnIndex == 4)
            {
                person personForm = new person();
                personForm.button1.Hide();
                personForm.textBox1.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
                personForm.textBox2.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
                personForm.textBox3.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
                personForm.textBox4.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();

                w_client.OperationChangesRef.Person p = new w_client.OperationChangesRef.Person();
                p.ID_person = Convert.ToInt16(this.dataGridView1.CurrentRow.Cells[0].Value);
                p.tableName = "data_base.persons";
                List <object> pn = GetL(p);
                p = (w_client.OperationChangesRef.Person)pn[0];

                Dictionary <int, string> id_namegr = new Dictionary <int, string>();
                Dictionary <string, int> namegr_id = new Dictionary <string, int>();
                Group_ gr = new Group_();
                gr.tableName = "data_base.groups";
                List <object> g = GetL(gr);
                foreach (object g_ in g)
                {
                    Group_ group = (Group_)g_;
                    personForm.comboBox1.Items.Add(group.name.ToString());
                    id_namegr.Add(group.ID_group, group.name);
                    try
                    {
                        namegr_id.Add(group.name, group.ID_group);
                    }
                    catch { }
                }
                personForm.comboBox1.SelectedIndex = personForm.comboBox1.FindStringExact(id_namegr[p.Groups_ID_Group]);

                Dictionary <int, string> id_privname      = new Dictionary <int, string>();
                w_client.OperationChangesRef.Privilege pg = new w_client.OperationChangesRef.Privilege(); // все существующие привилегии
                pg.tableName = "data_base.privileges";
                List <object> up = GetL(pg);
                List <w_client.OperationChangesRef.Privilege> pl = new List <w_client.OperationChangesRef.Privilege>();
                foreach (object u in up)
                {
                    w_client.OperationChangesRef.Privilege u_ = (w_client.OperationChangesRef.Privilege)u;
                    id_privname.Add(u_.ID_privilege, u_.name_func);
                    pl.Add(u_);
                }

                w_client.OperationChangesRef.Group_Privileges gp = new w_client.OperationChangesRef.Group_Privileges();
                gp.Groups_ID_group = namegr_id[personForm.comboBox1.SelectedItem.ToString()];
                gp.tableName       = "data_base.groups_privileges";
                List <object> grp = GetL(gp);
                List <w_client.OperationChangesRef.Group_Privileges> r = new List <w_client.OperationChangesRef.Group_Privileges>();
                foreach (object g_ in grp)
                {
                    r.Add((w_client.OperationChangesRef.Group_Privileges)g_);
                }


                w_client.OperationChangesRef.Persons_Privileges pp = new w_client.OperationChangesRef.Persons_Privileges();
                pp.Persons_ID_person = Convert.ToInt32(personForm.textBox1.Text);
                pp.tableName         = "data_base.persons_privileges";
                List <object> j = GetL(pp);
                List <w_client.OperationChangesRef.Persons_Privileges> pi = new List <w_client.OperationChangesRef.Persons_Privileges>();
                foreach (object j_ in j)
                {
                    w_client.OperationChangesRef.Persons_Privileges j0 = (w_client.OperationChangesRef.Persons_Privileges)j_;
                    pi.Add(j0);
                }

                foreach (w_client.OperationChangesRef.Persons_Privileges p_p in pi)
                {
                    personForm.dataGridView2.Rows.Add(p_p.Privileges_ID_privilege, id_privname[p_p.Privileges_ID_privilege], true);
                }

                foreach (w_client.OperationChangesRef.Privilege pt in pl)
                {
                    int flag = 0;
                    for (int i = 0; i <= personForm.dataGridView1.RowCount - 1; i++)
                    {
                        if (pt.ID_privilege.ToString() == personForm.dataGridView1.Rows[i].Cells[0].Value.ToString())
                        {
                            flag = 1;
                        }
                    }

                    for (int i = 0; i <= personForm.dataGridView2.RowCount - 1; i++)
                    {
                        if (pt.ID_privilege.ToString() == personForm.dataGridView2.Rows[i].Cells[0].Value.ToString())
                        {
                            flag = 1;
                        }
                    }

                    if (flag == 0)
                    {
                        personForm.dataGridView2.Rows.Add(pt.ID_privilege, id_privname[pt.ID_privilege]);
                    }
                }
                personForm.ShowDialog();
            }
        }