/**  版本信息模板在安装目录下，可自行修改。
* T_Sys_AutoCallTime.cs
*
* 功 能： N/A
* 类 名： T_Sys_AutoCallTime
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2022/3/19 10:20:53   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
 
using CallCenterApi.DB;

namespace CallCenterApi.DAL
{
	/// <summary>
	/// 数据访问类:T_Sys_AutoCallTime
	/// </summary>
	public partial class T_Sys_AutoCallTime
	{
		public T_Sys_AutoCallTime()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(CallCenterApi.Model.T_Sys_AutoCallTime model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_Sys_AutoCallTime(");
			strSql.Append("F_amStartTime,F_amEndTme,F_pmStatTime,F_pmEndTme)");
			strSql.Append(" values (");
			strSql.Append("@F_amStartTime,@F_amEndTme,@F_pmStatTime,@F_pmEndTme)");
			SqlParameter[] parameters = {
					new SqlParameter("@F_amStartTime", SqlDbType.NChar,10),
					new SqlParameter("@F_amEndTme", SqlDbType.NChar,10),
					new SqlParameter("@F_pmStatTime", SqlDbType.NChar,10),
					new SqlParameter("@F_pmEndTme", SqlDbType.NChar,10)};
			parameters[0].Value = model.F_amStartTime;
			parameters[1].Value = model.F_amEndTme;
			parameters[2].Value = model.F_pmStatTime;
			parameters[3].Value = model.F_pmEndTme;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CallCenterApi.Model.T_Sys_AutoCallTime model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Sys_AutoCallTime set ");
            strSql.Append("F_amStartTime=@F_amStartTime,");
            strSql.Append("F_amEndTme=@F_amEndTme,");
            strSql.Append("F_pmStatTime=@F_pmStatTime,");
            strSql.Append("F_pmEndTme=@F_pmEndTme,");
            strSql.Append("F_ModifyDate=@F_ModifyDate,");
            strSql.Append("F_ModifyBy=@F_ModifyBy");
           
            SqlParameter[] parameters = {
                    new SqlParameter("@F_amStartTime", SqlDbType.NChar,10),
                    new SqlParameter("@F_amEndTme", SqlDbType.NChar,10),
                    new SqlParameter("@F_pmStatTime", SqlDbType.NChar,10),
                    new SqlParameter("@F_pmEndTme", SqlDbType.NChar,10),
                    new SqlParameter("@F_ModifyDate", SqlDbType.DateTime),
                    new SqlParameter("@F_ModifyBy", SqlDbType.NChar,20)


            };
            parameters[0].Value = model.F_amStartTime;
			parameters[1].Value = model.F_amEndTme;
			parameters[2].Value = model.F_pmStatTime;
			parameters[3].Value = model.F_pmEndTme;

            parameters[4].Value = model.F_ModifyDate;
            parameters[5].Value = model.F_ModifyBy;
            int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_Sys_AutoCallTime ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
			};

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


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public CallCenterApi.Model.T_Sys_AutoCallTime GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 F_amStartTime,F_amEndTme,F_pmStatTime,F_pmEndTme from T_Sys_AutoCallTime ");
			 

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


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public CallCenterApi.Model.T_Sys_AutoCallTime DataRowToModel(DataRow row)
		{
			CallCenterApi.Model.T_Sys_AutoCallTime model=new CallCenterApi.Model.T_Sys_AutoCallTime();
			if (row != null)
			{
				if(row["F_amStartTime"]!=null)
				{
					model.F_amStartTime=row["F_amStartTime"].ToString();
				}
				if(row["F_amEndTme"]!=null)
				{
					model.F_amEndTme=row["F_amEndTme"].ToString();
				}
				if(row["F_pmStatTime"]!=null)
				{
					model.F_pmStatTime=row["F_pmStatTime"].ToString();
				}
				if(row["F_pmEndTme"]!=null)
				{
					model.F_pmEndTme=row["F_pmEndTme"].ToString();
				}
			}
			return model;
		}

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

