ProductSet.cs

using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data.SqlClient;
using System.Reflection;

namespace ProductManager.Model
{
    /*
     *声明一个强类型化的 DataContext 将所有 Table 集合声明为上下文的成员。
     *GetTable<TEntity>()是查询的主入口点。当创建强类型的 DataContext 时,
     *新生成的 TEntitys 属性会封装对此方法的调用。
     */
    [Database(Name = "ProductSet")]
    public partial class ProductSet : DataContext
    {
        public Table<Client> Client; // base.GetTable<Client>()
        public Table<ProductType> ProductType; // base.GetTable<ProductType>()
        public ProductSet(SqlConnection sql) : base(sql) { }

        #region ProductType 存储过程
        private void InsertProductType(ProductType obj)
        {
            this.InsertProductType(obj.TypeID, obj.TypeName);
        }

        private void UpdateProductType(ProductType obj)
        {
            this.UpdateProductType(obj.TypeID, obj.TypeName);
        }

        private void DeleteProductType(ProductType obj)
        {
            this.DeleteProductType(obj.TypeID);
        }

        [Function(Name = "dbo.InsertProductType")]
        public int InsertProductType([Parameter(Name = "TypeID", DbType = "VarChar(10)")] string typeID, [Parameter(Name = "TypeName", DbType = "VarChar(20)")] string typeName)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), typeID, typeName);
            return ((int)(result.ReturnValue));
        }

        [Function(Name = "dbo.UpdateProductType")]
        public int UpdateProductType([Parameter(Name = "TypeID", DbType = "VarChar(10)")] string typeID, [Parameter(Name = "TypeName", DbType = "VarChar(20)")] string typeName)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), typeID, typeName);
            return ((int)(result.ReturnValue));
        }

        [Function(Name = "dbo.DeleteProductType")]
        public int DeleteProductType([Parameter(Name = "TypeID", DbType = "VarChar(10)")] string typeID)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), typeID);
            return ((int)(result.ReturnValue));
        }
        #endregion

        #region Client 存储过程
        private void InsertClient(Client obj)
        {
            this.Insert_Client(obj.ClientID, obj.ClientName, obj.Linkman, obj.LinkPhone, obj.Fax, obj.Email, obj.Address, obj.Memo);
        }

        private void UpdateClient(Client obj)
        {
            this.Update_Client(obj.ClientID, obj.ClientName, obj.Linkman, obj.LinkPhone, obj.Fax, obj.Email, obj.Address, obj.Memo);
        }

        private void DeleteClient(Client obj)
        {
            this.Delete_Client(obj.ClientID);
        }

        [Function(Name = "dbo.Insert_Client")]
        public int Insert_Client([Parameter(Name = "ClientID", DbType = "VarChar(10)")] string clientID, [Parameter(Name = "ClientName", DbType = "VarChar(20)")] string clientName, [Parameter(Name = "Linkman", DbType = "VarChar(20)")] string linkman, [Parameter(Name = "LinkPhone", DbType = "VarChar(15)")] string linkPhone, [Parameter(Name = "Fax", DbType = "VarChar(15)")] string fax, [Parameter(Name = "Email", DbType = "VarChar(30)")] string email, [Parameter(Name = "Address", DbType = "NVarChar(100)")] string address, [Parameter(Name = "Memo", DbType = "NVarChar(50)")] string memo)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), clientID, clientName, linkman, linkPhone, fax, email, address, memo);
            return ((int)(result.ReturnValue));
        }

        [Function(Name = "dbo.Update_Client")]
        public int Update_Client([Parameter(Name = "ClientID", DbType = "VarChar(10)")] string clientID, [Parameter(Name = "ClientName", DbType = "VarChar(20)")] string clientName, [Parameter(Name = "Linkman", DbType = "VarChar(20)")] string linkman, [Parameter(Name = "LinkPhone", DbType = "VarChar(15)")] string linkPhone, [Parameter(Name = "Fax", DbType = "VarChar(15)")] string fax, [Parameter(Name = "Email", DbType = "VarChar(30)")] string email, [Parameter(Name = "Address", DbType = "NVarChar(100)")] string address, [Parameter(Name = "Memo", DbType = "NVarChar(50)")] string memo)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), clientID, clientName, linkman, linkPhone, fax, email, address, memo);
            return ((int)(result.ReturnValue));
        }

        [Function(Name = "dbo.Delete_Client")]
        public int Delete_Client([Parameter(Name = "ClientID", DbType = "VarChar(10)")] string clientID)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), clientID);
            return ((int)(result.ReturnValue));
        }
        #endregion
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值