using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using CallCenterApi.DB;//Please add references
using System.Collections.Generic;

namespace CallCenterApi.DAL
{

    /// <summary>
    /// 数据访问类:T_Bus_WorkOrder
    /// </summary>
    public partial class T_Bus_WorkOrder
    {
        public T_Bus_WorkOrder()
        {
        }
        #region  BasicMethod

        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return DbHelperSQL.GetMaxID("F_Id", "T_Bus_WorkOrder");
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string F_WorkOrderId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_Bus_WorkOrder WITH(NOLOCK)");
            strSql.Append(" where F_IsDelete=0 and F_WorkOrderId=@F_WorkOrderId");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderId", SqlDbType.NVarChar,20)
            };
            parameters[0].Value = F_WorkOrderId;

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

        /// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(CallCenterApi.Model.T_Bus_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_Bus_WorkOrder(");
            strSql.Append("F_WorkOrderId,F_CusName,F_CusSex,F_CusPhone,F_CusAddress,F_ConName,F_ConPhone,F_ZipCode,F_Email,F_InfoSource,F_ComTitle,F_ComContent,F_File,F_InfoType,F_InfoConBigType,F_InfoConSmallType,F_SourceArea,F_SourceAddress,F_WorkState,F_RemindDay,F_LimitTime,F_Key,F_SplitUser,F_Level,F_IsProtect,F_IsResult,F_Result,F_FinalOpinion,F_CallId,F_CallRecordId,F_LeaveRecordId,F_IsOverdue,F_IsSatisfie,F_IsRelease,F_IsReturn,F_IsReload,F_SubmitTime,F_AssignUser,F_AssignTime,F_MainDeptId,F_OtherDeptIds,F_DealDeptId,F_DealUser,F_DealTime,F_IsClosed,F_CloseUser,F_CloseTime,F_IsNotice,F_NoticeDeptIds,F_CreateUser,F_CreateTime,F_IsEnabled,F_EnableTime,F_IsDelete,F_DeleteUser,F_DeleteTime,F_Longitude,F_Latitude,F_MainDeptID3,F_IsStandard,F_StandardIDS,F_IsSms,IsExport,F_Post,F_Contact,F_Liable,F_Event,F_Transferor,F_TransferTime,F_Transferunit,F_Remarks,F_OldWorkOrderId,F_NewResult,F_ResultRemarks,F_Files,F_Scanning,F_Satisfaction,F_Backreason,F_MainWorkOrderId,ReminderNum,F_NewRemarks,F_Caseid,F_Mode,F_Did,requirementFinishDay,F_Hcdatetime, F_RelatedWorkOrder,F_WorkOrderType)");
            strSql.Append(" values (");
            strSql.Append("@F_WorkOrderId,@F_CusName,@F_CusSex,@F_CusPhone,@F_CusAddress,@F_ConName,@F_ConPhone,@F_ZipCode,@F_Email,@F_InfoSource,@F_ComTitle,@F_ComContent,@F_File,@F_InfoType,@F_InfoConBigType,@F_InfoConSmallType,@F_SourceArea,@F_SourceAddress,@F_WorkState,@F_RemindDay,@F_LimitTime,@F_Key,@F_SplitUser,@F_Level,@F_IsProtect,@F_IsResult,@F_Result,@F_FinalOpinion,@F_CallId,@F_CallRecordId,@F_LeaveRecordId,@F_IsOverdue,@F_IsSatisfie,@F_IsRelease,@F_IsReturn,@F_IsReload,@F_SubmitTime,@F_AssignUser,@F_AssignTime,@F_MainDeptId,@F_OtherDeptIds,@F_DealDeptId,@F_DealUser,@F_DealTime,@F_IsClosed,@F_CloseUser,@F_CloseTime,@F_IsNotice,@F_NoticeDeptIds,@F_CreateUser,@F_CreateTime,@F_IsEnabled,@F_EnableTime,@F_IsDelete,@F_DeleteUser,@F_DeleteTime,@F_Longitude,@F_Latitude,@F_MainDeptID3,@F_IsStandard,@F_StandardIDS,@F_IsSms,@IsExport,@F_Post,@F_Contact,@F_Liable,@F_Event,@F_Transferor,@F_TransferTime,@F_Transferunit,@F_Remarks,@F_OldWorkOrderId,@F_NewResult,@F_ResultRemarks,@F_Files,@F_Scanning,@F_Satisfaction,@F_Backreason,@F_MainWorkOrderId,@ReminderNum,@F_NewRemarks,@F_Caseid,@F_Mode,@F_Did,@requirementFinishDay,@F_Hcdatetime,@F_RelatedWorkOrder,@F_WorkOrderType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderId", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_CusName", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_CusSex", SqlDbType.NVarChar,10),
                    new SqlParameter("@F_CusPhone", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_CusAddress", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_ConName", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_ConPhone", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_ZipCode", SqlDbType.NVarChar,10),
                    new SqlParameter("@F_Email", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_InfoSource", SqlDbType.Int,4),
                    new SqlParameter("@F_ComTitle", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_ComContent", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_File", SqlDbType.VarChar,500),
                    new SqlParameter("@F_InfoType", SqlDbType.Int,4),
                    new SqlParameter("@F_InfoConBigType", SqlDbType.Int,4),
                    new SqlParameter("@F_InfoConSmallType", SqlDbType.Int,4),
                    new SqlParameter("@F_SourceArea", SqlDbType.Int,4),
                    new SqlParameter("@F_SourceAddress", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_WorkState", SqlDbType.Int,4),
                    new SqlParameter("@F_RemindDay", SqlDbType.Int,4),
                    new SqlParameter("@F_LimitTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Key", SqlDbType.VarChar,500),
                    new SqlParameter("@F_SplitUser", SqlDbType.VarChar,500),
                    new SqlParameter("@F_Level", SqlDbType.Int,4),
                    new SqlParameter("@F_IsProtect", SqlDbType.Int,4),
                    new SqlParameter("@F_IsResult", SqlDbType.Int,4),
                    new SqlParameter("@F_Result", SqlDbType.Text),
                    new SqlParameter("@F_FinalOpinion", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_CallId", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CallRecordId", SqlDbType.Int,4),
                    new SqlParameter("@F_LeaveRecordId", SqlDbType.Int,4),
                    new SqlParameter("@F_IsOverdue", SqlDbType.Int,4),
                    new SqlParameter("@F_IsSatisfie", SqlDbType.Int,4),
                    new SqlParameter("@F_IsRelease", SqlDbType.Int,4),
                    new SqlParameter("@F_IsReturn", SqlDbType.Int,4),
                    new SqlParameter("@F_IsReload", SqlDbType.Int,4),
                    new SqlParameter("@F_SubmitTime", SqlDbType.DateTime),
                    new SqlParameter("@F_AssignUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AssignTime", SqlDbType.DateTime),
                    new SqlParameter("@F_MainDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_OtherDeptIds", SqlDbType.VarChar,500),
                    new SqlParameter("@F_DealDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_DealUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DealTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsClosed", SqlDbType.Int,4),
                    new SqlParameter("@F_CloseUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CloseTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsNotice", SqlDbType.Int,4),
                    new SqlParameter("@F_NoticeDeptIds", SqlDbType.VarChar,500),
                    new SqlParameter("@F_CreateUser", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsEnabled", SqlDbType.Int,4),
                    new SqlParameter("@F_EnableTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Longitude", SqlDbType.Decimal,9),
                    new SqlParameter("@F_Latitude", SqlDbType.Decimal,9),
                    new SqlParameter("@F_MainDeptID3", SqlDbType.VarChar,500),
                    new SqlParameter("@F_IsStandard", SqlDbType.Int,4),
                    new SqlParameter("@F_IsSms", SqlDbType.Int,4),
                     new SqlParameter("@IsExport", SqlDbType.Int,4),
                     new SqlParameter("@F_Post", SqlDbType.VarChar,100),
                     new SqlParameter("@F_Contact", SqlDbType.VarChar,200),
                    new SqlParameter("@F_Liable", SqlDbType.VarChar,100),
                   new SqlParameter("@F_Event", SqlDbType.VarChar,100),
                  new SqlParameter("@F_Transferor", SqlDbType.VarChar,100),
                   new SqlParameter("@F_TransferTime", SqlDbType.DateTime ),
                  new SqlParameter("@F_Transferunit", SqlDbType.VarChar,100),
                  new SqlParameter("@F_Remarks", SqlDbType.VarChar,100),
                     new SqlParameter("@F_OldWorkOrderId", SqlDbType.VarChar,100),
                     new SqlParameter("@F_NewResult", SqlDbType.NVarChar,-1),
                      new SqlParameter("@F_ResultRemarks", SqlDbType.NVarChar,-1),
                         new SqlParameter("@F_Files", SqlDbType.VarChar,200),
                           new SqlParameter("@F_Scanning", SqlDbType.DateTime),
                            new SqlParameter("@F_Satisfaction", SqlDbType.Int,4),
                             new SqlParameter("@F_Backreason", SqlDbType.NVarChar,-1),
                  
                new SqlParameter("@F_StandardIDS", SqlDbType.NVarChar,200),
                new SqlParameter("@F_MainWorkOrderId", SqlDbType.NVarChar,50),
                new SqlParameter("@ReminderNum", SqlDbType.Int,4),
                new SqlParameter("@F_NewRemarks", SqlDbType.NVarChar,-1),
                 new SqlParameter("@F_Caseid", SqlDbType.Int,4),
                  new SqlParameter("@F_Mode", SqlDbType.Int,4),
                  new SqlParameter("@F_Did", SqlDbType.Int,4),
                     new SqlParameter("@requirementFinishDay",  SqlDbType.VarChar,100),
                        new SqlParameter("@F_Hcdatetime", SqlDbType.DateTime),
                
 new SqlParameter("@F_RelatedWorkOrder", SqlDbType.NVarChar,100),
     new SqlParameter("@F_WorkOrderType", SqlDbType.Int,4)
            };
            parameters[0].Value = model.F_WorkOrderId;
            parameters[1].Value = model.F_CusName;
            parameters[2].Value = model.F_CusSex;
            parameters[3].Value = model.F_CusPhone;
            parameters[4].Value = model.F_CusAddress;
            parameters[5].Value = model.F_ConName;
            parameters[6].Value = model.F_ConPhone;
            parameters[7].Value = model.F_ZipCode;
            parameters[8].Value = model.F_Email;
            parameters[9].Value = model.F_InfoSource;
            parameters[10].Value = model.F_ComTitle;
            parameters[11].Value = model.F_ComContent;
            parameters[12].Value = model.F_File;
            parameters[13].Value = model.F_InfoType;
            parameters[14].Value = model.F_InfoConBigType;
            parameters[15].Value = model.F_InfoConSmallType;
            parameters[16].Value = model.F_SourceArea;
            parameters[17].Value = model.F_SourceAddress;
            parameters[18].Value = model.F_WorkState;
            parameters[19].Value = model.F_RemindDay;
            parameters[20].Value = model.F_LimitTime;
            parameters[21].Value = model.F_Key;
            parameters[22].Value = model.F_SplitUser;
            parameters[23].Value = model.F_Level;
            parameters[24].Value = model.F_IsProtect;
            parameters[25].Value = model.F_IsResult;
            parameters[26].Value = model.F_Result;
            parameters[27].Value = model.F_FinalOpinion;
            parameters[28].Value = model.F_CallId;
            parameters[29].Value = model.F_CallRecordId;
            parameters[30].Value = model.F_LeaveRecordId;
            parameters[31].Value = model.F_IsOverdue;
            parameters[32].Value = model.F_IsSatisfie;
            parameters[33].Value = model.F_IsRelease;
            parameters[34].Value = model.F_IsReturn;
            parameters[35].Value = model.F_IsReload;
            parameters[36].Value = model.F_SubmitTime;
            parameters[37].Value = model.F_AssignUser;
            parameters[38].Value = model.F_AssignTime;
            parameters[39].Value = model.F_MainDeptId;
            parameters[40].Value = model.F_OtherDeptIds;
            parameters[41].Value = model.F_DealDeptId;
            parameters[42].Value = model.F_DealUser;
            parameters[43].Value = model.F_DealTime;
            parameters[44].Value = model.F_IsClosed;
            parameters[45].Value = model.F_CloseUser;
            parameters[46].Value = model.F_CloseTime;
            parameters[47].Value = model.F_IsNotice;
            parameters[48].Value = model.F_NoticeDeptIds;
            parameters[49].Value = model.F_CreateUser;
            parameters[50].Value = model.F_CreateTime;
            parameters[51].Value = model.F_IsEnabled;
            parameters[52].Value = model.F_EnableTime;
            parameters[53].Value = model.F_IsDelete;
            parameters[54].Value = model.F_DeleteUser;
            parameters[55].Value = model.F_DeleteTime;
            parameters[56].Value = model.F_Longitude;
            parameters[57].Value = model.F_Latitude;
            parameters[58].Value = model.F_MainDeptID3;
            parameters[59].Value = model.F_IsStandard;
            parameters[60].Value = model.F_IsSms;
            parameters[61].Value = model.IsExport;
            parameters[62].Value = model.F_Post;
            parameters[63].Value = model.F_Contact;
            parameters[64].Value = model.F_Liable;
            parameters[65].Value = model.F_Event;
            parameters[66].Value = model.F_Transferor;
            parameters[67].Value = model.F_TransferTime;
            parameters[68].Value = model.F_Transferunit;
            parameters[69].Value = model.F_Remarks;
            parameters[70].Value = model.F_OldWorkOrderId;
            parameters[71].Value = model.F_NewResult;
            parameters[72].Value = model.F_ResultRemarks;
            parameters[73].Value = model.F_Files;
            parameters[74].Value = model.F_Scanning;
            parameters[75].Value = model.F_Satisfaction;
            parameters[76].Value = model.F_Backreason;
            parameters[77].Value = model.F_StandardIDS;
            parameters[78].Value = model.F_MainWorkOrderId;
            parameters[79].Value = model.ReminderNum;
            parameters[80].Value = model.F_NewRemarks;
            parameters[81].Value = model.F_Caseid;
            parameters[82].Value = model.F_Mode;
            parameters[83].Value = model.F_Did;
            parameters[84].Value = model.requirementFinishDay;
            parameters[85].Value = model.F_Hcdatetime;

            //F_RelatedWorkOrder,F_WorkOrderType
            parameters[86].Value = model.F_RelatedWorkOrder;
            parameters[87].Value = model.F_WorkOrderType;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CallCenterApi.Model.T_Bus_WorkOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Bus_WorkOrder set ");
            strSql.Append("F_WorkOrderId=@F_WorkOrderId,");
            strSql.Append("F_CusName=@F_CusName,");
            strSql.Append("F_CusSex=@F_CusSex,");
            strSql.Append("F_CusPhone=@F_CusPhone,");
            strSql.Append("F_CusAddress=@F_CusAddress,");
            strSql.Append("F_ConName=@F_ConName,");
            strSql.Append("F_ConPhone=@F_ConPhone,");
            strSql.Append("F_ZipCode=@F_ZipCode,");
            strSql.Append("F_Email=@F_Email,");
            strSql.Append("F_InfoSource=@F_InfoSource,");
            strSql.Append("F_ComTitle=@F_ComTitle,");
            strSql.Append("F_ComContent=@F_ComContent,");
            strSql.Append("F_File=@F_File,");
            strSql.Append("F_InfoType=@F_InfoType,");
            strSql.Append("F_InfoConBigType=@F_InfoConBigType,");
            strSql.Append("F_InfoConSmallType=@F_InfoConSmallType,");
            strSql.Append("F_SourceArea=@F_SourceArea,");
            strSql.Append("F_SourceAddress=@F_SourceAddress,");
            strSql.Append("F_WorkState=@F_WorkState,");
            strSql.Append("F_RemindDay=@F_RemindDay,");
            strSql.Append("F_LimitTime=@F_LimitTime,");
            strSql.Append("F_Key=@F_Key,");
            strSql.Append("F_SplitUser=@F_SplitUser,");
            strSql.Append("F_Level=@F_Level,");
            strSql.Append("F_IsProtect=@F_IsProtect,");
            strSql.Append("F_IsResult=@F_IsResult,");
            strSql.Append("F_Result=@F_Result,");
            strSql.Append("F_FinalOpinion=@F_FinalOpinion,");
            strSql.Append("F_CallId=@F_CallId,");
            strSql.Append("F_CallRecordId=@F_CallRecordId,");
            strSql.Append("F_LeaveRecordId=@F_LeaveRecordId,");
            strSql.Append("F_IsOverdue=@F_IsOverdue,");
            strSql.Append("F_IsSatisfie=@F_IsSatisfie,");
            strSql.Append("F_IsRelease=@F_IsRelease,");
            strSql.Append("F_IsReturn=@F_IsReturn,");
            strSql.Append("F_IsReload=@F_IsReload,");
            strSql.Append("F_SubmitTime=@F_SubmitTime,");
            strSql.Append("F_AssignUser=@F_AssignUser,");
            strSql.Append("F_AssignTime=@F_AssignTime,");
            strSql.Append("F_MainDeptId=@F_MainDeptId,");
            strSql.Append("F_OtherDeptIds=@F_OtherDeptIds,");
            strSql.Append("F_DealDeptId=@F_DealDeptId,");
            strSql.Append("F_DealUser=@F_DealUser,");
            strSql.Append("F_DealTime=@F_DealTime,");
            strSql.Append("F_IsClosed=@F_IsClosed,");
            strSql.Append("F_CloseUser=@F_CloseUser,");
            strSql.Append("F_CloseTime=@F_CloseTime,");
            strSql.Append("F_IsNotice=@F_IsNotice,");
            strSql.Append("F_NoticeDeptIds=@F_NoticeDeptIds,");
            strSql.Append("F_CreateUser=@F_CreateUser,");
            strSql.Append("F_CreateTime=@F_CreateTime,");
            strSql.Append("F_IsEnabled=@F_IsEnabled,");
            strSql.Append("F_EnableTime=@F_EnableTime,");
            strSql.Append("F_IsDelete=@F_IsDelete,");
            strSql.Append("F_DeleteUser=@F_DeleteUser,");
            strSql.Append("F_DeleteTime=@F_DeleteTime,");
            strSql.Append("F_Longitude=@F_Longitude,");
            strSql.Append("F_Latitude=@F_Latitude,");
            strSql.Append("F_MainDeptID3=@F_MainDeptID3, ");
            strSql.Append("F_IsStandard=@F_IsStandard,");
            strSql.Append("F_StandardIDS=@F_StandardIDS, ");
            strSql.Append("IsExport=@IsExport, ");
            strSql.Append("F_Post=@F_Post, ");
            strSql.Append("F_Contact=@F_Contact, ");
            strSql.Append("F_Liable=@F_Liable, ");
            strSql.Append("F_Event=@F_Event, ");
            strSql.Append("F_Transferor=@F_Transferor, ");
            strSql.Append("F_TransferTime=@F_TransferTime, ");
            strSql.Append("F_Transferunit=@F_Transferunit, ");
            strSql.Append("F_Remarks=@F_Remarks, ");
            strSql.Append("F_OldWorkOrderId=@F_OldWorkOrderId, ");
            strSql.Append("F_NewResult=@F_NewResult, ");
            strSql.Append("F_ResultRemarks=@F_ResultRemarks, ");
            strSql.Append("F_Files=@F_Files, ");
            strSql.Append("F_Scanning=@F_Scanning, ");
            strSql.Append("F_Satisfaction=@F_Satisfaction, ");
            strSql.Append("F_Backreason=@F_Backreason, ");
            strSql.Append("F_WorkRemarks=@F_WorkRemarks, ");
            strSql.Append("F_IsSms=@F_IsSms,");
            strSql.Append("F_MainWorkOrderId=@F_MainWorkOrderId,");
            strSql.Append("ReminderNum=@ReminderNum,");
            strSql.Append("F_NewRemarks=@F_NewRemarks,");
            strSql.Append("F_Caseid=@F_Caseid,");
            strSql.Append("F_Mode=@F_Mode,");
            strSql.Append("F_Did=@F_Did,");
           
            strSql.Append("F_Hcdatetime=@F_Hcdatetime,");
            strSql.Append("F_HCFiles=@F_HCFiles,");
            strSql.Append("requirementFinishDay=@requirementFinishDay");
            
            strSql.Append(" where F_Id=@F_Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderId", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_CusName", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_CusSex", SqlDbType.NVarChar,10),
                    new SqlParameter("@F_CusPhone", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_CusAddress", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_ConName", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_ConPhone", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_ZipCode", SqlDbType.NVarChar,10),
                    new SqlParameter("@F_Email", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_InfoSource", SqlDbType.Int,4),
                    new SqlParameter("@F_ComTitle", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_ComContent", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_File", SqlDbType.VarChar,500),
                    new SqlParameter("@F_InfoType", SqlDbType.Int,4),
                    new SqlParameter("@F_InfoConBigType", SqlDbType.Int,4),
                    new SqlParameter("@F_InfoConSmallType", SqlDbType.Int,4),
                    new SqlParameter("@F_SourceArea", SqlDbType.Int,4),
                    new SqlParameter("@F_SourceAddress", SqlDbType.NVarChar,200),
                    new SqlParameter("@F_WorkState", SqlDbType.Int,4),
                    new SqlParameter("@F_RemindDay", SqlDbType.Int,4),
                    new SqlParameter("@F_LimitTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Key", SqlDbType.VarChar,500),
                    new SqlParameter("@F_SplitUser", SqlDbType.VarChar,500),
                    new SqlParameter("@F_Level", SqlDbType.Int,4),
                    new SqlParameter("@F_IsProtect", SqlDbType.Int,4),
                    new SqlParameter("@F_IsResult", SqlDbType.Int,4),
                    new SqlParameter("@F_Result", SqlDbType.Text),
                    new SqlParameter("@F_FinalOpinion", SqlDbType.NVarChar,-1),
                    new SqlParameter("@F_CallId", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CallRecordId", SqlDbType.Int,4),
                    new SqlParameter("@F_LeaveRecordId", SqlDbType.Int,4),
                    new SqlParameter("@F_IsOverdue", SqlDbType.Int,4),
                    new SqlParameter("@F_IsSatisfie", SqlDbType.Int,4),
                    new SqlParameter("@F_IsRelease", SqlDbType.Int,4),
                    new SqlParameter("@F_IsReturn", SqlDbType.Int,4),
                    new SqlParameter("@F_IsReload", SqlDbType.Int,4),
                    new SqlParameter("@F_SubmitTime", SqlDbType.DateTime),
                    new SqlParameter("@F_AssignUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AssignTime", SqlDbType.DateTime),
                    new SqlParameter("@F_MainDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_OtherDeptIds", SqlDbType.VarChar,500),
                    new SqlParameter("@F_DealDeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_DealUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DealTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsClosed", SqlDbType.Int,4),
                    new SqlParameter("@F_CloseUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CloseTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsNotice", SqlDbType.Int,4),
                    new SqlParameter("@F_NoticeDeptIds", SqlDbType.VarChar,500),
                    new SqlParameter("@F_CreateUser", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsEnabled", SqlDbType.Int,4),
                    new SqlParameter("@F_EnableTime", SqlDbType.DateTime),
                    new SqlParameter("@F_IsDelete", SqlDbType.Int,4),
                    new SqlParameter("@F_DeleteUser", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeleteTime", SqlDbType.DateTime),
                    new SqlParameter("@F_Longitude", SqlDbType.Decimal,9),
                    new SqlParameter("@F_Latitude", SqlDbType.Decimal,9),
                    new SqlParameter("@F_MainDeptID3", SqlDbType.VarChar,500),
                    new SqlParameter("@F_IsStandard", SqlDbType.Int,4),
                    new SqlParameter("@F_StandardIDS", SqlDbType.NVarChar,200),
                     new SqlParameter("@IsExport", SqlDbType.Int,4),
                       new SqlParameter("@F_Post", SqlDbType.NVarChar,100),
                    new SqlParameter("@F_Contact", SqlDbType.NVarChar,200),
                       new SqlParameter("@F_Liable", SqlDbType.NVarChar,100),
                        new SqlParameter("@F_Event", SqlDbType.NVarChar,100),
                      new SqlParameter("@F_Transferor", SqlDbType.NVarChar,100),
                        new SqlParameter("@F_TransferTime", SqlDbType.DateTime ),
                       new SqlParameter("@F_Transferunit", SqlDbType.NVarChar,100),
                        new SqlParameter("@F_Remarks", SqlDbType.NVarChar,100),
                         new SqlParameter("@F_OldWorkOrderId", SqlDbType.NVarChar,100),
                           new SqlParameter("@F_NewResult", SqlDbType.NVarChar,-1),
                             new SqlParameter("@F_ResultRemarks", SqlDbType.NVarChar,-1),
                              new SqlParameter("@F_Files", SqlDbType.NVarChar,200),
                               new SqlParameter("@F_Scanning", SqlDbType.DateTime),
                                new SqlParameter("@F_Satisfaction", SqlDbType.Int,4),
                                 new SqlParameter("@F_Backreason", SqlDbType.NVarChar,-1),
                                 new SqlParameter("@F_WorkRemarks", SqlDbType.NVarChar,-1),
                       
                       new SqlParameter("@F_IsSms", SqlDbType.Int,4),
                       new SqlParameter("@F_MainWorkOrderId", SqlDbType.NVarChar,50),
                       new SqlParameter("@ReminderNum", SqlDbType.Int,4),
                       new SqlParameter("@F_NewRemarks", SqlDbType.NVarChar,-1),
                        new SqlParameter("@F_Caseid", SqlDbType.Int,4),
                         new SqlParameter("@F_Mode", SqlDbType.Int,4),
                          new SqlParameter("@F_Did", SqlDbType.Int,4),
                       
                         new SqlParameter("@F_Hcdatetime", SqlDbType.DateTime),
                           new SqlParameter("@F_HCFiles", SqlDbType.NVarChar,500),
                             new SqlParameter("@requirementFinishDay", SqlDbType.NVarChar,100),
                       
                    new SqlParameter("@F_Id", SqlDbType.Int,4)};
            parameters[0].Value = model.F_WorkOrderId;
            parameters[1].Value = model.F_CusName;
            parameters[2].Value = model.F_CusSex;
            parameters[3].Value = model.F_CusPhone;
            parameters[4].Value = model.F_CusAddress;
            parameters[5].Value = model.F_ConName;
            parameters[6].Value = model.F_ConPhone;
            parameters[7].Value = model.F_ZipCode;
            parameters[8].Value = model.F_Email;
            parameters[9].Value = model.F_InfoSource;
            parameters[10].Value = model.F_ComTitle;
            parameters[11].Value = model.F_ComContent;
            parameters[12].Value = model.F_File;
            parameters[13].Value = model.F_InfoType;
            parameters[14].Value = model.F_InfoConBigType;
            parameters[15].Value = model.F_InfoConSmallType;
            parameters[16].Value = model.F_SourceArea;
            parameters[17].Value = model.F_SourceAddress;
            parameters[18].Value = model.F_WorkState;
            parameters[19].Value = model.F_RemindDay;
            parameters[20].Value = model.F_LimitTime;
            parameters[21].Value = model.F_Key;
            parameters[22].Value = model.F_SplitUser;
            parameters[23].Value = model.F_Level;
            parameters[24].Value = model.F_IsProtect;
            parameters[25].Value = model.F_IsResult;
            parameters[26].Value = model.F_Result;
            parameters[27].Value = model.F_FinalOpinion;
            parameters[28].Value = model.F_CallId;
            parameters[29].Value = model.F_CallRecordId;
            parameters[30].Value = model.F_LeaveRecordId;
            parameters[31].Value = model.F_IsOverdue;
            parameters[32].Value = model.F_IsSatisfie;
            parameters[33].Value = model.F_IsRelease;
            parameters[34].Value = model.F_IsReturn;
            parameters[35].Value = model.F_IsReload;
            parameters[36].Value = model.F_SubmitTime;
            parameters[37].Value = model.F_AssignUser;
            parameters[38].Value = model.F_AssignTime;
            parameters[39].Value = model.F_MainDeptId;
            parameters[40].Value = model.F_OtherDeptIds;
            parameters[41].Value = model.F_DealDeptId;
            parameters[42].Value = model.F_DealUser;
            parameters[43].Value = model.F_DealTime;
            parameters[44].Value = model.F_IsClosed;
            parameters[45].Value = model.F_CloseUser;
            parameters[46].Value = model.F_CloseTime;
            parameters[47].Value = model.F_IsNotice;
            parameters[48].Value = model.F_NoticeDeptIds;
            parameters[49].Value = model.F_CreateUser;
            parameters[50].Value = model.F_CreateTime;
            parameters[51].Value = model.F_IsEnabled;
            parameters[52].Value = model.F_EnableTime;
            parameters[53].Value = model.F_IsDelete;
            parameters[54].Value = model.F_DeleteUser;
            parameters[55].Value = model.F_DeleteTime;
            parameters[56].Value = model.F_Longitude;
            parameters[57].Value = model.F_Latitude;
            parameters[58].Value = model.F_MainDeptID3;
            parameters[59].Value = model.F_IsStandard;
            parameters[60].Value = model.F_StandardIDS;
            parameters[61].Value = model.IsExport;
            parameters[62].Value = model.F_Post;
            parameters[63].Value = model.F_Contact;
            parameters[64].Value = model.F_Liable;
            parameters[65].Value = model.F_Event;
            parameters[66].Value = model.F_Transferor;
            parameters[67].Value = model.F_TransferTime;
            parameters[68].Value = model.F_Transferunit;
            parameters[69].Value = model.F_Remarks;
            parameters[70].Value = model.F_OldWorkOrderId;
            parameters[71].Value = model.F_NewResult;
            parameters[72].Value = model.F_ResultRemarks;
            parameters[73].Value = model.F_Files;
            parameters[74].Value = model.F_Scanning;
            parameters[75].Value = model.F_Satisfaction;
            parameters[76].Value = model.F_Backreason;
            parameters[77].Value = model.F_WorkRemarks;
            parameters[78].Value = model.F_IsSms;
            parameters[79].Value = model.F_MainWorkOrderId;
            parameters[80].Value = model.ReminderNum;
            parameters[81].Value = model.F_NewRemarks;
            parameters[82].Value = model.F_Caseid;
            parameters[83].Value = model.F_Mode;
            parameters[84].Value = model.F_Did;

            
           parameters[85].Value = model.F_Hcdatetime;
            parameters[86].Value = model.F_HCFiles;
            parameters[87].Value = model.requirementFinishDay;
            
            parameters[88].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_Bus_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_Bus_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 bool DeleteLogicList(string F_WorkOrderIdlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Bus_WorkOrder set F_IsDelete=1 ");
            strSql.Append(" where F_WorkOrderId in (" + F_WorkOrderIdlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


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

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

            CallCenterApi.Model.T_Bus_WorkOrder model = new CallCenterApi.Model.T_Bus_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 CallCenterApi.Model.T_Bus_WorkOrder GetModel(string F_WorkOrderId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from T_Bus_WorkOrder WITH(NOLOCK) ");
            strSql.Append(" where F_WorkOrderId=@F_WorkOrderId");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WorkOrderId", SqlDbType.NVarChar,20)
            };
            parameters[0].Value = F_WorkOrderId;

            CallCenterApi.Model.T_Bus_WorkOrder model = new CallCenterApi.Model.T_Bus_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 CallCenterApi.Model.T_Bus_WorkOrder DataRowToModel(DataRow row)
        {
            CallCenterApi.Model.T_Bus_WorkOrder model = new CallCenterApi.Model.T_Bus_WorkOrder();
            if (row != null)
            {
                if (row["F_RelatedWorkOrder"] != null)
                {
                    model.F_RelatedWorkOrder = row["F_RelatedWorkOrder"].ToString();
                }
                if (row["F_WorkOrderType"] != null && row["F_WorkOrderType"].ToString() != "")
                {
                    model.F_WorkOrderType = int.Parse(row["F_WorkOrderType"].ToString());
                }


                if (row["F_Id"] != null && row["F_Id"].ToString() != "")
                {
                    model.F_Id = int.Parse(row["F_Id"].ToString());
                }
                if (row["F_WorkOrderId"] != null)
                {
                    model.F_WorkOrderId = row["F_WorkOrderId"].ToString();
                }
                if (row["F_CusName"] != null)
                {
                    model.F_CusName = row["F_CusName"].ToString();
                }
                if (row["F_CusSex"] != null)
                {
                    model.F_CusSex = row["F_CusSex"].ToString();
                }
                if (row["F_CusPhone"] != null)
                {
                    model.F_CusPhone = row["F_CusPhone"].ToString();
                }
                if (row["F_CusAddress"] != null)
                {
                    model.F_CusAddress = row["F_CusAddress"].ToString();
                }
                if (row["F_ConName"] != null)
                {
                    model.F_ConName = row["F_ConName"].ToString();
                }
                if (row["F_ConPhone"] != null)
                {
                    model.F_ConPhone = row["F_ConPhone"].ToString();
                }
                if (row["F_ZipCode"] != null)
                {
                    model.F_ZipCode = row["F_ZipCode"].ToString();
                }
                if (row["F_Email"] != null)
                {
                    model.F_Email = row["F_Email"].ToString();
                }
                if (row["F_InfoSource"] != null && row["F_InfoSource"].ToString() != "")
                {
                    model.F_InfoSource = int.Parse(row["F_InfoSource"].ToString());
                }
                if (row["F_ComTitle"] != null)
                {
                    model.F_ComTitle = row["F_ComTitle"].ToString();
                }
                if (row["F_ComContent"] != null)
                {
                    model.F_ComContent = row["F_ComContent"].ToString();
                }
                if (row["F_File"] != null)
                {
                    model.F_File = row["F_File"].ToString();
                }
                if (row["F_InfoType"] != null && row["F_InfoType"].ToString() != "")
                {
                    model.F_InfoType = int.Parse(row["F_InfoType"].ToString());
                }
                if (row["F_InfoConBigType"] != null && row["F_InfoConBigType"].ToString() != "")
                {
                    model.F_InfoConBigType = int.Parse(row["F_InfoConBigType"].ToString());
                }
                if (row["F_InfoConSmallType"] != null && row["F_InfoConSmallType"].ToString() != "")
                {
                    model.F_InfoConSmallType = int.Parse(row["F_InfoConSmallType"].ToString());
                }
                if (row["F_SourceArea"] != null && row["F_SourceArea"].ToString() != "")
                {
                    model.F_SourceArea = int.Parse(row["F_SourceArea"].ToString());
                }
                if (row["F_SourceAddress"] != null)
                {
                    model.F_SourceAddress = row["F_SourceAddress"].ToString();
                }
                if (row["F_WorkState"] != null && row["F_WorkState"].ToString() != "")
                {
                    model.F_WorkState = int.Parse(row["F_WorkState"].ToString());
                }
                if (row["F_RemindDay"] != null && row["F_RemindDay"].ToString() != "")
                {
                    model.F_RemindDay = int.Parse(row["F_RemindDay"].ToString());
                }
                if (row["F_LimitTime"] != null && row["F_LimitTime"].ToString() != "")
                {
                    model.F_LimitTime = DateTime.Parse(row["F_LimitTime"].ToString());
                }
                if (row["F_Scanning"] != null && row["F_Scanning"].ToString() != "")
                {
                    model.F_Scanning = DateTime.Parse(row["F_Scanning"].ToString());
                }
                
                if (row["F_Key"] != null)
                {
                    model.F_Key = row["F_Key"].ToString();
                }
                if (row["F_SplitUser"] != null)
                {
                    model.F_SplitUser = row["F_SplitUser"].ToString();
                }
                if (row["F_Level"] != null && row["F_Level"].ToString() != "")
                {
                    model.F_Level = int.Parse(row["F_Level"].ToString());
                }
                if (row["F_IsProtect"] != null && row["F_IsProtect"].ToString() != "")
                {
                    model.F_IsProtect = int.Parse(row["F_IsProtect"].ToString());
                }
                if (row["F_IsResult"] != null && row["F_IsResult"].ToString() != "")
                {
                    model.F_IsResult = int.Parse(row["F_IsResult"].ToString());
                }
                if (row["F_Result"] != null)
                {
                    model.F_Result = row["F_Result"].ToString();
                }
                if (row["F_FinalOpinion"] != null)
                {
                    model.F_FinalOpinion = row["F_FinalOpinion"].ToString();
                }
                if (row["F_CallId"] != null)
                {
                    model.F_CallId = row["F_CallId"].ToString();
                }
                if (row["F_CallRecordId"] != null && row["F_CallRecordId"].ToString() != "")
                {
                    model.F_CallRecordId = int.Parse(row["F_CallRecordId"].ToString());
                }
                if (row["F_LeaveRecordId"] != null && row["F_LeaveRecordId"].ToString() != "")
                {
                    model.F_LeaveRecordId = int.Parse(row["F_LeaveRecordId"].ToString());
                }
                if (row["F_IsOverdue"] != null && row["F_IsOverdue"].ToString() != "")
                {
                    model.F_IsOverdue = int.Parse(row["F_IsOverdue"].ToString());
                }
                if (row["F_IsSatisfie"] != null && row["F_IsSatisfie"].ToString() != "")
                {
                    model.F_IsSatisfie = int.Parse(row["F_IsSatisfie"].ToString());
                }
                if (row["F_IsRelease"] != null && row["F_IsRelease"].ToString() != "")
                {
                    model.F_IsRelease = int.Parse(row["F_IsRelease"].ToString());
                }
                if (row["F_IsReturn"] != null && row["F_IsReturn"].ToString() != "")
                {
                    model.F_IsReturn = int.Parse(row["F_IsReturn"].ToString());
                }
                if (row["F_IsReload"] != null && row["F_IsReload"].ToString() != "")
                {
                    model.F_IsReload = int.Parse(row["F_IsReload"].ToString());
                }
                if (row["F_SubmitTime"] != null && row["F_SubmitTime"].ToString() != "")
                {
                    model.F_SubmitTime = DateTime.Parse(row["F_SubmitTime"].ToString());
                }
                if (row["F_AssignUser"] != null)
                {
                    model.F_AssignUser = row["F_AssignUser"].ToString();
                }
                if (row["F_AssignTime"] != null && row["F_AssignTime"].ToString() != "")
                {
                    model.F_AssignTime = DateTime.Parse(row["F_AssignTime"].ToString());
                }
                if (row["F_MainDeptId"] != null && row["F_MainDeptId"].ToString() != "")
                {
                    model.F_MainDeptId = int.Parse(row["F_MainDeptId"].ToString());
                }
                if (row["F_OtherDeptIds"] != null)
                {
                    model.F_OtherDeptIds = row["F_OtherDeptIds"].ToString();
                }
                if (row["F_DealDeptId"] != null && row["F_DealDeptId"].ToString() != "")
                {
                    model.F_DealDeptId = int.Parse(row["F_DealDeptId"].ToString());
                }
                if (row["F_DealUser"] != null)
                {
                    model.F_DealUser = row["F_DealUser"].ToString();
                }
                if (row["F_DealTime"] != null && row["F_DealTime"].ToString() != "")
                {
                    model.F_DealTime = DateTime.Parse(row["F_DealTime"].ToString());
                }
                if (row["F_IsClosed"] != null && row["F_IsClosed"].ToString() != "")
                {
                    model.F_IsClosed = int.Parse(row["F_IsClosed"].ToString());
                }
                if (row["F_CloseUser"] != null)
                {
                    model.F_CloseUser = row["F_CloseUser"].ToString();
                }
                if (row["F_CloseTime"] != null && row["F_CloseTime"].ToString() != "")
                {
                    model.F_CloseTime = DateTime.Parse(row["F_CloseTime"].ToString());
                }
                if (row["F_IsNotice"] != null && row["F_IsNotice"].ToString() != "")
                {
                    model.F_IsNotice = int.Parse(row["F_IsNotice"].ToString());
                }
                if (row["F_NoticeDeptIds"] != null)
                {
                    model.F_NoticeDeptIds = row["F_NoticeDeptIds"].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_IsEnabled"] != null && row["F_IsEnabled"].ToString() != "")
                {
                    model.F_IsEnabled = int.Parse(row["F_IsEnabled"].ToString());
                }
                if (row["F_EnableTime"] != null && row["F_EnableTime"].ToString() != "")
                {
                    model.F_EnableTime = DateTime.Parse(row["F_EnableTime"].ToString());
                }
                if (row["F_IsDelete"] != null && row["F_IsDelete"].ToString() != "")
                {
                    model.F_IsDelete = int.Parse(row["F_IsDelete"].ToString());
                }
                if (row["F_DeleteUser"] != null)
                {
                    model.F_DeleteUser = row["F_DeleteUser"].ToString();
                }
                if (row["F_DeleteTime"] != null && row["F_DeleteTime"].ToString() != "")
                {
                    model.F_DeleteTime = DateTime.Parse(row["F_DeleteTime"].ToString());
                }
                if (row["F_Latitude"] != null && row["F_Latitude"].ToString() != "")
                {
                    model.F_Latitude = decimal.Parse(row["F_Latitude"].ToString());
                }
                if (row["F_Longitude"] != null && row["F_Longitude"].ToString() != "")
                {
                    model.F_Longitude = decimal.Parse(row["F_Longitude"].ToString());
                }
                if (row["F_MainDeptID3"] != null)
                {
                    model.F_MainDeptID3 = row["F_MainDeptID3"].ToString();
                }
                if (row["F_IsStandard"] != null && row["F_IsStandard"].ToString() != "")
                {
                    model.F_IsStandard = int.Parse(row["F_IsStandard"].ToString());
                }
                if (row["F_StandardIDS"] != null)
                {
                    model.F_StandardIDS = row["F_StandardIDS"].ToString();
                }
                if (row["F_IsSms"] != null && row["F_IsSms"].ToString() != "")
                {
                    model.F_IsSms = int.Parse(row["F_IsSms"].ToString());
                }
                if (row["IsExport"] != null && row["IsExport"].ToString() != "")
                {
                    model.IsExport = int.Parse(row["IsExport"].ToString());
                }
                if (row["F_Satisfaction"] != null && row["F_Satisfaction"].ToString() != "")
                {
                    model.F_Satisfaction = int.Parse(row["F_Satisfaction"].ToString());
                }
                if (row["F_Post"] != null)
                {
                    model.F_Post = row["F_Post"].ToString();
                }
                if (row["F_Contact"] != null)
                {
                    model.F_Contact = row["F_Contact"].ToString();
                }
                if (row["F_Liable"] != null)
                {
                    model.F_Liable = row["F_Liable"].ToString();
                }
                if (row["F_Event"] != null)
                {
                    model.F_Event = row["F_Event"].ToString();
                }
                if (row["F_Transferor"] != null)
                {
                    model.F_Transferor = row["F_Transferor"].ToString();
                }
                if (row["F_TransferTime"] != null && row["F_TransferTime"].ToString() != "")
                {
                    model.F_TransferTime = DateTime.Parse(row["F_TransferTime"].ToString());
                }
                if (row["F_Transferunit"] != null)
                {
                    model.F_Transferunit = row["F_Transferunit"].ToString();
                }
                if (row["F_Remarks"] != null)
                {
                    model.F_Remarks = row["F_Remarks"].ToString();
                }
                if (row["F_OldWorkOrderId"] != null)
                {
                    model.F_OldWorkOrderId = row["F_OldWorkOrderId"].ToString();
                }
                if (row["F_NewResult"] != null)
                {
                    model.F_NewResult = row["F_NewResult"].ToString();
                }
                if (row["F_ResultRemarks"] != null)
                {
                    model.F_ResultRemarks = row["F_ResultRemarks"].ToString();
                }
                if (row["F_Files"] != null)
                {
                    model.F_Files = row["F_Files"].ToString();
                }
                if (row["F_Backreason"] != null)
                {
                    model.F_Backreason = row["F_Backreason"].ToString();
                }
                if (row["F_WorkRemarks"] != null)
                {
                    model.F_WorkRemarks = row["F_WorkRemarks"].ToString();
                }

                if (row["F_NewRemarks"] != null)
                {
                    model.F_NewRemarks = row["F_NewRemarks"].ToString();
                }
                if (row["F_Hcdatetime"] != null && row["F_Hcdatetime"].ToString() != "")
                {
                    model.F_Hcdatetime = DateTime.Parse(row["F_Hcdatetime"].ToString());
                }
                
                if (row["F_MainWorkOrderId"] != null)
                {
                    model.F_MainWorkOrderId = row["F_MainWorkOrderId"].ToString();
                }
                if (row["ReminderNum"] != null && row["ReminderNum"].ToString() != "")
                {
                    model.ReminderNum = int.Parse(row["ReminderNum"].ToString());
                }
                if (row["F_Caseid"] != null && row["F_Caseid"].ToString() != "")
                {
                    model.F_Caseid = int.Parse(row["F_Caseid"].ToString());
                }
                if (row["F_Mode"] != null && row["F_Mode"].ToString() != "")
                {
                    model.F_Mode = int.Parse(row["F_Mode"].ToString());
                }
                if (row["F_Did"] != null && row["F_Did"].ToString() != "")
                {
                    model.F_Did = int.Parse(row["F_Did"].ToString());
                }
                if (row["F_HCFiles"] != null)
                {
                    model.F_HCFiles = row["F_HCFiles"].ToString();
                }
                if (row["requirementFinishDay"] != null)
                {
                    model.requirementFinishDay = row["requirementFinishDay"].ToString();
                }
                
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * FROM T_Bus_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(" * FROM T_Bus_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_Bus_WorkOrder WITH(NOLOCK) ");
            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_Bus_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_Bus_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");
        }*/


        /// <summary>
        /// 根据坐席号获取新的工单号
        /// </summary>
        /// <param name="p_UserCode"></param>
        /// <returns></returns>
        public string GetNewWorkOrderID(string p_UserCode)
        {

            string newWorkOrderID = string.Empty;//新工单号

            #region 旧方法
            //string oldWorkOrderID = string.Empty;
            //string headPart = DateTime.Now.ToString("yyyyMMdd");//工单号前8位
            //string middlePart = string.Empty;//工单号中间部分
            //string endPart = "0001";//工单号最后部分，如果超过初始位数，自动从头开始           
            //StringBuilder strSql = new StringBuilder();
            //object p_Result = null;
            ////如果是网站
            //if (string.IsNullOrEmpty(p_UserCode.Trim()))
            //{
            //    middlePart = "00";
            //    strSql.Append("select top 1 F_WorkOrderId from T_Bus_WorkOrder");
            //    //strSql.Append(" where F_UserCode is null or F_UserCode=''  order by F_RegDate desc");
            //    strSql.AppendFormat(" where F_WorkOrderId like '{0}%' order by F_WorkOrderId desc", headPart + middlePart);
            //    p_Result = DbHelperSQL.GetSingle(strSql.ToString());
            //}
            //else
            //{
            //    middlePart = p_UserCode;
            //    strSql.Append("select top 1 F_WorkOrderId from T_Bus_WorkOrder");
            //    //strSql.Append(" where  F_UserCode=@F_UserCode  order by F_RegDate desc");
            //    strSql.AppendFormat(" where  F_WorkOrderId like '{0}%'  order by F_WorkOrderId desc", headPart + middlePart);
            //    SqlParameter[] parameters = {
            //        new SqlParameter("@F_UserCode", SqlDbType.NVarChar,20)};
            //    parameters[0].Value = p_UserCode;
            //    p_Result = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            //}


            //if (p_Result != null)
            //{

            //    oldWorkOrderID = p_Result.ToString();
            //    if (oldWorkOrderID.Length > 8)
            //    {
            //        string oldHead = oldWorkOrderID.Substring(0, 8);
            //        string oldEnd = oldWorkOrderID.Substring(oldWorkOrderID.Length - endPart.Length);
            //        int num = Convert.ToInt32(oldEnd) + 1;
            //        string newCode = string.Empty;
            //        for (int i = num.ToString().Length; i < endPart.Length; i++)
            //        {
            //            newCode += "0";
            //        }
            //        endPart = newCode + num;
            //    }

            //}
            //newWorkOrderID = headPart + middlePart + endPart; 
            #endregion

            // newWorkOrderID=DbHelperSQL.GetSingle("select dbo.GetNewWorkOrderId('"+ p_UserCode + "')").ToString();
            
       newWorkOrderID = DbHelperSQL.GetSingle("exec [GetNewWorkOrderIdByYear]").ToString();

            return newWorkOrderID;
        }
        #endregion  Method


        public string GetNewWorkOrderIDPF(string p_UserCode)
        {

            string newWorkOrderID = string.Empty;//新工单号

          

            newWorkOrderID = DbHelperSQL.GetSingle("exec [GetNewWorkOrderIdByYearPF]").ToString();

            return newWorkOrderID;
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateWorkOrder(int F_Id, Dictionary<string, object> keyValues)
        {
            Dictionary<string, string> paras = new Dictionary<string, string>();
            string sql = "";
            foreach (var v in keyValues)
            {
                sql += "," + v.Key + " = @" + v.Key;
                paras.Add("@" + v.Key, v.Value?.ToString() ?? null);
            }
            sql = sql.TrimStart(',');
            int rows = DbHelperSQL.ExecuteSql(" update T_Bus_WorkOrder set " + sql + " where F_Id ='" + F_Id + "'", paras);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

