using CallCenterApi.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 CallCenterApi.DAL
{
    /// <summary>
	/// 数据访问类:T_Wo_WorkOrderBase
	/// </summary>
	public partial class T_Wo_WorkOrderBase
    {
        public T_Wo_WorkOrderBase()
        { }
        #region  Method



        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CallCenterApi.Model.T_Wo_WorkOrderBase model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_Wo_WorkOrderBase(");
            strSql.Append("F_WORKORDERTYPEID,F_WORKORDERSTATEID,F_CODE,F_WORKORDERNAME,F_NUMBER,F_CUSTOMERNAME,F_CUSTOMERTELEPHONE,F_LINKMAN,F_LINKMANTELEPHONE,F_ADSLACCOUNT,F_BANDWIDTH,F_STANDARDADDRESS,F_INSTALLADDRESS,F_KSHADDRESSCODE,F_PROVINCE,F_CITY,F_AREA,F_ROAD,F_HOUSING,F_WORKORDERFROM,F_WORKORDERLEVELID,F_FILEFLAG,F_CONTENT,F_CREATEBY,F_CREATEDATE,F_DEPTCODE,F_EMPCODE,F_DEPTID,F_USERID,F_USERNAME,F_RETURNVISITFLAG,F_RETURNVISITSTATE,F_RETURNVISITRESULT,F_RETURNVISITCONTENT,F_DELETEFLAG,F_ALLUSETIMES,F_STARTTIME,F_ENDTIME,F_REMAINDERTIME,F_REMAINDERENDTIME,F_SUBSCRIBETIME1,F_SUBSCRIBETIME2,F_ACCEPTTIMELIMIT,F_ASKFINISHTIME,F_OVERTIMES,F_FORMID,F_HASTENCOUNTS,F_RANGEID,F_RANGEX,F_RANGEY,F_INSTANCEID,F_CUSTOMERID,F_REPAIRMANID,F_REPAIRMANNAME,F_REPAIRMANPHONE,F_REPAIRREQUEST,F_REPAIRCLOSEMANID,F_REPAIRCLOSEMANNAME,F_REPAIRCLOSEREASONS,F_REPAIRCLOSEREPTID,F_REPAIRCLOSEREPT,F_REPAIRLEVEL,F_REPAIRLEVELNAME,F_SENTORDERTIME,F_USERPHONE,F_RETURNVISITTIME,F_REQUESTSERVICETIME,F_SERVICETYPE,F_DECLARATIONTIME,F_SERVICENATURE,F_SERVICEWAY,F_RETURNVISITMAN,F_RETURNVISITID,F_RETURNVISITOPINION,F_RETURNVISITPROBLEM)");
            strSql.Append(" values (");
            strSql.Append("@F_WORKORDERTYPEID,@F_WORKORDERSTATEID,@F_CODE,@F_WORKORDERNAME,@F_NUMBER,@F_CUSTOMERNAME,@F_CUSTOMERTELEPHONE,@F_LINKMAN,@F_LINKMANTELEPHONE,@F_ADSLACCOUNT,@F_BANDWIDTH,@F_STANDARDADDRESS,@F_INSTALLADDRESS,@F_KSHADDRESSCODE,@F_PROVINCE,@F_CITY,@F_AREA,@F_ROAD,@F_HOUSING,@F_WORKORDERFROM,@F_WORKORDERLEVELID,@F_FILEFLAG,@F_CONTENT,@F_CREATEBY,@F_CREATEDATE,@F_DEPTCODE,@F_EMPCODE,@F_DEPTID,@F_USERID,@F_USERNAME,@F_RETURNVISITFLAG,@F_RETURNVISITSTATE,@F_RETURNVISITRESULT,@F_RETURNVISITCONTENT,@F_DELETEFLAG,@F_ALLUSETIMES,@F_STARTTIME,@F_ENDTIME,@F_REMAINDERTIME,@F_REMAINDERENDTIME,@F_SUBSCRIBETIME1,@F_SUBSCRIBETIME2,@F_ACCEPTTIMELIMIT,@F_ASKFINISHTIME,@F_OVERTIMES,@F_FORMID,@F_HASTENCOUNTS,@F_RANGEID,@F_RANGEX,@F_RANGEY,@F_INSTANCEID,@F_CUSTOMERID,@F_REPAIRMANID,@F_REPAIRMANNAME,@F_REPAIRMANPHONE,@F_REPAIRREQUEST,@F_REPAIRCLOSEMANID,@F_REPAIRCLOSEMANNAME,@F_REPAIRCLOSEREASONS,@F_REPAIRCLOSEREPTID,@F_REPAIRCLOSEREPT,@F_REPAIRLEVEL,@F_REPAIRLEVELNAME,@F_SENTORDERTIME,@F_USERPHONE,@F_RETURNVISITTIME,@F_REQUESTSERVICETIME,@F_SERVICETYPE,@F_DECLARATIONTIME,@F_SERVICENATURE,@F_SERVICEWAY,@F_RETURNVISITMAN,@F_RETURNVISITID,@F_RETURNVISITOPINION,@F_RETURNVISITPROBLEM)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WORKORDERTYPEID", SqlDbType.Int,4),
                    new SqlParameter("@F_WORKORDERSTATEID", SqlDbType.Int,4),
                    new SqlParameter("@F_CODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_WORKORDERNAME", SqlDbType.VarChar,100),
                    new SqlParameter("@F_NUMBER", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CUSTOMERNAME", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CUSTOMERTELEPHONE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_LINKMAN", SqlDbType.VarChar,50),
                    new SqlParameter("@F_LINKMANTELEPHONE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ADSLACCOUNT", SqlDbType.VarChar,50),
                    new SqlParameter("@F_BANDWIDTH", SqlDbType.VarChar,50),
                    new SqlParameter("@F_STANDARDADDRESS", SqlDbType.VarChar,200),
                    new SqlParameter("@F_INSTALLADDRESS", SqlDbType.VarChar,200),
                    new SqlParameter("@F_KSHADDRESSCODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_PROVINCE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CITY", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AREA", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ROAD", SqlDbType.VarChar,50),
                    new SqlParameter("@F_HOUSING", SqlDbType.VarChar,50),
                    new SqlParameter("@F_WORKORDERFROM", SqlDbType.VarChar,500),
                    new SqlParameter("@F_WORKORDERLEVELID", SqlDbType.Int,4),
                    new SqlParameter("@F_FILEFLAG", SqlDbType.Int,4),
                    new SqlParameter("@F_CONTENT", SqlDbType.Text),
                    new SqlParameter("@F_CREATEBY", SqlDbType.Int,4),
                    new SqlParameter("@F_CREATEDATE", SqlDbType.DateTime),
                    new SqlParameter("@F_DEPTCODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_EMPCODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DEPTID", SqlDbType.Int,4),
                    new SqlParameter("@F_USERID", SqlDbType.Int,4),
                    new SqlParameter("@F_USERNAME", SqlDbType.VarChar,20),
                    new SqlParameter("@F_RETURNVISITFLAG", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITSTATE", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITRESULT", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITCONTENT", SqlDbType.VarChar,800),
                    new SqlParameter("@F_DELETEFLAG", SqlDbType.Int,4),
                    new SqlParameter("@F_ALLUSETIMES", SqlDbType.Int,4),
                    new SqlParameter("@F_STARTTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_ENDTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_REMAINDERTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_REMAINDERENDTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_SUBSCRIBETIME1", SqlDbType.DateTime),
                    new SqlParameter("@F_SUBSCRIBETIME2", SqlDbType.DateTime),
                    new SqlParameter("@F_ACCEPTTIMELIMIT", SqlDbType.DateTime),
                    new SqlParameter("@F_ASKFINISHTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_OVERTIMES", SqlDbType.Int,4),
                    new SqlParameter("@F_FORMID", SqlDbType.Int,4),
                    new SqlParameter("@F_HASTENCOUNTS", SqlDbType.Int,4),
                    new SqlParameter("@F_RANGEID", SqlDbType.Decimal,9),
                    new SqlParameter("@F_RANGEX", SqlDbType.Decimal,9),
                    new SqlParameter("@F_RANGEY", SqlDbType.Decimal,9),
                    new SqlParameter("@F_INSTANCEID", SqlDbType.Int,4),
                    new SqlParameter("@F_CUSTOMERID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRMANID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRMANNAME", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_REPAIRMANPHONE", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_REPAIRREQUEST", SqlDbType.NVarChar,2000),
                    new SqlParameter("@F_REPAIRCLOSEMANID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRCLOSEMANNAME", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_REPAIRCLOSEREASONS", SqlDbType.NVarChar,4000),
                    new SqlParameter("@F_REPAIRCLOSEREPTID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRCLOSEREPT", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_REPAIRLEVEL", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRLEVELNAME", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_SENTORDERTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_USERPHONE", SqlDbType.VarChar,20),
                    new SqlParameter("@F_RETURNVISITTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_REQUESTSERVICETIME", SqlDbType.DateTime),
                    new SqlParameter("@F_SERVICETYPE", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DECLARATIONTIME", SqlDbType.Decimal,9),
                    new SqlParameter("@F_SERVICENATURE", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_SERVICEWAY", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_RETURNVISITMAN", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_RETURNVISITID", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITOPINION", SqlDbType.NChar,10),
                    new SqlParameter("@F_RETURNVISITPROBLEM", SqlDbType.NVarChar,2000)};
            parameters[0].Value = model.F_WORKORDERTYPEID;
            parameters[1].Value = model.F_WORKORDERSTATEID;
            parameters[2].Value = model.F_CODE;
            parameters[3].Value = model.F_WORKORDERNAME;
            parameters[4].Value = model.F_NUMBER;
            parameters[5].Value = model.F_CUSTOMERNAME;
            parameters[6].Value = model.F_CUSTOMERTELEPHONE;
            parameters[7].Value = model.F_LINKMAN;
            parameters[8].Value = model.F_LINKMANTELEPHONE;
            parameters[9].Value = model.F_ADSLACCOUNT;
            parameters[10].Value = model.F_BANDWIDTH;
            parameters[11].Value = model.F_STANDARDADDRESS;
            parameters[12].Value = model.F_INSTALLADDRESS;
            parameters[13].Value = model.F_KSHADDRESSCODE;
            parameters[14].Value = model.F_PROVINCE;
            parameters[15].Value = model.F_CITY;
            parameters[16].Value = model.F_AREA;
            parameters[17].Value = model.F_ROAD;
            parameters[18].Value = model.F_HOUSING;
            parameters[19].Value = model.F_WORKORDERFROM;
            parameters[20].Value = model.F_WORKORDERLEVELID;
            parameters[21].Value = model.F_FILEFLAG;
            parameters[22].Value = model.F_CONTENT;
            parameters[23].Value = model.F_CREATEBY;
            parameters[24].Value = model.F_CREATEDATE;
            parameters[25].Value = model.F_DEPTCODE;
            parameters[26].Value = model.F_EMPCODE;
            parameters[27].Value = model.F_DEPTID;
            parameters[28].Value = model.F_USERID;
            parameters[29].Value = model.F_USERNAME;
            parameters[30].Value = model.F_RETURNVISITFLAG;
            parameters[31].Value = model.F_RETURNVISITSTATE;
            parameters[32].Value = model.F_RETURNVISITRESULT;
            parameters[33].Value = model.F_RETURNVISITCONTENT;
            parameters[34].Value = model.F_DELETEFLAG;
            parameters[35].Value = model.F_ALLUSETIMES;
            parameters[36].Value = model.F_STARTTIME;
            parameters[37].Value = model.F_ENDTIME;
            parameters[38].Value = model.F_REMAINDERTIME;
            parameters[39].Value = model.F_REMAINDERENDTIME;
            parameters[40].Value = model.F_SUBSCRIBETIME1;
            parameters[41].Value = model.F_SUBSCRIBETIME2;
            parameters[42].Value = model.F_ACCEPTTIMELIMIT;
            parameters[43].Value = model.F_ASKFINISHTIME;
            parameters[44].Value = model.F_OVERTIMES;
            parameters[45].Value = model.F_FORMID;
            parameters[46].Value = model.F_HASTENCOUNTS;
            parameters[47].Value = model.F_RANGEID;
            parameters[48].Value = model.F_RANGEX;
            parameters[49].Value = model.F_RANGEY;
            parameters[50].Value = model.F_INSTANCEID;
            parameters[51].Value = model.F_CUSTOMERID;
            parameters[52].Value = model.F_REPAIRMANID;
            parameters[53].Value = model.F_REPAIRMANNAME;
            parameters[54].Value = model.F_REPAIRMANPHONE;
            parameters[55].Value = model.F_REPAIRREQUEST;
            parameters[56].Value = model.F_REPAIRCLOSEMANID;
            parameters[57].Value = model.F_REPAIRCLOSEMANNAME;
            parameters[58].Value = model.F_REPAIRCLOSEREASONS;
            parameters[59].Value = model.F_REPAIRCLOSEREPTID;
            parameters[60].Value = model.F_REPAIRCLOSEREPT;
            parameters[61].Value = model.F_REPAIRLEVEL;
            parameters[62].Value = model.F_REPAIRLEVELNAME;
            parameters[63].Value = model.F_SENTORDERTIME;
            parameters[64].Value = model.F_USERPHONE;
            parameters[65].Value = model.F_RETURNVISITTIME;
            parameters[66].Value = model.F_REQUESTSERVICETIME;
            parameters[67].Value = model.F_SERVICETYPE;
            parameters[68].Value = model.F_DECLARATIONTIME;
            parameters[69].Value = model.F_SERVICENATURE;
            parameters[70].Value = model.F_SERVICEWAY;
            parameters[71].Value = model.F_RETURNVISITMAN;
            parameters[72].Value = model.F_RETURNVISITID;
            parameters[73].Value = model.F_RETURNVISITOPINION;
            parameters[74].Value = model.F_RETURNVISITPROBLEM;

            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_Wo_WorkOrderBase model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Wo_WorkOrderBase set ");
            strSql.Append("F_WORKORDERTYPEID=@F_WORKORDERTYPEID,");
            strSql.Append("F_WORKORDERSTATEID=@F_WORKORDERSTATEID,");
            strSql.Append("F_CODE=@F_CODE,");
            strSql.Append("F_WORKORDERNAME=@F_WORKORDERNAME,");
            strSql.Append("F_NUMBER=@F_NUMBER,");
            strSql.Append("F_CUSTOMERNAME=@F_CUSTOMERNAME,");
            strSql.Append("F_CUSTOMERTELEPHONE=@F_CUSTOMERTELEPHONE,");
            strSql.Append("F_LINKMAN=@F_LINKMAN,");
            strSql.Append("F_LINKMANTELEPHONE=@F_LINKMANTELEPHONE,");
            strSql.Append("F_ADSLACCOUNT=@F_ADSLACCOUNT,");
            strSql.Append("F_BANDWIDTH=@F_BANDWIDTH,");
            strSql.Append("F_STANDARDADDRESS=@F_STANDARDADDRESS,");
            strSql.Append("F_INSTALLADDRESS=@F_INSTALLADDRESS,");
            strSql.Append("F_KSHADDRESSCODE=@F_KSHADDRESSCODE,");
            strSql.Append("F_PROVINCE=@F_PROVINCE,");
            strSql.Append("F_CITY=@F_CITY,");
            strSql.Append("F_AREA=@F_AREA,");
            strSql.Append("F_ROAD=@F_ROAD,");
            strSql.Append("F_HOUSING=@F_HOUSING,");
            strSql.Append("F_WORKORDERFROM=@F_WORKORDERFROM,");
            strSql.Append("F_WORKORDERLEVELID=@F_WORKORDERLEVELID,");
            strSql.Append("F_FILEFLAG=@F_FILEFLAG,");
            strSql.Append("F_CONTENT=@F_CONTENT,");
            strSql.Append("F_CREATEBY=@F_CREATEBY,");
            strSql.Append("F_CREATEDATE=@F_CREATEDATE,");
            strSql.Append("F_DEPTCODE=@F_DEPTCODE,");
            strSql.Append("F_EMPCODE=@F_EMPCODE,");
            strSql.Append("F_DEPTID=@F_DEPTID,");
            strSql.Append("F_USERID=@F_USERID,");
            strSql.Append("F_USERNAME=@F_USERNAME,");
            strSql.Append("F_RETURNVISITFLAG=@F_RETURNVISITFLAG,");
            strSql.Append("F_RETURNVISITSTATE=@F_RETURNVISITSTATE,");
            strSql.Append("F_RETURNVISITRESULT=@F_RETURNVISITRESULT,");
            strSql.Append("F_RETURNVISITCONTENT=@F_RETURNVISITCONTENT,");
            strSql.Append("F_DELETEFLAG=@F_DELETEFLAG,");
            strSql.Append("F_ALLUSETIMES=@F_ALLUSETIMES,");
            strSql.Append("F_STARTTIME=@F_STARTTIME,");
            strSql.Append("F_ENDTIME=@F_ENDTIME,");
            strSql.Append("F_REMAINDERTIME=@F_REMAINDERTIME,");
            strSql.Append("F_REMAINDERENDTIME=@F_REMAINDERENDTIME,");
            strSql.Append("F_SUBSCRIBETIME1=@F_SUBSCRIBETIME1,");
            strSql.Append("F_SUBSCRIBETIME2=@F_SUBSCRIBETIME2,");
            strSql.Append("F_ACCEPTTIMELIMIT=@F_ACCEPTTIMELIMIT,");
            strSql.Append("F_ASKFINISHTIME=@F_ASKFINISHTIME,");
            strSql.Append("F_OVERTIMES=@F_OVERTIMES,");
            strSql.Append("F_FORMID=@F_FORMID,");
            strSql.Append("F_HASTENCOUNTS=@F_HASTENCOUNTS,");
            strSql.Append("F_RANGEID=@F_RANGEID,");
            strSql.Append("F_RANGEX=@F_RANGEX,");
            strSql.Append("F_RANGEY=@F_RANGEY,");
            strSql.Append("F_INSTANCEID=@F_INSTANCEID,");
            strSql.Append("F_CUSTOMERID=@F_CUSTOMERID,");
            strSql.Append("F_REPAIRMANID=@F_REPAIRMANID,");
            strSql.Append("F_REPAIRMANNAME=@F_REPAIRMANNAME,");
            strSql.Append("F_REPAIRMANPHONE=@F_REPAIRMANPHONE,");
            strSql.Append("F_REPAIRREQUEST=@F_REPAIRREQUEST,");
            strSql.Append("F_REPAIRCLOSEMANID=@F_REPAIRCLOSEMANID,");
            strSql.Append("F_REPAIRCLOSEMANNAME=@F_REPAIRCLOSEMANNAME,");
            strSql.Append("F_REPAIRCLOSEREASONS=@F_REPAIRCLOSEREASONS,");
            strSql.Append("F_REPAIRCLOSEREPTID=@F_REPAIRCLOSEREPTID,");
            strSql.Append("F_REPAIRCLOSEREPT=@F_REPAIRCLOSEREPT,");
            strSql.Append("F_REPAIRLEVEL=@F_REPAIRLEVEL,");
            strSql.Append("F_REPAIRLEVELNAME=@F_REPAIRLEVELNAME,");
            strSql.Append("F_SENTORDERTIME=@F_SENTORDERTIME,");
            strSql.Append("F_USERPHONE=@F_USERPHONE,");
            strSql.Append("F_RETURNVISITTIME=@F_RETURNVISITTIME,");
            strSql.Append("F_REQUESTSERVICETIME=@F_REQUESTSERVICETIME,");
            strSql.Append("F_SERVICETYPE=@F_SERVICETYPE,");
            strSql.Append("F_DECLARATIONTIME=@F_DECLARATIONTIME,");
            strSql.Append("F_SERVICENATURE=@F_SERVICENATURE,");
            strSql.Append("F_SERVICEWAY=@F_SERVICEWAY,");
            strSql.Append("F_RETURNVISITMAN=@F_RETURNVISITMAN,");
            strSql.Append("F_RETURNVISITID=@F_RETURNVISITID,");
            strSql.Append("F_RETURNVISITOPINION=@F_RETURNVISITOPINION,");
            strSql.Append("F_RETURNVISITPROBLEM=@F_RETURNVISITPROBLEM");
            strSql.Append(" where F_WORKORDERID=@F_WORKORDERID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WORKORDERTYPEID", SqlDbType.Int,4),
                    new SqlParameter("@F_WORKORDERSTATEID", SqlDbType.Int,4),
                    new SqlParameter("@F_CODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_WORKORDERNAME", SqlDbType.VarChar,100),
                    new SqlParameter("@F_NUMBER", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CUSTOMERNAME", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CUSTOMERTELEPHONE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_LINKMAN", SqlDbType.VarChar,50),
                    new SqlParameter("@F_LINKMANTELEPHONE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ADSLACCOUNT", SqlDbType.VarChar,50),
                    new SqlParameter("@F_BANDWIDTH", SqlDbType.VarChar,50),
                    new SqlParameter("@F_STANDARDADDRESS", SqlDbType.VarChar,200),
                    new SqlParameter("@F_INSTALLADDRESS", SqlDbType.VarChar,200),
                    new SqlParameter("@F_KSHADDRESSCODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_PROVINCE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_CITY", SqlDbType.VarChar,50),
                    new SqlParameter("@F_AREA", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ROAD", SqlDbType.VarChar,50),
                    new SqlParameter("@F_HOUSING", SqlDbType.VarChar,50),
                    new SqlParameter("@F_WORKORDERFROM", SqlDbType.VarChar,500),
                    new SqlParameter("@F_WORKORDERLEVELID", SqlDbType.Int,4),
                    new SqlParameter("@F_FILEFLAG", SqlDbType.Int,4),
                    new SqlParameter("@F_CONTENT", SqlDbType.Text),
                    new SqlParameter("@F_CREATEBY", SqlDbType.Int,4),
                    new SqlParameter("@F_CREATEDATE", SqlDbType.DateTime),
                    new SqlParameter("@F_DEPTCODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_EMPCODE", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DEPTID", SqlDbType.Int,4),
                    new SqlParameter("@F_USERID", SqlDbType.Int,4),
                    new SqlParameter("@F_USERNAME", SqlDbType.VarChar,20),
                    new SqlParameter("@F_RETURNVISITFLAG", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITSTATE", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITRESULT", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITCONTENT", SqlDbType.VarChar,800),
                    new SqlParameter("@F_DELETEFLAG", SqlDbType.Int,4),
                    new SqlParameter("@F_ALLUSETIMES", SqlDbType.Int,4),
                    new SqlParameter("@F_STARTTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_ENDTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_REMAINDERTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_REMAINDERENDTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_SUBSCRIBETIME1", SqlDbType.DateTime),
                    new SqlParameter("@F_SUBSCRIBETIME2", SqlDbType.DateTime),
                    new SqlParameter("@F_ACCEPTTIMELIMIT", SqlDbType.DateTime),
                    new SqlParameter("@F_ASKFINISHTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_OVERTIMES", SqlDbType.Int,4),
                    new SqlParameter("@F_FORMID", SqlDbType.Int,4),
                    new SqlParameter("@F_HASTENCOUNTS", SqlDbType.Int,4),
                    new SqlParameter("@F_RANGEID", SqlDbType.Decimal,9),
                    new SqlParameter("@F_RANGEX", SqlDbType.Decimal,9),
                    new SqlParameter("@F_RANGEY", SqlDbType.Decimal,9),
                    new SqlParameter("@F_INSTANCEID", SqlDbType.Int,4),
                    new SqlParameter("@F_CUSTOMERID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRMANID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRMANNAME", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_REPAIRMANPHONE", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_REPAIRREQUEST", SqlDbType.NVarChar,2000),
                    new SqlParameter("@F_REPAIRCLOSEMANID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRCLOSEMANNAME", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_REPAIRCLOSEREASONS", SqlDbType.NVarChar,4000),
                    new SqlParameter("@F_REPAIRCLOSEREPTID", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRCLOSEREPT", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_REPAIRLEVEL", SqlDbType.Int,4),
                    new SqlParameter("@F_REPAIRLEVELNAME", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_SENTORDERTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_USERPHONE", SqlDbType.VarChar,20),
                    new SqlParameter("@F_RETURNVISITTIME", SqlDbType.DateTime),
                    new SqlParameter("@F_REQUESTSERVICETIME", SqlDbType.DateTime),
                    new SqlParameter("@F_SERVICETYPE", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DECLARATIONTIME", SqlDbType.Decimal,9),
                    new SqlParameter("@F_SERVICENATURE", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_SERVICEWAY", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_RETURNVISITMAN", SqlDbType.NVarChar,20),
                    new SqlParameter("@F_RETURNVISITID", SqlDbType.Int,4),
                    new SqlParameter("@F_RETURNVISITOPINION", SqlDbType.NChar,10),
                    new SqlParameter("@F_RETURNVISITPROBLEM", SqlDbType.NVarChar,2000),
                    new SqlParameter("@F_WORKORDERID", SqlDbType.Int,4)};
            parameters[0].Value = model.F_WORKORDERTYPEID;
            parameters[1].Value = model.F_WORKORDERSTATEID;
            parameters[2].Value = model.F_CODE;
            parameters[3].Value = model.F_WORKORDERNAME;
            parameters[4].Value = model.F_NUMBER;
            parameters[5].Value = model.F_CUSTOMERNAME;
            parameters[6].Value = model.F_CUSTOMERTELEPHONE;
            parameters[7].Value = model.F_LINKMAN;
            parameters[8].Value = model.F_LINKMANTELEPHONE;
            parameters[9].Value = model.F_ADSLACCOUNT;
            parameters[10].Value = model.F_BANDWIDTH;
            parameters[11].Value = model.F_STANDARDADDRESS;
            parameters[12].Value = model.F_INSTALLADDRESS;
            parameters[13].Value = model.F_KSHADDRESSCODE;
            parameters[14].Value = model.F_PROVINCE;
            parameters[15].Value = model.F_CITY;
            parameters[16].Value = model.F_AREA;
            parameters[17].Value = model.F_ROAD;
            parameters[18].Value = model.F_HOUSING;
            parameters[19].Value = model.F_WORKORDERFROM;
            parameters[20].Value = model.F_WORKORDERLEVELID;
            parameters[21].Value = model.F_FILEFLAG;
            parameters[22].Value = model.F_CONTENT;
            parameters[23].Value = model.F_CREATEBY;
            parameters[24].Value = model.F_CREATEDATE;
            parameters[25].Value = model.F_DEPTCODE;
            parameters[26].Value = model.F_EMPCODE;
            parameters[27].Value = model.F_DEPTID;
            parameters[28].Value = model.F_USERID;
            parameters[29].Value = model.F_USERNAME;
            parameters[30].Value = model.F_RETURNVISITFLAG;
            parameters[31].Value = model.F_RETURNVISITSTATE;
            parameters[32].Value = model.F_RETURNVISITRESULT;
            parameters[33].Value = model.F_RETURNVISITCONTENT;
            parameters[34].Value = model.F_DELETEFLAG;
            parameters[35].Value = model.F_ALLUSETIMES;
            parameters[36].Value = model.F_STARTTIME;
            parameters[37].Value = model.F_ENDTIME;
            parameters[38].Value = model.F_REMAINDERTIME;
            parameters[39].Value = model.F_REMAINDERENDTIME;
            parameters[40].Value = model.F_SUBSCRIBETIME1;
            parameters[41].Value = model.F_SUBSCRIBETIME2;
            parameters[42].Value = model.F_ACCEPTTIMELIMIT;
            parameters[43].Value = model.F_ASKFINISHTIME;
            parameters[44].Value = model.F_OVERTIMES;
            parameters[45].Value = model.F_FORMID;
            parameters[46].Value = model.F_HASTENCOUNTS;
            parameters[47].Value = model.F_RANGEID;
            parameters[48].Value = model.F_RANGEX;
            parameters[49].Value = model.F_RANGEY;
            parameters[50].Value = model.F_INSTANCEID;
            parameters[51].Value = model.F_CUSTOMERID;
            parameters[52].Value = model.F_REPAIRMANID;
            parameters[53].Value = model.F_REPAIRMANNAME;
            parameters[54].Value = model.F_REPAIRMANPHONE;
            parameters[55].Value = model.F_REPAIRREQUEST;
            parameters[56].Value = model.F_REPAIRCLOSEMANID;
            parameters[57].Value = model.F_REPAIRCLOSEMANNAME;
            parameters[58].Value = model.F_REPAIRCLOSEREASONS;
            parameters[59].Value = model.F_REPAIRCLOSEREPTID;
            parameters[60].Value = model.F_REPAIRCLOSEREPT;
            parameters[61].Value = model.F_REPAIRLEVEL;
            parameters[62].Value = model.F_REPAIRLEVELNAME;
            parameters[63].Value = model.F_SENTORDERTIME;
            parameters[64].Value = model.F_USERPHONE;
            parameters[65].Value = model.F_RETURNVISITTIME;
            parameters[66].Value = model.F_REQUESTSERVICETIME;
            parameters[67].Value = model.F_SERVICETYPE;
            parameters[68].Value = model.F_DECLARATIONTIME;
            parameters[69].Value = model.F_SERVICENATURE;
            parameters[70].Value = model.F_SERVICEWAY;
            parameters[71].Value = model.F_RETURNVISITMAN;
            parameters[72].Value = model.F_RETURNVISITID;
            parameters[73].Value = model.F_RETURNVISITOPINION;
            parameters[74].Value = model.F_RETURNVISITPROBLEM;
            parameters[75].Value = model.F_WORKORDERID;

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

        public bool Update1(CallCenterApi.Model.T_Wo_WorkOrderBase model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Wo_WorkOrderBase set ");
            strSql.Append("F_CONTENT=@F_CONTENT");
            strSql.Append(" where F_WORKORDERID=@F_WORKORDERID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_CONTENT", SqlDbType.Text),
                    new SqlParameter("@F_WORKORDERID", SqlDbType.Int,4)};
            parameters[0].Value = model.F_CONTENT;
            parameters[1].Value = model.F_WORKORDERID;

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

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int F_WORKORDERID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_Wo_WorkOrderBase ");
            strSql.Append(" where F_WORKORDERID=@F_WORKORDERID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WORKORDERID", SqlDbType.Int,4)
};
            parameters[0].Value = F_WORKORDERID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string F_WORKORDERIDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_Wo_WorkOrderBase ");
            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_Wo_WorkOrderBase GetModel(int F_WORKORDERID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 F_WORKORDERID,F_WORKORDERTYPEID,F_WORKORDERSTATEID,F_CODE,F_WORKORDERNAME,F_NUMBER,F_CUSTOMERNAME,F_CUSTOMERTELEPHONE,F_LINKMAN,F_LINKMANTELEPHONE,F_ADSLACCOUNT,F_BANDWIDTH,F_STANDARDADDRESS,F_INSTALLADDRESS,F_KSHADDRESSCODE,F_PROVINCE,F_CITY,F_AREA,F_ROAD,F_HOUSING,F_WORKORDERFROM,F_WORKORDERLEVELID,F_FILEFLAG,F_CONTENT,F_CREATEBY,F_CREATEDATE,F_DEPTCODE,F_EMPCODE,F_DEPTID,F_USERID,F_USERNAME,F_RETURNVISITFLAG,F_RETURNVISITSTATE,F_RETURNVISITRESULT,F_RETURNVISITCONTENT,F_DELETEFLAG,F_ALLUSETIMES,F_STARTTIME,F_ENDTIME,F_REMAINDERTIME,F_REMAINDERENDTIME,F_SUBSCRIBETIME1,F_SUBSCRIBETIME2,F_ACCEPTTIMELIMIT,F_ASKFINISHTIME,F_OVERTIMES,F_FORMID,F_HASTENCOUNTS,F_RANGEID,F_RANGEX,F_RANGEY,F_INSTANCEID,F_CUSTOMERID,F_REPAIRMANID,F_REPAIRMANNAME,F_REPAIRMANPHONE,F_REPAIRREQUEST,F_REPAIRCLOSEMANID,F_REPAIRCLOSEMANNAME,F_REPAIRCLOSEREASONS,F_REPAIRCLOSEREPTID,F_REPAIRCLOSEREPT,F_REPAIRLEVEL,F_REPAIRLEVELNAME,F_SENTORDERTIME,F_USERPHONE,F_RETURNVISITTIME,F_REQUESTSERVICETIME,F_SERVICETYPE,F_DECLARATIONTIME,F_SERVICENATURE,F_SERVICEWAY,F_RETURNVISITMAN,F_RETURNVISITID,F_RETURNVISITOPINION,F_RETURNVISITPROBLEM from T_Wo_WorkOrderBase ");
            strSql.Append(" where F_WORKORDERID=@F_WORKORDERID");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_WORKORDERID", SqlDbType.Int,4)
};
            parameters[0].Value = F_WORKORDERID;

            CallCenterApi.Model.T_Wo_WorkOrderBase model = new CallCenterApi.Model.T_Wo_WorkOrderBase();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["F_WORKORDERID"] != null && ds.Tables[0].Rows[0]["F_WORKORDERID"].ToString() != "")
                {
                    model.F_WORKORDERID = int.Parse(ds.Tables[0].Rows[0]["F_WORKORDERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_WORKORDERTYPEID"] != null && ds.Tables[0].Rows[0]["F_WORKORDERTYPEID"].ToString() != "")
                {
                    model.F_WORKORDERTYPEID = int.Parse(ds.Tables[0].Rows[0]["F_WORKORDERTYPEID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_WORKORDERSTATEID"] != null && ds.Tables[0].Rows[0]["F_WORKORDERSTATEID"].ToString() != "")
                {
                    model.F_WORKORDERSTATEID = int.Parse(ds.Tables[0].Rows[0]["F_WORKORDERSTATEID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_CODE"] != null && ds.Tables[0].Rows[0]["F_CODE"].ToString() != "")
                {
                    model.F_CODE = ds.Tables[0].Rows[0]["F_CODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_WORKORDERNAME"] != null && ds.Tables[0].Rows[0]["F_WORKORDERNAME"].ToString() != "")
                {
                    model.F_WORKORDERNAME = ds.Tables[0].Rows[0]["F_WORKORDERNAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_NUMBER"] != null && ds.Tables[0].Rows[0]["F_NUMBER"].ToString() != "")
                {
                    model.F_NUMBER = ds.Tables[0].Rows[0]["F_NUMBER"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_CUSTOMERNAME"] != null && ds.Tables[0].Rows[0]["F_CUSTOMERNAME"].ToString() != "")
                {
                    model.F_CUSTOMERNAME = ds.Tables[0].Rows[0]["F_CUSTOMERNAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_CUSTOMERTELEPHONE"] != null && ds.Tables[0].Rows[0]["F_CUSTOMERTELEPHONE"].ToString() != "")
                {
                    model.F_CUSTOMERTELEPHONE = ds.Tables[0].Rows[0]["F_CUSTOMERTELEPHONE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_LINKMAN"] != null && ds.Tables[0].Rows[0]["F_LINKMAN"].ToString() != "")
                {
                    model.F_LINKMAN = ds.Tables[0].Rows[0]["F_LINKMAN"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_LINKMANTELEPHONE"] != null && ds.Tables[0].Rows[0]["F_LINKMANTELEPHONE"].ToString() != "")
                {
                    model.F_LINKMANTELEPHONE = ds.Tables[0].Rows[0]["F_LINKMANTELEPHONE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_ADSLACCOUNT"] != null && ds.Tables[0].Rows[0]["F_ADSLACCOUNT"].ToString() != "")
                {
                    model.F_ADSLACCOUNT = ds.Tables[0].Rows[0]["F_ADSLACCOUNT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_BANDWIDTH"] != null && ds.Tables[0].Rows[0]["F_BANDWIDTH"].ToString() != "")
                {
                    model.F_BANDWIDTH = ds.Tables[0].Rows[0]["F_BANDWIDTH"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_STANDARDADDRESS"] != null && ds.Tables[0].Rows[0]["F_STANDARDADDRESS"].ToString() != "")
                {
                    model.F_STANDARDADDRESS = ds.Tables[0].Rows[0]["F_STANDARDADDRESS"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_INSTALLADDRESS"] != null && ds.Tables[0].Rows[0]["F_INSTALLADDRESS"].ToString() != "")
                {
                    model.F_INSTALLADDRESS = ds.Tables[0].Rows[0]["F_INSTALLADDRESS"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_KSHADDRESSCODE"] != null && ds.Tables[0].Rows[0]["F_KSHADDRESSCODE"].ToString() != "")
                {
                    model.F_KSHADDRESSCODE = ds.Tables[0].Rows[0]["F_KSHADDRESSCODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_PROVINCE"] != null && ds.Tables[0].Rows[0]["F_PROVINCE"].ToString() != "")
                {
                    model.F_PROVINCE = ds.Tables[0].Rows[0]["F_PROVINCE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_CITY"] != null && ds.Tables[0].Rows[0]["F_CITY"].ToString() != "")
                {
                    model.F_CITY = ds.Tables[0].Rows[0]["F_CITY"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_AREA"] != null && ds.Tables[0].Rows[0]["F_AREA"].ToString() != "")
                {
                    model.F_AREA = ds.Tables[0].Rows[0]["F_AREA"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_ROAD"] != null && ds.Tables[0].Rows[0]["F_ROAD"].ToString() != "")
                {
                    model.F_ROAD = ds.Tables[0].Rows[0]["F_ROAD"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_HOUSING"] != null && ds.Tables[0].Rows[0]["F_HOUSING"].ToString() != "")
                {
                    model.F_HOUSING = ds.Tables[0].Rows[0]["F_HOUSING"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_WORKORDERFROM"] != null && ds.Tables[0].Rows[0]["F_WORKORDERFROM"].ToString() != "")
                {
                    model.F_WORKORDERFROM = ds.Tables[0].Rows[0]["F_WORKORDERFROM"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_WORKORDERLEVELID"] != null && ds.Tables[0].Rows[0]["F_WORKORDERLEVELID"].ToString() != "")
                {
                    model.F_WORKORDERLEVELID = int.Parse(ds.Tables[0].Rows[0]["F_WORKORDERLEVELID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_FILEFLAG"] != null && ds.Tables[0].Rows[0]["F_FILEFLAG"].ToString() != "")
                {
                    model.F_FILEFLAG = int.Parse(ds.Tables[0].Rows[0]["F_FILEFLAG"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_CONTENT"] != null && ds.Tables[0].Rows[0]["F_CONTENT"].ToString() != "")
                {
                    model.F_CONTENT = ds.Tables[0].Rows[0]["F_CONTENT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_CREATEBY"] != null && ds.Tables[0].Rows[0]["F_CREATEBY"].ToString() != "")
                {
                    model.F_CREATEBY = int.Parse(ds.Tables[0].Rows[0]["F_CREATEBY"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_CREATEDATE"] != null && ds.Tables[0].Rows[0]["F_CREATEDATE"].ToString() != "")
                {
                    model.F_CREATEDATE = DateTime.Parse(ds.Tables[0].Rows[0]["F_CREATEDATE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_DEPTCODE"] != null && ds.Tables[0].Rows[0]["F_DEPTCODE"].ToString() != "")
                {
                    model.F_DEPTCODE = ds.Tables[0].Rows[0]["F_DEPTCODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_EMPCODE"] != null && ds.Tables[0].Rows[0]["F_EMPCODE"].ToString() != "")
                {
                    model.F_EMPCODE = ds.Tables[0].Rows[0]["F_EMPCODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_DEPTID"] != null && ds.Tables[0].Rows[0]["F_DEPTID"].ToString() != "")
                {
                    model.F_DEPTID = int.Parse(ds.Tables[0].Rows[0]["F_DEPTID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_USERID"] != null && ds.Tables[0].Rows[0]["F_USERID"].ToString() != "")
                {
                    model.F_USERID = int.Parse(ds.Tables[0].Rows[0]["F_USERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_USERNAME"] != null && ds.Tables[0].Rows[0]["F_USERNAME"].ToString() != "")
                {
                    model.F_USERNAME = ds.Tables[0].Rows[0]["F_USERNAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITFLAG"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITFLAG"].ToString() != "")
                {
                    model.F_RETURNVISITFLAG = int.Parse(ds.Tables[0].Rows[0]["F_RETURNVISITFLAG"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITSTATE"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITSTATE"].ToString() != "")
                {
                    model.F_RETURNVISITSTATE = int.Parse(ds.Tables[0].Rows[0]["F_RETURNVISITSTATE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITRESULT"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITRESULT"].ToString() != "")
                {
                    model.F_RETURNVISITRESULT = int.Parse(ds.Tables[0].Rows[0]["F_RETURNVISITRESULT"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITCONTENT"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITCONTENT"].ToString() != "")
                {
                    model.F_RETURNVISITCONTENT = ds.Tables[0].Rows[0]["F_RETURNVISITCONTENT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_DELETEFLAG"] != null && ds.Tables[0].Rows[0]["F_DELETEFLAG"].ToString() != "")
                {
                    model.F_DELETEFLAG = int.Parse(ds.Tables[0].Rows[0]["F_DELETEFLAG"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_ALLUSETIMES"] != null && ds.Tables[0].Rows[0]["F_ALLUSETIMES"].ToString() != "")
                {
                    model.F_ALLUSETIMES = int.Parse(ds.Tables[0].Rows[0]["F_ALLUSETIMES"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_STARTTIME"] != null && ds.Tables[0].Rows[0]["F_STARTTIME"].ToString() != "")
                {
                    model.F_STARTTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_STARTTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_ENDTIME"] != null && ds.Tables[0].Rows[0]["F_ENDTIME"].ToString() != "")
                {
                    model.F_ENDTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_ENDTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REMAINDERTIME"] != null && ds.Tables[0].Rows[0]["F_REMAINDERTIME"].ToString() != "")
                {
                    model.F_REMAINDERTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_REMAINDERTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REMAINDERENDTIME"] != null && ds.Tables[0].Rows[0]["F_REMAINDERENDTIME"].ToString() != "")
                {
                    model.F_REMAINDERENDTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_REMAINDERENDTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_SUBSCRIBETIME1"] != null && ds.Tables[0].Rows[0]["F_SUBSCRIBETIME1"].ToString() != "")
                {
                    model.F_SUBSCRIBETIME1 = DateTime.Parse(ds.Tables[0].Rows[0]["F_SUBSCRIBETIME1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_SUBSCRIBETIME2"] != null && ds.Tables[0].Rows[0]["F_SUBSCRIBETIME2"].ToString() != "")
                {
                    model.F_SUBSCRIBETIME2 = DateTime.Parse(ds.Tables[0].Rows[0]["F_SUBSCRIBETIME2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_ACCEPTTIMELIMIT"] != null && ds.Tables[0].Rows[0]["F_ACCEPTTIMELIMIT"].ToString() != "")
                {
                    model.F_ACCEPTTIMELIMIT = DateTime.Parse(ds.Tables[0].Rows[0]["F_ACCEPTTIMELIMIT"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_ASKFINISHTIME"] != null && ds.Tables[0].Rows[0]["F_ASKFINISHTIME"].ToString() != "")
                {
                    model.F_ASKFINISHTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_ASKFINISHTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_OVERTIMES"] != null && ds.Tables[0].Rows[0]["F_OVERTIMES"].ToString() != "")
                {
                    model.F_OVERTIMES = int.Parse(ds.Tables[0].Rows[0]["F_OVERTIMES"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_FORMID"] != null && ds.Tables[0].Rows[0]["F_FORMID"].ToString() != "")
                {
                    model.F_FORMID = int.Parse(ds.Tables[0].Rows[0]["F_FORMID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_HASTENCOUNTS"] != null && ds.Tables[0].Rows[0]["F_HASTENCOUNTS"].ToString() != "")
                {
                    model.F_HASTENCOUNTS = int.Parse(ds.Tables[0].Rows[0]["F_HASTENCOUNTS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RANGEID"] != null && ds.Tables[0].Rows[0]["F_RANGEID"].ToString() != "")
                {
                    model.F_RANGEID = decimal.Parse(ds.Tables[0].Rows[0]["F_RANGEID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RANGEX"] != null && ds.Tables[0].Rows[0]["F_RANGEX"].ToString() != "")
                {
                    model.F_RANGEX = decimal.Parse(ds.Tables[0].Rows[0]["F_RANGEX"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RANGEY"] != null && ds.Tables[0].Rows[0]["F_RANGEY"].ToString() != "")
                {
                    model.F_RANGEY = decimal.Parse(ds.Tables[0].Rows[0]["F_RANGEY"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_INSTANCEID"] != null && ds.Tables[0].Rows[0]["F_INSTANCEID"].ToString() != "")
                {
                    model.F_INSTANCEID = int.Parse(ds.Tables[0].Rows[0]["F_INSTANCEID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_CUSTOMERID"] != null && ds.Tables[0].Rows[0]["F_CUSTOMERID"].ToString() != "")
                {
                    model.F_CUSTOMERID = int.Parse(ds.Tables[0].Rows[0]["F_CUSTOMERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRMANID"] != null && ds.Tables[0].Rows[0]["F_REPAIRMANID"].ToString() != "")
                {
                    model.F_REPAIRMANID = int.Parse(ds.Tables[0].Rows[0]["F_REPAIRMANID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRMANNAME"] != null && ds.Tables[0].Rows[0]["F_REPAIRMANNAME"].ToString() != "")
                {
                    model.F_REPAIRMANNAME = ds.Tables[0].Rows[0]["F_REPAIRMANNAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRMANPHONE"] != null && ds.Tables[0].Rows[0]["F_REPAIRMANPHONE"].ToString() != "")
                {
                    model.F_REPAIRMANPHONE = ds.Tables[0].Rows[0]["F_REPAIRMANPHONE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRREQUEST"] != null && ds.Tables[0].Rows[0]["F_REPAIRREQUEST"].ToString() != "")
                {
                    model.F_REPAIRREQUEST = ds.Tables[0].Rows[0]["F_REPAIRREQUEST"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRCLOSEMANID"] != null && ds.Tables[0].Rows[0]["F_REPAIRCLOSEMANID"].ToString() != "")
                {
                    model.F_REPAIRCLOSEMANID = int.Parse(ds.Tables[0].Rows[0]["F_REPAIRCLOSEMANID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRCLOSEMANNAME"] != null && ds.Tables[0].Rows[0]["F_REPAIRCLOSEMANNAME"].ToString() != "")
                {
                    model.F_REPAIRCLOSEMANNAME = ds.Tables[0].Rows[0]["F_REPAIRCLOSEMANNAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRCLOSEREASONS"] != null && ds.Tables[0].Rows[0]["F_REPAIRCLOSEREASONS"].ToString() != "")
                {
                    model.F_REPAIRCLOSEREASONS = ds.Tables[0].Rows[0]["F_REPAIRCLOSEREASONS"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRCLOSEREPTID"] != null && ds.Tables[0].Rows[0]["F_REPAIRCLOSEREPTID"].ToString() != "")
                {
                    model.F_REPAIRCLOSEREPTID = int.Parse(ds.Tables[0].Rows[0]["F_REPAIRCLOSEREPTID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRCLOSEREPT"] != null && ds.Tables[0].Rows[0]["F_REPAIRCLOSEREPT"].ToString() != "")
                {
                    model.F_REPAIRCLOSEREPT = ds.Tables[0].Rows[0]["F_REPAIRCLOSEREPT"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRLEVEL"] != null && ds.Tables[0].Rows[0]["F_REPAIRLEVEL"].ToString() != "")
                {
                    model.F_REPAIRLEVEL = int.Parse(ds.Tables[0].Rows[0]["F_REPAIRLEVEL"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REPAIRLEVELNAME"] != null && ds.Tables[0].Rows[0]["F_REPAIRLEVELNAME"].ToString() != "")
                {
                    model.F_REPAIRLEVELNAME = ds.Tables[0].Rows[0]["F_REPAIRLEVELNAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_SENTORDERTIME"] != null && ds.Tables[0].Rows[0]["F_SENTORDERTIME"].ToString() != "")
                {
                    model.F_SENTORDERTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_SENTORDERTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_USERPHONE"] != null && ds.Tables[0].Rows[0]["F_USERPHONE"].ToString() != "")
                {
                    model.F_USERPHONE = ds.Tables[0].Rows[0]["F_USERPHONE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITTIME"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITTIME"].ToString() != "")
                {
                    model.F_RETURNVISITTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_RETURNVISITTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_REQUESTSERVICETIME"] != null && ds.Tables[0].Rows[0]["F_REQUESTSERVICETIME"].ToString() != "")
                {
                    model.F_REQUESTSERVICETIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_REQUESTSERVICETIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_SERVICETYPE"] != null && ds.Tables[0].Rows[0]["F_SERVICETYPE"].ToString() != "")
                {
                    model.F_SERVICETYPE = ds.Tables[0].Rows[0]["F_SERVICETYPE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_DECLARATIONTIME"] != null && ds.Tables[0].Rows[0]["F_DECLARATIONTIME"].ToString() != "")
                {
                    model.F_DECLARATIONTIME = decimal.Parse(ds.Tables[0].Rows[0]["F_DECLARATIONTIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_SERVICENATURE"] != null && ds.Tables[0].Rows[0]["F_SERVICENATURE"].ToString() != "")
                {
                    model.F_SERVICENATURE = ds.Tables[0].Rows[0]["F_SERVICENATURE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_SERVICEWAY"] != null && ds.Tables[0].Rows[0]["F_SERVICEWAY"].ToString() != "")
                {
                    model.F_SERVICEWAY = ds.Tables[0].Rows[0]["F_SERVICEWAY"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITMAN"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITMAN"].ToString() != "")
                {
                    model.F_RETURNVISITMAN = ds.Tables[0].Rows[0]["F_RETURNVISITMAN"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITID"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITID"].ToString() != "")
                {
                    model.F_RETURNVISITID = int.Parse(ds.Tables[0].Rows[0]["F_RETURNVISITID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITOPINION"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITOPINION"].ToString() != "")
                {
                    model.F_RETURNVISITOPINION = ds.Tables[0].Rows[0]["F_RETURNVISITOPINION"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_RETURNVISITPROBLEM"] != null && ds.Tables[0].Rows[0]["F_RETURNVISITPROBLEM"].ToString() != "")
                {
                    model.F_RETURNVISITPROBLEM = ds.Tables[0].Rows[0]["F_RETURNVISITPROBLEM"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select F_WORKORDERID,F_WORKORDERTYPEID,F_WORKORDERSTATEID,F_CODE,F_WORKORDERNAME,F_NUMBER,F_CUSTOMERNAME,F_CUSTOMERTELEPHONE,F_LINKMAN,F_LINKMANTELEPHONE,F_ADSLACCOUNT,F_BANDWIDTH,F_STANDARDADDRESS,F_INSTALLADDRESS,F_KSHADDRESSCODE,F_PROVINCE,F_CITY,F_AREA,F_ROAD,F_HOUSING,F_WORKORDERFROM,F_WORKORDERLEVELID,F_FILEFLAG,F_CONTENT,F_CREATEBY,F_CREATEDATE,F_DEPTCODE,F_EMPCODE,F_DEPTID,F_USERID,F_USERNAME,F_RETURNVISITFLAG,F_RETURNVISITSTATE,F_RETURNVISITRESULT,F_RETURNVISITCONTENT,F_DELETEFLAG,F_ALLUSETIMES,F_STARTTIME,F_ENDTIME,F_REMAINDERTIME,F_REMAINDERENDTIME,F_SUBSCRIBETIME1,F_SUBSCRIBETIME2,F_ACCEPTTIMELIMIT,F_ASKFINISHTIME,F_OVERTIMES,F_FORMID,F_HASTENCOUNTS,F_RANGEID,F_RANGEX,F_RANGEY,F_INSTANCEID,F_CUSTOMERID,F_REPAIRMANID,F_REPAIRMANNAME,F_REPAIRMANPHONE,F_REPAIRREQUEST,F_REPAIRCLOSEMANID,F_REPAIRCLOSEMANNAME,F_REPAIRCLOSEREASONS,F_REPAIRCLOSEREPTID,F_REPAIRCLOSEREPT,F_REPAIRLEVEL,F_REPAIRLEVELNAME,F_SENTORDERTIME,F_USERPHONE,F_RETURNVISITTIME,F_REQUESTSERVICETIME,F_SERVICETYPE,F_DECLARATIONTIME,F_SERVICENATURE,F_SERVICEWAY,F_RETURNVISITMAN,F_RETURNVISITID,F_RETURNVISITOPINION,F_RETURNVISITPROBLEM ");
            strSql.Append(" FROM T_Wo_WorkOrderBase ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" F_WORKORDERID,F_WORKORDERTYPEID,F_WORKORDERSTATEID,F_CODE,F_WORKORDERNAME,F_NUMBER,F_CUSTOMERNAME,F_CUSTOMERTELEPHONE,F_LINKMAN,F_LINKMANTELEPHONE,F_ADSLACCOUNT,F_BANDWIDTH,F_STANDARDADDRESS,F_INSTALLADDRESS,F_KSHADDRESSCODE,F_PROVINCE,F_CITY,F_AREA,F_ROAD,F_HOUSING,F_WORKORDERFROM,F_WORKORDERLEVELID,F_FILEFLAG,F_CONTENT,F_CREATEBY,F_CREATEDATE,F_DEPTCODE,F_EMPCODE,F_DEPTID,F_USERID,F_USERNAME,F_RETURNVISITFLAG,F_RETURNVISITSTATE,F_RETURNVISITRESULT,F_RETURNVISITCONTENT,F_DELETEFLAG,F_ALLUSETIMES,F_STARTTIME,F_ENDTIME,F_REMAINDERTIME,F_REMAINDERENDTIME,F_SUBSCRIBETIME1,F_SUBSCRIBETIME2,F_ACCEPTTIMELIMIT,F_ASKFINISHTIME,F_OVERTIMES,F_FORMID,F_HASTENCOUNTS,F_RANGEID,F_RANGEX,F_RANGEY,F_INSTANCEID,F_CUSTOMERID,F_REPAIRMANID,F_REPAIRMANNAME,F_REPAIRMANPHONE,F_REPAIRREQUEST,F_REPAIRCLOSEMANID,F_REPAIRCLOSEMANNAME,F_REPAIRCLOSEREASONS,F_REPAIRCLOSEREPTID,F_REPAIRCLOSEREPT,F_REPAIRLEVEL,F_REPAIRLEVELNAME,F_SENTORDERTIME,F_USERPHONE,F_RETURNVISITTIME,F_REQUESTSERVICETIME,F_SERVICETYPE,F_DECLARATIONTIME,F_SERVICENATURE,F_SERVICEWAY,F_RETURNVISITMAN,F_RETURNVISITID,F_RETURNVISITOPINION,F_RETURNVISITPROBLEM ");
            strSql.Append(" FROM T_Wo_WorkOrderBase ");
            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_Wo_WorkOrderBase ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.F_WORKORDERID desc");
            }
            strSql.Append(")AS Row, T.*  from T_Wo_WorkOrderBase 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_Wo_WorkOrderBase";
			parameters[1].Value = "F_WORKORDERID";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

        #endregion  Method
    }
}
