// Save button private void button1_Click(object sender, EventArgs e) { add_condition.PerformClick(); List <List <string> > Temp_Rule_List = _parent.Get_Rule_List_Public(); for (int i = Temp_Rule_List.Count - 1; i >= 0; i--) { try { if (Temp_Rule_List[i][1] == "DATABASE_INFO") { _parent._GLOBAL_DELETE_FORMAT_RULE("DATABASE_INFO"); } } catch { } } if (db_password.Text.Length > 0 || db_user.Text.Length > 0) { if (db_conn_str.Text.Length > 0 && db_name.Text.Length > 0 && db_password.Text.Length > 0 && db_user.Text.Length > 0) { Modify_Rule("DATABASE_INFO", enc_obj.Encrypt(db_user.Text) + "†" + enc_obj.Encrypt(db_password.Text) + "†" + enc_obj.Encrypt(db_name.Text) + "†" + enc_obj.Encrypt(db_conn_str.Text) ); } else { MessageBox.Show("Database information missing; database information not stored"); } } else { MessageBox.Show("Database information missing; database information not stored"); } _parent._GLOBAL_DELETE_FORMAT_RULE("LEADING_ZEROES"); _parent._GLOBAL_DELETE_FORMAT_RULE("LEADING_LETTER"); _parent._GLOBAL_DELETE_FORMAT_RULE("FIRST_LINE"); _parent._GLOBAL_DELETE_FORMAT_RULE("LAST_LINE"); _parent._GLOBAL_DELETE_FORMAT_RULE("LIST_OF_CONDITIONS"); Modify_Rule("LEADING_ZEROES", count_box.Text); Modify_Rule("LEADING_LETTER", value.Text); Modify_Rule("FIRST_LINE", first_line_box.Text); Modify_Rule("LAST_LINE", last_line_box.Text); // Add conditions OUTPUT_FORMAT_LIST.AddRange(List_of_Conditions); _parent.Rule_List.AddRange(OUTPUT_FORMAT_LIST); _parent._Setup_Rule_List(); this.Close(); this.Dispose(); }
public void Populate_Grid() { this.Size = new Size(952, 122); dataGridView1.Rows.Clear(); for (int i = 0; i < Rule_List.Count(); i++) { if (i >= 22) { Console.WriteLine(); } string p = Rule_List[i][5]; if (p.Contains("[/GRP]")) { int start_index = p.IndexOf("[GRP]"); int end_index = p.IndexOf("[/GRP]") + 6; p = p.Substring(end_index); } if (p.Contains(" bin") || p.Contains("(bin") || p.Contains("IFCHK((") ||// If comment contains ' bin' _parent._Setup_Rule_List(true, i).Contains(" bin") || _parent._Setup_Rule_List(true, i).Contains("(bin") || _parent.COUNT_TOKEN(_parent._Setup_Rule_List(true, i), "%") >= 2) { // showing the original rule line takes precedence to comment if (_parent._Setup_Rule_List(true, i).Contains(" bin") || _parent._Setup_Rule_List(true, i).Contains("(bin") || _parent.COUNT_TOKEN(_parent._Setup_Rule_List(true, i), "%") >= 2) { string g = Parse_Bin_Numbers(_parent._Setup_Rule_List(true, i)); if (g.Contains(textBox1.Text)) { dataGridView1.Rows.Add((i + 1).ToString(), _parent._Setup_Rule_List(true, i), g); } } else if (p.Contains(" bin") || p.Contains("(bin")) { string g = Parse_Bin_Numbers(Rule_List[i][5]); if (g.Contains(textBox1.Text)) { dataGridView1.Rows.Add((i + 1).ToString(), p, g); } } else if (p.Contains("IFCHK((")) { string g = Parse_Bin_Numbers(Rule_List[i][5]); if (g.Contains(textBox1.Text)) { dataGridView1.Rows.Add((i + 1).ToString(), _parent._Setup_Rule_List(true, i), g); } } } else if (Rule_List[i][0] == "FORMAT_RULE" && Rule_List[i][1] == "BIN_ASSIGNMENT") { int count = 0; string[] split_1 = Rule_List[i][2].Split(new string[] { "|" }, StringSplitOptions.None); foreach (string g in split_1) { string[] split_2 = g.Split(new string[] { "~" }, StringSplitOptions.None); if (split_2[0].Contains(textBox1.Text)) { dataGridView1.Rows.Add("10000", "Pre-assigned Value: " + split_2[1] + " (" + split_2[2] + ")", split_2[0]); } count++; int index2 = dataGridView1.Rows.Count - 1; var dataGridViewCellStyle2 = new DataGridViewCellStyle { Padding = new Padding(1000, 0, 0, 0) }; if (index2 >= 0) { dataGridView1.Rows[index2].Cells[0].Style = dataGridViewCellStyle2; dataGridView1.Rows[index2].Cells[0].Style.BackColor = (index2 % 2 == 0 ? System.Drawing.ColorTranslator.FromHtml("#A2D7FF") : System.Drawing.ColorTranslator.FromHtml("#D0EBFF")); dataGridView1.Rows[index2].Cells[1].Style.BackColor = (index2 % 2 == 0 ? System.Drawing.ColorTranslator.FromHtml("#A2D7FF") : System.Drawing.ColorTranslator.FromHtml("#D0EBFF")); dataGridView1.Rows[index2].Cells[2].Style.BackColor = (index2 % 2 == 0 ? System.Drawing.ColorTranslator.FromHtml("#A2D7FF") : System.Drawing.ColorTranslator.FromHtml("#D0EBFF")); } } } int index = dataGridView1.Rows.Count - 1; if (index >= 0) { dataGridView1.Rows[index].Cells[0].Style.BackColor = (index % 2 == 0 ? System.Drawing.ColorTranslator.FromHtml("#A2D7FF") : System.Drawing.ColorTranslator.FromHtml("#D0EBFF")); dataGridView1.Rows[index].Cells[1].Style.BackColor = (index % 2 == 0 ? System.Drawing.ColorTranslator.FromHtml("#A2D7FF") : System.Drawing.ColorTranslator.FromHtml("#D0EBFF")); dataGridView1.Rows[index].Cells[2].Style.BackColor = (index % 2 == 0 ? System.Drawing.ColorTranslator.FromHtml("#A2D7FF") : System.Drawing.ColorTranslator.FromHtml("#D0EBFF")); } } this.Height += dataGridView1.Rows.Count * 20; }