コード例 #1
0
        //Ctategory search button
        private void Categorysearch_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 != "")
                {
                    obj.CategoryId   = textBox1.Text;
                    obj.CategoryName = textBox2.Text;

                    //  ExecuteNonQuery() if worked return value=truee return value=0 CtegoryClass in BusinessLayer
                    if (obj.CategorySearch() == 1)
                    {
                        textBox1.Text = obj.CategoryId;
                        textBox2.Text = obj.CategoryName;
                    }
                    else
                    {
                        MessageBox.Show("---Can not  Search category  !---");
                    }
                }
                else
                {
                    MessageBox.Show("---please enter values !---");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("---ERROR IN SQL CONNECTION---" + '\n' + ex);
            }
        }