📄 customer.cs.svn-base
字号:
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//请先添加引用
namespace Maticsoft.DAL
{
/// <summary>
/// 数据访问类Customer。
/// </summary>
public class Customer
{
public Customer()
{}
#region 成员方法
/// <summary>
/// 是否存在该记录
/// </summary>
public bool Exists(string CustomerID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from Customer");
strSql.Append(" where CustomerID=@CustomerID ");
SqlParameter[] parameters = {
new SqlParameter("@CustomerID", SqlDbType.NVarChar,50)};
parameters[0].Value = CustomerID;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
/// <summary>
/// 增加一条数据
/// </summary>
public void Add(Maticsoft.Model.Customer model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into Customer(");
strSql.Append("CustomerID,CustomerName,SpecCode,LinkMan,Phone,Fax,Address,AccountBak,AccountNo,RegionID,Email,QQ,MSN,Password,LogInID,IsActive)");
strSql.Append(" values (");
strSql.Append("@CustomerID,@CustomerName,@SpecCode,@LinkMan,@Phone,@Fax,@Address,@AccountBak,@AccountNo,@RegionID,@Email,@QQ,@MSN,@Password,@LogInID,@IsActive)");
SqlParameter[] parameters = {
new SqlParameter("@CustomerID", SqlDbType.NVarChar,12),
new SqlParameter("@CustomerName", SqlDbType.NVarChar,100),
new SqlParameter("@SpecCode", SqlDbType.NVarChar,50),
new SqlParameter("@LinkMan", SqlDbType.NVarChar,20),
new SqlParameter("@Phone", SqlDbType.NVarChar,20),
new SqlParameter("@Fax", SqlDbType.NVarChar,20),
new SqlParameter("@Address", SqlDbType.NVarChar,50),
new SqlParameter("@AccountBak", SqlDbType.NVarChar,50),
new SqlParameter("@AccountNo", SqlDbType.NVarChar,30),
new SqlParameter("@RegionID", SqlDbType.NVarChar,12),
new SqlParameter("@Email", SqlDbType.NVarChar,30),
new SqlParameter("@QQ", SqlDbType.NVarChar,20),
new SqlParameter("@MSN", SqlDbType.NVarChar,20),
new SqlParameter("@Password", SqlDbType.NVarChar,20),
new SqlParameter("@LogInID", SqlDbType.NVarChar,20),
new SqlParameter("@IsActive", SqlDbType.Bit,1)};
parameters[0].Value = model.CustomerID;
parameters[1].Value = model.CustomerName;
parameters[2].Value = model.SpecCode;
parameters[3].Value = model.LinkMan;
parameters[4].Value = model.Phone;
parameters[5].Value = model.Fax;
parameters[6].Value = model.Address;
parameters[7].Value = model.AccountBak;
parameters[8].Value = model.AccountNo;
parameters[9].Value = model.RegionID;
parameters[10].Value = model.Email;
parameters[11].Value = model.QQ;
parameters[12].Value = model.MSN;
parameters[13].Value = model.Password;
parameters[14].Value = model.LogInID;
parameters[15].Value = model.IsActive;
DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 更新一条数据
/// </summary>
public void Update(Maticsoft.Model.Customer model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update Customer set ");
strSql.Append("CustomerName=@CustomerName,");
strSql.Append("SpecCode=@SpecCode,");
strSql.Append("LinkMan=@LinkMan,");
strSql.Append("Phone=@Phone,");
strSql.Append("Fax=@Fax,");
strSql.Append("Address=@Address,");
strSql.Append("AccountBak=@AccountBak,");
strSql.Append("AccountNo=@AccountNo,");
strSql.Append("RegionID=@RegionID,");
strSql.Append("Email=@Email,");
strSql.Append("QQ=@QQ,");
strSql.Append("MSN=@MSN,");
strSql.Append("Password=@Password,");
strSql.Append("LogInID=@LogInID,");
strSql.Append("IsActive=@IsActive");
strSql.Append(" where CustomerID=@CustomerID ");
SqlParameter[] parameters = {
new SqlParameter("@CustomerID", SqlDbType.NVarChar,12),
new SqlParameter("@CustomerName", SqlDbType.NVarChar,100),
new SqlParameter("@SpecCode", SqlDbType.NVarChar,50),
new SqlParameter("@LinkMan", SqlDbType.NVarChar,20),
new SqlParameter("@Phone", SqlDbType.NVarChar,20),
new SqlParameter("@Fax", SqlDbType.NVarChar,20),
new SqlParameter("@Address", SqlDbType.NVarChar,50),
new SqlParameter("@AccountBak", SqlDbType.NVarChar,50),
new SqlParameter("@AccountNo", SqlDbType.NVarChar,30),
new SqlParameter("@RegionID", SqlDbType.NVarChar,12),
new SqlParameter("@Email", SqlDbType.NVarChar,30),
new SqlParameter("@QQ", SqlDbType.NVarChar,20),
new SqlParameter("@MSN", SqlDbType.NVarChar,20),
new SqlParameter("@Password", SqlDbType.NVarChar,20),
new SqlParameter("@LogInID", SqlDbType.NVarChar,20),
new SqlParameter("@IsActive", SqlDbType.Bit,1)};
parameters[0].Value = model.CustomerID;
parameters[1].Value = model.CustomerName;
parameters[2].Value = model.SpecCode;
parameters[3].Value = model.LinkMan;
parameters[4].Value = model.Phone;
parameters[5].Value = model.Fax;
parameters[6].Value = model.Address;
parameters[7].Value = model.AccountBak;
parameters[8].Value = model.AccountNo;
parameters[9].Value = model.RegionID;
parameters[10].Value = model.Email;
parameters[11].Value = model.QQ;
parameters[12].Value = model.MSN;
parameters[13].Value = model.Password;
parameters[14].Value = model.LogInID;
parameters[15].Value = model.IsActive;
DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 删除一条数据
/// </summary>
public void Delete(string CustomerID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete Customer ");
strSql.Append(" where CustomerID=@CustomerID ");
SqlParameter[] parameters = {
new SqlParameter("@CustomerID", SqlDbType.NVarChar,50)};
parameters[0].Value = CustomerID;
DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public Maticsoft.Model.Customer GetModel(string CustomerID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select CustomerID,CustomerName,SpecCode,LinkMan,Phone,Fax,Address,AccountBak,AccountNo,RegionID,Email,QQ,MSN,Password,LogInID,IsActive from Customer ");
strSql.Append(" where CustomerID=@CustomerID ");
SqlParameter[] parameters = {
new SqlParameter("@CustomerID", SqlDbType.NVarChar,50)};
parameters[0].Value = CustomerID;
Maticsoft.Model.Customer model=new Maticsoft.Model.Customer();
DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
if(ds.Tables[0].Rows.Count>0)
{
model.CustomerID=ds.Tables[0].Rows[0]["CustomerID"].ToString();
model.CustomerName=ds.Tables[0].Rows[0]["CustomerName"].ToString();
model.SpecCode=ds.Tables[0].Rows[0]["SpecCode"].ToString();
model.LinkMan=ds.Tables[0].Rows[0]["LinkMan"].ToString();
model.Phone=ds.Tables[0].Rows[0]["Phone"].ToString();
model.Fax=ds.Tables[0].Rows[0]["Fax"].ToString();
model.Address=ds.Tables[0].Rows[0]["Address"].ToString();
model.AccountBak=ds.Tables[0].Rows[0]["AccountBak"].ToString();
model.AccountNo=ds.Tables[0].Rows[0]["AccountNo"].ToString();
model.RegionID=ds.Tables[0].Rows[0]["RegionID"].ToString();
model.Email=ds.Tables[0].Rows[0]["Email"].ToString();
model.QQ=ds.Tables[0].Rows[0]["QQ"].ToString();
model.MSN=ds.Tables[0].Rows[0]["MSN"].ToString();
model.Password=ds.Tables[0].Rows[0]["Password"].ToString();
model.LogInID=ds.Tables[0].Rows[0]["LogInID"].ToString();
if(ds.Tables[0].Rows[0]["IsActive"].ToString()!="")
{
if((ds.Tables[0].Rows[0]["IsActive"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsActive"].ToString().ToLower()=="true"))
{
model.IsActive=true;
}
else
{
model.IsActive=false;
}
}
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select CustomerID,CustomerName,SpecCode,LinkMan,Phone,Fax,Address,AccountBak,AccountNo,RegionID,Email,QQ,MSN,Password,LogInID,IsActive ");
strSql.Append(" FROM Customer ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.Query(strSql.ToString());
}
/*
/// <summary>
/// 分页获取数据列表
/// </summary>
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
{
SqlParameter[] parameters = {
new SqlParameter("@tblName", SqlDbType.VarChar, 255),
new SqlParameter("@fldName", SqlDbType.VarChar, 255),
new SqlParameter("@PageSize", SqlDbType.Int),
new SqlParameter("@PageIndex", SqlDbType.Int),
new SqlParameter("@IsReCount", SqlDbType.Bit),
new SqlParameter("@OrderType", SqlDbType.Bit),
new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
};
parameters[0].Value = "Customer";
parameters[1].Value = "ID";
parameters[2].Value = PageSize;
parameters[3].Value = PageIndex;
parameters[4].Value = 0;
parameters[5].Value = 0;
parameters[6].Value = strWhere;
return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
}*/
#endregion 成员方法
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -