private void Addbutton_Click(object sender, EventArgs e) { panel1.Enabled = false; panel2.Enabled = false; panel3.Visible = true; Nametext.ReadOnly = Gorodtext.ReadOnly = Statustext.ReadOnly = Teltext.ReadOnly = Adrestext.ReadOnly = false; Nametext.Text = Gorodtext.Text = Statustext.Text = Teltext.Text = Adrestext.Text = ""; Nametext.Focus(); is_insert = true; }
private void Savebutton_Click(object sender, EventArgs e) { #region if (Nametext.Text.Trim() == "") { MessageBox.Show("Введите название поставщика"); Nametext.Focus(); return; } if (is_insert || !is_insert && oldName != Nametext.Text) { if (dataSet1.postavshiki.Select("nazvanie='" + Nametext.Text + "'").Count() > 0) { MessageBox.Show("Такое поставщик уже существует"); Nametext.Focus(); return; } } if (Gorodtext.Text.Trim() == "") { MessageBox.Show("Введите город поставщика"); Gorodtext.Focus(); return; } if (Statustext.Text.Trim() == "") { MessageBox.Show("Введите статус поставщика"); Statustext.Focus(); return; } if (Adrestext.Text.Trim() == "") { MessageBox.Show("Введите адрес поставщика"); Adrestext.Focus(); return; } if (Teltext.Text.Trim() == "") { MessageBox.Show("Введите телефон поставщика"); Teltext.Focus(); return; } #endregion if (is_insert) { row = dataSet1.postavshiki.NewRow(); //MessageBox.Show(row[0].ToString()); row[1] = Nametext.Text; row[2] = Statustext.Text; row[3] = Gorodtext.Text; row[4] = Adrestext.Text; row[5] = Teltext.Text; dataSet1.postavshiki.Rows.Add(row); } else { String[] vs = { Nametext.Text, Statustext.Text, Gorodtext.Text, Adrestext.Text, Teltext.Text }; row = dataSet1.postavshiki.Rows.Find(((DataRowView)postavshikiBindingSource.Current)[0]); for (int i = 0; i < vs.Length; i++) { row[i + 1] = vs[i]; } } edited.Value = true; panel1.Enabled = true; panel2.Enabled = true; panel3.Visible = false; Nametext.ReadOnly = Gorodtext.ReadOnly = Statustext.ReadOnly = Teltext.ReadOnly = Adrestext.ReadOnly = true; if (is_insert) { postavshikiBindingSource.MoveLast(); } buttons(); }