//add button CATEGORY private void XuiSuperButton2_Click(object sender, EventArgs e) { try { //value passs to business layer Logclass variable to CategoryClass obj = new CategoryClass(); //check text box empty or not if ((textBox1.Text != "") && (textBox2.Text != "")) { obj.CategoryId = textBox1.Text; obj.CategoryName = textBox2.Text; // ExecuteNonQuery() if worked return value=truee return value=0 CtegoryClass in BusinessLayer if (obj.CategoryAdd() == 1) { MessageBox.Show("---Created new Cateogry---" + obj.CategoryName); } else { MessageBox.Show("---Can not create same category name again !---"); } } else { MessageBox.Show("---please enter values !---"); } } catch (Exception ex) { MessageBox.Show("---ERROR IN SQL CONNECTION---" + '\n' + ex); // Console.WriteLine("---ERROR IN SQL CONNECTION---"); // Console.WriteLine(ex); } }