Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
        }