using RMYY_CallCenter_Api.DB;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RMYY_CallCenter_Api.Dal
{
    /// <summary>
    /// 数据访问类:T_Acc_WorkOrder
    /// </summary>
    public partial class T_Acc_WorkOrder
    {
        public T_Acc_WorkOrder()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int F_Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_Acc_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_Acc_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_Acc_WorkOrder(");
            strSql.Append("F_Type,F_WorkOrderCode,F_HosId,F_ProposerDeptId,F_ProposerDeptName,F_ProposerCode,F_ProposerName,F_ProposerPhon,F_Source,F_CallID,F_PatientName,F_BedNum,F_InpatientNum,F_CheckItem,F_InspectionTime,F_NeedAttention,F_TravelMode,F_NursingLevel,F_IsWithPipe,F_Remark,F_CreateTime,F_CreateCode,F_CreateName,F_State,F_ControlManCode,F_ControlManName,F_TransPersonCode,F_TransPerson,F_SureMan,F_SureManName,F_SureManPhon,F_SureManTalkie,F_IsDel,F_DeleteBy,F_DeleteTime,F_FinishTime,F_DriverName,F_DriverPhon,F_CarMessage)");
            strSql.Append(" values (");
            strSql.Append("@F_Type,@F_WorkOrderCode,@F_HosId,@F_ProposerDeptId,@F_ProposerDeptName,@F_ProposerCode,@F_ProposerName,@F_ProposerPhon,@F_Source,@F_CallID,@F_PatientName,@F_BedNum,@F_InpatientNum,@F_CheckItem,@F_InspectionTime,@F_NeedAttention,@F_TravelMode,@F_NursingLevel,@F_IsWithPipe,@F_Remark,@F_CreateTime,@F_CreateCode,@F_CreateName,@F_State,@F_ControlManCode,@F_ControlManName,@F_TransPersonCode,@F_TransPerson,@F_SureMan,@F_SureManName,@F_SureManPhon,@F_SureManTalkie,@F_IsDel,@F_DeleteBy,@F_DeleteTime,@F_FinishTime,@F_DriverName,@F_DriverPhon,@F_CarMessage)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_Type", SqlDbType.Int,4),
                    new SqlParameter("@F_WorkOrderCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_HosId", SqlDbType.Int,4),
                    new SqlParameter("@F_ProposerDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_ProposerDeptName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_Source", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_CallID", SqlDbType.VarChar,50),
                    new SqlParameter("@F_PatientName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_BedNum", SqlDbType.VarChar,50),
                    new SqlParameter("@F_InpatientNum", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CheckItem", SqlDbType.VarChar,50),
                    new SqlParameter("@F_InspectionTime", SqlDbType.DateTime),
                    new SqlParameter("@F_NeedAttention", SqlDbType.VarChar,50),
                    new SqlParameter("@F_TravelMode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_NursingLevel", SqlDbType.VarChar,50),
                    new SqlParameter("@F_IsWithPipe", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Remark", SqlDbType.NText),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CreateCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CreateName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_ControlManCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ControlManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_TransPersonCode", SqlDbType.NText),
                    new SqlParameter("@F_TransPerson", SqlDbType.NText),
                    new SqlParameter("@F_SureMan", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SureManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SureManPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_SureManTalkie", SqlDbType.VarChar,20),
                    new SqlParameter("@F_IsDel", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteBy", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_FinishTime", SqlDbType.DateTime),
                    new SqlParameter("@F_DriverName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DriverPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_CarMessage", SqlDbType.NVarChar,300)};
            parameters[0].Value = model.F_Type;
            parameters[1].Value = model.F_WorkOrderCode;
            parameters[2].Value = model.F_HosId;
            parameters[3].Value = model.F_ProposerDeptId;
            parameters[4].Value = model.F_ProposerDeptName;
            parameters[5].Value = model.F_ProposerCode;
            parameters[6].Value = model.F_ProposerName;
            parameters[7].Value = model.F_ProposerPhon;
            parameters[8].Value = model.F_Source;
            parameters[9].Value = model.F_CallID;
            parameters[10].Value = model.F_PatientName;
            parameters[11].Value = model.F_BedNum;
            parameters[12].Value = model.F_InpatientNum;
            parameters[13].Value = model.F_CheckItem;
            parameters[14].Value = model.F_InspectionTime;
            parameters[15].Value = model.F_NeedAttention;
            parameters[16].Value = model.F_TravelMode;
            parameters[17].Value = model.F_NursingLevel;
            parameters[18].Value = model.F_IsWithPipe;
            parameters[19].Value = model.F_Remark;
            parameters[20].Value = model.F_CreateTime;
            parameters[21].Value = model.F_CreateCode;
            parameters[22].Value = model.F_CreateName;
            parameters[23].Value = model.F_State;
            parameters[24].Value = model.F_ControlManCode;
            parameters[25].Value = model.F_ControlManName;
            parameters[26].Value = model.F_TransPersonCode;
            parameters[27].Value = model.F_TransPerson;
            parameters[28].Value = model.F_SureMan;
            parameters[29].Value = model.F_SureManName;
            parameters[30].Value = model.F_SureManPhon;
            parameters[31].Value = model.F_SureManTalkie;
            parameters[32].Value = model.F_IsDel;
            parameters[33].Value = model.F_DeleteBy;
            parameters[34].Value = model.F_DeleteTime;
            parameters[35].Value = model.F_FinishTime;
            parameters[36].Value = model.F_DriverName;
            parameters[37].Value = model.F_DriverPhon;
            parameters[38].Value = model.F_CarMessage;

            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_Acc_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Acc_WorkOrder set ");
            strSql.Append("F_Type=@F_Type,");
            strSql.Append("F_WorkOrderCode=@F_WorkOrderCode,");
            strSql.Append("F_HosId=@F_HosId,");
            strSql.Append("F_ProposerDeptId=@F_ProposerDeptId,");
            strSql.Append("F_ProposerDeptName=@F_ProposerDeptName,");
            strSql.Append("F_ProposerCode=@F_ProposerCode,");
            strSql.Append("F_ProposerName=@F_ProposerName,");
            strSql.Append("F_ProposerPhon=@F_ProposerPhon,");
            strSql.Append("F_Source=@F_Source,");
            strSql.Append("F_CallID=@F_CallID,");
            strSql.Append("F_PatientName=@F_PatientName,");
            strSql.Append("F_BedNum=@F_BedNum,");
            strSql.Append("F_InpatientNum=@F_InpatientNum,");
            strSql.Append("F_CheckItem=@F_CheckItem,");
            strSql.Append("F_InspectionTime=@F_InspectionTime,");
            strSql.Append("F_NeedAttention=@F_NeedAttention,");
            strSql.Append("F_TravelMode=@F_TravelMode,");
            strSql.Append("F_NursingLevel=@F_NursingLevel,");
            strSql.Append("F_IsWithPipe=@F_IsWithPipe,");
            strSql.Append("F_Remark=@F_Remark,");
            strSql.Append("F_CreateTime=@F_CreateTime,");
            strSql.Append("F_CreateCode=@F_CreateCode,");
            strSql.Append("F_CreateName=@F_CreateName,");
            strSql.Append("F_State=@F_State,");
            strSql.Append("F_ControlManCode=@F_ControlManCode,");
            strSql.Append("F_ControlManName=@F_ControlManName,");
            strSql.Append("F_TransPersonCode=@F_TransPersonCode,");
            strSql.Append("F_TransPerson=@F_TransPerson,");
            strSql.Append("F_SureMan=@F_SureMan,");
            strSql.Append("F_SureManName=@F_SureManName,");
            strSql.Append("F_SureManPhon=@F_SureManPhon,");
            strSql.Append("F_SureManTalkie=@F_SureManTalkie,");
            strSql.Append("F_IsDel=@F_IsDel,");
            strSql.Append("F_DeleteBy=@F_DeleteBy,");
            strSql.Append("F_DeleteTime=@F_DeleteTime,");
            strSql.Append("F_FinishTime=@F_FinishTime,");
            strSql.Append("F_DriverName=@F_DriverName,");
            strSql.Append("F_DriverPhon=@F_DriverPhon,");
            strSql.Append("F_CarMessage=@F_CarMessage");
            strSql.Append(" where F_Id=@F_Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_Type", SqlDbType.Int,4),
                    new SqlParameter("@F_WorkOrderCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_HosId", SqlDbType.Int,4),
                    new SqlParameter("@F_ProposerDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_ProposerDeptName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ProposerPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_Source", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_CallID", SqlDbType.VarChar,50),
                    new SqlParameter("@F_PatientName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_BedNum", SqlDbType.VarChar,50),
                    new SqlParameter("@F_InpatientNum", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CheckItem", SqlDbType.VarChar,50),
                    new SqlParameter("@F_InspectionTime", SqlDbType.DateTime),
                    new SqlParameter("@F_NeedAttention", SqlDbType.VarChar,50),
                    new SqlParameter("@F_TravelMode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_NursingLevel", SqlDbType.VarChar,50),
                    new SqlParameter("@F_IsWithPipe", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Remark", SqlDbType.NText),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_CreateCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CreateName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_ControlManCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ControlManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_TransPersonCode", SqlDbType.NText),
                    new SqlParameter("@F_TransPerson", SqlDbType.NText),
                    new SqlParameter("@F_SureMan", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SureManName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SureManPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_SureManTalkie", SqlDbType.VarChar,20),
                    new SqlParameter("@F_IsDel", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteBy", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_FinishTime", SqlDbType.DateTime),
                    new SqlParameter("@F_DriverName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DriverPhon", SqlDbType.VarChar,20),
                    new SqlParameter("@F_CarMessage", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_Id", SqlDbType.Int,4)};
            parameters[0].Value = model.F_Type;
            parameters[1].Value = model.F_WorkOrderCode;
            parameters[2].Value = model.F_HosId;
            parameters[3].Value = model.F_ProposerDeptId;
            parameters[4].Value = model.F_ProposerDeptName;
            parameters[5].Value = model.F_ProposerCode;
            parameters[6].Value = model.F_ProposerName;
            parameters[7].Value = model.F_ProposerPhon;
            parameters[8].Value = model.F_Source;
            parameters[9].Value = model.F_CallID;
            parameters[10].Value = model.F_PatientName;
            parameters[11].Value = model.F_BedNum;
            parameters[12].Value = model.F_InpatientNum;
            parameters[13].Value = model.F_CheckItem;
            parameters[14].Value = model.F_InspectionTime;
            parameters[15].Value = model.F_NeedAttention;
            parameters[16].Value = model.F_TravelMode;
            parameters[17].Value = model.F_NursingLevel;
            parameters[18].Value = model.F_IsWithPipe;
            parameters[19].Value = model.F_Remark;
            parameters[20].Value = model.F_CreateTime;
            parameters[21].Value = model.F_CreateCode;
            parameters[22].Value = model.F_CreateName;
            parameters[23].Value = model.F_State;
            parameters[24].Value = model.F_ControlManCode;
            parameters[25].Value = model.F_ControlManName;
            parameters[26].Value = model.F_TransPersonCode;
            parameters[27].Value = model.F_TransPerson;
            parameters[28].Value = model.F_SureMan;
            parameters[29].Value = model.F_SureManName;
            parameters[30].Value = model.F_SureManPhon;
            parameters[31].Value = model.F_SureManTalkie;
            parameters[32].Value = model.F_IsDel;
            parameters[33].Value = model.F_DeleteBy;
            parameters[34].Value = model.F_DeleteTime;
            parameters[35].Value = model.F_FinishTime;
            parameters[36].Value = model.F_DriverName;
            parameters[37].Value = model.F_DriverPhon;
            parameters[38].Value = model.F_CarMessage;
            parameters[39].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("delete from T_Acc_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_Acc_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_Acc_WorkOrder GetModel(int F_Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 F_Id,F_Type,F_WorkOrderCode,F_HosId,F_ProposerDeptId,F_ProposerDeptName,F_ProposerCode,F_ProposerName,F_ProposerPhon,F_Source,F_CallID,F_PatientName,F_BedNum,F_InpatientNum,F_CheckItem,F_InspectionTime,F_NeedAttention,F_TravelMode,F_NursingLevel,F_IsWithPipe,F_Remark,F_CreateTime,F_CreateCode,F_CreateName,F_State,F_ControlManCode,F_ControlManName,F_TransPersonCode,F_TransPerson,F_SureMan,F_SureManName,F_SureManPhon,F_SureManTalkie,F_IsDel,F_DeleteBy,F_DeleteTime,F_FinishTime,F_DriverName,F_DriverPhon,F_CarMessage from T_Acc_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_Acc_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Acc_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_Acc_WorkOrder DataRowToModel(DataRow row)
        {
            RMYY_CallCenter_Api.Model.T_Acc_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Acc_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_Type"] != null && row["F_Type"].ToString() != "")
                {
                    model.F_Type = int.Parse(row["F_Type"].ToString());
                }
                if (row["F_WorkOrderCode"] != null)
                {
                    model.F_WorkOrderCode = row["F_WorkOrderCode"].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_ProposerDeptName"] != null)
                {
                    model.F_ProposerDeptName = row["F_ProposerDeptName"].ToString();
                }
                if (row["F_ProposerCode"] != null)
                {
                    model.F_ProposerCode = row["F_ProposerCode"].ToString();
                }
                if (row["F_ProposerName"] != null)
                {
                    model.F_ProposerName = row["F_ProposerName"].ToString();
                }
                if (row["F_ProposerPhon"] != null)
                {
                    model.F_ProposerPhon = row["F_ProposerPhon"].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_PatientName"] != null)
                {
                    model.F_PatientName = row["F_PatientName"].ToString();
                }
                if (row["F_BedNum"] != null)
                {
                    model.F_BedNum = row["F_BedNum"].ToString();
                }
                if (row["F_InpatientNum"] != null)
                {
                    model.F_InpatientNum = row["F_InpatientNum"].ToString();
                }
                if (row["F_CheckItem"] != null)
                {
                    model.F_CheckItem = row["F_CheckItem"].ToString();
                }
                if (row["F_InspectionTime"] != null && row["F_InspectionTime"].ToString() != "")
                {
                    model.F_InspectionTime = DateTime.Parse(row["F_InspectionTime"].ToString());
                }
                if (row["F_NeedAttention"] != null)
                {
                    model.F_NeedAttention = row["F_NeedAttention"].ToString();
                }
                if (row["F_TravelMode"] != null)
                {
                    model.F_TravelMode = row["F_TravelMode"].ToString();
                }
                if (row["F_NursingLevel"] != null)
                {
                    model.F_NursingLevel = row["F_NursingLevel"].ToString();
                }
                if (row["F_IsWithPipe"] != null)
                {
                    model.F_IsWithPipe = row["F_IsWithPipe"].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_CreateCode"] != null)
                {
                    model.F_CreateCode = row["F_CreateCode"].ToString();
                }
                if (row["F_CreateName"] != null)
                {
                    model.F_CreateName = row["F_CreateName"].ToString();
                }
                if (row["F_State"] != null && row["F_State"].ToString() != "")
                {
                    model.F_State = int.Parse(row["F_State"].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_TransPersonCode"] != null)
                {
                    model.F_TransPersonCode = row["F_TransPersonCode"].ToString();
                }
                if (row["F_TransPerson"] != null)
                {
                    model.F_TransPerson = row["F_TransPerson"].ToString();
                }
                if (row["F_SureMan"] != null)
                {
                    model.F_SureMan = row["F_SureMan"].ToString();
                }
                if (row["F_SureManName"] != null)
                {
                    model.F_SureManName = row["F_SureManName"].ToString();
                }
                if (row["F_SureManPhon"] != null)
                {
                    model.F_SureManPhon = row["F_SureManPhon"].ToString();
                }
                if (row["F_SureManTalkie"] != null)
                {
                    model.F_SureManTalkie = row["F_SureManTalkie"].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_FinishTime"] != null && row["F_FinishTime"].ToString() != "")
                {
                    model.F_FinishTime = DateTime.Parse(row["F_FinishTime"].ToString());
                }
                if (row["F_DriverName"] != null)
                {
                    model.F_DriverName = row["F_DriverName"].ToString();
                }
                if (row["F_DriverPhon"] != null)
                {
                    model.F_DriverPhon = row["F_DriverPhon"].ToString();
                }
                if (row["F_CarMessage"] != null)
                {
                    model.F_CarMessage = row["F_CarMessage"].ToString();
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select F_Id,F_Type,F_WorkOrderCode,F_HosId,F_ProposerDeptId,F_ProposerDeptName,F_ProposerCode,F_ProposerName,F_ProposerPhon,F_Source,F_CallID,F_PatientName,F_BedNum,F_InpatientNum,F_CheckItem,F_InspectionTime,F_NeedAttention,F_TravelMode,F_NursingLevel,F_IsWithPipe,F_Remark,F_CreateTime,F_CreateCode,F_CreateName,F_State,F_ControlManCode,F_ControlManName,F_TransPersonCode,F_TransPerson,F_SureMan,F_SureManName,F_SureManPhon,F_SureManTalkie,F_IsDel,F_DeleteBy,F_DeleteTime,F_FinishTime,F_DriverName,F_DriverPhon,F_CarMessage ");
            strSql.Append(" FROM T_Acc_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_Type,F_WorkOrderCode,F_HosId,F_ProposerDeptId,F_ProposerDeptName,F_ProposerCode,F_ProposerName,F_ProposerPhon,F_Source,F_CallID,F_PatientName,F_BedNum,F_InpatientNum,F_CheckItem,F_InspectionTime,F_NeedAttention,F_TravelMode,F_NursingLevel,F_IsWithPipe,F_Remark,F_CreateTime,F_CreateCode,F_CreateName,F_State,F_ControlManCode,F_ControlManName,F_TransPersonCode,F_TransPerson,F_SureMan,F_SureManName,F_SureManPhon,F_SureManTalkie,F_IsDel,F_DeleteBy,F_DeleteTime,F_FinishTime,F_DriverName,F_DriverPhon,F_CarMessage ");
            strSql.Append(" FROM T_Acc_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_Acc_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_Acc_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());
        }

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}
