diff --git a/sql2/Forms/DataForm.Designer.cs b/sql2/Forms/DataForm.Designer.cs index 919f62c..a21ec19 100644 --- a/sql2/Forms/DataForm.Designer.cs +++ b/sql2/Forms/DataForm.Designer.cs @@ -81,6 +81,7 @@ this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(366, 26); this.textBox1.TabIndex = 2; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); // // button1 // @@ -91,6 +92,7 @@ this.button1.TabIndex = 3; this.button1.Text = "Поиск"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // label2 // @@ -141,6 +143,7 @@ this.toolStripButton1.Name = "toolStripButton1"; this.toolStripButton1.Size = new System.Drawing.Size(121, 29); this.toolStripButton1.Text = "Обновить"; + this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); // // toolStripSeparator2 // diff --git a/sql2/Forms/DataForm.cs b/sql2/Forms/DataForm.cs index a1cc5f1..e6fd5b1 100644 --- a/sql2/Forms/DataForm.cs +++ b/sql2/Forms/DataForm.cs @@ -14,6 +14,7 @@ namespace PaymentLogs { public partial class DataForm : Form { + public DataForm() { InitializeComponent(); @@ -59,7 +60,7 @@ namespace PaymentLogs { try { - if(row.Cells.Count > 1) + if(row.Cells.Count > 1 && row.Cells["id"].Value != null) { Payment payment = new Payment { @@ -85,5 +86,54 @@ namespace PaymentLogs } Program.PaymentRepository.Save(); } + + private void button1_Click(object sender, EventArgs e) + { + string FCsText = textBox1.Text; + string CourseText = textBox2.Text; + List> filtredList = new List>(); + foreach (DataGridViewRow row in dataGridView1.Rows) + { + try + { + if(row.Cells["fcs"].Value == null) + { + continue; + } + string FCs = row.Cells["fcs"].Value.ToString(); + string course = row.Cells["course"].Value.ToString(); + if (((FCs.Equals(FCsText)) && (course.Equals(CourseText))) ) + { + List list = new List + { row.Cells["id"].Value.ToString(), row.Cells["fcs"].Value.ToString(), + row.Cells["course"].Value.ToString(), row.Cells["course_price"].Value.ToString(), + row.Cells["paid"].Value.ToString(), row.Cells["debt"].Value.ToString() }; + + filtredList.Add(list); + } + } + catch(Exception ignored) + { + + } + } + dataGridView1.Rows.Clear(); + foreach (List args in filtredList) + { + dataGridView1.Rows.Add(args[0], args[1], args[2], args[3], args[4], args[5]); + } + + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + + } + + private void toolStripButton1_Click(object sender, EventArgs e) + { + dataGridView1.Rows.Clear(); + Form1_Load(null, null); + } } }