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_Con_WorkOrder
	/// </summary>
	public partial class T_Con_WorkOrder
    {
        public T_Con_WorkOrder()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int F_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_Con_WorkOrder with(nolock)");
            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_Con_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_Con_WorkOrder(");
            strSql.Append("F_WorkOrderCode,F_Source,F_Customer,F_Sex,F_CusAddress,F_Phon,F_IdCard,F_ServiceItems,F_Address,F_FirstCheckHospital,F_NoduleSize,F_FirstFindTime,F_Urgency,F_DealOpinions,F_DealType,F_DealResult,F_HandleBy,F_HandleTime,F_NotHandleReasons,F_WorkOrderContents,F_ResponDept,F_ResponPerson,F_CallID,F_LimitTime,F_IsReturnBak,F_ReturnBakTime,F_IsTimeOut,F_CreateUserID,F_CreateUser,F_CreateTime,F_IsDel,F_CreateUserName,F_DeleteBy,F_DeleteTime,F_IsAudit,F_AuditState,F_AuditUser,F_AuditTime,F_AuditCont,F_AppointTime,F_Answer,F_DealContents,F_File,F_Satisfaction,F_State,F_type1,F_type2,F_type3,F_Cathetertype,F_Catheterdept,F_Cathetertime,F_BedNum,F_InpatientNum,F_CallRecordId, F_LeaveRecordId,F_Relationship,F_FullName,F_IDNumber,F_ComplaintDept,F_ComplaintUser,F_IsVisit,F_ComplaintSource,F_ReplayCount,F_AppointmentTime,F_EmergencyTypes)");
            strSql.Append(" values (");
            strSql.Append("@F_WorkOrderCode,@F_Source,@F_Customer,@F_Sex,@F_CusAddress,@F_Phon,@F_IdCard,@F_ServiceItems,@F_Address,@F_FirstCheckHospital,@F_NoduleSize,@F_FirstFindTime,@F_Urgency,@F_DealOpinions,@F_DealType,@F_DealResult,@F_HandleBy,@F_HandleTime,@F_NotHandleReasons,@F_WorkOrderContents,@F_ResponDept,@F_ResponPerson,@F_CallID,@F_LimitTime,@F_IsReturnBak,@F_ReturnBakTime,@F_IsTimeOut,@F_CreateUserID,@F_CreateUser,@F_CreateTime,@F_IsDel,@F_CreateUserName,@F_DeleteBy,@F_DeleteTime,@F_IsAudit,@F_AuditState,@F_AuditUser,@F_AuditTime,@F_AuditCont,@F_AppointTime,@F_Answer,@F_DealContents,@F_File,@F_Satisfaction,@F_State,@F_type1,@F_type2,@F_type3,@F_Cathetertype,@F_Catheterdept,@F_Cathetertime,@F_BedNum,@F_InpatientNum,@F_CallRecordId , @F_LeaveRecordId,@F_Relationship,@F_FullName,@F_IDNumber,@F_ComplaintDept,@F_ComplaintUser,@F_IsVisit,@F_ComplaintSource,@F_ReplayCount,@F_AppointmentTime,@F_EmergencyTypes)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Source", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_Customer", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_Sex", SqlDbType.Int,4),
                    new SqlParameter("@F_CusAddress", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_Phon", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_IdCard", SqlDbType.VarChar,18),
                    new SqlParameter("@F_ServiceItems", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_Address", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_FirstCheckHospital", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_NoduleSize", SqlDbType.Decimal,9),
                    new SqlParameter("@F_FirstFindTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Urgency", SqlDbType.Int,4),
                    new SqlParameter("@F_DealOpinions", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_DealType", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_DealResult", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_HandleBy", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_HandleTime", SqlDbType.DateTime),
                    new SqlParameter("@F_NotHandleReasons", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_WorkOrderContents", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_ResponDept", SqlDbType.Int,4),
                    new SqlParameter("@F_ResponPerson", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CallID", SqlDbType.VarChar,50),
                    new SqlParameter("@F_LimitTime", SqlDbType.Decimal,9),
                    new SqlParameter("@F_IsReturnBak", SqlDbType.Int,4),
                    new SqlParameter("@F_ReturnBakTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsTimeOut", SqlDbType.Int,4),
                    new SqlParameter("@F_CreateUserID", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsDel", SqlDbType.Int,4),
                    new SqlParameter("@F_CreateUserName", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeleteBy", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsAudit", SqlDbType.Int,4),
                    new SqlParameter("@F_AuditState", SqlDbType.Int,4),
                    new SqlParameter("@F_AuditUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AuditTime", SqlDbType.DateTime),
                    new SqlParameter("@F_AuditCont", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_AppointTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Answer", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_DealContents", SqlDbType.NText),
                    new SqlParameter("@F_File", SqlDbType.VarChar,500),
                    new SqlParameter("@F_Satisfaction", SqlDbType.Int,4),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_type1", SqlDbType.Int,4),
                    new SqlParameter("@F_type2", SqlDbType.Int,4),
                    new SqlParameter("@F_type3", SqlDbType.Int,4),
                    new SqlParameter("@F_Cathetertype", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_Catheterdept", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_Cathetertime", SqlDbType.DateTime),
                    new SqlParameter("@F_BedNum", SqlDbType.VarChar,50),
                    new SqlParameter("@F_InpatientNum", SqlDbType.VarChar,50),
                     new SqlParameter("@F_CallRecordId", SqlDbType.Int,4),
                    new SqlParameter("@F_LeaveRecordId", SqlDbType.Int,4),
                   
                     new SqlParameter("@F_Relationship", SqlDbType.VarChar,500),
                    new SqlParameter("@F_FullName", SqlDbType.VarChar,500),
                    new SqlParameter("@F_IDNumber", SqlDbType.VarChar,500),
                    new SqlParameter("@F_ComplaintDept", SqlDbType.Int ,4),
                   new SqlParameter("@F_ComplaintUser", SqlDbType.VarChar,500),
                  new  SqlParameter("@F_IsVisit", SqlDbType.Int,4),
                 new SqlParameter("@F_ComplaintSource", SqlDbType.Int ,4)  ,
                  new SqlParameter("@F_ReplayCount", SqlDbType.Int ,4),

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


            };
            parameters[0].Value = model.F_WorkOrderCode;
            parameters[1].Value = model.F_Source;
            parameters[2].Value = model.F_Customer;
            parameters[3].Value = model.F_Sex;
            parameters[4].Value = model.F_CusAddress;
            parameters[5].Value = model.F_Phon;
            parameters[6].Value = model.F_IdCard;
            parameters[7].Value = model.F_ServiceItems;
            parameters[8].Value = model.F_Address;
            parameters[9].Value = model.F_FirstCheckHospital;
            parameters[10].Value = model.F_NoduleSize;
            parameters[11].Value = model.F_FirstFindTime;
            parameters[12].Value = model.F_Urgency;
            parameters[13].Value = model.F_DealOpinions;
            parameters[14].Value = model.F_DealType;
            parameters[15].Value = model.F_DealResult;
            parameters[16].Value = model.F_HandleBy;
            parameters[17].Value = model.F_HandleTime;
            parameters[18].Value = model.F_NotHandleReasons;
            parameters[19].Value = model.F_WorkOrderContents;
            parameters[20].Value = model.F_ResponDept;
            parameters[21].Value = model.F_ResponPerson;
            parameters[22].Value = model.F_CallID;
            parameters[23].Value = model.F_LimitTime;
            parameters[24].Value = model.F_IsReturnBak;
            parameters[25].Value = model.F_ReturnBakTime;
            parameters[26].Value = model.F_IsTimeOut;
            parameters[27].Value = model.F_CreateUserID;
            parameters[28].Value = model.F_CreateUser;
            parameters[29].Value = model.F_CreateTime;
            parameters[30].Value = model.F_IsDel;
            parameters[31].Value = model.F_CreateUserName;
            parameters[32].Value = model.F_DeleteBy;
            parameters[33].Value = model.F_DeleteTime;
            parameters[34].Value = model.F_IsAudit;
            parameters[35].Value = model.F_AuditState;
            parameters[36].Value = model.F_AuditUser;
            parameters[37].Value = model.F_AuditTime;
            parameters[38].Value = model.F_AuditCont;
            parameters[39].Value = model.F_AppointTime;
            parameters[40].Value = model.F_Answer;
            parameters[41].Value = model.F_DealContents;
            parameters[42].Value = model.F_File;
            parameters[43].Value = model.F_Satisfaction;
            parameters[44].Value = model.F_State;
            parameters[45].Value = model.F_type1;
            parameters[46].Value = model.F_type2;
            parameters[47].Value = model.F_type3;
            parameters[48].Value = model.F_Cathetertype;
            parameters[49].Value = model.F_Catheterdept;
            parameters[50].Value = model.F_Cathetertime;
            parameters[51].Value = model.F_BedNum;
            parameters[52].Value = model.F_InpatientNum;
           
              parameters[53].Value = model.F_CallRecordId;
            parameters[54].Value = model.F_LeaveRecordId;
           
                parameters[55].Value = model.F_Relationship;
            parameters[56].Value = model.F_FullName;
            parameters[57].Value = model.F_IDNumber;
            parameters[58].Value = model.F_ComplaintDept;
            parameters[59].Value = model.F_ComplaintUser;
            parameters[60].Value = model.F_IsVisit;
            parameters[61].Value = model.F_ComplaintSource;
            parameters[62].Value = model.F_ReplayCount;
            parameters[63].Value = model.F_EmergencyTypes;
            parameters[64].Value = model.F_AppointmentTime;
            

            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_Con_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Con_WorkOrder set ");
            strSql.Append("F_WorkOrderCode=@F_WorkOrderCode,");
            strSql.Append("F_Source=@F_Source,");
            strSql.Append("F_Customer=@F_Customer,");
            strSql.Append("F_Sex=@F_Sex,");
            strSql.Append("F_CusAddress=@F_CusAddress,");
            strSql.Append("F_Phon=@F_Phon,");
            strSql.Append("F_IdCard=@F_IdCard,");
            strSql.Append("F_ServiceItems=@F_ServiceItems,");
            strSql.Append("F_Address=@F_Address,");
            strSql.Append("F_FirstCheckHospital=@F_FirstCheckHospital,");
            strSql.Append("F_NoduleSize=@F_NoduleSize,");
            strSql.Append("F_FirstFindTime=@F_FirstFindTime,");
            strSql.Append("F_Urgency=@F_Urgency,");
            strSql.Append("F_DealOpinions=@F_DealOpinions,");
            strSql.Append("F_DealType=@F_DealType,");
            strSql.Append("F_DealResult=@F_DealResult,");
            strSql.Append("F_HandleBy=@F_HandleBy,");
            strSql.Append("F_HandleTime=@F_HandleTime,");
            strSql.Append("F_NotHandleReasons=@F_NotHandleReasons,");
            strSql.Append("F_WorkOrderContents=@F_WorkOrderContents,");
            strSql.Append("F_ResponDept=@F_ResponDept,");
            strSql.Append("F_ResponPerson=@F_ResponPerson,");
            strSql.Append("F_CallID=@F_CallID,");
            strSql.Append("F_LimitTime=@F_LimitTime,");
            strSql.Append("F_IsReturnBak=@F_IsReturnBak,");
            strSql.Append("F_ReturnBakTime=@F_ReturnBakTime,");
            strSql.Append("F_IsTimeOut=@F_IsTimeOut,");
            strSql.Append("F_CreateUserID=@F_CreateUserID,");
            strSql.Append("F_CreateUser=@F_CreateUser,");
            strSql.Append("F_CreateTime=@F_CreateTime,");
            strSql.Append("F_IsDel=@F_IsDel,");
            strSql.Append("F_CreateUserName=@F_CreateUserName,");
            strSql.Append("F_DeleteBy=@F_DeleteBy,");
            strSql.Append("F_DeleteTime=@F_DeleteTime,");
            strSql.Append("F_IsAudit=@F_IsAudit,");
            strSql.Append("F_AuditState=@F_AuditState,");
            strSql.Append("F_AuditUser=@F_AuditUser,");
            strSql.Append("F_AuditTime=@F_AuditTime,");
            strSql.Append("F_AuditCont=@F_AuditCont,");
            strSql.Append("F_AppointTime=@F_AppointTime,");
            strSql.Append("F_Answer=@F_Answer,");
            strSql.Append("F_DealContents=@F_DealContents,");
            strSql.Append("F_File=@F_File,");
            strSql.Append("F_Satisfaction=@F_Satisfaction,");
            strSql.Append("F_State=@F_State,");
            strSql.Append("F_type1=@F_type1,");
            strSql.Append("F_type2=@F_type2,");
            strSql.Append("F_type3=@F_type3,");
            strSql.Append("F_Cathetertype=@F_Cathetertype,");
            strSql.Append("F_Catheterdept=@F_Catheterdept,");
            strSql.Append("F_Cathetertime=@F_Cathetertime,");
            strSql.Append("F_BedNum=@F_BedNum,");
            strSql.Append("F_InpatientNum=@F_InpatientNum,");
            strSql.Append("F_CallRecordId=@F_CallRecordId,");
            strSql.Append("F_Relationship=@F_Relationship,");
            strSql.Append("F_FullName=@F_FullName,");
            strSql.Append("F_IDNumber=@F_IDNumber,");
            strSql.Append("F_ComplaintDept=@F_ComplaintDept,");
            strSql.Append("F_ComplaintUser=@F_ComplaintUser,");
           
            strSql.Append("F_LeaveRecordId=@F_LeaveRecordId,");
            strSql.Append("F_IsVisit=@F_IsVisit,");
            strSql.Append("F_ComplaintSource=@F_ComplaintSource,");
            strSql.Append("F_ReplayCount=@F_ReplayCount,");
            strSql.Append("F_AcceptTime=@F_AcceptTime,");

            strSql.Append("F_EmergencyTypes=@F_EmergencyTypes,");
            strSql.Append("F_AppointmentTime=@F_AppointmentTime");
            
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Source", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_Customer", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_Sex", SqlDbType.Int,4),
                    new SqlParameter("@F_CusAddress", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_Phon", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_IdCard", SqlDbType.VarChar,18),
                    new SqlParameter("@F_ServiceItems", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_Address", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_FirstCheckHospital", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_NoduleSize", SqlDbType.Decimal,9),
                    new SqlParameter("@F_FirstFindTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Urgency", SqlDbType.Int,4),
                    new SqlParameter("@F_DealOpinions", SqlDbType.NVarChar,300),
                    new SqlParameter("@F_DealType", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_DealResult", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_HandleBy", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_HandleTime", SqlDbType.DateTime),
                    new SqlParameter("@F_NotHandleReasons", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_WorkOrderContents", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_ResponDept", SqlDbType.Int,4),
                    new SqlParameter("@F_ResponPerson", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CallID", SqlDbType.VarChar,50),
                    new SqlParameter("@F_LimitTime", SqlDbType.Decimal,9),
                    new SqlParameter("@F_IsReturnBak", SqlDbType.Int,4),
                    new SqlParameter("@F_ReturnBakTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsTimeOut", SqlDbType.Int,4),
                    new SqlParameter("@F_CreateUserID", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsDel", SqlDbType.Int,4),
                    new SqlParameter("@F_CreateUserName", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeleteBy", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsAudit", SqlDbType.Int,4),
                    new SqlParameter("@F_AuditState", SqlDbType.Int,4),
                    new SqlParameter("@F_AuditUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AuditTime", SqlDbType.DateTime),
                    new SqlParameter("@F_AuditCont", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_AppointTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Answer", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_DealContents", SqlDbType.NText),
                    new SqlParameter("@F_File", SqlDbType.VarChar,500),
                    new SqlParameter("@F_Satisfaction", SqlDbType.Int,4),
                    new SqlParameter("@F_State", SqlDbType.Int,4),
                    new SqlParameter("@F_type1", SqlDbType.Int,4),
                    new SqlParameter("@F_type2", SqlDbType.Int,4),
                    new SqlParameter("@F_type3", SqlDbType.Int,4),
                    new SqlParameter("@F_Cathetertype", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_Catheterdept", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_Cathetertime", SqlDbType.DateTime),
                    new SqlParameter("@F_BedNum", SqlDbType.VarChar,50),
                    new SqlParameter("@F_InpatientNum", SqlDbType.VarChar,50),

                     new SqlParameter("@F_CallRecordId", SqlDbType.Int,4),
                   
                      new SqlParameter("@F_Relationship", SqlDbType.VarChar,500),
                       new SqlParameter("@F_FullName", SqlDbType.VarChar,500),
                        new SqlParameter("@F_IDNumber", SqlDbType.VarChar,500),
                         new SqlParameter("@F_ComplaintDept", SqlDbType.Int ,4),
                          new SqlParameter("@F_ComplaintUser", SqlDbType.VarChar,500),
                    new SqlParameter("@F_LeaveRecordId", SqlDbType.Int,4),
                      new SqlParameter("@F_IsVisit", SqlDbType.Int,4),
                         new SqlParameter("@F_ComplaintSource", SqlDbType.Int,4),
                              new SqlParameter("@F_ReplayCount", SqlDbType.Int,4),
                                new SqlParameter("@F_AcceptTime", SqlDbType.DateTime),

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

                new SqlParameter("@F_AppointmentTime", SqlDbType.DateTime),
                    
                    new SqlParameter("@F_ID", SqlDbType.Int,4)};
            parameters[0].Value = model.F_WorkOrderCode;
            parameters[1].Value = model.F_Source;
            parameters[2].Value = model.F_Customer;
            parameters[3].Value = model.F_Sex;
            parameters[4].Value = model.F_CusAddress;
            parameters[5].Value = model.F_Phon;
            parameters[6].Value = model.F_IdCard;
            parameters[7].Value = model.F_ServiceItems;
            parameters[8].Value = model.F_Address;
            parameters[9].Value = model.F_FirstCheckHospital;
            parameters[10].Value = model.F_NoduleSize;
            parameters[11].Value = model.F_FirstFindTime;
            parameters[12].Value = model.F_Urgency;
            parameters[13].Value = model.F_DealOpinions;
            parameters[14].Value = model.F_DealType;
            parameters[15].Value = model.F_DealResult;
            parameters[16].Value = model.F_HandleBy;
            parameters[17].Value = model.F_HandleTime;
            parameters[18].Value = model.F_NotHandleReasons;
            parameters[19].Value = model.F_WorkOrderContents;
            parameters[20].Value = model.F_ResponDept;
            parameters[21].Value = model.F_ResponPerson;
            parameters[22].Value = model.F_CallID;
            parameters[23].Value = model.F_LimitTime;
            parameters[24].Value = model.F_IsReturnBak;
            parameters[25].Value = model.F_ReturnBakTime;
            parameters[26].Value = model.F_IsTimeOut;
            parameters[27].Value = model.F_CreateUserID;
            parameters[28].Value = model.F_CreateUser;
            parameters[29].Value = model.F_CreateTime;
            parameters[30].Value = model.F_IsDel;
            parameters[31].Value = model.F_CreateUserName;
            parameters[32].Value = model.F_DeleteBy;
            parameters[33].Value = model.F_DeleteTime;
            parameters[34].Value = model.F_IsAudit;
            parameters[35].Value = model.F_AuditState;
            parameters[36].Value = model.F_AuditUser;
            parameters[37].Value = model.F_AuditTime;
            parameters[38].Value = model.F_AuditCont;
            parameters[39].Value = model.F_AppointTime;
            parameters[40].Value = model.F_Answer;
            parameters[41].Value = model.F_DealContents;
            parameters[42].Value = model.F_File;
            parameters[43].Value = model.F_Satisfaction;
            parameters[44].Value = model.F_State;
            parameters[45].Value = model.F_type1;
            parameters[46].Value = model.F_type2;
            parameters[47].Value = model.F_type3;
            parameters[48].Value = model.F_Cathetertype;
            parameters[49].Value = model.F_Catheterdept;
            parameters[50].Value = model.F_Cathetertime;
            parameters[51].Value = model.F_BedNum;
            parameters[52].Value = model.F_InpatientNum;


            parameters[53].Value = model.F_CallRecordId;
           
                 parameters[54].Value = model.F_Relationship;
            parameters[55].Value = model.F_FullName;
            parameters[56].Value = model.F_IDNumber;
            parameters[57].Value = model.F_ComplaintDept;
            parameters[58].Value = model.F_ComplaintUser;
            parameters[59].Value = model.F_LeaveRecordId;
            parameters[60].Value = model.F_IsVisit;

            parameters[61].Value = model.F_ComplaintSource;
            parameters[62].Value = model.F_ReplayCount;
            parameters[63].Value = model.F_AcceptTime;
            parameters[64].Value = model.F_EmergencyTypes;


            parameters[65].Value = model.F_AppointmentTime;

            
  parameters[66].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_Con_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_Con_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_Con_WorkOrder GetModel(int F_ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from T_Con_WorkOrder with(nolock) ");
            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_Con_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Con_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_Con_WorkOrder GetModelByCode(string F_WorkOrderCode)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from T_Con_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_Con_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Con_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_Con_WorkOrder DataRowToModel(DataRow row)
        {
            RMYY_CallCenter_Api.Model.T_Con_WorkOrder model = new RMYY_CallCenter_Api.Model.T_Con_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_AcceptTime"] != null && row["F_AcceptTime"].ToString() != "")
                {
                    model.F_AcceptTime = DateTime.Parse(row["F_AcceptTime"].ToString());
                }
                if (row["F_WorkOrderCode"] != null)
                {
                    model.F_WorkOrderCode = row["F_WorkOrderCode"].ToString();
                }
                if (row["F_Source"] != null)
                {
                    model.F_Source = row["F_Source"].ToString();
                }
                if (row["F_Customer"] != null)
                {
                    model.F_Customer = row["F_Customer"].ToString();
                }
                if (row["F_Sex"] != null && row["F_Sex"].ToString() != "")
                {
                    model.F_Sex = int.Parse(row["F_Sex"].ToString());
                }
                if (row["F_CusAddress"] != null)
                {
                    model.F_CusAddress = row["F_CusAddress"].ToString();
                }
                if (row["F_Phon"] != null)
                {
                    model.F_Phon = row["F_Phon"].ToString();
                }
                if (row["F_IdCard"] != null)
                {
                    model.F_IdCard = row["F_IdCard"].ToString();
                }
                if (row["F_ServiceItems"] != null)
                {
                    model.F_ServiceItems = row["F_ServiceItems"].ToString();
                }
                if (row["F_Address"] != null)
                {
                    model.F_Address = row["F_Address"].ToString();
                }
                if (row["F_FirstCheckHospital"] != null)
                {
                    model.F_FirstCheckHospital = row["F_FirstCheckHospital"].ToString();
                }
                if (row["F_NoduleSize"] != null && row["F_NoduleSize"].ToString() != "")
                {
                    model.F_NoduleSize = decimal.Parse(row["F_NoduleSize"].ToString());
                }
                if (row["F_FirstFindTime"] != null && row["F_FirstFindTime"].ToString() != "")
                {
                    model.F_FirstFindTime = DateTime.Parse(row["F_FirstFindTime"].ToString());
                }
                if (row["F_Urgency"] != null && row["F_Urgency"].ToString() != "")
                {
                    model.F_Urgency = int.Parse(row["F_Urgency"].ToString());
                }
                if (row["F_DealOpinions"] != null)
                {
                    model.F_DealOpinions = row["F_DealOpinions"].ToString();
                }
                if (row["F_DealType"] != null)
                {
                    model.F_DealType = row["F_DealType"].ToString();
                }
                if (row["F_DealResult"] != null)
                {
                    model.F_DealResult = row["F_DealResult"].ToString();
                }
                if (row["F_HandleBy"] != null)
                {
                    model.F_HandleBy = row["F_HandleBy"].ToString();
                }
                if (row["F_HandleTime"] != null && row["F_HandleTime"].ToString() != "")
                {
                    model.F_HandleTime = DateTime.Parse(row["F_HandleTime"].ToString());
                }
                if (row["F_NotHandleReasons"] != null)
                {
                    model.F_NotHandleReasons = row["F_NotHandleReasons"].ToString();
                }
                if (row["F_WorkOrderContents"] != null)
                {
                    model.F_WorkOrderContents = row["F_WorkOrderContents"].ToString();
                }
                if (row["F_ResponDept"] != null && row["F_ResponDept"].ToString() != "")
                {
                    model.F_ResponDept = int.Parse(row["F_ResponDept"].ToString());
                }
                if (row["F_ReplayCount"] != null && row["F_ReplayCount"].ToString() != "")
                {
                    model.F_ReplayCount = int.Parse(row["F_ReplayCount"].ToString());
                }
                

                if (row["F_ResponPerson"] != null)
                {
                    model.F_ResponPerson = row["F_ResponPerson"].ToString();
                }
                if (row["F_CallID"] != null)
                {
                    model.F_CallID = row["F_CallID"].ToString();
                }
                if (row["F_LimitTime"] != null && row["F_LimitTime"].ToString() != "")
                {
                    model.F_LimitTime = decimal.Parse(row["F_LimitTime"].ToString());
                }
                if (row["F_IsReturnBak"] != null && row["F_IsReturnBak"].ToString() != "")
                {
                    model.F_IsReturnBak = int.Parse(row["F_IsReturnBak"].ToString());
                }
                if (row["F_ReturnBakTime"] != null && row["F_ReturnBakTime"].ToString() != "")
                {
                    model.F_ReturnBakTime = DateTime.Parse(row["F_ReturnBakTime"].ToString());
                }
                if (row["F_IsTimeOut"] != null && row["F_IsTimeOut"].ToString() != "")
                {
                    model.F_IsTimeOut = int.Parse(row["F_IsTimeOut"].ToString());
                }
                if (row["F_CreateUserID"] != null)
                {
                    model.F_CreateUserID = row["F_CreateUserID"].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_IsDel"] != null && row["F_IsDel"].ToString() != "")
                {
                    model.F_IsDel = int.Parse(row["F_IsDel"].ToString());
                }
                if (row["F_CreateUserName"] != null)
                {
                    model.F_CreateUserName = row["F_CreateUserName"].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_IsAudit"] != null && row["F_IsAudit"].ToString() != "")
                {
                    model.F_IsAudit = int.Parse(row["F_IsAudit"].ToString());
                }
                if (row["F_AuditState"] != null && row["F_AuditState"].ToString() != "")
                {
                    model.F_AuditState = int.Parse(row["F_AuditState"].ToString());
                }
                if (row["F_AuditUser"] != null)
                {
                    model.F_AuditUser = row["F_AuditUser"].ToString();
                }
                if (row["F_AuditTime"] != null && row["F_AuditTime"].ToString() != "")
                {
                    model.F_AuditTime = DateTime.Parse(row["F_AuditTime"].ToString());
                }
                if (row["F_AuditCont"] != null)
                {
                    model.F_AuditCont = row["F_AuditCont"].ToString();
                }
                if (row["F_AppointTime"] != null && row["F_AppointTime"].ToString() != "")
                {
                    model.F_AppointTime = DateTime.Parse(row["F_AppointTime"].ToString());
                }
                if (row["F_Answer"] != null)
                {
                    model.F_Answer = row["F_Answer"].ToString();
                }
                if (row["F_DealContents"] != null)
                {
                    model.F_DealContents = row["F_DealContents"].ToString();
                }
                if (row["F_File"] != null)
                {
                    model.F_File = row["F_File"].ToString();
                }
                if (row["F_Satisfaction"] != null && row["F_Satisfaction"].ToString() != "")
                {
                    model.F_Satisfaction = int.Parse(row["F_Satisfaction"].ToString());
                }
                if (row["F_State"] != null && row["F_State"].ToString() != "")
                {
                    model.F_State = int.Parse(row["F_State"].ToString());
                }
                if (row["F_type1"] != null && row["F_type1"].ToString() != "")
                {
                    model.F_type1 = int.Parse(row["F_type1"].ToString());
                }
                if (row["F_type2"] != null && row["F_type2"].ToString() != "")
                {
                    model.F_type2 = int.Parse(row["F_type2"].ToString());
                }
                if (row["F_type3"] != null && row["F_type3"].ToString() != "")
                {
                    model.F_type3 = int.Parse(row["F_type3"].ToString());
                }
                if (row["F_Cathetertype"] != null)
                {
                    model.F_Cathetertype = row["F_Cathetertype"].ToString();
                }
                if (row["F_Catheterdept"] != null)
                {
                    model.F_Catheterdept = row["F_Catheterdept"].ToString();
                }
                if (row["F_Cathetertime"] != null && row["F_Cathetertime"].ToString() != "")
                {
                    model.F_Cathetertime = DateTime.Parse(row["F_Cathetertime"].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_Relationship"] != null)
                {
                    model.F_Relationship = row["F_Relationship"].ToString();
                }
                if (row["F_FullName"] != null)
                {
                    model.F_FullName = row["F_FullName"].ToString();
                }
                if (row["F_IDNumber"] != null)
                {
                    model.F_IDNumber = row["F_IDNumber"].ToString();
                }
                if (row["F_ComplaintDept"] != null && row["F_ComplaintDept"].ToString() != "")
                {
                    model.F_ComplaintDept = int .Parse(row["F_ComplaintDept"].ToString());
                }
                if (row["F_ComplaintUser"] != null)
                {
                    model.F_ComplaintUser = row["F_ComplaintUser"].ToString();
                }
                if (row["F_IsVisit"] != null && row["F_IsVisit"].ToString() != "")
                {
                    model.F_IsVisit = int.Parse(row["F_IsVisit"].ToString());
                }
                if (row["F_AppointmentTime"] != null && row["F_AppointmentTime"].ToString() != "")
                {
                    model.F_AppointmentTime = DateTime.Parse(row["F_AppointmentTime"].ToString());
                }
                
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  *  ");
            strSql.Append(" FROM T_Con_WorkOrder with(nolock)");
            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_AppointmentTime,F_Source, F_Relationship,F_FullName,F_IDNumber,F_ComplaintDept,F_ComplaintUser,F_Customer,F_Sex,F_CusAddress,F_Phon,F_IdCard,F_ServiceItems,F_Address,F_FirstCheckHospital,F_NoduleSize,F_FirstFindTime,F_Urgency,F_DealOpinions,F_DealType,F_DealResult,F_HandleBy,F_HandleTime,F_NotHandleReasons,F_WorkOrderContents,F_ResponDept,F_ResponPerson,F_CallID,F_LimitTime,F_IsReturnBak,F_ReturnBakTime,F_IsTimeOut,F_CreateUserID,F_CreateUser,F_CreateTime,F_IsDel,F_CreateUserName,F_DeleteBy,F_DeleteTime,F_IsAudit,F_AuditState,F_AuditUser,F_AuditTime,F_AuditCont,F_AppointTime,F_Answer,F_DealContents,F_File,F_Satisfaction,F_State,F_type1,F_type2,F_type3,F_Cathetertype,F_Catheterdept,F_Cathetertime,F_BedNum,F_InpatientNum,F_IsVisit,F_ReplayCount ,F_AcceptTime,F_EmergencyTypes");
            strSql.Append(" FROM T_Con_WorkOrder with(nolock)");
            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_Con_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_Con_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_Con_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
    }
}