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

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

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

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

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


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(Model.T_FaultRepair_Base model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_FaultRepair_Base(");
			strSql.Append("F_WorkOrderCode,F_Applicant,F_ApplicationDept,F_Applicantsphone,F_Phone,F_WorkOrderCategory,F_Content,F_PlaceOfRepair,F_WorkOrderState,F_Maintenancer,F_MaintenanceDept,F_AssignTime,F_Endtime,F_UpdateTime,F_Deadline,F_CreateUser,F_CreateTime,F_CreateUserDept,F_File,F_ReturnNum,F_InternalWorkOrderCode,F_ExternalWorkOrderCode,F_IsDelete,F_LeaveRecordId,F_CallRecordId,F_CallId,F_IsStop,F_AssignUser,F_ReplayCount,F_EmergencyTypes,F_DeviceEncode)");
			strSql.Append(" values (");
			strSql.Append("@F_WorkOrderCode,@F_Applicant,@F_ApplicationDept,@F_Applicantsphone,@F_Phone,@F_WorkOrderCategory,@F_Content,@F_PlaceOfRepair,@F_WorkOrderState,@F_Maintenancer,@F_MaintenanceDept,@F_AssignTime,@F_Endtime,@F_UpdateTime,@F_Deadline,@F_CreateUser,@F_CreateTime,@F_CreateUserDept,@F_File,@F_ReturnNum,@F_InternalWorkOrderCode,@F_ExternalWorkOrderCode,@F_IsDelete,@F_LeaveRecordId,@F_CallRecordId,@F_CallId,@F_IsStop,@F_AssignUser,@F_ReplayCount,@F_EmergencyTypes,@F_DeviceEncode)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@F_WorkOrderCode", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Applicant", SqlDbType.NVarChar,50),
					new SqlParameter("@F_ApplicationDept", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Applicantsphone", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Phone", SqlDbType.NVarChar,50),
					new SqlParameter("@F_WorkOrderCategory", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Content", SqlDbType.NVarChar,1000),
					new SqlParameter("@F_PlaceOfRepair", SqlDbType.NVarChar,500),
					new SqlParameter("@F_WorkOrderState", SqlDbType.Int,4),
					new SqlParameter("@F_Maintenancer", SqlDbType.NVarChar,50),
					new SqlParameter("@F_MaintenanceDept", SqlDbType.NVarChar,50),
					new SqlParameter("@F_AssignTime", SqlDbType.DateTime),
					new SqlParameter("@F_Endtime", SqlDbType.DateTime),
					new SqlParameter("@F_UpdateTime", SqlDbType.DateTime),
					new SqlParameter("@F_Deadline", SqlDbType.DateTime),
					new SqlParameter("@F_CreateUser", SqlDbType.NVarChar,50),
					new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
					new SqlParameter("@F_CreateUserDept", SqlDbType.NVarChar,50),
					new SqlParameter("@F_File", SqlDbType.NVarChar,500),
					new SqlParameter("@F_ReturnNum", SqlDbType.Int,4),
					new SqlParameter("@F_InternalWorkOrderCode", SqlDbType.NVarChar,100),
					new SqlParameter("@F_ExternalWorkOrderCode", SqlDbType.NVarChar,100),
					new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
                    new SqlParameter("@F_LeaveRecordId", SqlDbType.Int,4),
                         new SqlParameter("@F_CallRecordId", SqlDbType.Int,4),
                         new SqlParameter("@F_CallId", SqlDbType.NVarChar,50),
                            new SqlParameter("@F_IsStop", SqlDbType.Int,4),
                            new SqlParameter("@F_AssignUser", SqlDbType.NVarChar,100)   ,
                             
 new SqlParameter("@F_ReplayCount", SqlDbType.Int,4),
  new SqlParameter("@F_EmergencyTypes",  SqlDbType.NVarChar,50),
    new SqlParameter("@F_DeviceEncode",  SqlDbType.NVarChar,50)
       


            };
			parameters[0].Value = model.F_WorkOrderCode;
			parameters[1].Value = model.F_Applicant;
			parameters[2].Value = model.F_ApplicationDept;
			parameters[3].Value = model.F_Applicantsphone;
			parameters[4].Value = model.F_Phone;
			parameters[5].Value = model.F_WorkOrderCategory;
			parameters[6].Value = model.F_Content;
			parameters[7].Value = model.F_PlaceOfRepair;
			parameters[8].Value = model.F_WorkOrderState;
			parameters[9].Value = model.F_Maintenancer;
			parameters[10].Value = model.F_MaintenanceDept;
			parameters[11].Value = model.F_AssignTime;
			parameters[12].Value = model.F_Endtime;
			parameters[13].Value = model.F_UpdateTime;
			parameters[14].Value = model.F_Deadline;
			parameters[15].Value = model.F_CreateUser;
			parameters[16].Value = model.F_CreateTime;
			parameters[17].Value = model.F_CreateUserDept;
			parameters[18].Value = model.F_File;
			parameters[19].Value = model.F_ReturnNum;
			parameters[20].Value = model.F_InternalWorkOrderCode;
			parameters[21].Value = model.F_ExternalWorkOrderCode;
			parameters[22].Value = model.F_IsDelete;
          
            parameters[23].Value = model.F_LeaveRecordId;
            parameters[24].Value = model.F_CallRecordId;
            parameters[25].Value = model.F_CallId;
            
            parameters[26].Value = model.F_IsStop;
            parameters[27].Value = model.F_AssignUser;
            parameters[28].Value = model.F_ReplayCount;
            parameters[29].Value = model.F_EmergencyTypes;
            parameters[30].Value = model.F_DeviceEncode;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update( Model.T_FaultRepair_Base model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_FaultRepair_Base set ");
			strSql.Append("F_WorkOrderCode=@F_WorkOrderCode,");
			strSql.Append("F_Applicant=@F_Applicant,");
			strSql.Append("F_ApplicationDept=@F_ApplicationDept,");
			strSql.Append("F_Applicantsphone=@F_Applicantsphone,");
			strSql.Append("F_Phone=@F_Phone,");
			strSql.Append("F_WorkOrderCategory=@F_WorkOrderCategory,");
			strSql.Append("F_Content=@F_Content,");
			strSql.Append("F_PlaceOfRepair=@F_PlaceOfRepair,");
			strSql.Append("F_WorkOrderState=@F_WorkOrderState,");
			strSql.Append("F_Maintenancer=@F_Maintenancer,");
			strSql.Append("F_MaintenanceDept=@F_MaintenanceDept,");
			strSql.Append("F_AssignTime=@F_AssignTime,");
			strSql.Append("F_Endtime=@F_Endtime,");
			strSql.Append("F_UpdateTime=@F_UpdateTime,");
			strSql.Append("F_Deadline=@F_Deadline,");
			strSql.Append("F_CreateUser=@F_CreateUser,");
			strSql.Append("F_CreateTime=@F_CreateTime,");
			strSql.Append("F_CreateUserDept=@F_CreateUserDept,");
			strSql.Append("F_File=@F_File,");
			strSql.Append("F_ReturnNum=@F_ReturnNum,");
			strSql.Append("F_InternalWorkOrderCode=@F_InternalWorkOrderCode,");
			strSql.Append("F_ExternalWorkOrderCode=@F_ExternalWorkOrderCode,");
			strSql.Append("F_IsDelete=@F_IsDelete,");

           
            strSql.Append("F_LeaveRecordId=@F_LeaveRecordId,");
            strSql.Append("F_CallRecordId=@F_CallRecordId,");
            strSql.Append("F_CallId=@F_CallId,");
            strSql.Append("F_Score=@F_Score,");
            strSql.Append("F_IsStop=@F_IsStop,");
            strSql.Append("F_StopTime=@F_StopTime,");
            strSql.Append("F_ArriveTime=@F_ArriveTime,");
            strSql.Append("F_AssignUser=@F_AssignUser,");
            strSql.Append("F_ReplayCount=@F_ReplayCount,");
            strSql.Append("MYD=@MYD,");
            strSql.Append("F_AcceptTime=@F_AcceptTime,");
            strSql.Append("F_EmergencyTypes=@F_EmergencyTypes,");
            strSql.Append("F_ConfirmEquip=@F_ConfirmEquip,");
            strSql.Append("F_DeviceEncode=@F_DeviceEncode");


            
            strSql.Append(" where F_WorkOrderId=@F_WorkOrderId");
			SqlParameter[] parameters = {
					new SqlParameter("@F_WorkOrderCode", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Applicant", SqlDbType.NVarChar,50),
					new SqlParameter("@F_ApplicationDept", SqlDbType.NVarChar,10),
					new SqlParameter("@F_Applicantsphone", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Phone", SqlDbType.NVarChar,50),
					new SqlParameter("@F_WorkOrderCategory", SqlDbType.NVarChar,50),
					new SqlParameter("@F_Content", SqlDbType.NVarChar,1000),
					new SqlParameter("@F_PlaceOfRepair", SqlDbType.NVarChar,500),
					new SqlParameter("@F_WorkOrderState", SqlDbType.Int,4),
					new SqlParameter("@F_Maintenancer", SqlDbType.NVarChar,50),
					new SqlParameter("@F_MaintenanceDept", SqlDbType.NVarChar,50),
					new SqlParameter("@F_AssignTime", SqlDbType.DateTime),
					new SqlParameter("@F_Endtime", SqlDbType.DateTime),
					new SqlParameter("@F_UpdateTime", SqlDbType.DateTime),
					new SqlParameter("@F_Deadline", SqlDbType.DateTime),
					new SqlParameter("@F_CreateUser", SqlDbType.NVarChar,50),
					new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
					new SqlParameter("@F_CreateUserDept", SqlDbType.NVarChar,50),
					new SqlParameter("@F_File", SqlDbType.NVarChar,500),
					new SqlParameter("@F_ReturnNum", SqlDbType.Int,4),
					new SqlParameter("@F_InternalWorkOrderCode", SqlDbType.NVarChar,100),
					new SqlParameter("@F_ExternalWorkOrderCode", SqlDbType.NVarChar,100),
					new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
					new SqlParameter("@F_WorkOrderId", SqlDbType.Int,4),
                    
                    new SqlParameter("@F_LeaveRecordId", SqlDbType.Int,4),
                    new SqlParameter("@F_CallRecordId", SqlDbType.Int,4),
                    new SqlParameter("@F_CallId", SqlDbType.NVarChar,50),
                      new SqlParameter("@F_Score", SqlDbType.Int,4),
                    new SqlParameter("@F_IsStop", SqlDbType.Int,4),
                  new SqlParameter("@F_StopTime", SqlDbType.DateTime),
                 new SqlParameter("@F_ArriveTime", SqlDbType.DateTime),
                    new SqlParameter("@F_AssignUser", SqlDbType.NVarChar,100) ,
                  new SqlParameter("@F_ReplayCount", SqlDbType.Int,4),
                  new SqlParameter("@MYD", SqlDbType.Int,4),
                   new SqlParameter("@F_AcceptTime", SqlDbType.DateTime),
                    new SqlParameter("@F_EmergencyTypes", SqlDbType.NVarChar,50) ,

                  new SqlParameter("@F_ConfirmEquip", SqlDbType.Int,4),
new SqlParameter("@F_DeviceEncode", SqlDbType.NVarChar,50)
                  


            };
			parameters[0].Value = model.F_WorkOrderCode;
			parameters[1].Value = model.F_Applicant;
			parameters[2].Value = model.F_ApplicationDept;
			parameters[3].Value = model.F_Applicantsphone;
			parameters[4].Value = model.F_Phone;
			parameters[5].Value = model.F_WorkOrderCategory;
			parameters[6].Value = model.F_Content;
			parameters[7].Value = model.F_PlaceOfRepair;
			parameters[8].Value = model.F_WorkOrderState;
			parameters[9].Value = model.F_Maintenancer;
			parameters[10].Value = model.F_MaintenanceDept;
			parameters[11].Value = model.F_AssignTime;
			parameters[12].Value = model.F_Endtime;
			parameters[13].Value = model.F_UpdateTime;
			parameters[14].Value = model.F_Deadline;
			parameters[15].Value = model.F_CreateUser;
			parameters[16].Value = model.F_CreateTime;
			parameters[17].Value = model.F_CreateUserDept;
			parameters[18].Value = model.F_File;
			parameters[19].Value = model.F_ReturnNum;
			parameters[20].Value = model.F_InternalWorkOrderCode;
			parameters[21].Value = model.F_ExternalWorkOrderCode;
			parameters[22].Value = model.F_IsDelete;
			parameters[23].Value = model.F_WorkOrderId;

            parameters[24].Value = model.F_LeaveRecordId;
            parameters[25].Value = model.F_CallRecordId;
            parameters[26].Value = model.F_CallId;
            parameters[27].Value = model.F_Score;
            parameters[28].Value = model.F_IsStop;

            parameters[29].Value = model.F_StopTime;

            parameters[30].Value = model.F_ArriveTime;

            parameters[31].Value = model.F_AssignUser;
            parameters[32].Value = model.F_ReplayCount;
            parameters[33].Value = model.MYD;
            parameters[34].Value = model.F_AcceptTime;
            parameters[35].Value = model.F_EmergencyTypes;
            parameters[36].Value = model.F_ConfirmEquip;
            parameters[37].Value = model.F_DeviceEncode;

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

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

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


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public RMYY_CallCenter_Api.Model.T_FaultRepair_Base GetModel(string workordercode)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 *  from T_FaultRepair_Base ");
			strSql.Append(" where F_WorkOrderCode=@F_WorkOrderId");
			SqlParameter[] parameters = {
					new SqlParameter("@F_WorkOrderId", SqlDbType.VarChar)
			};
			parameters[0].Value = workordercode;

            RMYY_CallCenter_Api.Model.T_FaultRepair_Base model=new RMYY_CallCenter_Api.Model.T_FaultRepair_Base();
			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 RMYY_CallCenter_Api.Model.T_FaultRepair_Base DataRowToModel(DataRow row)
		{
            RMYY_CallCenter_Api.Model.T_FaultRepair_Base model=new RMYY_CallCenter_Api.Model.T_FaultRepair_Base();
			if (row != null)
			{
                if (row["F_ConfirmEquip"] != null && row["F_ConfirmEquip"].ToString() != "")
                {
                    model.F_ConfirmEquip = int.Parse(row["F_ConfirmEquip"].ToString());
                }



                if (row["F_DeviceEncode"] != null)
                {
                    model.F_DeviceEncode = row["F_DeviceEncode"].ToString();
                }
                if (row["F_WorkOrderId"]!=null && row["F_WorkOrderId"].ToString()!="")
				{
					model.F_WorkOrderId=int.Parse(row["F_WorkOrderId"].ToString());
				}
				if(row["F_WorkOrderCode"]!=null)
				{
					model.F_WorkOrderCode=row["F_WorkOrderCode"].ToString();
				}
				if(row["F_Applicant"]!=null)
				{
					model.F_Applicant=row["F_Applicant"].ToString();
				}
              
                


                if (row["F_ApplicationDept"]!=null)
				{
					model.F_ApplicationDept=row["F_ApplicationDept"].ToString();
				}
				if(row["F_Applicantsphone"]!=null)
				{
					model.F_Applicantsphone=row["F_Applicantsphone"].ToString();
				}
				if(row["F_Phone"]!=null)
				{
					model.F_Phone=row["F_Phone"].ToString();
				}
				if(row["F_WorkOrderCategory"]!=null)
				{
					model.F_WorkOrderCategory=row["F_WorkOrderCategory"].ToString();
				}
				if(row["F_Content"]!=null)
				{
					model.F_Content=row["F_Content"].ToString();
				}
				if(row["F_PlaceOfRepair"]!=null)
				{
					model.F_PlaceOfRepair=row["F_PlaceOfRepair"].ToString();
				}
				if(row["F_WorkOrderState"]!=null && row["F_WorkOrderState"].ToString()!="")
				{
					model.F_WorkOrderState=int.Parse(row["F_WorkOrderState"].ToString());
				}
				if(row["F_Maintenancer"]!=null)
				{
					model.F_Maintenancer=row["F_Maintenancer"].ToString();
				}

                if (row["F_EmergencyTypes"] != null)
                {
                    model.F_EmergencyTypes = row["F_EmergencyTypes"].ToString();
                }
                if (row["F_MaintenanceDept"]!=null)
				{
					model.F_MaintenanceDept=row["F_MaintenanceDept"].ToString();
				}
				if(row["F_AssignTime"]!=null && row["F_AssignTime"].ToString()!="")
				{
					model.F_AssignTime=DateTime.Parse(row["F_AssignTime"].ToString());
				}
				if(row["F_Endtime"]!=null && row["F_Endtime"].ToString()!="")
				{
					model.F_Endtime=DateTime.Parse(row["F_Endtime"].ToString());
				}
                if (row["F_AcceptTime"] != null && row["F_AcceptTime"].ToString() != "")
                {
                    model.F_AcceptTime = DateTime.Parse(row["F_AcceptTime"].ToString());
                }
                if (row["F_UpdateTime"]!=null && row["F_UpdateTime"].ToString()!="")
				{
					model.F_UpdateTime=DateTime.Parse(row["F_UpdateTime"].ToString());
				}
				if(row["F_Deadline"]!=null && row["F_Deadline"].ToString()!="")
				{
					model.F_Deadline=DateTime.Parse(row["F_Deadline"].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_CreateUserDept"]!=null)
				{
					model.F_CreateUserDept=row["F_CreateUserDept"].ToString();
				}
				if(row["F_File"]!=null)
				{
					model.F_File=row["F_File"].ToString();
				}
				if(row["F_ReturnNum"]!=null && row["F_ReturnNum"].ToString()!="")
				{
					model.F_ReturnNum=int.Parse(row["F_ReturnNum"].ToString());
				}

                

    if (row["F_ReplayCount"] != null && row["F_ReplayCount"].ToString() != "")
                {
                    model.F_ReplayCount = int.Parse(row["F_ReplayCount"].ToString());
                }

                if (row["F_InternalWorkOrderCode"]!=null)
				{
					model.F_InternalWorkOrderCode=row["F_InternalWorkOrderCode"].ToString();
				}
				if(row["F_ExternalWorkOrderCode"]!=null)
				{
					model.F_ExternalWorkOrderCode=row["F_ExternalWorkOrderCode"].ToString();
				}
				if(row["F_IsDelete"]!=null && row["F_IsDelete"].ToString()!="")
				{
					model.F_IsDelete=int.Parse(row["F_IsDelete"].ToString());
				}
                if (row["F_IsStop"] != null && row["F_IsStop"].ToString() != "")
                {
                    model.F_IsStop = int.Parse(row["F_IsStop"].ToString());
                }

                

            }
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select *");
			strSql.Append(" FROM T_FaultRepair_Base ");
			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_WorkOrderId,F_WorkOrderCode,F_Applicant,F_ApplicationDept,F_Applicantsphone,F_Phone,F_WorkOrderCategory,F_Content,F_PlaceOfRepair,F_WorkOrderState,F_Maintenancer,F_MaintenanceDept,F_AssignTime,F_Endtime,F_UpdateTime,F_Deadline,F_CreateUser,F_CreateTime,F_CreateUserDept,F_File,F_ReturnNum,F_InternalWorkOrderCode,F_ExternalWorkOrderCode,F_IsDelete ,F_ReplayCount,F_AcceptTime,F_EmergencyTypes,F_DeviceEncode");
			strSql.Append(" FROM T_FaultRepair_Base ");
			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_FaultRepair_Base ");
			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_WorkOrderId desc");
			}
			strSql.Append(")AS Row, T.*  from T_FaultRepair_Base 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_FaultRepair_Base";
			parameters[1].Value = "F_WorkOrderId";
			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
	}
}

