当前位置:编程学习 > C#/ASP.NET >>

codesmith生成代码问题

--------------------编程问答-------------------- ------CT_Append_BLL.cs---------------------------------------------------------------------
// =================================================================== 
// Name: DataAccess Factory
// Author: 小华
// DateTime: 2011-07-08
// Description: DataAccess.cs
// =================================================================== 
using System;
using System.Collections.Generic;
using GPOS.Components;
using GPOS.Model;
using GPOS.IDAL;
using GPOS.DALFactory;

namespace GPOS.BLL
{
    public class CT_Append
    {
        private static readonly ICT_Append dal = DataAccess.CreateCT_Append();

        // <summary>
        // 添加充值
        // </summary>
        // <param name="CT_AppendInfo">充值信息</param>
        // <returns></returns>
        public static int Create(CT_AppendInfo _CT_AppendInfo)
        {
            if (_CT_AppendInfo == null)
                return 0;
            else
                return dal.Create(_CT_AppendInfo);

        }


        // <summary>
        // 删除充值记录
        // </summary>
        // <param name="vC_A_SNNO">充值交易序号</param>
        // <returns></returns>
        public static int Remove(string vC_A_SNNO)
        {
                return dal.Remove(vC_A_SNNO);

        }

        // <summary>
        // 根据交易序号获取一条充值信息
        // </summary>
        // <param name="vC_A_SNNO">充值交易序号</param>
        // <returns></returns>
        public static CT_AppendInfo GetById(string vC_A_SNNO)
        {
                return dal.GetById(vC_A_SNNO);

        }

        // <summary>
        // 获取一个分页列表
        // </summary>
        // <param name="TotalRecords">行数</param>
        // <param name="PageIndex">索引</param>
        // <returns></returns>
        public static PageSetInfo Get(int TotalRecords, int PageIndex)
        {
            if (TotalRecords > 0 && PageIndex > 0)
                return dal.Get(TotalRecords, PageIndex);
            else
                return null;
        }


        /// <summary>
        /// 查询充值记录
        /// </summary>
        /// <param name="VC_A_SNNO">充值交易序号</param>
        /// <param name="VC_OC_UserName">客户名称</param> 
        /// <param name="VC_OC_Company">单位</param>
        /// <param name="VC_A_CardNO">卡号</param>
        /// <param name="CardType">卡片类型</param>
        /// <param name="VC_A_AppendType">充值类型</param>
        /// <param name="VC_TicketType">发票类型</param>
        /// <param name="VC_TicketNO">发票编号</param>
        /// <param name="StartDate">开始日期</param>
        /// <param name="EndDate">结束日期</param>
        /// <param name="TotalRecords">每页的条数</param>
        /// <param name="PageIndex">页数</param>
        /// <returns></returns>
        public static PageSetInfo Search(string VC_A_SNNO, string VC_OC_UserName, string 

VC_OC_Company, string VC_A_CardNO, int CardType, string VC_A_AppendType, string VC_TicketType, 

string VC_TicketNO, string StartDate, string EndDate, int TotalRecords, int PageIndex)
        {
            return dal.Search(VC_A_SNNO, VC_OC_UserName, VC_OC_Company, VC_A_CardNO, CardType, 

VC_A_AppendType, VC_TicketType,
                              VC_TicketNO, StartDate, EndDate, TotalRecords, PageIndex);
        }
        /// <summary>
        /// 客户IC卡充值明细报表查询
        /// </summary>
        /// <param name="VC_A_CardNO">客户卡号</param>
        /// <param name="VC_OC_UserName">客户名称</param>
        /// <param name="VC_OC_Company">客户单位</param>
        /// <param name="I_A_CardType">卡片类型</param>
        /// <param name="StartDate">开始日期</param>
        /// <param name="EndDate">结束日期</param>
        /// <param name="TotalRecords">每页的记录数</param>
        /// <param name="PageIndex">当前页数</param>
        /// <returns></returns>
        public static PageSetInfo Search(string VC_A_CardNO, string VC_OC_UserName, string 

VC_OC_Company, int I_A_CardType, string StartDate, string EndDate, int TotalRecords, int 

PageIndex)
        {
            return Search("", VC_OC_UserName, VC_OC_Company, VC_A_CardNO, I_A_CardType, "", "", 

"", StartDate, EndDate, TotalRecords,
                          PageIndex);
        }
    }
} --------------------编程问答-------------------- -----CT_Append_DAL.cs--------------------------------------------------------------------------
// =================================================================== 
// Name: CT_Append Data Layers
// Author: 小华
// DateTime: 2011-07-08
// Description: CT_Append.cs
// =================================================================== 
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using GPOS.Components;
using GPOS.Model;
using GPOS.IDAL;

