private void button1_Click_1(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Please insert vendor's name."); } else { DataSet ds = new DataSet(); ds = _sqlSetup.GetData("select Name from Vendor where Name = '" + textBox1.Text + "'", false, null); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("This vendor already exists."); } else { int insert = _sqlSetup.SetData("Insert into Vendor(idVendor, Name) values " + "((Select Top 1 idVendor from Vendor order by idVendor desc) +1,'" + textBox1.Text + "')", false, null); MessageBox.Show("Vendor Added."); this.Close(); AddMedicineStock fm = new AddMedicineStock(); fm.Show(); } } } }
private void button1_Click(object sender, EventArgs e) { stock_added = true; AddMedicineStock frm1 = new AddMedicineStock(); frm1.RefreshDgv += new AddMedicineStock.DoEvent(fm_RefreshDgv); frm1.Show(); }