/**  版本信息模板在安装目录下，可自行修改。
* T_Cus_ContactPerson.cs
*
* 功 能： N/A
* 类 名： T_Cus_ContactPerson
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2015/3/5 11:17:53   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using ZXDT.DBUtility;//Please add references
namespace ZXDT.CallCenter.DAL
{
	/// <summary>
	/// 数据访问类:T_Cus_ContactPerson
	/// </summary>
	public partial class T_Cus_ContactPerson
	{
		public T_Cus_ContactPerson()
		{}
		#region  BasicMethod

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("F_ManId", "T_Cus_ContactPerson"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int F_ManId)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from T_Cus_ContactPerson");
			strSql.Append(" where F_ManId=@F_ManId");
			SqlParameter[] parameters = {
					new SqlParameter("@F_ManId", SqlDbType.Int,4)
			};
			parameters[0].Value = F_ManId;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(ZXDT.CallCenter.Model.T_Cus_ContactPerson model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_Cus_ContactPerson(");
            strSql.Append("F_CustomerId,F_CategoryId,F_Name,F_EName,F_IsMain,F_Sex,F_Telephone,F_Mobile,F_Fax,F_Address,F_Email,F_Duty,F_Department,F_QQ,F_MSN,F_IsBirth,F_Birthday,F_BirthType,F_BirthCN,F_BirthCNYear,F_BirthCNMonth,F_BirthCNDay,F_IsSMS,F_SMSContent,F_FirstDate,F_LatelyDate,F_Remark,F_CreateBy,F_CreateOn,F_ModifyBy,F_ModifyOn,F_DeletionStateCode,F_UserAccount,F_Password,F_RoleId)");
			strSql.Append(" values (");
            strSql.Append("@F_CustomerId,@F_CategoryId,@F_Name,@F_EName,@F_IsMain,@F_Sex,@F_Telephone,@F_Mobile,@F_Fax,@F_Address,@F_Email,@F_Duty,@F_Department,@F_QQ,@F_MSN,@F_IsBirth,@F_Birthday,@F_BirthType,@F_BirthCN,@F_BirthCNYear,@F_BirthCNMonth,@F_BirthCNDay,@F_IsSMS,@F_SMSContent,@F_FirstDate,@F_LatelyDate,@F_Remark,@F_CreateBy,@F_CreateOn,@F_ModifyBy,@F_ModifyOn,@F_DeletionStateCode,@F_UserAccount,@F_Password,@F_RoleId)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@F_CustomerId", SqlDbType.Int,4),
					new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
					new SqlParameter("@F_Name", SqlDbType.NVarChar,50),
					new SqlParameter("@F_EName", SqlDbType.NVarChar,50),
					new SqlParameter("@F_IsMain", SqlDbType.Bit,1),
					new SqlParameter("@F_Sex", SqlDbType.VarChar,6),
					new SqlParameter("@F_Telephone", SqlDbType.NVarChar,100),
					new SqlParameter("@F_Mobile", SqlDbType.NVarChar,100),
					new SqlParameter("@F_Fax", SqlDbType.VarChar,100),
					new SqlParameter("@F_Address", SqlDbType.NVarChar,200),
					new SqlParameter("@F_Email", SqlDbType.VarChar,100),
					new SqlParameter("@F_Duty", SqlDbType.VarChar,50),
					new SqlParameter("@F_Department", SqlDbType.NVarChar,50),
					new SqlParameter("@F_QQ", SqlDbType.NVarChar,50),
					new SqlParameter("@F_MSN", SqlDbType.NVarChar,50),
					new SqlParameter("@F_IsBirth", SqlDbType.Bit,1),
					new SqlParameter("@F_Birthday", SqlDbType.DateTime),
					new SqlParameter("@F_BirthType", SqlDbType.SmallInt,2),
					new SqlParameter("@F_BirthCN", SqlDbType.DateTime),
					new SqlParameter("@F_BirthCNYear", SqlDbType.Int,4),
					new SqlParameter("@F_BirthCNMonth", SqlDbType.Int,4),
					new SqlParameter("@F_BirthCNDay", SqlDbType.Int,4),
					new SqlParameter("@F_IsSMS", SqlDbType.Bit,1),
					new SqlParameter("@F_SMSContent", SqlDbType.NVarChar,200),
					new SqlParameter("@F_FirstDate", SqlDbType.DateTime),
					new SqlParameter("@F_LatelyDate", SqlDbType.DateTime),
					new SqlParameter("@F_Remark", SqlDbType.NVarChar,800),
					new SqlParameter("@F_CreateBy", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
					new SqlParameter("@F_ModifyBy", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@F_ModifyOn", SqlDbType.DateTime),
					new SqlParameter("@F_DeletionStateCode", SqlDbType.SmallInt,2),            
                    new SqlParameter("@F_UserAccount", SqlDbType.VarChar,50),            
                    new SqlParameter("@F_Password", SqlDbType.VarChar,50),           
                    new SqlParameter("@F_RoleId", SqlDbType.Int,4)};
			parameters[0].Value = model.F_CustomerId;
			parameters[1].Value = model.F_CategoryId;
			parameters[2].Value = model.F_Name;
			parameters[3].Value = model.F_EName;
			parameters[4].Value = model.F_IsMain;
			parameters[5].Value = model.F_Sex;
			parameters[6].Value = model.F_Telephone;
			parameters[7].Value = model.F_Mobile;
			parameters[8].Value = model.F_Fax;
			parameters[9].Value = model.F_Address;
			parameters[10].Value = model.F_Email;
			parameters[11].Value = model.F_Duty;
			parameters[12].Value = model.F_Department;
			parameters[13].Value = model.F_QQ;
			parameters[14].Value = model.F_MSN;
			parameters[15].Value = model.F_IsBirth;
			parameters[16].Value = model.F_Birthday;
			parameters[17].Value = model.F_BirthType;
			parameters[18].Value = model.F_BirthCN;
			parameters[19].Value = model.F_BirthCNYear;
			parameters[20].Value = model.F_BirthCNMonth;
			parameters[21].Value = model.F_BirthCNDay;
			parameters[22].Value = model.F_IsSMS;
			parameters[23].Value = model.F_SMSContent;
			parameters[24].Value = model.F_FirstDate;
			parameters[25].Value = model.F_LatelyDate;
			parameters[26].Value = model.F_Remark;
			parameters[27].Value = Guid.NewGuid();
			parameters[28].Value = model.F_CreateOn;
			parameters[29].Value = Guid.NewGuid();
			parameters[30].Value = model.F_ModifyOn;
			parameters[31].Value = model.F_DeletionStateCode;
            parameters[32].Value = model.F_UserAccount;
            parameters[33].Value = model.F_Password;
            parameters[34].Value = model.F_RoleId;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ZXDT.CallCenter.Model.T_Cus_ContactPerson model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_Cus_ContactPerson set ");
			strSql.Append("F_CustomerId=@F_CustomerId,");
			strSql.Append("F_CategoryId=@F_CategoryId,");
			strSql.Append("F_Name=@F_Name,");
			strSql.Append("F_EName=@F_EName,");
			strSql.Append("F_IsMain=@F_IsMain,");
			strSql.Append("F_Sex=@F_Sex,");
			strSql.Append("F_Telephone=@F_Telephone,");
			strSql.Append("F_Mobile=@F_Mobile,");
			strSql.Append("F_Fax=@F_Fax,");
			strSql.Append("F_Address=@F_Address,");
			strSql.Append("F_Email=@F_Email,");
			strSql.Append("F_Duty=@F_Duty,");
			strSql.Append("F_Department=@F_Department,");
			strSql.Append("F_QQ=@F_QQ,");
			strSql.Append("F_MSN=@F_MSN,");
			strSql.Append("F_IsBirth=@F_IsBirth,");
			strSql.Append("F_Birthday=@F_Birthday,");
			strSql.Append("F_BirthType=@F_BirthType,");
			strSql.Append("F_BirthCN=@F_BirthCN,");
			strSql.Append("F_BirthCNYear=@F_BirthCNYear,");
			strSql.Append("F_BirthCNMonth=@F_BirthCNMonth,");
			strSql.Append("F_BirthCNDay=@F_BirthCNDay,");
			strSql.Append("F_IsSMS=@F_IsSMS,");
			strSql.Append("F_SMSContent=@F_SMSContent,");
			strSql.Append("F_FirstDate=@F_FirstDate,");
			strSql.Append("F_LatelyDate=@F_LatelyDate,");
			strSql.Append("F_Remark=@F_Remark,");
			strSql.Append("F_CreateBy=@F_CreateBy,");
			strSql.Append("F_CreateOn=@F_CreateOn,");
			strSql.Append("F_ModifyBy=@F_ModifyBy,");
			strSql.Append("F_ModifyOn=@F_ModifyOn,");
			strSql.Append("F_DeletionStateCode=@F_DeletionStateCode,");
            strSql.Append(" F_UserAccount = @F_UserAccount , ");
            strSql.Append(" F_Password = @F_Password , ");
            strSql.Append(" F_RoleId = @F_RoleId ");  
			strSql.Append(" where F_ManId=@F_ManId");
			SqlParameter[] parameters = {
					new SqlParameter("@F_CustomerId", SqlDbType.Int,4),
					new SqlParameter("@F_CategoryId", SqlDbType.Int,4),
					new SqlParameter("@F_Name", SqlDbType.NVarChar,50),
					new SqlParameter("@F_EName", SqlDbType.NVarChar,50),
					new SqlParameter("@F_IsMain", SqlDbType.Bit,1),
					new SqlParameter("@F_Sex", SqlDbType.VarChar,6),
					new SqlParameter("@F_Telephone", SqlDbType.NVarChar,100),
					new SqlParameter("@F_Mobile", SqlDbType.NVarChar,100),
					new SqlParameter("@F_Fax", SqlDbType.VarChar,100),
					new SqlParameter("@F_Address", SqlDbType.NVarChar,200),
					new SqlParameter("@F_Email", SqlDbType.VarChar,100),
					new SqlParameter("@F_Duty", SqlDbType.VarChar,50),
					new SqlParameter("@F_Department", SqlDbType.NVarChar,50),
					new SqlParameter("@F_QQ", SqlDbType.NVarChar,50),
					new SqlParameter("@F_MSN", SqlDbType.NVarChar,50),
					new SqlParameter("@F_IsBirth", SqlDbType.Bit,1),
					new SqlParameter("@F_Birthday", SqlDbType.DateTime),
					new SqlParameter("@F_BirthType", SqlDbType.SmallInt,2),
					new SqlParameter("@F_BirthCN", SqlDbType.DateTime),
					new SqlParameter("@F_BirthCNYear", SqlDbType.Int,4),
					new SqlParameter("@F_BirthCNMonth", SqlDbType.Int,4),
					new SqlParameter("@F_BirthCNDay", SqlDbType.Int,4),
					new SqlParameter("@F_IsSMS", SqlDbType.Bit,1),
					new SqlParameter("@F_SMSContent", SqlDbType.NVarChar,200),
					new SqlParameter("@F_FirstDate", SqlDbType.DateTime),
					new SqlParameter("@F_LatelyDate", SqlDbType.DateTime),
					new SqlParameter("@F_Remark", SqlDbType.NVarChar,800),
					new SqlParameter("@F_CreateBy", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
					new SqlParameter("@F_ModifyBy", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@F_ModifyOn", SqlDbType.DateTime),
					new SqlParameter("@F_DeletionStateCode", SqlDbType.SmallInt,2),
                    new SqlParameter("@F_UserAccount", SqlDbType.VarChar,50) ,            
                    new SqlParameter("@F_Password", SqlDbType.VarChar,50) ,            
                    new SqlParameter("@F_RoleId", SqlDbType.Int,4) , 
					new SqlParameter("@F_ManId", SqlDbType.Int,4)};
			parameters[0].Value = model.F_CustomerId;
			parameters[1].Value = model.F_CategoryId;
			parameters[2].Value = model.F_Name;
			parameters[3].Value = model.F_EName;
			parameters[4].Value = model.F_IsMain;
			parameters[5].Value = model.F_Sex;
			parameters[6].Value = model.F_Telephone;
			parameters[7].Value = model.F_Mobile;
			parameters[8].Value = model.F_Fax;
			parameters[9].Value = model.F_Address;
			parameters[10].Value = model.F_Email;
			parameters[11].Value = model.F_Duty;
			parameters[12].Value = model.F_Department;
			parameters[13].Value = model.F_QQ;
			parameters[14].Value = model.F_MSN;
			parameters[15].Value = model.F_IsBirth;
			parameters[16].Value = model.F_Birthday;
			parameters[17].Value = model.F_BirthType;
			parameters[18].Value = model.F_BirthCN;
			parameters[19].Value = model.F_BirthCNYear;
			parameters[20].Value = model.F_BirthCNMonth;
			parameters[21].Value = model.F_BirthCNDay;
			parameters[22].Value = model.F_IsSMS;
			parameters[23].Value = model.F_SMSContent;
			parameters[24].Value = model.F_FirstDate;
			parameters[25].Value = model.F_LatelyDate;
			parameters[26].Value = model.F_Remark;
			parameters[27].Value = model.F_CreateBy;
			parameters[28].Value = model.F_CreateOn;
			parameters[29].Value = model.F_ModifyBy;
			parameters[30].Value = model.F_ModifyOn;
			parameters[31].Value = model.F_DeletionStateCode;
            parameters[32].Value = model.F_UserAccount;
            parameters[33].Value = model.F_Password;
            parameters[34].Value = model.F_RoleId;
			parameters[35].Value = model.F_ManId;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int F_ManId)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_Cus_ContactPerson ");
			strSql.Append(" where F_ManId=@F_ManId");
			SqlParameter[] parameters = {
					new SqlParameter("@F_ManId", SqlDbType.Int,4)
			};
			parameters[0].Value = F_ManId;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string F_ManIdlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_Cus_ContactPerson ");
			strSql.Append(" where F_ManId in ("+F_ManIdlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ZXDT.CallCenter.Model.T_Cus_ContactPerson GetModel(int F_ManId)
		{
			
			StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 F_ManId,F_CustomerId,F_CategoryId,F_Name,F_EName,F_IsMain,F_Sex,F_Telephone,F_Mobile,F_Fax,F_Address,F_Email,F_Duty,F_Department,F_QQ,F_MSN,F_IsBirth,F_Birthday,F_BirthType,F_BirthCN,F_BirthCNYear,F_BirthCNMonth,F_BirthCNDay,F_IsSMS,F_SMSContent,F_FirstDate,F_LatelyDate,F_Remark,F_CreateBy,F_CreateOn,F_ModifyBy,F_ModifyOn,F_DeletionStateCode, F_UserAccount, F_Password, F_RoleId from T_Cus_ContactPerson ");
			strSql.Append(" where F_ManId=@F_ManId");
			SqlParameter[] parameters = {
					new SqlParameter("@F_ManId", SqlDbType.Int,4)
			};
			parameters[0].Value = F_ManId;

			ZXDT.CallCenter.Model.T_Cus_ContactPerson model=new ZXDT.CallCenter.Model.T_Cus_ContactPerson();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ZXDT.CallCenter.Model.T_Cus_ContactPerson DataRowToModel(DataRow row)
		{
			ZXDT.CallCenter.Model.T_Cus_ContactPerson model=new ZXDT.CallCenter.Model.T_Cus_ContactPerson();
			if (row != null)
			{
				if(row["F_ManId"]!=null && row["F_ManId"].ToString()!="")
				{
					model.F_ManId=int.Parse(row["F_ManId"].ToString());
				}
				if(row["F_CustomerId"]!=null && row["F_CustomerId"].ToString()!="")
				{
					model.F_CustomerId=int.Parse(row["F_CustomerId"].ToString());
				}
				if(row["F_CategoryId"]!=null && row["F_CategoryId"].ToString()!="")
				{
					model.F_CategoryId=int.Parse(row["F_CategoryId"].ToString());
				}
				if(row["F_Name"]!=null)
				{
					model.F_Name=row["F_Name"].ToString();
				}
				if(row["F_EName"]!=null)
				{
					model.F_EName=row["F_EName"].ToString();
				}
				if(row["F_IsMain"]!=null && row["F_IsMain"].ToString()!="")
				{
					if((row["F_IsMain"].ToString()=="1")||(row["F_IsMain"].ToString().ToLower()=="true"))
					{
						model.F_IsMain=true;
					}
					else
					{
						model.F_IsMain=false;
					}
				}
				if(row["F_Sex"]!=null)
				{
					model.F_Sex=row["F_Sex"].ToString();
				}
				if(row["F_Telephone"]!=null)
				{
					model.F_Telephone=row["F_Telephone"].ToString();
				}
				if(row["F_Mobile"]!=null)
				{
					model.F_Mobile=row["F_Mobile"].ToString();
				}
				if(row["F_Fax"]!=null)
				{
					model.F_Fax=row["F_Fax"].ToString();
				}
				if(row["F_Address"]!=null)
				{
					model.F_Address=row["F_Address"].ToString();
				}
				if(row["F_Email"]!=null)
				{
					model.F_Email=row["F_Email"].ToString();
				}
				if(row["F_Duty"]!=null)
				{
					model.F_Duty=row["F_Duty"].ToString();
				}
				if(row["F_Department"]!=null)
				{
					model.F_Department=row["F_Department"].ToString();
				}
				if(row["F_QQ"]!=null)
				{
					model.F_QQ=row["F_QQ"].ToString();
				}
				if(row["F_MSN"]!=null)
				{
					model.F_MSN=row["F_MSN"].ToString();
				}
				if(row["F_IsBirth"]!=null && row["F_IsBirth"].ToString()!="")
				{
					if((row["F_IsBirth"].ToString()=="1")||(row["F_IsBirth"].ToString().ToLower()=="true"))
					{
						model.F_IsBirth=true;
					}
					else
					{
						model.F_IsBirth=false;
					}
				}
				if(row["F_Birthday"]!=null && row["F_Birthday"].ToString()!="")
				{
					model.F_Birthday=DateTime.Parse(row["F_Birthday"].ToString());
				}
				if(row["F_BirthType"]!=null && row["F_BirthType"].ToString()!="")
				{
					model.F_BirthType=int.Parse(row["F_BirthType"].ToString());
				}
				if(row["F_BirthCN"]!=null && row["F_BirthCN"].ToString()!="")
				{
					model.F_BirthCN=DateTime.Parse(row["F_BirthCN"].ToString());
				}
				if(row["F_BirthCNYear"]!=null && row["F_BirthCNYear"].ToString()!="")
				{
					model.F_BirthCNYear=int.Parse(row["F_BirthCNYear"].ToString());
				}
				if(row["F_BirthCNMonth"]!=null && row["F_BirthCNMonth"].ToString()!="")
				{
					model.F_BirthCNMonth=int.Parse(row["F_BirthCNMonth"].ToString());
				}
				if(row["F_BirthCNDay"]!=null && row["F_BirthCNDay"].ToString()!="")
				{
					model.F_BirthCNDay=int.Parse(row["F_BirthCNDay"].ToString());
				}
				if(row["F_IsSMS"]!=null && row["F_IsSMS"].ToString()!="")
				{
					if((row["F_IsSMS"].ToString()=="1")||(row["F_IsSMS"].ToString().ToLower()=="true"))
					{
						model.F_IsSMS=true;
					}
					else
					{
						model.F_IsSMS=false;
					}
				}
				if(row["F_SMSContent"]!=null)
				{
					model.F_SMSContent=row["F_SMSContent"].ToString();
				}
				if(row["F_FirstDate"]!=null && row["F_FirstDate"].ToString()!="")
				{
					model.F_FirstDate=DateTime.Parse(row["F_FirstDate"].ToString());
				}
				if(row["F_LatelyDate"]!=null && row["F_LatelyDate"].ToString()!="")
				{
					model.F_LatelyDate=DateTime.Parse(row["F_LatelyDate"].ToString());
				}
				if(row["F_Remark"]!=null)
				{
					model.F_Remark=row["F_Remark"].ToString();
				}
				if(row["F_CreateBy"]!=null && row["F_CreateBy"].ToString()!="")
				{
					model.F_CreateBy= new Guid(row["F_CreateBy"].ToString());
				}
				if(row["F_CreateOn"]!=null && row["F_CreateOn"].ToString()!="")
				{
					model.F_CreateOn=DateTime.Parse(row["F_CreateOn"].ToString());
				}
				if(row["F_ModifyBy"]!=null && row["F_ModifyBy"].ToString()!="")
				{
					model.F_ModifyBy= new Guid(row["F_ModifyBy"].ToString());
				}
				if(row["F_ModifyOn"]!=null && row["F_ModifyOn"].ToString()!="")
				{
					model.F_ModifyOn=DateTime.Parse(row["F_ModifyOn"].ToString());
				}
				if(row["F_DeletionStateCode"]!=null && row["F_DeletionStateCode"].ToString()!="")
				{
					model.F_DeletionStateCode=int.Parse(row["F_DeletionStateCode"].ToString());
				}
                if (row["F_UserAccount"] != null && row["F_UserAccount"].ToString() != "")
                {
                    model.F_UserAccount = row["F_UserAccount"].ToString();
                }
                if (row["F_Password"] != null && row["F_Password"].ToString() != "")
                {
                    model.F_Password = row["F_Password"].ToString();
                }
                if (row["F_RoleId"] != null && row["F_RoleId"].ToString() != "")
                {
                    model.F_RoleId = int.Parse(row["F_RoleId"].ToString());
                }
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
            strSql.Append("select F_ManId,F_CustomerId,F_CategoryId,F_Name,F_EName,F_IsMain,F_Sex,F_Telephone,F_Mobile,F_Fax,F_Address,F_Email,F_Duty,F_Department,F_QQ,F_MSN,F_IsBirth,F_Birthday,F_BirthType,F_BirthCN,F_BirthCNYear,F_BirthCNMonth,F_BirthCNDay,F_IsSMS,F_SMSContent,F_FirstDate,F_LatelyDate,F_Remark,F_CreateBy,F_CreateOn,F_ModifyBy,F_ModifyOn,F_DeletionStateCode, F_UserAccount, F_Password, F_RoleId ");
			strSql.Append(" FROM T_Cus_ContactPerson ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
            strSql.Append(" F_ManId,F_CustomerId,F_CategoryId,F_Name,F_EName,F_IsMain,F_Sex,F_Telephone,F_Mobile,F_Fax,F_Address,F_Email,F_Duty,F_Department,F_QQ,F_MSN,F_IsBirth,F_Birthday,F_BirthType,F_BirthCN,F_BirthCNYear,F_BirthCNMonth,F_BirthCNDay,F_IsSMS,F_SMSContent,F_FirstDate,F_LatelyDate,F_Remark,F_CreateBy,F_CreateOn,F_ModifyBy,F_ModifyOn,F_DeletionStateCode, F_UserAccount, F_Password, F_RoleId ");
			strSql.Append(" FROM T_Cus_ContactPerson ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM T_Cus_ContactPerson ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.F_ManId desc");
			}
			strSql.Append(")AS Row, T.*  from T_Cus_ContactPerson T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			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 = "T_Cus_ContactPerson";
			parameters[1].Value = "F_ManId";
			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  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