namespace GPOS.DAL
{
    public class CT_Append : ICT_Append
    {
        private readonly string connectionString = ForumConfig.ReadConfigInfo().DataBase;

        // <summary>
        // Create a records
        // </summary>
        // <param name="CT_AppendInfo">Model::CT_AppendInfo</param>
        // <returns></returns>
        public int Create(CT_AppendInfo _CT_AppendInfo)
        {
            int ret = -1;
            SqlConnection myConnection = new SqlConnection(connectionString);
            SqlCommand myCommand = new SqlCommand("CT_Append_Create", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add("@VC_A_SNNO", SqlDbType.VarChar, 50).Value = 
_CT_AppendInfo.VC_A_SNNO;
            myCommand.Parameters.Add("@VC_A_AppendType", SqlDbType.VarChar, 50).Value = 
_CT_AppendInfo.VC_A_AppendType;
            myCommand.Parameters.Add("@VC_A_CardNO", SqlDbType.VarChar, 50).Value = 
_CT_AppendInfo.VC_A_CardNO;
            myCommand.Parameters.Add("@I_A_CardType", SqlDbType.Int).Value = 
_CT_AppendInfo.I_A_CardType;
            myCommand.Parameters.Add("@I_A_PointToOil", SqlDbType.Int).Value = 

_CT_AppendInfo.I_A_PointToOil;
            myCommand.Parameters.Add("@VC_TicketType", SqlDbType.VarChar, 50).Value = 

_CT_AppendInfo.VC_TicketType;
            myCommand.Parameters.Add("@VC_TicketNO", SqlDbType.VarChar, 50).Value = 

_CT_AppendInfo.VC_TicketNO;
            myCommand.Parameters.Add("@DE_A_BAmount", SqlDbType.Decimal).Value = 
_CT_AppendInfo.DE_A_BAmount;
            myCommand.Parameters.Add("@DE_A_AppendAmount", SqlDbType.Decimal).Value = 
_CT_AppendInfo.DE_A_AppendAmount;
            myCommand.Parameters.Add("@DE_A_AAmount", SqlDbType.Decimal).Value = 
_CT_AppendInfo.DE_A_AAmount;
            myCommand.Parameters.Add("@D_A_AppendDateTime", SqlDbType.DateTime).Value = 
_CT_AppendInfo.D_A_AppendDateTime;
            myCommand.Parameters.Add("@VC_A_Remark", SqlDbType.VarChar, 256).Value = 
_CT_AppendInfo.VC_A_Remark;
            myCommand.Parameters.Add("@VC_A_OperatorNO", SqlDbType.VarChar, 50).Value = 
_CT_AppendInfo.VC_A_OperatorNO;
            myConnection.Open();
            try
            {
                ret = Convert.ToInt32(myCommand.ExecuteScalar());
            }
            catch (Exception ex)
            {
                WriteDataErrLog.WriteDataErrDetail(myCommand, ex.ToString());           
            }
            myConnection.Close();
            return ret;
        }
        // <summary>
        // Delete a records
        // </summary>
        // <param name="vC_A_SNNO">string::vC_A_SNNO</param>
        // <returns></returns>
        public int Remove(string vC_A_SNNO)
        {
            int ret = -1;
            SqlConnection myConnection = new SqlConnection(connectionString);
            SqlCommand myCommand = new SqlCommand("CT_Append_Remove", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add("@VC_A_SNNO", SqlDbType.VarChar).Value = vC_A_SNNO;
            myConnection.Open();
            try
            {
                ret = Convert.ToInt32(myCommand.ExecuteScalar());
            }
            catch (Exception ex)
            {
                WriteDataErrLog.WriteDataErrDetail(myCommand, ex.ToString());
            }
            myConnection.Close();
            return ret;
        }
        // <summary>
        // Get a records
        // </summary>
        // <param name="vC_A_SNNO">string::vC_A_SNNO</param>
        // <returns></returns>
        public CT_AppendInfo GetById(string vC_A_SNNO)
        {
            SqlConnection myConnection = new SqlConnection(connectionString);
            SqlCommand myCommand = new SqlCommand("CT_Append_GetByVC_A_SNNO", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add("@VC_A_SNNO", SqlDbType.VarChar).Value = vC_A_SNNO;
            myConnection.Open();
            CT_AppendInfo _CT_AppendInfo2 = new CT_AppendInfo();
            SqlDataReader dr = myCommand.ExecuteReader();

            while (dr.Read())
                _CT_AppendInfo2 = Populate(dr);
            dr.Close();
            myConnection.Close();
            return _CT_AppendInfo2;
        }
        // <summary>
        // Get List
        // </summary>
        // <param name="TotalRecords">Int::TotalRecords</param>
        // <param name="PageSize">Int::PageSize</param>
        // <returns></returns>
        public PageSetInfo Get(int TotalRecords, int PageIndex)
        {
            SqlConnection myConnection = new SqlConnection(connectionString);
            SqlCommand myCommand = new SqlCommand("CT_Append_Get", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add("@TotalRecords", SqlDbType.Int).Value = TotalRecords;
            myCommand.Parameters.Add("@PageIndex", SqlDbType.Int).Value = PageIndex;
            myConnection.Open();
            PageSetInfo _CT_AppendSetInfo = new PageSetInfo();
            try
            {
                SqlDataReader dr = myCommand.ExecuteReader();
                while (dr.Read())
                    _CT_AppendSetInfo.CT_AppendInfo.Add(Populate(dr));
                dr.NextResult();
                while (dr.Read())
                    _CT_AppendSetInfo.TotalRecords = Convert.ToInt32(dr["TotalRecords"]);
                dr.Close();
            }
            catch (Exception ex)
            {
                WriteDataErrLog.WriteDataErrDetail(myCommand, ex.ToString());
            }

            myConnection.Close();
            return _CT_AppendSetInfo;
        }
        /// <summary>
        /// 查询充值记录
        /// </summary>
        /// <param name="VC_A_SNNO">充值交易序号</param>
        /// <param name="VC_OC_UserName">客户名称</param> 
        /// <param name="VC_OC_Company">单位</param>
        /// <param name="VC_A_CardNO">卡号</param>
        /// <param name="CardType">卡片类型</param>
        /// <param name="VC_A_AppendType">充值类型</param>
        /// <param name="VC_TicketType">发票类型</param>
        /// <param name="VC_TicketNO">发票编号</param>
        /// <param name="StartDate">开始日期</param>
        /// <param name="EndDate">结束日期</param>
        /// <param name="TotalRecords">每页的条数</param>
        /// <param name="PageIndex">页数</param>
        /// <returns></returns>
        public PageSetInfo Search(string VC_A_SNNO,string VC_OC_UserName,string 

VC_OC_Company,string VC_A_CardNO,int CardType,string VC_A_AppendType,string 

VC_TicketType,string VC_TicketNO, string StartDate, string EndDate, int TotalRecords, int 

PageIndex)
        {
            SqlConnection myConnection = new SqlConnection(connectionString);
            SqlCommand myCommand = new SqlCommand("CT_Append_Search", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters.Add("@VC_A_SNNO", SqlDbType.VarChar).Value = VC_A_SNNO;
            myCommand.Parameters.Add("@VC_OC_UserName", SqlDbType.VarChar).Value = 
VC_OC_UserName;
            myCommand.Parameters.Add("@VC_OC_Company", SqlDbType.VarChar).Value = 
VC_OC_Company;
            myCommand.Parameters.Add("@VC_A_CardNO", SqlDbType.VarChar).Value = VC_A_CardNO;
            myCommand.Parameters.Add("@CardType", SqlDbType.Int).Value = CardType;
            myCommand.Parameters.Add("@StartDate", SqlDbType.VarChar).Value = StartDate;
            myCommand.Parameters.Add("@EndDate", SqlDbType.VarChar).Value = EndDate;
            myCommand.Parameters.Add("@TotalRecords", SqlDbType.Int).Value = TotalRecords;
            myCommand.Parameters.Add("@PageIndex", SqlDbType.Int).Value = PageIndex;
            myConnection.Open();
            PageSetInfo _CT_AppendSetInfo = new PageSetInfo();
            try
            {
                SqlDataReader dr = myCommand.ExecuteReader();
                while (dr.Read())
                    _CT_AppendSetInfo.CT_AppendInfo.Add(Populate(dr));
                dr.NextResult();
                while (dr.Read())
                    _CT_AppendSetInfo.TotalRecords = Convert.ToInt32(dr["TotalRecords"]);
                dr.Close();
            }
            catch (Exception ex)
            {
                WriteDataErrLog.WriteDataErrDetail(myCommand, ex.ToString());
            }
            myConnection.Close();
            return _CT_AppendSetInfo;
        }

        private CT_AppendInfo Populate(SqlDataReader dr)
        {
            CT_AppendInfo _CT_AppendInfo = new CT_AppendInfo();
            _CT_AppendInfo.VC_A_SNNO = Convert.ToString(dr["VC_A_SNNO"]);
            _CT_AppendInfo.VC_A_AppendType = Convert.ToString(dr["VC_A_AppendType"]);
            _CT_AppendInfo.VC_A_CardNO = Convert.ToString(dr["VC_A_CardNO"]);
            _CT_AppendInfo.I_A_CardType = Convert.ToInt32(dr["I_A_CardType"]);
            _CT_AppendInfo.I_A_CardTypeName = Filter.CardTypeToStr

(_CT_AppendInfo.I_A_CardType);
            _CT_AppendInfo.I_A_PointToOil = Convert.ToInt32(dr["I_A_PointToOil"]);
            _CT_AppendInfo.VC_TicketType = Convert.ToString(dr["VC_TicketType"]);
            return _CT_AppendInfo;
        }
    }
} --------------------编程问答--------------------

----ICT_Append_IDAL.cs------------------------------------------------------------------------
// =================================================================== 
// Name: The Inte易做图ce of CT_Append
// Author: 小华
// DateTime: 2011-07-08
// Description: ICT_Append.cs
// =================================================================== 
using System;
using System.Collections.Generic;
using GPOS.Model;

namespace GPOS.IDAL
{
    public inte易做图ce ICT_Append
    {
        int Create(CT_AppendInfo _CT_AppendInfo);
        int Remove(string vC_A_SNNO);
        CT_AppendInfo GetById(string vC_A_SNNO);
        PageSetInfo Get(int TotalRecords, int PageIndex);

        PageSetInfo Search(string VC_A_SNNO, string VC_OC_UserName, string VC_OC_Company, 

string VC_A_CardNO, int CardType,
                           string VC_A_AppendType, string VC_TicketType, string VC_TicketNO, 

string StartDate,
                           string EndDate, int TotalRecords, int PageIndex);
    }
}

补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,