private void SaveButton_Click(object sender, EventArgs e)
{
contactsTableAdapter.Update(testDataSet);
}
private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
DialogResult dr = MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
if (dr == DialogResult.Cancel)
{
e.Cancel = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
AddForm af = new AddForm();
af.Owner = this;
af.Show();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
public void AddBtn_Click(object sender, EventArgs e)
{
Form1 main = this.Owner as Form1;
if (main != null)
{
DataRow nRow = main.testDataSet.Tables[0].NewRow();
int rc = main.dataGridView1.RowCount + 1;
nRow[0] = rc;
nRow[1] = tbName.Text;
nRow[2] = tbPhone.Text;
nRow[3] = tbMail.Text;
nRow[4] = tbPhoto.Text;
main.testDataSet.Tables[0].Rows.Add(nRow);
main.contactsTableAdapter.Update(main.testDataSet.contacts);
main.testDataSet.Tables[0].AcceptChanges();
main.dataGridView1.Refresh();
tbName.Text = "";
tbPhone.Text = "";
tbMail.Text = "";
tbPhoto.Text = "";
}
}
private void button2_Click(object sender, EventArgs e)
{
SearchForm sf = new SearchForm();
sf.Owner = this;
sf.Show();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 main = this.Owner as Form1;
if (main != null)
{
for (int i = 0; i < main.dataGridView1.RowCount; i++)
{
main.dataGridView1.Rows[i].Selected = false;
for (int j = 0; j < main.dataGridView1.ColumnCount; j++)
if (main.dataGridView1.Rows[i].Cells[j].Value != null)
if (main.dataGridView1.Rows[i].Cells[j].Value.ToString().Contains(tbStr.Text))
{
main.dataGridView1.Rows[i].Selected = true;
break;
}
}
}
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}