private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text.Trim())) { MessageBox.Show("Please enter a field name..", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (regex.Checked == true) { if (!types.Text.Trim().Equals("Text (Generic)")) { MessageBox.Show("You cannot have a Custom Regex for any other Field Type than Text (Generic)", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } DialogResult addField = MessageBox.Show("Add field: " + textBox1.Text.Trim(), "Quill", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (addField == DialogResult.Yes) { string fieldName = textBox1.Text.Trim().Replace("'", "").ToUpper(); bool findAllIn = findAll.Checked; string temp = "FALSE"; string fieldType = types.Text.Trim(); if (findAllIn == true) { temp = "TRUE"; } string depupeIN = "TRUE"; if (dedup.Checked == false) { depupeIN = "FALSE"; } string currSymbolOnlyIN = "FALSE"; if (currSymbol.Checked == true) { currSymbolOnlyIN = "TRUE"; } if (findAllIn == true) { Loading ld = new Loading(); ld.Show(); string add = servRef.AddField(Globals.sqlCon, fieldName, fieldType, temp, clientid, secret); if (regex.Checked == true) { if (!string.IsNullOrEmpty(strRegex.Text.Trim())) { servRef.UpdateFieldRegex(Globals.sqlCon, fieldName, strRegex.Text.Trim(), clientid, secret); } } string depDupeOut = servRef.UpdateFieldDeDupe(Globals.sqlCon, fieldName, depupeIN, clientid, secret); if (currSymbolOnlyIN.Equals("TRUE")) { string currSymbolOnly = servRef.UpdateFieldCurrencySymbolOnly(Globals.sqlCon, fieldName, currSymbolOnlyIN, clientid, secret); } ld.Close(); MessageBox.Show("Field: " + fieldName + " Added.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (dgvWords.Rows.Count == 1) { MessageBox.Show("Unless you use Find All, you must enter at least one word.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dgvPhrases.Rows.Count == 1) { MessageBox.Show("Unless you use Find All, you must enter at least one phrase.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Loading ld = new Loading(); ld.Show(); string add = servRef.AddField(Globals.sqlCon, fieldName, fieldType, temp, clientid, secret); foreach (DataGridViewRow word in dgvWords.Rows) { if (word != null) { try { if (!string.IsNullOrEmpty(word.Cells["Word"].Value.ToString().Trim())) { string wordIN = word.Cells["Word"].Value.ToString().Trim(); string forward = word.Cells["Forward"].Value.ToString().Trim(); string backwards = word.Cells["Backward"].Value.ToString().Trim(); string addWord = servRef.UpdateFieldWords(Globals.sqlCon, fieldName, wordIN, clientid, secret, forward, backwards); } } catch { //skip as cannot be added } } } foreach (DataGridViewRow phrase in dgvPhrases.Rows) { if (phrase != null) { try { if (!string.IsNullOrEmpty(phrase.Cells["Phrase"].Value.ToString().Trim())) { string phraseIN = phrase.Cells["Phrase"].Value.ToString().Trim(); string percision = phrase.Cells["Precision"].Value.ToString().Trim(); string addPhrase = servRef.UpdateFieldPhrases(Globals.sqlCon, clientid, secret, fieldName, phraseIN, percision); } } catch { //skip as cannot be added } } } if (regex.Checked == true) { if (!string.IsNullOrEmpty(strRegex.Text.Trim())) { servRef.UpdateFieldRegex(Globals.sqlCon, fieldName, strRegex.Text.Trim(), clientid, secret); } } string depDupeOut = servRef.UpdateFieldDeDupe(Globals.sqlCon, fieldName, depupeIN, clientid, secret); if (currSymbol.Equals("TRUE")) { string currSymbolOnly = servRef.UpdateFieldCurrencySymbolOnly(Globals.sqlCon, fieldName, currSymbolOnlyIN, clientid, secret); } ld.Close(); MessageBox.Show("Field Added.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } }