private void button1_Click(object sender, EventArgs e)
        {
            //单击按钮后添加规则  根据textbox1-4
            //若想在规则列表中看到返回再进
            Rule rule = new Rule(Convert.ToInt32(textBox1.Text.Trim()),
                                 Convert.ToInt32(textBox2.Text.Trim()),
                                 Convert.ToInt32(textBox3.Text.Trim()),
                                 Convert.ToInt32(textBox4.Text.Trim()),
                                 Convert.ToInt32(textBox5.Text.Trim()),
                                 Convert.ToInt32(textBox6.Text.Trim()),
                                 Convert.ToInt32(textBox7.Text.Trim()),
                                 Convert.ToInt32(textBox8.Text.Trim()),
                                 Convert.ToInt32(textBox9.Text.Trim()),
                                 Convert.ToInt32(textBox10.Text.Trim()),
                                 Convert.ToInt32(textBox11.Text.Trim()),
                                 Convert.ToInt32(textBox12.Text.Trim()),
                                 Convert.ToInt32(textBox13.Text.Trim())
                                 );

            IOStream iOStream = new IOStream();

            Static.rule_index.Add(rule);
            iOStream.write_rule(rule);
            ad_ch_success ad_Ch_Success = new ad_ch_success();

            ad_Ch_Success.Show();
        }
        private void button3_Click_1(object sender, EventArgs e)
        {
            Query_history query_History;
            Rule          rule;
            string        ACTION;
            IOStream      iOStream = new IOStream();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value) == 0)
                {
                    ACTION = "add_access";
                }
                else
                {
                    ACTION = "remove_access";
                }
                Hang hang = new Hang
                                (Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[6].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[7].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[8].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[9].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[10].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[11].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[12].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[13].Value),
                                Convert.ToInt32(dataGridView1.Rows[i].Cells[14].Value),
                                Convert.ToDateTime(dataGridView1.Rows[i].Cells[3].Value));


                query_History = new Query_history(ACTION, hang.TARGET_NAME, hang.PERSON_BUSINESS_TITLE, hang.PERSON_BUSINESS_TITLE_DETAIL, hang.PERSON_COMPANY, hang.PERSON_DEPTNAME, hang.PERSON_JOB_CODE, hang.PERSON_JOB_FAMILY,
                                                  hang.PERSON_LOCATION, hang.PERSON_MGR_ID, hang.PERSON_ROLLUP_1, hang.PERSON_ROLLUP_2, hang.PERSON_ROLLUP_3, hang.REQUEST_DATE); //构造函数
                Static.query_history_index.Add(query_History);
                iOStream.write_query(query_History);

                rule = new Rule(Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value), hang.TARGET_NAME, hang.PERSON_BUSINESS_TITLE, hang.PERSON_BUSINESS_TITLE_DETAIL, hang.PERSON_COMPANY, hang.PERSON_DEPTNAME, hang.PERSON_JOB_CODE, hang.PERSON_JOB_FAMILY,
                                hang.PERSON_LOCATION, hang.PERSON_MGR_ID, hang.PERSON_ROLLUP_1, hang.PERSON_ROLLUP_2, hang.PERSON_ROLLUP_3); //构造函数
                Static.rule_index.Add(rule);
                iOStream.write_rule(rule);
            }

            this.dataGridView1.Rows.Clear();
            ad_ch_success form = new ad_ch_success();

            form.Show();
        }
