datagridview绑定源3layer

datagridview绑定源3layer

本文介绍了datagridview绑定源3layer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

这个源代码有rine时间错误

plzzzzzzzzzzzzzzzzzzzzzz帮助我

============ ========================

hello
this source code have rine time error
plzzzzzzzzzzzzzzzzzz help me
====================================

namespace project1.DAL.Services
{
    public class CategoryService
    {

        public static void AddCategory(Category category)
        {
            try
            {
                SqlParameter[] pr = null;

                pr = new SqlParameter[1];

                pr[1] = new SqlParameter("@c", System.Data.SqlDbType.NVarChar, 20);
                pr[1].Value = category.CG;
                Data.ExecuteInsertQuery("addcategory", pr);


            }
            catch
            {
                throw;
            }

        }


    }



======== ==============================

BAL

categoryBAL


======================================
BAL
categoryBAL

namespace project1.BAL.Controllers
{
  public  class CategoryBAL
    {
      public  static bool InsertCategory(Category ctg  )
      {

          try
          {
              CategoryService.AddCategory(ctg);

              return true;
          }
          catch
          {

              throw;
          }
      }
    }
}





======= =============================

UI



====================================
UI

private void ADDCATEGORY_Click(object sender, EventArgs e)
       {
           try
           {
               Comman.Entities.Category c1 = new Comman.Entities.Category();
              BAL.Controllers.CategoryBAL.InsertCategory(c1);

               bindingSource1.Add(c1);
               dataGridView1.DataSource = bindingSource1;
               MessageBox.Show("عملیات با موفقیت انجام شد");
this.Close();
           }
           catch (Exception d)
           {

               MessageBox.Show(d.Message, "error");
           }

       }

推荐答案



这篇关于datagridview绑定源3layer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 05:32