随笔 - 87  文章 - 1  评论 - 610  阅读 - 44万

SQL 存储过程封装代码生成器

界面图:

生成的代码如下:(通过sqlHelp封装执行)
using System;
using System.Data.SqlClient;
using System.Data;

namespace Etime.BEP
{
 /// <summary>
 ///  ProjectTask
 /// </summary>
 public class ProjectTask
 {
  public ProjectTask()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }

  #region AddActivityToRole
  /// <summary>
  /// AddActivityToRole
  /// </summary>
  /// <param name="_RoleID"></param>
  /// <param name="_ActivityName"></param>
  /// <returns></returns>
  public static void AddActivityToRole(int _RoleID,string _ActivityName)
  {
   try
   {
    System.Data.SqlClient.SqlParameter[] ps=new SqlParameter[]{
         new SqlParameter("@iv_RoleID",SqlDbType.Int,4),
         new SqlParameter("@iv_ActivityName",SqlDbType.VarChar,50),

                    };
    ps[0].Value =_RoleID;
    ps[1].Value =_ActivityName;

    SqlHelper.ExecuteNonQuery(SqlHelper.CONN_STRING,CommandType.StoredProcedure,"AddActivityToRole",ps);

   }
   catch(System.Data.SqlClient.SqlException ex)
   {
    throw ex;
   }

  }
  #endregion AddActivityToRole

  #region GetUserList
  /// <summary>
  /// GetUserList
  /// </summary>
  /// <returns></returns>
  public static DataSet GetUserList()
  {
   try
   {
    System.Data.SqlClient.SqlParameter[] ps=new SqlParameter[]{

                    };

    
    return SqlHelper.ExecuteDataset(SqlHelper.CONN_STRING,CommandType.StoredProcedure,"GetUserList",ps);

   }
   catch(System.Data.SqlClient.SqlException ex)
   {
    throw ex;
   }

  }
  #endregion GetUserList

  #region updateCharge
  /// <summary>
  /// updateCharge
  /// </summary>
  /// <param name="_typeName"></param>
  /// <param name="_value"></param>
  /// <param name="_ChargeID"></param>
  /// <returns></returns>
  public static void updateCharge(string _typeName,string _value,int _ChargeID)
  {
   try
   {
    System.Data.SqlClient.SqlParameter[] ps=new SqlParameter[]{
         new SqlParameter("@iv_typeName",SqlDbType.VarChar,50),
         new SqlParameter("@iv_value",SqlDbType.VarChar,8),
         new SqlParameter("@iv_ChargeID",SqlDbType.Int,4),

                    };
    ps[0].Value =_typeName;
    ps[1].Value =_value;
    ps[2].Value =_ChargeID;

    SqlHelper.ExecuteNonQuery(SqlHelper.CONN_STRING,CommandType.StoredProcedure,"updateCharge",ps);

   }
   catch(System.Data.SqlClient.SqlException ex)
   {
    throw ex;
   }

  }
  #endregion updateCharge


 }

}



有兴趣联系:edobnet@163.com

posted on   edobnet  阅读(4164)  评论(12编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· [AI/GPT/综述] AI Agent的设计模式综述
< 2004年6月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

点击右上角即可分享
微信分享提示