示例#3
0
        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.Columns[e.ColumnIndex].Name == "btnMDF" && e.RowIndex >= 0)  //单击修改
            {
                Rule rule = new Rule(Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[1].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[3].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[4].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[5].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[6].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[7].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[8].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[9].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[10].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[11].Value),
                                     Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[12].Value));

                Static.rule_index.RemoveAt(e.RowIndex);
                Static.rule_index.Add(rule);
                IOStream   iOStream = new IOStream();
                string     filepath = "..\\..\\rule.csv"; // 文件路径
                FileStream fs       = new FileStream(filepath, FileMode.Create);
                fs.Close();
                for (int i = 0; i < Static.rule_index.Count; i++)
                {
                    Rule now = (Rule)Static.rule_index[i];
                    iOStream.write_rule(now);
                }

                ad_ch_success form = new ad_ch_success();
                form.Show();
            }
            if (dataGridView1.Columns[e.ColumnIndex].Name == "btnDELETE" && e.RowIndex >= 0)  //单击删除
            {
                IOStream   iOStream = new IOStream();
                string     filepath = "..\\..\\rule.csv"; // 文件路径
                FileStream fs       = new FileStream(filepath, FileMode.Create);
                fs.Close();
                int index = -1;
                for (int i = 0; i < Static.rule_index.Count; i++)
                {
                    Rule now = (Rule)Static.rule_index[i];
                    if (now.ACTION == (int)dataGridView1.Rows[e.RowIndex].Cells[0].Value &&
                        now.TARGET_NAME == (int)dataGridView1.Rows[e.RowIndex].Cells[1].Value &&
                        now.PERSON_BUSINESS_TITLE == (int)dataGridView1.Rows[e.RowIndex].Cells[2].Value &&
                        now.PERSON_BUSINESS_TITLE_DETAIL == (int)dataGridView1.Rows[e.RowIndex].Cells[3].Value &&
                        now.PERSON_COMPANY == (int)dataGridView1.Rows[e.RowIndex].Cells[4].Value &&
                        now.PERSON_DEPTNAME == (int)dataGridView1.Rows[e.RowIndex].Cells[5].Value &&
                        now.PERSON_JOB_CODE == (int)dataGridView1.Rows[e.RowIndex].Cells[6].Value &&
                        now.PERSON_JOB_FAMILY == (int)dataGridView1.Rows[e.RowIndex].Cells[7].Value &&
                        now.PERSON_LOCATION == (int)dataGridView1.Rows[e.RowIndex].Cells[8].Value &&
                        now.PERSON_MGR_ID == (int)dataGridView1.Rows[e.RowIndex].Cells[9].Value &&
                        now.PERSON_ROLLUP_1 == (int)dataGridView1.Rows[e.RowIndex].Cells[10].Value &&
                        now.PERSON_ROLLUP_2 == (int)dataGridView1.Rows[e.RowIndex].Cells[11].Value &&
                        now.PERSON_ROLLUP_3 == (int)dataGridView1.Rows[e.RowIndex].Cells[12].Value)
                    {
                        index = i;
                    }
                    else
                    {
                        iOStream.write_rule(now);
                    }
                }
                if (index != -1)
                {
                    Static.rule_index.RemoveAt(index);
                }
                else
                {
                    System.Console.WriteLine("NOT FOUND");
                }

                ad_ch_success form = new ad_ch_success();
                form.Show();
            }


            this.dataGridView1.Rows.Clear();
            for (int i = 0; i < Static.rule_index.Count; i++)
            {
                Rule query_out_his = (Rule)Static.rule_index[i];


                int index = this.dataGridView1.Rows.Add();

                this.dataGridView1.Rows[index].Cells[0].Value  = query_out_his.ACTION;      //授权结果
                this.dataGridView1.Rows[index].Cells[1].Value  = query_out_his.TARGET_NAME; //资源名称
                this.dataGridView1.Rows[index].Cells[2].Value  = query_out_his.PERSON_BUSINESS_TITLE;
                this.dataGridView1.Rows[index].Cells[3].Value  = query_out_his.PERSON_BUSINESS_TITLE_DETAIL;
                this.dataGridView1.Rows[index].Cells[4].Value  = query_out_his.PERSON_COMPANY;
                this.dataGridView1.Rows[index].Cells[5].Value  = query_out_his.PERSON_DEPTNAME;
                this.dataGridView1.Rows[index].Cells[6].Value  = query_out_his.PERSON_JOB_CODE;
                this.dataGridView1.Rows[index].Cells[7].Value  = query_out_his.PERSON_JOB_FAMILY;
                this.dataGridView1.Rows[index].Cells[8].Value  = query_out_his.PERSON_LOCATION;
                this.dataGridView1.Rows[index].Cells[9].Value  = query_out_his.PERSON_MGR_ID;
                this.dataGridView1.Rows[index].Cells[10].Value = query_out_his.PERSON_ROLLUP_1;
                this.dataGridView1.Rows[index].Cells[11].Value = query_out_his.PERSON_ROLLUP_2;
                this.dataGridView1.Rows[index].Cells[12].Value = query_out_his.PERSON_ROLLUP_3;
            }
        }