using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using CallCenterApi.DB;

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

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


        /// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(CallCenterApi.Model.T_Repository_List model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_Repository_List(");
            strSql.Append("F_DeptId,F_Key,F_Title,F_MainDept,F_PublicPhone1,F_PublicPhone2,F_PrivatePhone1,F_PrivatePhone2,F_Points,F_BaseAnswer,F_EndAnswer,F_DealType,F_LegalLimitTime,F_PromiseLimitTime,F_IsPay,F_PayMoney,F_OfficeAddress,F_Object,F_BusLine,F_OfficeTime,F_OtherDept,F_OtherPublicPhone,F_OtherPrivatePhone,F_Remark,F_BaseOn,F_Process,F_Material,F_Template,F_PayInfo,F_File,F_State,F_CreateUser,F_CreateTime,F_IsDelete,F_DeleteUser,F_DeleteTime,F_UpdateUser,F_UpdateTime,F_ClickCount,F_ValidCount,F_InValidCount,F_AuditID,F_IsUrgent)");
            strSql.Append(" values (");
            strSql.Append("@F_DeptId,@F_Key,@F_Title,@F_MainDept,@F_PublicPhone1,@F_PublicPhone2,@F_PrivatePhone1,@F_PrivatePhone2,@F_Points,@F_BaseAnswer,@F_EndAnswer,@F_DealType,@F_LegalLimitTime,@F_PromiseLimitTime,@F_IsPay,@F_PayMoney,@F_OfficeAddress,@F_Object,@F_BusLine,@F_OfficeTime,@F_OtherDept,@F_OtherPublicPhone,@F_OtherPrivatePhone,@F_Remark,@F_BaseOn,@F_Process,@F_Material,@F_Template,@F_PayInfo,@F_File,@F_State,@F_CreateUser,@F_CreateTime,@F_IsDelete,@F_DeleteUser,@F_DeleteTime,@F_UpdateUser,@F_UpdateTime,@F_ClickCount,@F_ValidCount,@F_InValidCount,@F_AuditID,@F_IsUrgent)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_DeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_Key", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_Title", SqlDbType.NVarChar,2000),
                    new SqlParameter("@F_MainDept", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_PublicPhone1", SqlDbType.VarChar,200),
                    new SqlParameter("@F_PublicPhone2", SqlDbType.VarChar,200),
                    new SqlParameter("@F_PrivatePhone1", SqlDbType.VarChar,200),
                    new SqlParameter("@F_PrivatePhone2", SqlDbType.VarChar,200),
                    new SqlParameter("@F_Points", SqlDbType.NVarChar),
                    new SqlParameter("@F_BaseAnswer", SqlDbType.NVarChar),
                    new SqlParameter("@F_EndAnswer", SqlDbType.NVarChar),
                    new SqlParameter("@F_DealType", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_LegalLimitTime", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_PromiseLimitTime", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_IsPay", SqlDbType.Int,4),
                    new SqlParameter("@F_PayMoney", SqlDbType.Decimal,9),
                    new SqlParameter("@F_OfficeAddress", SqlDbType.NVarChar,2000),
                    new SqlParameter("@F_Object", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_BusLine", SqlDbType.NVarChar),
                    new SqlParameter("@F_OfficeTime", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_OtherDept", SqlDbType.NVarChar),
                    new SqlParameter("@F_OtherPublicPhone", SqlDbType.VarChar,200),
                    new SqlParameter("@F_OtherPrivatePhone", SqlDbType.VarChar,200),
                    new SqlParameter("@F_Remark", SqlDbType.NVarChar),
                    new SqlParameter("@F_BaseOn", SqlDbType.NVarChar),
                    new SqlParameter("@F_Process", SqlDbType.NVarChar),
                    new SqlParameter("@F_Material", SqlDbType.NVarChar),
                    new SqlParameter("@F_Template", SqlDbType.NVarChar),
                    new SqlParameter("@F_PayInfo", SqlDbType.NVarChar),
                    new SqlParameter("@F_File", SqlDbType.VarChar),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_UpdateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_UpdateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_ClickCount", SqlDbType.Int,4),
                    new SqlParameter("@F_ValidCount", SqlDbType.Int,4),
                    new SqlParameter("@F_InValidCount", SqlDbType.Int,4),
                    new SqlParameter("@F_AuditID", SqlDbType.Int,4),
                    new SqlParameter("@F_IsUrgent", SqlDbType.Int,4)};
            parameters[0].Value = model.F_DeptId;
            parameters[1].Value = model.F_Key;
            parameters[2].Value = model.F_Title;
            parameters[3].Value = model.F_MainDept;
            parameters[4].Value = model.F_PublicPhone1;
            parameters[5].Value = model.F_PublicPhone2;
            parameters[6].Value = model.F_PrivatePhone1;
            parameters[7].Value = model.F_PrivatePhone2;
            parameters[8].Value = model.F_Points;
            parameters[9].Value = model.F_BaseAnswer;
            parameters[10].Value = model.F_EndAnswer;
            parameters[11].Value = model.F_DealType;
            parameters[12].Value = model.F_LegalLimitTime;
            parameters[13].Value = model.F_PromiseLimitTime;
            parameters[14].Value = model.F_IsPay;
            parameters[15].Value = model.F_PayMoney;
            parameters[16].Value = model.F_OfficeAddress;
            parameters[17].Value = model.F_Object;
            parameters[18].Value = model.F_BusLine;
            parameters[19].Value = model.F_OfficeTime;
            parameters[20].Value = model.F_OtherDept;
            parameters[21].Value = model.F_OtherPublicPhone;
            parameters[22].Value = model.F_OtherPrivatePhone;
            parameters[23].Value = model.F_Remark;
            parameters[24].Value = model.F_BaseOn;
            parameters[25].Value = model.F_Process;
            parameters[26].Value = model.F_Material;
            parameters[27].Value = model.F_Template;
            parameters[28].Value = model.F_PayInfo;
            parameters[29].Value = model.F_File;
            parameters[30].Value = model.F_State;
            parameters[31].Value = model.F_CreateUser;
            parameters[32].Value = model.F_CreateTime;
            parameters[33].Value = model.F_IsDelete;
            parameters[34].Value = model.F_DeleteUser;
            parameters[35].Value = model.F_DeleteTime;
            parameters[36].Value = model.F_UpdateUser;
            parameters[37].Value = model.F_UpdateTime;
            parameters[38].Value = model.F_ClickCount;
            parameters[39].Value = model.F_ValidCount;
            parameters[40].Value = model.F_InValidCount;
            parameters[41].Value = model.F_AuditID;
            parameters[42].Value = model.F_IsUrgent;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CallCenterApi.Model.T_Repository_List model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Repository_List set ");
            strSql.Append("F_DeptId=@F_DeptId,");
            strSql.Append("F_Key=@F_Key,");
            strSql.Append("F_Title=@F_Title,");
            strSql.Append("F_MainDept=@F_MainDept,");
            strSql.Append("F_PublicPhone1=@F_PublicPhone1,");
            strSql.Append("F_PublicPhone2=@F_PublicPhone2,");
            strSql.Append("F_PrivatePhone1=@F_PrivatePhone1,");
            strSql.Append("F_PrivatePhone2=@F_PrivatePhone2,");
            strSql.Append("F_Points=@F_Points,");
            strSql.Append("F_BaseAnswer=@F_BaseAnswer,");
            strSql.Append("F_EndAnswer=@F_EndAnswer,");
            strSql.Append("F_DealType=@F_DealType,");
            strSql.Append("F_LegalLimitTime=@F_LegalLimitTime,");
            strSql.Append("F_PromiseLimitTime=@F_PromiseLimitTime,");
            strSql.Append("F_IsPay=@F_IsPay,");
            strSql.Append("F_PayMoney=@F_PayMoney,");
            strSql.Append("F_OfficeAddress=@F_OfficeAddress,");
            strSql.Append("F_Object=@F_Object,");
            strSql.Append("F_BusLine=@F_BusLine,");
            strSql.Append("F_OfficeTime=@F_OfficeTime,");
            strSql.Append("F_OtherDept=@F_OtherDept,");
            strSql.Append("F_OtherPublicPhone=@F_OtherPublicPhone,");
            strSql.Append("F_OtherPrivatePhone=@F_OtherPrivatePhone,");
            strSql.Append("F_Remark=@F_Remark,");
            strSql.Append("F_BaseOn=@F_BaseOn,");
            strSql.Append("F_Process=@F_Process,");
            strSql.Append("F_Material=@F_Material,");
            strSql.Append("F_Template=@F_Template,");
            strSql.Append("F_PayInfo=@F_PayInfo,");
            strSql.Append("F_File=@F_File,");
            strSql.Append("F_State=@F_State,");
            strSql.Append("F_CreateUser=@F_CreateUser,");
            strSql.Append("F_CreateTime=@F_CreateTime,");
            strSql.Append("F_IsDelete=@F_IsDelete,");
            strSql.Append("F_DeleteUser=@F_DeleteUser,");
            strSql.Append("F_DeleteTime=@F_DeleteTime,");
            strSql.Append("F_UpdateUser=@F_UpdateUser,");
            strSql.Append("F_UpdateTime=@F_UpdateTime,");
            strSql.Append("F_ClickCount=@F_ClickCount,");
            strSql.Append("F_ValidCount=@F_ValidCount,");
            strSql.Append("F_InValidCount=@F_InValidCount,");
            strSql.Append("F_AuditID=@F_AuditID,");
            strSql.Append("F_IsUrgent=@F_IsUrgent");
            strSql.Append(" where F_Id=@F_Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_DeptId", SqlDbType.Int,4),
                     new SqlParameter("@F_Key", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_Title", SqlDbType.NVarChar,2000),
                    new SqlParameter("@F_MainDept", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_PublicPhone1", SqlDbType.VarChar,200),
                    new SqlParameter("@F_PublicPhone2", SqlDbType.VarChar,200),
                    new SqlParameter("@F_PrivatePhone1", SqlDbType.VarChar,200),
                    new SqlParameter("@F_PrivatePhone2", SqlDbType.VarChar,200),
                    new SqlParameter("@F_Points", SqlDbType.NVarChar),
                    new SqlParameter("@F_BaseAnswer", SqlDbType.NVarChar),
                    new SqlParameter("@F_EndAnswer", SqlDbType.NVarChar),
                    new SqlParameter("@F_DealType", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_LegalLimitTime", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_PromiseLimitTime", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_IsPay", SqlDbType.Int,4),
                    new SqlParameter("@F_PayMoney", SqlDbType.Decimal,9),
                    new SqlParameter("@F_OfficeAddress", SqlDbType.NVarChar,2000),
                    new SqlParameter("@F_Object", SqlDbType.NVarChar,500),
                    new SqlParameter("@F_BusLine", SqlDbType.NVarChar),
                    new SqlParameter("@F_OfficeTime", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_OtherDept", SqlDbType.NVarChar),
                    new SqlParameter("@F_OtherPublicPhone", SqlDbType.VarChar,200),
                    new SqlParameter("@F_OtherPrivatePhone", SqlDbType.VarChar,200),
                    new SqlParameter("@F_Remark", SqlDbType.NVarChar),
                    new SqlParameter("@F_BaseOn", SqlDbType.NVarChar),
                    new SqlParameter("@F_Process", SqlDbType.NVarChar),
                    new SqlParameter("@F_Material", SqlDbType.NVarChar),
                    new SqlParameter("@F_Template", SqlDbType.NVarChar),
                    new SqlParameter("@F_PayInfo", SqlDbType.NVarChar),
                    new SqlParameter("@F_File", SqlDbType.VarChar),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_UpdateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_UpdateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_ClickCount", SqlDbType.Int,4),
                    new SqlParameter("@F_ValidCount", SqlDbType.Int,4),
                    new SqlParameter("@F_InValidCount", SqlDbType.Int,4),
                    new SqlParameter("@F_AuditID", SqlDbType.Int,4),
                    new SqlParameter("@F_IsUrgent", SqlDbType.Int,4),
                    new SqlParameter("@F_Id", SqlDbType.Int,4)};
            parameters[0].Value = model.F_DeptId;
            parameters[1].Value = model.F_Key;
            parameters[2].Value = model.F_Title;
            parameters[3].Value = model.F_MainDept;
            parameters[4].Value = model.F_PublicPhone1;
            parameters[5].Value = model.F_PublicPhone2;
            parameters[6].Value = model.F_PrivatePhone1;
            parameters[7].Value = model.F_PrivatePhone2;
            parameters[8].Value = model.F_Points;
            parameters[9].Value = model.F_BaseAnswer;
            parameters[10].Value = model.F_EndAnswer;
            parameters[11].Value = model.F_DealType;
            parameters[12].Value = model.F_LegalLimitTime;
            parameters[13].Value = model.F_PromiseLimitTime;
            parameters[14].Value = model.F_IsPay;
            parameters[15].Value = model.F_PayMoney;
            parameters[16].Value = model.F_OfficeAddress;
            parameters[17].Value = model.F_Object;
            parameters[18].Value = model.F_BusLine;
            parameters[19].Value = model.F_OfficeTime;
            parameters[20].Value = model.F_OtherDept;
            parameters[21].Value = model.F_OtherPublicPhone;
            parameters[22].Value = model.F_OtherPrivatePhone;
            parameters[23].Value = model.F_Remark;
            parameters[24].Value = model.F_BaseOn;
            parameters[25].Value = model.F_Process;
            parameters[26].Value = model.F_Material;
            parameters[27].Value = model.F_Template;
            parameters[28].Value = model.F_PayInfo;
            parameters[29].Value = model.F_File;
            parameters[30].Value = model.F_State;
            parameters[31].Value = model.F_CreateUser;
            parameters[32].Value = model.F_CreateTime;
            parameters[33].Value = model.F_IsDelete;
            parameters[34].Value = model.F_DeleteUser;
            parameters[35].Value = model.F_DeleteTime;
            parameters[36].Value = model.F_UpdateUser;
            parameters[37].Value = model.F_UpdateTime;
            parameters[38].Value = model.F_ClickCount;
            parameters[39].Value = model.F_ValidCount;
            parameters[40].Value = model.F_InValidCount;
            parameters[41].Value = model.F_AuditID;
            parameters[42].Value = model.F_IsUrgent;
            parameters[43].Value = model.F_Id;

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


        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int F_Id, string usercode)
        {

            StringBuilder strSql = new StringBuilder();
            //strSql.Append("delete from T_Repository_List ");
            strSql.Append(" update T_Repository_List set F_IsDelete=1,F_DeleteUser='" + usercode + "',F_DeleteTime=getdate()");
            strSql.Append(" where F_Id=@F_Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_Id", SqlDbType.Int,4)
            };
            parameters[0].Value = F_Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string F_Idlist,string usercode)
        {
            StringBuilder strSql = new StringBuilder();
            //strSql.Append("delete from T_Repository_List ");
            strSql.Append(" update T_Repository_List set F_IsDelete=1,F_DeleteUser='" + usercode + "',F_DeleteTime=getdate()");
            strSql.Append(" where F_Id in (" + F_Idlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CallCenterApi.Model.T_Repository_List GetModel(int F_Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from T_Repository_List ");
            strSql.Append(" where F_Id=@F_Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_Id", SqlDbType.Int,4)
            };
            parameters[0].Value = F_Id;

            CallCenterApi.Model.T_Repository_List model = new CallCenterApi.Model.T_Repository_List();
            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 CallCenterApi.Model.T_Repository_List DataRowToModel(DataRow row)
        {
            CallCenterApi.Model.T_Repository_List model = new CallCenterApi.Model.T_Repository_List();
            if (row != null)
            {
                if (row["F_Id"] != null && row["F_Id"].ToString() != "")
                {
                    model.F_Id = int.Parse(row["F_Id"].ToString());
                }
                if (row["F_DeptId"] != null && row["F_DeptId"].ToString() != "")
                {
                    model.F_DeptId = int.Parse(row["F_DeptId"].ToString());
                }
                if (row["F_Key"] != null)
                {
                    model.F_Key = row["F_Key"].ToString();
                }
                if (row["F_Title"] != null)
                {
                    model.F_Title = row["F_Title"].ToString();
                }
                if (row["F_MainDept"] != null)
                {
                    model.F_MainDept = row["F_MainDept"].ToString();
                }
                if (row["F_PublicPhone1"] != null)
                {
                    model.F_PublicPhone1 = row["F_PublicPhone1"].ToString();
                }
                if (row["F_PublicPhone2"] != null)
                {
                    model.F_PublicPhone2 = row["F_PublicPhone2"].ToString();
                }
                if (row["F_PrivatePhone1"] != null)
                {
                    model.F_PrivatePhone1 = row["F_PrivatePhone1"].ToString();
                }
                if (row["F_PrivatePhone2"] != null)
                {
                    model.F_PrivatePhone2 = row["F_PrivatePhone2"].ToString();
                }
                if (row["F_Points"] != null)
                {
                    model.F_Points = row["F_Points"].ToString();
                }
                if (row["F_BaseAnswer"] != null)
                {
                    model.F_BaseAnswer = row["F_BaseAnswer"].ToString();
                }
                if (row["F_EndAnswer"] != null)
                {
                    model.F_EndAnswer = row["F_EndAnswer"].ToString();
                }
                if (row["F_DealType"] != null)
                {
                    model.F_DealType = row["F_DealType"].ToString();
                }
                if (row["F_LegalLimitTime"] != null)
                {
                    model.F_LegalLimitTime = row["F_LegalLimitTime"].ToString();
                }
                if (row["F_PromiseLimitTime"] != null)
                {
                    model.F_PromiseLimitTime = row["F_PromiseLimitTime"].ToString();
                }
                if (row["F_IsPay"] != null && row["F_IsPay"].ToString() != "")
                {
                    model.F_IsPay = int.Parse(row["F_IsPay"].ToString());
                }
                if (row["F_PayMoney"] != null && row["F_PayMoney"].ToString() != "")
                {
                    model.F_PayMoney = decimal.Parse(row["F_PayMoney"].ToString());
                }
                if (row["F_OfficeAddress"] != null)
                {
                    model.F_OfficeAddress = row["F_OfficeAddress"].ToString();
                }
                if (row["F_Object"] != null)
                {
                    model.F_Object = row["F_Object"].ToString();
                }
                if (row["F_BusLine"] != null)
                {
                    model.F_BusLine = row["F_BusLine"].ToString();
                }
                if (row["F_OfficeTime"] != null)
                {
                    model.F_OfficeTime = row["F_OfficeTime"].ToString();
                }
                if (row["F_OtherDept"] != null)
                {
                    model.F_OtherDept = row["F_OtherDept"].ToString();
                }
                if (row["F_OtherPublicPhone"] != null)
                {
                    model.F_OtherPublicPhone = row["F_OtherPublicPhone"].ToString();
                }
                if (row["F_OtherPrivatePhone"] != null)
                {
                    model.F_OtherPrivatePhone = row["F_OtherPrivatePhone"].ToString();
                }
                if (row["F_Remark"] != null)
                {
                    model.F_Remark = row["F_Remark"].ToString();
                }
                if (row["F_BaseOn"] != null)
                {
                    model.F_BaseOn = row["F_BaseOn"].ToString();
                }
                if (row["F_Process"] != null)
                {
                    model.F_Process = row["F_Process"].ToString();
                }
                if (row["F_Material"] != null)
                {
                    model.F_Material = row["F_Material"].ToString();
                }
                if (row["F_Template"] != null)
                {
                    model.F_Template = row["F_Template"].ToString();
                }
                if (row["F_PayInfo"] != null)
                {
                    model.F_PayInfo = row["F_PayInfo"].ToString();
                }
                if (row["F_File"] != null)
                {
                    model.F_File = row["F_File"].ToString();
                }
                if (row["F_State"] != null && row["F_State"].ToString() != "")
                {
                    model.F_State = int.Parse(row["F_State"].ToString());
                }
                if (row["F_CreateUser"] != null)
                {
                    model.F_CreateUser = row["F_CreateUser"].ToString();
                }
                if (row["F_CreateTime"] != null && row["F_CreateTime"].ToString() != "")
                {
                    model.F_CreateTime = DateTime.Parse(row["F_CreateTime"].ToString());
                }
                if (row["F_IsDelete"] != null && row["F_IsDelete"].ToString() != "")
                {
                    model.F_IsDelete = int.Parse(row["F_IsDelete"].ToString());
                }
                if (row["F_DeleteUser"] != null)
                {
                    model.F_DeleteUser = row["F_DeleteUser"].ToString();
                }
                if (row["F_DeleteTime"] != null && row["F_DeleteTime"].ToString() != "")
                {
                    model.F_DeleteTime = DateTime.Parse(row["F_DeleteTime"].ToString());
                }
                if (row["F_UpdateUser"] != null)
                {
                    model.F_UpdateUser = row["F_UpdateUser"].ToString();
                }
                if (row["F_UpdateTime"] != null && row["F_UpdateTime"].ToString() != "")
                {
                    model.F_UpdateTime = DateTime.Parse(row["F_UpdateTime"].ToString());
                }
                if (row["F_ClickCount"] != null && row["F_ClickCount"].ToString() != "")
                {
                    model.F_ClickCount = int.Parse(row["F_ClickCount"].ToString());
                }
                if (row["F_ValidCount"] != null && row["F_ValidCount"].ToString() != "")
                {
                    model.F_ValidCount = int.Parse(row["F_ValidCount"].ToString());
                }
                if (row["F_InValidCount"] != null && row["F_InValidCount"].ToString() != "")
                {
                    model.F_InValidCount = int.Parse(row["F_InValidCount"].ToString());
                }
                if (row["F_AuditID"] != null && row["F_AuditID"].ToString() != "")
                {
                    model.F_AuditID = int.Parse(row["F_AuditID"].ToString());
                }
                if (row["F_IsUrgent"] != null && row["F_IsUrgent"].ToString() != "")
                {
                    model.F_IsUrgent = int.Parse(row["F_IsUrgent"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM T_Repository_List ");
            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_Repository_List ");
            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_Repository_List ");
            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_Id desc");
            }
            strSql.Append(")AS Row, T.*  from T_Repository_List 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_Repository_List";
			parameters[1].Value = "F_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  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

