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

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

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

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int F_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_Car_WorkOrder");
            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(RMYY_CallCenter_Api.Model.T_Car_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_Car_WorkOrder(");
            strSql.Append("F_WorkOrderCode,F_Type,F_HosId,F_ProposerDeptId,F_Source,F_CallID,F_DepartPlace,F_Destination,F_ProposerCode,F_Phon,F_CarType,F_Remark,F_CreateTime,F_CarMessage,F_DriverCode,F_DriverPhon,F_DepartTime,F_DriverName,F_ProposerName,F_State,F_IsDel,F_DeleteBy,F_DeleteTime,F_CreateUser,F_AssistMan,F_IsAssist,F_FinishTime,F_CarId,F_AssistManName,F_ControlManCode,F_ControlManName,F_Content,F_UseTime,F_StartTime,F_EndTime,F_StartFile,F_EndFile,F_Birth,F_LeaveRecordId,F_EmergencyTypes)");
            strSql.Append(" values (");
            strSql.Append("@F_WorkOrderCode,@F_Type,@F_HosId,@F_ProposerDeptId,@F_Source,@F_CallID,@F_DepartPlace,@F_Destination,@F_ProposerCode,@F_Phon,@F_CarType,@F_Remark,@F_CreateTime,@F_CarMessage,@F_DriverCode,@F_DriverPhon,@F_DepartTime,@F_DriverName,@F_ProposerName,@F_State,@F_IsDel,@F_DeleteBy,@F_DeleteTime,@F_CreateUser,@F_AssistMan,@F_IsAssist,@F_FinishTime,@F_CarId,@F_AssistManName,@F_ControlManCode,@F_ControlManName,@F_Content,@F_UseTime,@F_StartTime,@F_EndTime,@F_StartFile,@F_EndFile,@F_Birth,@F_LeaveRecordId,@F_EmergencyTypes)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Type", SqlDbType.Int,4),
                    new SqlParameter("@F_HosId", SqlDbType.Int,4),
                    new SqlParameter("@F_ProposerDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_Source", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_CallID", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DepartPlace", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_Destination", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_ProposerCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Phon", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_CarType", SqlDbType.Int,4),
                    new SqlParameter("@F_Remark", SqlDbType.NText),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CarMessage", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_DriverCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DriverPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_DepartTime", SqlDbType.DateTime),
                    new SqlParameter("@F_DriverName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_IsDel", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteBy", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AssistMan", SqlDbType.VarChar,50),
                    new SqlParameter("@F_IsAssist", SqlDbType.Int,4),
                    new SqlParameter("@F_FinishTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CarId", SqlDbType.Int,4),
                    new SqlParameter("@F_AssistManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ControlManCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ControlManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Content", SqlDbType.VarChar,-1),
                    new SqlParameter("@F_UseTime", SqlDbType.VarChar,500),
                    new SqlParameter("@F_StartTime", SqlDbType.DateTime),
                    new SqlParameter("@F_EndTime", SqlDbType.DateTime),
                    new SqlParameter("@F_StartFile", SqlDbType.VarChar,50),
                    new SqlParameter("@F_EndFile", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Birth", SqlDbType.Int,4),
                    new SqlParameter("@F_LeaveRecordId", SqlDbType.Int,4),


   new SqlParameter("@F_EmergencyTypes", SqlDbType.NVarChar,50) 


            };
            parameters[0].Value = model.F_WorkOrderCode;
            parameters[1].Value = model.F_Type;
            parameters[2].Value = model.F_HosId;
            parameters[3].Value = model.F_ProposerDeptId;
            parameters[4].Value = model.F_Source;
            parameters[5].Value = model.F_CallID;
            parameters[6].Value = model.F_DepartPlace;
            parameters[7].Value = model.F_Destination;
            parameters[8].Value = model.F_ProposerCode;
            parameters[9].Value = model.F_Phon;
            parameters[10].Value = model.F_CarType;
            parameters[11].Value = model.F_Remark;
            parameters[12].Value = model.F_CreateTime;
            parameters[13].Value = model.F_CarMessage;
            parameters[14].Value = model.F_DriverCode;
            parameters[15].Value = model.F_DriverPhon;
            parameters[16].Value = model.F_DepartTime;
            parameters[17].Value = model.F_DriverName;
            parameters[18].Value = model.F_ProposerName;
            parameters[19].Value = model.F_State;
            parameters[20].Value = model.F_IsDel;
            parameters[21].Value = model.F_DeleteBy;
            parameters[22].Value = model.F_DeleteTime;
            parameters[23].Value = model.F_CreateUser;
            parameters[24].Value = model.F_AssistMan;
            parameters[25].Value = model.F_IsAssist;
            parameters[26].Value = model.F_FinishTime;
            parameters[27].Value = model.F_CarId;
            parameters[28].Value = model.F_AssistManName;
            parameters[29].Value = model.F_ControlManCode;
            parameters[30].Value = model.F_ControlManName;
            parameters[31].Value = model.F_Content;
            parameters[32].Value = model.F_UseTime;
            parameters[33].Value = model.F_StartTime;
            parameters[34].Value = model.F_EndTime;
            parameters[35].Value = model.F_StartFile;
            parameters[36].Value = model.F_EndFile;
            parameters[37].Value = model.F_Birth;
            parameters[38].Value = model.F_LeaveRecordId;
            parameters[39].Value = model.F_EmergencyTypes;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(RMYY_CallCenter_Api.Model.T_Car_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Car_WorkOrder set ");
            strSql.Append("F_WorkOrderCode=@F_WorkOrderCode,");
            strSql.Append("F_Type=@F_Type,");
            strSql.Append("F_HosId=@F_HosId,");
            strSql.Append("F_ProposerDeptId=@F_ProposerDeptId,");
            strSql.Append("F_Source=@F_Source,");
            strSql.Append("F_CallID=@F_CallID,");
            strSql.Append("F_DepartPlace=@F_DepartPlace,");
            strSql.Append("F_Destination=@F_Destination,");
            strSql.Append("F_ProposerCode=@F_ProposerCode,");
            strSql.Append("F_Phon=@F_Phon,");
            strSql.Append("F_CarType=@F_CarType,");
            strSql.Append("F_Remark=@F_Remark,");
            strSql.Append("F_CreateTime=@F_CreateTime,");
            strSql.Append("F_CarMessage=@F_CarMessage,");
            strSql.Append("F_DriverCode=@F_DriverCode,");
            strSql.Append("F_DriverPhon=@F_DriverPhon,");
            strSql.Append("F_DepartTime=@F_DepartTime,");
            strSql.Append("F_DriverName=@F_DriverName,");
            strSql.Append("F_ProposerName=@F_ProposerName,");
            strSql.Append("F_State=@F_State,");
            strSql.Append("F_IsDel=@F_IsDel,");
            strSql.Append("F_DeleteBy=@F_DeleteBy,");
            strSql.Append("F_DeleteTime=@F_DeleteTime,");
            strSql.Append("F_CreateUser=@F_CreateUser,");
            strSql.Append("F_AssistMan=@F_AssistMan,");
            strSql.Append("F_IsAssist=@F_IsAssist,");
            strSql.Append("F_FinishTime=@F_FinishTime,");
            strSql.Append("F_CarId=@F_CarId,");
            strSql.Append("F_AssistManName=@F_AssistManName,");
            strSql.Append("F_ControlManCode=@F_ControlManCode,");
            strSql.Append("F_ControlManName=@F_ControlManName,");
            strSql.Append("F_Content=@F_Content,");
            strSql.Append("F_UseTime=@F_UseTime,");
            strSql.Append("F_StartTime=@F_StartTime,");
            strSql.Append("F_EndTime=@F_EndTime,");
            strSql.Append("F_StartFile=@F_StartFile,");
            strSql.Append("F_EndFile=@F_EndFile,");
            strSql.Append("F_Birth=@F_Birth,");
            strSql.Append("MYD=@MYD,");
            strSql.Append("F_AcceptTime=@F_AcceptTime,");

            strSql.Append("F_EmergencyTypes=@F_EmergencyTypes,");

            strSql.Append("F_LeaveRecordId=@F_LeaveRecordId");
            
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Type", SqlDbType.Int,4),
                    new SqlParameter("@F_HosId", SqlDbType.Int,4),
                    new SqlParameter("@F_ProposerDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_Source", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_CallID", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DepartPlace", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_Destination", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_ProposerCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Phon", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_CarType", SqlDbType.Int,4),
                    new SqlParameter("@F_Remark", SqlDbType.NText),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CarMessage", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_DriverCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DriverPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_DepartTime", SqlDbType.DateTime),
                    new SqlParameter("@F_DriverName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_IsDel", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteBy", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AssistMan", SqlDbType.VarChar,50),
                    new SqlParameter("@F_IsAssist", SqlDbType.Int,4),
                    new SqlParameter("@F_FinishTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CarId", SqlDbType.Int,4),
                    new SqlParameter("@F_AssistManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ControlManCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ControlManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Content", SqlDbType.VarChar,-1),
                    new SqlParameter("@F_UseTime", SqlDbType.VarChar,500),
                    new SqlParameter("@F_StartTime", SqlDbType.DateTime),
                    new SqlParameter("@F_EndTime", SqlDbType.DateTime),
                    new SqlParameter("@F_StartFile", SqlDbType.VarChar,50),
                    new SqlParameter("@F_EndFile", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Birth", 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_LeaveRecordId", SqlDbType.Int,4),
                    
                    new SqlParameter("@F_ID", SqlDbType.Int,4)};
            parameters[0].Value = model.F_WorkOrderCode;
            parameters[1].Value = model.F_Type;
            parameters[2].Value = model.F_HosId;
            parameters[3].Value = model.F_ProposerDeptId;
            parameters[4].Value = model.F_Source;
            parameters[5].Value = model.F_CallID;
            parameters[6].Value = model.F_DepartPlace;
            parameters[7].Value = model.F_Destination;
            parameters[8].Value = model.F_ProposerCode;
            parameters[9].Value = model.F_Phon;
            parameters[10].Value = model.F_CarType;
            parameters[11].Value = model.F_Remark;
            parameters[12].Value = model.F_CreateTime;
            parameters[13].Value = model.F_CarMessage;
            parameters[14].Value = model.F_DriverCode;
            parameters[15].Value = model.F_DriverPhon;
            parameters[16].Value = model.F_DepartTime;
            parameters[17].Value = model.F_DriverName;
            parameters[18].Value = model.F_ProposerName;
            parameters[19].Value = model.F_State;
            parameters[20].Value = model.F_IsDel;
            parameters[21].Value = model.F_DeleteBy;
            parameters[22].Value = model.F_DeleteTime;
            parameters[23].Value = model.F_CreateUser;
            parameters[24].Value = model.F_AssistMan;
            parameters[25].Value = model.F_IsAssist;
            parameters[26].Value = model.F_FinishTime;
            parameters[27].Value = model.F_CarId;
            parameters[28].Value = model.F_AssistManName;
            parameters[29].Value = model.F_ControlManCode;
            parameters[30].Value = model.F_ControlManName;
            parameters[31].Value = model.F_Content;
            parameters[32].Value = model.F_UseTime;
            parameters[33].Value = model.F_StartTime;
            parameters[34].Value = model.F_EndTime;
            parameters[35].Value = model.F_StartFile;
            parameters[36].Value = model.F_EndFile;
            parameters[37].Value = model.F_Birth;
            parameters[38].Value = model.MYD;
            parameters[39].Value = model.F_AcceptTime;
            parameters[40].Value = model.F_EmergencyTypes;
            parameters[41].Value = model.F_LeaveRecordId;
            parameters[42].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)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Car_WorkOrder set ");
            strSql.Append("F_IsDel=@F_IsDel");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_IsDel",  SqlDbType.Int,4),
                    new SqlParameter("@F_ID", SqlDbType.Int,4)};
            parameters[0].Value = 1;
            parameters[1].Value = 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)
        //{

        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append("delete from  T_Car_WorkOrder  ");
        //    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)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_Car_WorkOrder ");
            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 RMYY_CallCenter_Api.Model.T_Car_WorkOrder GetModel(int F_ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 F_ID,F_WorkOrderCode,F_LeaveRecordId,F_Type,F_HosId,F_ProposerDeptId,F_Source,F_CallID,F_DepartPlace,F_Destination,F_ProposerCode,F_Phon,F_CarType,F_Remark,F_CreateTime,F_CarMessage,F_DriverCode,F_DriverPhon,F_DepartTime,F_DriverName,F_ProposerName,F_State,F_IsDel,F_DeleteBy,F_DeleteTime,F_CreateUser,F_AssistMan,F_IsAssist,F_FinishTime,F_CarId,F_AssistManName,F_ControlManCode,F_ControlManName,F_Content,F_UseTime,F_StartTime,F_EndTime,F_StartFile,F_EndFile,F_Birth,F_AcceptTime,F_EmergencyTypes from T_Car_WorkOrder ");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_ID", SqlDbType.Int,4)
            };
            parameters[0].Value = F_ID;

            RMYY_CallCenter_Api.Model.T_Car_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Car_WorkOrder();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
        public RMYY_CallCenter_Api.Model.T_Car_WorkOrder GetModelByCode(string F_WorkOrderCode)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from T_Car_WorkOrder with(nolock) ");
            strSql.Append(" where F_WorkOrderCode=@F_WorkOrderCode");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderCode",  SqlDbType.VarChar,50)
            };
            parameters[0].Value = F_WorkOrderCode;

            RMYY_CallCenter_Api.Model.T_Car_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Car_WorkOrder();
            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_Car_WorkOrder DataRowToModel(DataRow row)
        {
            RMYY_CallCenter_Api.Model.T_Car_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Car_WorkOrder();
            if (row != null)
            {
                if (row["F_ID"] != null && row["F_ID"].ToString() != "")
                {
                    model.F_ID = int.Parse(row["F_ID"].ToString());
                }
                if (row["F_EmergencyTypes"] != null)
                {
                    model.F_EmergencyTypes = row["F_EmergencyTypes"].ToString();
                }
                if (row["F_WorkOrderCode"] != null)
                {
                    model.F_WorkOrderCode = row["F_WorkOrderCode"].ToString();
                }
                if (row["F_Type"] != null && row["F_Type"].ToString() != "")
                {
                    model.F_Type = int.Parse(row["F_Type"].ToString());
                }
                if (row["F_HosId"] != null && row["F_HosId"].ToString() != "")
                {
                    model.F_HosId = int.Parse(row["F_HosId"].ToString());
                }
                if (row["F_ProposerDeptId"] != null && row["F_ProposerDeptId"].ToString() != "")
                {
                    model.F_ProposerDeptId = int.Parse(row["F_ProposerDeptId"].ToString());
                }
                if (row["F_Source"] != null)
                {
                    model.F_Source = row["F_Source"].ToString();
                }
                if (row["F_CallID"] != null)
                {
                    model.F_CallID = row["F_CallID"].ToString();
                }
                if (row["F_DepartPlace"] != null)
                {
                    model.F_DepartPlace = row["F_DepartPlace"].ToString();
                }
                if (row["F_Destination"] != null)
                {
                    model.F_Destination = row["F_Destination"].ToString();
                }
                if (row["F_ProposerCode"] != null)
                {
                    model.F_ProposerCode = row["F_ProposerCode"].ToString();
                }
                if (row["F_Phon"] != null)
                {
                    model.F_Phon = row["F_Phon"].ToString();
                }
                if (row["F_CarType"] != null && row["F_CarType"].ToString() != "")
                {
                    model.F_CarType = int.Parse(row["F_CarType"].ToString());
                }
                if (row["F_Remark"] != null)
                {
                    model.F_Remark = row["F_Remark"].ToString();
                }
                if (row["F_CreateTime"] != null && row["F_CreateTime"].ToString() != "")
                {
                    model.F_CreateTime = DateTime.Parse(row["F_CreateTime"].ToString());
                }
                if (row["F_CarMessage"] != null)
                {
                    model.F_CarMessage = row["F_CarMessage"].ToString();
                }
                if (row["F_DriverCode"] != null)
                {
                    model.F_DriverCode = row["F_DriverCode"].ToString();
                }
                if (row["F_DriverPhon"] != null)
                {
                    model.F_DriverPhon = row["F_DriverPhon"].ToString();
                }
                if (row["F_DepartTime"] != null && row["F_DepartTime"].ToString() != "")
                {
                    model.F_DepartTime = DateTime.Parse(row["F_DepartTime"].ToString());
                }
                if (row["F_DriverName"] != null)
                {
                    model.F_DriverName = row["F_DriverName"].ToString();
                }
                if (row["F_ProposerName"] != null)
                {
                    model.F_ProposerName = row["F_ProposerName"].ToString();
                }
                if (row["F_State"] != null && row["F_State"].ToString() != "")
                {
                    model.F_State = int.Parse(row["F_State"].ToString());
                }
                if (row["F_IsDel"] != null && row["F_IsDel"].ToString() != "")
                {
                    model.F_IsDel = int.Parse(row["F_IsDel"].ToString());
                }
                if (row["F_DeleteBy"] != null)
                {
                    model.F_DeleteBy = row["F_DeleteBy"].ToString();
                }
                if (row["F_DeleteTime"] != null && row["F_DeleteTime"].ToString() != "")
                {
                    model.F_DeleteTime = DateTime.Parse(row["F_DeleteTime"].ToString());
                }
                if (row["F_CreateUser"] != null)
                {
                    model.F_CreateUser = row["F_CreateUser"].ToString();
                }
                if (row["F_AssistMan"] != null)
                {
                    model.F_AssistMan = row["F_AssistMan"].ToString();
                }
                if (row["F_IsAssist"] != null && row["F_IsAssist"].ToString() != "")
                {
                    model.F_IsAssist = int.Parse(row["F_IsAssist"].ToString());
                }
                if (row["F_FinishTime"] != null && row["F_FinishTime"].ToString() != "")
                {
                    model.F_FinishTime = DateTime.Parse(row["F_FinishTime"].ToString());
                }
                if (row["F_CarId"] != null && row["F_CarId"].ToString() != "")
                {
                    model.F_CarId = int.Parse(row["F_CarId"].ToString());
                }
                if (row["F_AssistManName"] != null)
                {
                    model.F_AssistManName = row["F_AssistManName"].ToString();
                }
                if (row["F_ControlManCode"] != null)
                {
                    model.F_ControlManCode = row["F_ControlManCode"].ToString();
                }
                if (row["F_ControlManName"] != null)
                {
                    model.F_ControlManName = row["F_ControlManName"].ToString();
                }
                if (row["F_Content"] != null)
                {
                    model.F_Content = row["F_Content"].ToString();
                }
                if (row["F_UseTime"] != null)
                {
                    model.F_UseTime = row["F_UseTime"].ToString();
                }
                if (row["F_StartTime"] != null && row["F_StartTime"].ToString() != "")
                {
                    model.F_StartTime = DateTime.Parse(row["F_StartTime"].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_StartFile"] != null)
                {
                    model.F_StartFile = row["F_StartFile"].ToString();
                }
                if (row["F_EndFile"] != null)
                {
                    model.F_EndFile = row["F_EndFile"].ToString();
                }
                if (row["F_Birth"] != null && row["F_Birth"].ToString() != "")
                {
                    model.F_Birth = int.Parse(row["F_Birth"].ToString());
                }
                if (row["F_LeaveRecordId"] != null && row["F_LeaveRecordId"].ToString() != "")
                {
                    model.F_LeaveRecordId = int.Parse(row["F_LeaveRecordId"].ToString());
                }
                
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select F_ID,F_WorkOrderCode,F_LeaveRecordId,F_Type,F_HosId,F_ProposerDeptId,F_Source,F_CallID,F_DepartPlace,F_Destination,F_ProposerCode,F_Phon,F_CarType,F_Remark,F_CreateTime,F_CarMessage,F_DriverCode,F_DriverPhon,F_DepartTime,F_DriverName,F_ProposerName,F_State,F_IsDel,F_DeleteBy,F_DeleteTime,F_CreateUser,F_AssistMan,F_IsAssist,F_FinishTime,F_CarId,F_AssistManName,F_ControlManCode,F_ControlManName,F_Content,F_UseTime,F_StartTime,F_EndTime,F_StartFile,F_EndFile,F_Birth,F_AcceptTime,F_EmergencyTypes ");
            strSql.Append(" FROM T_Car_WorkOrder ");
            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_ID,F_WorkOrderCode,F_Type,F_LeaveRecordId,F_HosId,F_ProposerDeptId,F_Source,F_CallID,F_DepartPlace,F_Destination,F_ProposerCode,F_Phon,F_CarType,F_Remark,F_CreateTime,F_CarMessage,F_DriverCode,F_DriverPhon,F_DepartTime,F_DriverName,F_ProposerName,F_State,F_IsDel,F_DeleteBy,F_DeleteTime,F_CreateUser,F_AssistMan,F_IsAssist,F_FinishTime,F_CarId,F_AssistManName,F_ControlManCode,F_ControlManName,F_Content,F_UseTime,F_StartTime,F_EndTime,F_StartFile,F_EndFile,F_Birth,F_AcceptTime,F_EmergencyTypes ");
            strSql.Append(" FROM T_Car_WorkOrder ");
            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_Car_WorkOrder ");
            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_Car_WorkOrder 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_Car_WorkOrder";
			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
    }
}