private void btnok_Click(object sender, EventArgs e) { Brandform ChangeBrandfrm = (Brandform)this.Owner; string id = Convert.ToString(ChangeBrandfrm.dgvbrand.Rows[ChangeBrandfrm.dgvbrand.CurrentRow.Index].Cells["id"].Value); string txtQueryChangeClass = "UPDATE Brand SET name='" + txtnamebrand.Text + "' WHERE id='" + id + "'"; _SQl.SQL_Query(txtQueryChangeClass); this.Close(); ChangeBrandfrm.load_brand(); }
private void торговаяМаркаToolStripMenuItem_Click(object sender, EventArgs e) { // проверяем не запущена ли форма for (int x = 0; x < this.MdiChildren.Length; x++) { if (this.MdiChildren[x].Name == "Brandform") { this.MdiChildren[x].Focus(); return; } } // Запускаем форму если она не запущена Form Brandform = new Brandform(); Brandform.StartPosition = FormStartPosition.CenterScreen; Brandform.WindowState = FormWindowState.Maximized; //указываем владельца для формы Brandform.MdiParent = this; // где containerInstance - это экземпляр контейнера или указатель на MainForm Brandform.Show(); AttachAsMDIChild(Brandform); }
private void btnok_Click(object sender, EventArgs e) { Brandform NewBrandfrm = (Brandform)this.Owner; DataTable DTnbrand = _SQl.ExecuteSQL("SELECT max(id) FROM Brand"); if (DTnbrand.Rows[0][0].ToString() == "") { int id_brandn = 1; string txtQueryNewBrandAdd = "INSERT INTO Brand VALUES('" + id_brandn + "','" + txtnamebrand.Text + "')"; _SQl.SQL_Query(txtQueryNewBrandAdd); } else { int id_brandn = Convert.ToInt32(DTnbrand.Rows[0][0].ToString()) + 1; string txtQueryNewBrandAdd = "INSERT INTO Brand VALUES('" + id_brandn + "','" + txtnamebrand.Text + "')"; _SQl.SQL_Query(txtQueryNewBrandAdd); } this.Close(); NewBrandfrm.load_brand(); }
private void ChangeBrandform_Load(object sender, EventArgs e) { Brandform ChangeBrandfrm = (Brandform)this.Owner; txtnamebrand.Text = Convert.ToString(ChangeBrandfrm.dgvbrand.Rows[ChangeBrandfrm.dgvbrand.CurrentRow.Index].Cells["name"].Value); }