using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using ZXDT.DBUtility;

namespace ZXDT.CallCenter.DAL
{
    /// <summary>
    /// 数据访问类:T_Call_CallRecords_All
	/// </summary>
	public partial class T_Call_CallRecords_All
	{
        public T_Call_CallRecords_All()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int CallRecordsId)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from T_Call_CallRecords");
			strSql.Append(" where CallRecordsId=@CallRecordsId");
			SqlParameter[] parameters = {
					new SqlParameter("@CallRecordsId", SqlDbType.Int,4)
			};
			parameters[0].Value = CallRecordsId;

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


		/// <summary>
		/// 增加一条数据
		/// </summary>
        public int Add(ZXDT.CallCenter.Model.T_Call_CallRecords_All model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_Call_CallRecords(");
			strSql.Append("CallId,CallNumber,CusId,CusCode,CallType,CallState,DealType,BeginTime,IvrStartTime,IvrEndTime,RingStartTime,RingEndTime,TalkStartTime,TalkEndTime,EndTime,LongTime,IvrLongTime,RingLongTime,TalkLongTime,UserId,UserCode,UserName,ExtNumber,FilePath,IsExitWorkOrder,IsDeal,OperateType,OperateObject,OperateTime,Remark,MYD,BusinessType,Location,WaitStartTime,WaitEndTime,WaitLongTime,NoCallState,WorkTimesDiff,F_QCState,F_QCScore,F_QCRemark,F_QCUserId,F_QCUserName,F_QCTime,F_QCIsSelect,F_HJJGId,F_HJJGName,F_Key1,F_Key2,F_Key3)");
			strSql.Append(" values (");
			strSql.Append("@CallId,@CallNumber,@CusId,@CusCode,@CallType,@CallState,@DealType,@BeginTime,@IvrStartTime,@IvrEndTime,@RingStartTime,@RingEndTime,@TalkStartTime,@TalkEndTime,@EndTime,@LongTime,@IvrLongTime,@RingLongTime,@TalkLongTime,@UserId,@UserCode,@UserName,@ExtNumber,@FilePath,@IsExitWorkOrder,@IsDeal,@OperateType,@OperateObject,@OperateTime,@Remark,@MYD,@BusinessType,@Location,@WaitStartTime,@WaitEndTime,@WaitLongTime,@NoCallState,@WorkTimesDiff,@F_QCState,@F_QCScore,@F_QCRemark,@F_QCUserId,@F_QCUserName,@F_QCTime,@F_QCIsSelect,@F_HJJGId,@F_HJJGName,@F_Key1,@F_Key2,@F_Key3)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@CallId", SqlDbType.VarChar,50),
					new SqlParameter("@CallNumber", SqlDbType.VarChar,100),
					new SqlParameter("@CusId", SqlDbType.VarChar,50),
					new SqlParameter("@CusCode", SqlDbType.VarChar,50),
					new SqlParameter("@CallType", SqlDbType.Int,4),
					new SqlParameter("@CallState", SqlDbType.Int,4),
					new SqlParameter("@DealType", SqlDbType.Int,4),
					new SqlParameter("@BeginTime", SqlDbType.DateTime),
					new SqlParameter("@IvrStartTime", SqlDbType.DateTime),
					new SqlParameter("@IvrEndTime", SqlDbType.DateTime),
					new SqlParameter("@RingStartTime", SqlDbType.DateTime),
					new SqlParameter("@RingEndTime", SqlDbType.DateTime),
					new SqlParameter("@TalkStartTime", SqlDbType.DateTime),
					new SqlParameter("@TalkEndTime", SqlDbType.DateTime),
					new SqlParameter("@EndTime", SqlDbType.DateTime),
					new SqlParameter("@LongTime", SqlDbType.Int,4),
					new SqlParameter("@IvrLongTime", SqlDbType.Int,4),
					new SqlParameter("@RingLongTime", SqlDbType.Int,4),
					new SqlParameter("@TalkLongTime", SqlDbType.Int,4),
					new SqlParameter("@UserId", SqlDbType.Int,4),
					new SqlParameter("@UserCode", SqlDbType.VarChar,50),
					new SqlParameter("@UserName", SqlDbType.NVarChar,20),
					new SqlParameter("@ExtNumber", SqlDbType.VarChar,50),
					new SqlParameter("@FilePath", SqlDbType.VarChar,200),
					new SqlParameter("@IsExitWorkOrder", SqlDbType.Bit,1),
					new SqlParameter("@IsDeal", SqlDbType.Int,4),
					new SqlParameter("@OperateType", SqlDbType.Int,4),
					new SqlParameter("@OperateObject", SqlDbType.VarChar,20),
					new SqlParameter("@OperateTime", SqlDbType.DateTime),
					new SqlParameter("@Remark", SqlDbType.NVarChar,1000),
					new SqlParameter("@MYD", SqlDbType.Int,4),
					new SqlParameter("@BusinessType", SqlDbType.Int,4),
					new SqlParameter("@Location", SqlDbType.NVarChar,100),
					new SqlParameter("@WaitStartTime", SqlDbType.DateTime),
					new SqlParameter("@WaitEndTime", SqlDbType.DateTime),
					new SqlParameter("@WaitLongTime", SqlDbType.Int,4),
					new SqlParameter("@NoCallState", SqlDbType.Int,4),
					new SqlParameter("@WorkTimesDiff", SqlDbType.Int,4),
					new SqlParameter("@F_QCState", SqlDbType.SmallInt,2),
					new SqlParameter("@F_QCScore", SqlDbType.Decimal,9),
					new SqlParameter("@F_QCRemark", SqlDbType.Text),
					new SqlParameter("@F_QCUserId", SqlDbType.Int,4),
					new SqlParameter("@F_QCUserName", SqlDbType.NVarChar,50),
					new SqlParameter("@F_QCTime", SqlDbType.DateTime),
					new SqlParameter("@F_QCIsSelect", SqlDbType.SmallInt,2),
					new SqlParameter("@F_HJJGId", SqlDbType.Int,4),
					new SqlParameter("@F_HJJGName", SqlDbType.NVarChar,500),
					new SqlParameter("@F_Key1", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Key2", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Key3", SqlDbType.NVarChar,50)};
			parameters[0].Value = model.CallId;
			parameters[1].Value = model.CallNumber;
			parameters[2].Value = model.CusId;
			parameters[3].Value = model.CusCode;
			parameters[4].Value = model.CallType;
			parameters[5].Value = model.CallState;
			parameters[6].Value = model.DealType;
			parameters[7].Value = model.BeginTime;
			parameters[8].Value = model.IvrStartTime;
			parameters[9].Value = model.IvrEndTime;
			parameters[10].Value = model.RingStartTime;
			parameters[11].Value = model.RingEndTime;
			parameters[12].Value = model.TalkStartTime;
			parameters[13].Value = model.TalkEndTime;
			parameters[14].Value = model.EndTime;
			parameters[15].Value = model.LongTime;
			parameters[16].Value = model.IvrLongTime;
			parameters[17].Value = model.RingLongTime;
			parameters[18].Value = model.TalkLongTime;
			parameters[19].Value = model.UserId;
			parameters[20].Value = model.UserCode;
			parameters[21].Value = model.UserName;
			parameters[22].Value = model.ExtNumber;
			parameters[23].Value = model.FilePath;
			parameters[24].Value = model.IsExitWorkOrder;
			parameters[25].Value = model.IsDeal;
			parameters[26].Value = model.OperateType;
			parameters[27].Value = model.OperateObject;
			parameters[28].Value = model.OperateTime;
			parameters[29].Value = model.Remark;
			parameters[30].Value = model.MYD;
			parameters[31].Value = model.BusinessType;
			parameters[32].Value = model.Location;
			parameters[33].Value = model.WaitStartTime;
			parameters[34].Value = model.WaitEndTime;
			parameters[35].Value = model.WaitLongTime;
			parameters[36].Value = model.NoCallState;
			parameters[37].Value = model.WorkTimesDiff;
			parameters[38].Value = model.F_QCState;
			parameters[39].Value = model.F_QCScore;
			parameters[40].Value = model.F_QCRemark;
			parameters[41].Value = model.F_QCUserId;
			parameters[42].Value = model.F_QCUserName;
			parameters[43].Value = model.F_QCTime;
			parameters[44].Value = model.F_QCIsSelect;
			parameters[45].Value = model.F_HJJGId;
			parameters[46].Value = model.F_HJJGName;
			parameters[47].Value = model.F_Key1;
			parameters[48].Value = model.F_Key2;
			parameters[49].Value = model.F_Key3;

			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_Call_CallRecords_All model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_Call_CallRecords set ");
			strSql.Append("CallId=@CallId,");
			strSql.Append("CallNumber=@CallNumber,");
			strSql.Append("CusId=@CusId,");
			strSql.Append("CusCode=@CusCode,");
			strSql.Append("CallType=@CallType,");
			strSql.Append("CallState=@CallState,");
			strSql.Append("DealType=@DealType,");
			strSql.Append("BeginTime=@BeginTime,");
			strSql.Append("IvrStartTime=@IvrStartTime,");
			strSql.Append("IvrEndTime=@IvrEndTime,");
			strSql.Append("RingStartTime=@RingStartTime,");
			strSql.Append("RingEndTime=@RingEndTime,");
			strSql.Append("TalkStartTime=@TalkStartTime,");
			strSql.Append("TalkEndTime=@TalkEndTime,");
			strSql.Append("EndTime=@EndTime,");
			strSql.Append("LongTime=@LongTime,");
			strSql.Append("IvrLongTime=@IvrLongTime,");
			strSql.Append("RingLongTime=@RingLongTime,");
			strSql.Append("TalkLongTime=@TalkLongTime,");
			strSql.Append("UserId=@UserId,");
			strSql.Append("UserCode=@UserCode,");
			strSql.Append("UserName=@UserName,");
			strSql.Append("ExtNumber=@ExtNumber,");
			strSql.Append("FilePath=@FilePath,");
			strSql.Append("IsExitWorkOrder=@IsExitWorkOrder,");
			strSql.Append("IsDeal=@IsDeal,");
			strSql.Append("OperateType=@OperateType,");
			strSql.Append("OperateObject=@OperateObject,");
			strSql.Append("OperateTime=@OperateTime,");
			strSql.Append("Remark=@Remark,");
			strSql.Append("MYD=@MYD,");
			strSql.Append("BusinessType=@BusinessType,");
			strSql.Append("Location=@Location,");
			strSql.Append("WaitStartTime=@WaitStartTime,");
			strSql.Append("WaitEndTime=@WaitEndTime,");
			strSql.Append("WaitLongTime=@WaitLongTime,");
			strSql.Append("NoCallState=@NoCallState,");
			strSql.Append("WorkTimesDiff=@WorkTimesDiff,");
			strSql.Append("F_QCState=@F_QCState,");
			strSql.Append("F_QCScore=@F_QCScore,");
			strSql.Append("F_QCRemark=@F_QCRemark,");
			strSql.Append("F_QCUserId=@F_QCUserId,");
			strSql.Append("F_QCUserName=@F_QCUserName,");
			strSql.Append("F_QCTime=@F_QCTime,");
			strSql.Append("F_QCIsSelect=@F_QCIsSelect,");
			strSql.Append("F_HJJGId=@F_HJJGId,");
			strSql.Append("F_HJJGName=@F_HJJGName,");
			strSql.Append("F_Key1=@F_Key1,");
			strSql.Append("F_Key2=@F_Key2,");
			strSql.Append("F_Key3=@F_Key3");
			strSql.Append(" where CallRecordsId=@CallRecordsId");
			SqlParameter[] parameters = {
					new SqlParameter("@CallId", SqlDbType.VarChar,50),
					new SqlParameter("@CallNumber", SqlDbType.VarChar,100),
					new SqlParameter("@CusId", SqlDbType.VarChar,50),
					new SqlParameter("@CusCode", SqlDbType.VarChar,50),
					new SqlParameter("@CallType", SqlDbType.Int,4),
					new SqlParameter("@CallState", SqlDbType.Int,4),
					new SqlParameter("@DealType", SqlDbType.Int,4),
					new SqlParameter("@BeginTime", SqlDbType.DateTime),
					new SqlParameter("@IvrStartTime", SqlDbType.DateTime),
					new SqlParameter("@IvrEndTime", SqlDbType.DateTime),
					new SqlParameter("@RingStartTime", SqlDbType.DateTime),
					new SqlParameter("@RingEndTime", SqlDbType.DateTime),
					new SqlParameter("@TalkStartTime", SqlDbType.DateTime),
					new SqlParameter("@TalkEndTime", SqlDbType.DateTime),
					new SqlParameter("@EndTime", SqlDbType.DateTime),
					new SqlParameter("@LongTime", SqlDbType.Int,4),
					new SqlParameter("@IvrLongTime", SqlDbType.Int,4),
					new SqlParameter("@RingLongTime", SqlDbType.Int,4),
					new SqlParameter("@TalkLongTime", SqlDbType.Int,4),
					new SqlParameter("@UserId", SqlDbType.Int,4),
					new SqlParameter("@UserCode", SqlDbType.VarChar,50),
					new SqlParameter("@UserName", SqlDbType.NVarChar,20),
					new SqlParameter("@ExtNumber", SqlDbType.VarChar,50),
					new SqlParameter("@FilePath", SqlDbType.VarChar,200),
					new SqlParameter("@IsExitWorkOrder", SqlDbType.Bit,1),
					new SqlParameter("@IsDeal", SqlDbType.Int,4),
					new SqlParameter("@OperateType", SqlDbType.Int,4),
					new SqlParameter("@OperateObject", SqlDbType.VarChar,20),
					new SqlParameter("@OperateTime", SqlDbType.DateTime),
					new SqlParameter("@Remark", SqlDbType.NVarChar,1000),
					new SqlParameter("@MYD", SqlDbType.Int,4),
					new SqlParameter("@BusinessType", SqlDbType.Int,4),
					new SqlParameter("@Location", SqlDbType.NVarChar,100),
					new SqlParameter("@WaitStartTime", SqlDbType.DateTime),
					new SqlParameter("@WaitEndTime", SqlDbType.DateTime),
					new SqlParameter("@WaitLongTime", SqlDbType.Int,4),
					new SqlParameter("@NoCallState", SqlDbType.Int,4),
					new SqlParameter("@WorkTimesDiff", SqlDbType.Int,4),
					new SqlParameter("@F_QCState", SqlDbType.SmallInt,2),
					new SqlParameter("@F_QCScore", SqlDbType.Decimal,9),
					new SqlParameter("@F_QCRemark", SqlDbType.Text),
					new SqlParameter("@F_QCUserId", SqlDbType.Int,4),
					new SqlParameter("@F_QCUserName", SqlDbType.NVarChar,50),
					new SqlParameter("@F_QCTime", SqlDbType.DateTime),
					new SqlParameter("@F_QCIsSelect", SqlDbType.SmallInt,2),
					new SqlParameter("@F_HJJGId", SqlDbType.Int,4),
					new SqlParameter("@F_HJJGName", SqlDbType.NVarChar,500),
					new SqlParameter("@F_Key1", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Key2", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Key3", SqlDbType.NVarChar,50),
					new SqlParameter("@CallRecordsId", SqlDbType.Int,4)};
			parameters[0].Value = model.CallId;
			parameters[1].Value = model.CallNumber;
			parameters[2].Value = model.CusId;
			parameters[3].Value = model.CusCode;
			parameters[4].Value = model.CallType;
			parameters[5].Value = model.CallState;
			parameters[6].Value = model.DealType;
			parameters[7].Value = model.BeginTime;
			parameters[8].Value = model.IvrStartTime;
			parameters[9].Value = model.IvrEndTime;
			parameters[10].Value = model.RingStartTime;
			parameters[11].Value = model.RingEndTime;
			parameters[12].Value = model.TalkStartTime;
			parameters[13].Value = model.TalkEndTime;
			parameters[14].Value = model.EndTime;
			parameters[15].Value = model.LongTime;
			parameters[16].Value = model.IvrLongTime;
			parameters[17].Value = model.RingLongTime;
			parameters[18].Value = model.TalkLongTime;
			parameters[19].Value = model.UserId;
			parameters[20].Value = model.UserCode;
			parameters[21].Value = model.UserName;
			parameters[22].Value = model.ExtNumber;
			parameters[23].Value = model.FilePath;
			parameters[24].Value = model.IsExitWorkOrder;
			parameters[25].Value = model.IsDeal;
			parameters[26].Value = model.OperateType;
			parameters[27].Value = model.OperateObject;
			parameters[28].Value = model.OperateTime;
			parameters[29].Value = model.Remark;
			parameters[30].Value = model.MYD;
			parameters[31].Value = model.BusinessType;
			parameters[32].Value = model.Location;
			parameters[33].Value = model.WaitStartTime;
			parameters[34].Value = model.WaitEndTime;
			parameters[35].Value = model.WaitLongTime;
			parameters[36].Value = model.NoCallState;
			parameters[37].Value = model.WorkTimesDiff;
			parameters[38].Value = model.F_QCState;
			parameters[39].Value = model.F_QCScore;
			parameters[40].Value = model.F_QCRemark;
			parameters[41].Value = model.F_QCUserId;
			parameters[42].Value = model.F_QCUserName;
			parameters[43].Value = model.F_QCTime;
			parameters[44].Value = model.F_QCIsSelect;
			parameters[45].Value = model.F_HJJGId;
			parameters[46].Value = model.F_HJJGName;
			parameters[47].Value = model.F_Key1;
			parameters[48].Value = model.F_Key2;
			parameters[49].Value = model.F_Key3;
			parameters[50].Value = model.CallRecordsId;

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

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

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


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
        public ZXDT.CallCenter.Model.T_Call_CallRecords_All GetModel(int CallRecordsId)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 * from T_Call_CallRecords ");
			strSql.Append(" where CallRecordsId=@CallRecordsId");
			SqlParameter[] parameters = {
					new SqlParameter("@CallRecordsId", SqlDbType.Int,4)
			};
			parameters[0].Value = CallRecordsId;

            ZXDT.CallCenter.Model.T_Call_CallRecords_All model = new ZXDT.CallCenter.Model.T_Call_CallRecords_All();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["CallId"]!=null && ds.Tables[0].Rows[0]["CallId"].ToString()!="")
				{
					model.CallId=ds.Tables[0].Rows[0]["CallId"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CallNumber"]!=null && ds.Tables[0].Rows[0]["CallNumber"].ToString()!="")
				{
					model.CallNumber=ds.Tables[0].Rows[0]["CallNumber"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CusId"]!=null && ds.Tables[0].Rows[0]["CusId"].ToString()!="")
				{
					model.CusId=ds.Tables[0].Rows[0]["CusId"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CusCode"]!=null && ds.Tables[0].Rows[0]["CusCode"].ToString()!="")
				{
					model.CusCode=ds.Tables[0].Rows[0]["CusCode"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CallType"]!=null && ds.Tables[0].Rows[0]["CallType"].ToString()!="")
				{
					model.CallType=int.Parse(ds.Tables[0].Rows[0]["CallType"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CallState"]!=null && ds.Tables[0].Rows[0]["CallState"].ToString()!="")
				{
					model.CallState=int.Parse(ds.Tables[0].Rows[0]["CallState"].ToString());
				}
				if(ds.Tables[0].Rows[0]["DealType"]!=null && ds.Tables[0].Rows[0]["DealType"].ToString()!="")
				{
					model.DealType=int.Parse(ds.Tables[0].Rows[0]["DealType"].ToString());
				}
				if(ds.Tables[0].Rows[0]["BeginTime"]!=null && ds.Tables[0].Rows[0]["BeginTime"].ToString()!="")
				{
					model.BeginTime=DateTime.Parse(ds.Tables[0].Rows[0]["BeginTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IvrStartTime"]!=null && ds.Tables[0].Rows[0]["IvrStartTime"].ToString()!="")
				{
					model.IvrStartTime=DateTime.Parse(ds.Tables[0].Rows[0]["IvrStartTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IvrEndTime"]!=null && ds.Tables[0].Rows[0]["IvrEndTime"].ToString()!="")
				{
					model.IvrEndTime=DateTime.Parse(ds.Tables[0].Rows[0]["IvrEndTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["RingStartTime"]!=null && ds.Tables[0].Rows[0]["RingStartTime"].ToString()!="")
				{
					model.RingStartTime=DateTime.Parse(ds.Tables[0].Rows[0]["RingStartTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["RingEndTime"]!=null && ds.Tables[0].Rows[0]["RingEndTime"].ToString()!="")
				{
					model.RingEndTime=DateTime.Parse(ds.Tables[0].Rows[0]["RingEndTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["TalkStartTime"]!=null && ds.Tables[0].Rows[0]["TalkStartTime"].ToString()!="")
				{
					model.TalkStartTime=DateTime.Parse(ds.Tables[0].Rows[0]["TalkStartTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["TalkEndTime"]!=null && ds.Tables[0].Rows[0]["TalkEndTime"].ToString()!="")
				{
					model.TalkEndTime=DateTime.Parse(ds.Tables[0].Rows[0]["TalkEndTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["EndTime"]!=null && ds.Tables[0].Rows[0]["EndTime"].ToString()!="")
				{
					model.EndTime=DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["LongTime"]!=null && ds.Tables[0].Rows[0]["LongTime"].ToString()!="")
				{
					model.LongTime=int.Parse(ds.Tables[0].Rows[0]["LongTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IvrLongTime"]!=null && ds.Tables[0].Rows[0]["IvrLongTime"].ToString()!="")
				{
					model.IvrLongTime=int.Parse(ds.Tables[0].Rows[0]["IvrLongTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["RingLongTime"]!=null && ds.Tables[0].Rows[0]["RingLongTime"].ToString()!="")
				{
					model.RingLongTime=int.Parse(ds.Tables[0].Rows[0]["RingLongTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["TalkLongTime"]!=null && ds.Tables[0].Rows[0]["TalkLongTime"].ToString()!="")
				{
					model.TalkLongTime=int.Parse(ds.Tables[0].Rows[0]["TalkLongTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["UserId"]!=null && ds.Tables[0].Rows[0]["UserId"].ToString()!="")
				{
					model.UserId=int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["UserCode"]!=null && ds.Tables[0].Rows[0]["UserCode"].ToString()!="")
				{
					model.UserCode=ds.Tables[0].Rows[0]["UserCode"].ToString();
				}
				if(ds.Tables[0].Rows[0]["UserName"]!=null && ds.Tables[0].Rows[0]["UserName"].ToString()!="")
				{
					model.UserName=ds.Tables[0].Rows[0]["UserName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ExtNumber"]!=null && ds.Tables[0].Rows[0]["ExtNumber"].ToString()!="")
				{
					model.ExtNumber=ds.Tables[0].Rows[0]["ExtNumber"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FilePath"]!=null && ds.Tables[0].Rows[0]["FilePath"].ToString()!="")
				{
					model.FilePath=ds.Tables[0].Rows[0]["FilePath"].ToString();
				}
				if(ds.Tables[0].Rows[0]["IsExitWorkOrder"]!=null && ds.Tables[0].Rows[0]["IsExitWorkOrder"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsExitWorkOrder"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsExitWorkOrder"].ToString().ToLower()=="true"))
					{
						model.IsExitWorkOrder=true;
					}
					else
					{
						model.IsExitWorkOrder=false;
					}
				}
				if(ds.Tables[0].Rows[0]["IsDeal"]!=null && ds.Tables[0].Rows[0]["IsDeal"].ToString()!="")
				{
					model.IsDeal=int.Parse(ds.Tables[0].Rows[0]["IsDeal"].ToString());
				}
				if(ds.Tables[0].Rows[0]["OperateType"]!=null && ds.Tables[0].Rows[0]["OperateType"].ToString()!="")
				{
					model.OperateType=int.Parse(ds.Tables[0].Rows[0]["OperateType"].ToString());
				}
				if(ds.Tables[0].Rows[0]["OperateObject"]!=null && ds.Tables[0].Rows[0]["OperateObject"].ToString()!="")
				{
					model.OperateObject=ds.Tables[0].Rows[0]["OperateObject"].ToString();
				}
				if(ds.Tables[0].Rows[0]["OperateTime"]!=null && ds.Tables[0].Rows[0]["OperateTime"].ToString()!="")
				{
					model.OperateTime=DateTime.Parse(ds.Tables[0].Rows[0]["OperateTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Remark"]!=null && ds.Tables[0].Rows[0]["Remark"].ToString()!="")
				{
					model.Remark=ds.Tables[0].Rows[0]["Remark"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MYD"]!=null && ds.Tables[0].Rows[0]["MYD"].ToString()!="")
				{
					model.MYD=int.Parse(ds.Tables[0].Rows[0]["MYD"].ToString());
				}
				if(ds.Tables[0].Rows[0]["BusinessType"]!=null && ds.Tables[0].Rows[0]["BusinessType"].ToString()!="")
				{
					model.BusinessType=int.Parse(ds.Tables[0].Rows[0]["BusinessType"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Location"]!=null && ds.Tables[0].Rows[0]["Location"].ToString()!="")
				{
					model.Location=ds.Tables[0].Rows[0]["Location"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CallRecordsId"]!=null && ds.Tables[0].Rows[0]["CallRecordsId"].ToString()!="")
				{
					model.CallRecordsId=int.Parse(ds.Tables[0].Rows[0]["CallRecordsId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["WaitStartTime"]!=null && ds.Tables[0].Rows[0]["WaitStartTime"].ToString()!="")
				{
					model.WaitStartTime=DateTime.Parse(ds.Tables[0].Rows[0]["WaitStartTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["WaitEndTime"]!=null && ds.Tables[0].Rows[0]["WaitEndTime"].ToString()!="")
				{
					model.WaitEndTime=DateTime.Parse(ds.Tables[0].Rows[0]["WaitEndTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["WaitLongTime"]!=null && ds.Tables[0].Rows[0]["WaitLongTime"].ToString()!="")
				{
					model.WaitLongTime=int.Parse(ds.Tables[0].Rows[0]["WaitLongTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["NoCallState"]!=null && ds.Tables[0].Rows[0]["NoCallState"].ToString()!="")
				{
					model.NoCallState=int.Parse(ds.Tables[0].Rows[0]["NoCallState"].ToString());
				}
				if(ds.Tables[0].Rows[0]["WorkTimesDiff"]!=null && ds.Tables[0].Rows[0]["WorkTimesDiff"].ToString()!="")
				{
					model.WorkTimesDiff=int.Parse(ds.Tables[0].Rows[0]["WorkTimesDiff"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_QCState"]!=null && ds.Tables[0].Rows[0]["F_QCState"].ToString()!="")
				{
					model.F_QCState=int.Parse(ds.Tables[0].Rows[0]["F_QCState"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_QCScore"]!=null && ds.Tables[0].Rows[0]["F_QCScore"].ToString()!="")
				{
					model.F_QCScore=decimal.Parse(ds.Tables[0].Rows[0]["F_QCScore"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_QCRemark"]!=null && ds.Tables[0].Rows[0]["F_QCRemark"].ToString()!="")
				{
					model.F_QCRemark=ds.Tables[0].Rows[0]["F_QCRemark"].ToString();
				}
				if(ds.Tables[0].Rows[0]["F_QCUserId"]!=null && ds.Tables[0].Rows[0]["F_QCUserId"].ToString()!="")
				{
					model.F_QCUserId=int.Parse(ds.Tables[0].Rows[0]["F_QCUserId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_QCUserName"]!=null && ds.Tables[0].Rows[0]["F_QCUserName"].ToString()!="")
				{
					model.F_QCUserName=ds.Tables[0].Rows[0]["F_QCUserName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["F_QCTime"]!=null && ds.Tables[0].Rows[0]["F_QCTime"].ToString()!="")
				{
					model.F_QCTime=DateTime.Parse(ds.Tables[0].Rows[0]["F_QCTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_QCIsSelect"]!=null && ds.Tables[0].Rows[0]["F_QCIsSelect"].ToString()!="")
				{
					model.F_QCIsSelect=int.Parse(ds.Tables[0].Rows[0]["F_QCIsSelect"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_HJJGId"]!=null && ds.Tables[0].Rows[0]["F_HJJGId"].ToString()!="")
				{
					model.F_HJJGId=int.Parse(ds.Tables[0].Rows[0]["F_HJJGId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["F_HJJGName"]!=null && ds.Tables[0].Rows[0]["F_HJJGName"].ToString()!="")
				{
					model.F_HJJGName=ds.Tables[0].Rows[0]["F_HJJGName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["F_Key1"]!=null && ds.Tables[0].Rows[0]["F_Key1"].ToString()!="")
				{
					model.F_Key1=ds.Tables[0].Rows[0]["F_Key1"].ToString();
				}
				if(ds.Tables[0].Rows[0]["F_Key2"]!=null && ds.Tables[0].Rows[0]["F_Key2"].ToString()!="")
				{
					model.F_Key2=ds.Tables[0].Rows[0]["F_Key2"].ToString();
				}
				if(ds.Tables[0].Rows[0]["F_Key3"]!=null && ds.Tables[0].Rows[0]["F_Key3"].ToString()!="")
				{
					model.F_Key3=ds.Tables[0].Rows[0]["F_Key3"].ToString();
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM T_Call_CallRecords ");
			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(" * ");
			strSql.Append(" FROM T_Call_CallRecords ");
			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_Call_CallRecords ");
			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.CallRecordsId desc");
			}
			strSql.Append(")AS Row, T.*  from T_Call_CallRecords 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_Call_CallRecords";
			parameters[1].Value = "CallRecordsId";
			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  Method
	}
}

