/// <summary>
 /// 设置新增和修改的参数数组的值
 /// </summary>
 /// <param name="parameters">参数数组</param>
 /// <param name="model">实体类</param>
 /// <returns>返回参数数组</returns>
 private static SqlParameter[] SetInsertAndUpdateParametersValue(SqlParameter[] parameters, ProjectConstructionModel model)
 {
     if (!model.SummaryID.HasValue) parameters[m_summaryIDCol].Value = System.DBNull.Value; else parameters[m_summaryIDCol].Value = model.SummaryID; // 概要编号
     parameters[m_companyCDCol].Value = model.CompanyCD; // 企业编码
     parameters[m_summaryNameCol].Value = model.SummaryName; // 概要名称
     if (!model.StructID.HasValue) parameters[m_structIDCol].Value = System.DBNull.Value; else parameters[m_structIDCol].Value = model.StructID; // 所属工程概要编号
     if (!model.ProcessScale.HasValue) parameters[m_processScaleCol].Value = System.DBNull.Value; else parameters[m_processScaleCol].Value = model.ProcessScale; // 工艺定额
     if (!model.KeyPress.HasValue) parameters[m_keyPressCol].Value = System.DBNull.Value; else parameters[m_keyPressCol].Value = model.KeyPress; // 是否为受约进度(0:不是,1是)
     parameters[m_proessIDCol].Value = model.ProessID; // 受约进度编号(多编号用”,”隔开)
     if (!model.BeginDate.HasValue) parameters[m_beginDateCol].Value = System.DBNull.Value; else parameters[m_beginDateCol].Value = model.BeginDate; // 开始时间
     if (!model.EndDate.HasValue) parameters[m_endDateCol].Value = System.DBNull.Value; else parameters[m_endDateCol].Value = model.EndDate; // 结束时间
     if (!model.StartFlag.HasValue) parameters[m_startFlagCol].Value = System.DBNull.Value; else parameters[m_startFlagCol].Value = model.StartFlag; // 是否执行(0:不执行,1执行)
     if (!model.GmanagerID.HasValue) parameters[m_gmanagerIDCol].Value = System.DBNull.Value; else parameters[m_gmanagerIDCol].Value = model.GmanagerID; // 工程负责人
     parameters[m_projectMemoCol].Value = model.ProjectMemo; // 工程备注
     
     return parameters;
 }
		/// <summary>
        /// 修改数据记录
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>修改数据是否成功:true成功,false不成功</returns>
        public static bool Update(ProjectConstructionModel model)
        {
            bool returnValue = false; // 返回值
            
            // SQL语句
            StringBuilder sqlSentence = new StringBuilder(C_UPDATE);
            
            // 参数设置
            SqlParameter[] parameters = SetInsertAndUpdateParameters();
            parameters = SetInsertAndUpdateParametersValue(parameters, model);
            
            //执行SQL
            returnValue = SqlHelper.ExecuteTransSql(sqlSentence.ToString(), parameters) > 0;
            
            return returnValue;
        }
		/// <summary>
        /// 插入操作的执行命令
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>插入操作的执行命令</returns>
        public static SqlCommand InsertCommand(ProjectConstructionModel model)
        {
            // SQL语句
			SqlCommand comm = new SqlCommand();
			comm.CommandText = C_INSERT + " SET @IndexID = @@IDENTITY ";
			// 参数设置
            SqlParameter[] parameters = SetInsertAndUpdateParameters();
            parameters = SetInsertAndUpdateParametersValue(parameters, model);
            
			comm.Parameters.AddRange(parameters);
			SqlParameter IndexID = new SqlParameter("@IndexID", SqlDbType.Int);
            IndexID.Direction = ParameterDirection.Output;
            comm.Parameters.Add(IndexID);
			
			return comm;
		}
		/// <summary>
        /// 修改数据记录
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>修改操作的执行命令</returns>
        public static SqlCommand UpdateCommand(ProjectConstructionModel model)
        {
			 // SQL语句
			SqlCommand comm = new SqlCommand();
			comm.CommandText = C_UPDATE;
			// 参数设置
            SqlParameter[] parameters = SetInsertAndUpdateParameters();
            parameters = SetInsertAndUpdateParametersValue(parameters, model);
            
			comm.Parameters.AddRange(parameters);
			
			return comm;
        }
		/// <summary>
        /// 列表界面查询方法
        /// </summary>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageCount">每页记录数</param>
        /// <param name="orderBy">排序方法</param>
        /// <param name="TotalCount">总记录数</param>
        /// <param name="model">实体类</param>
        /// <returns></returns>
        public static DataTable SelectListData(int pageIndex, int pageCount, string orderBy, ref int TotalCount
            , ProjectConstructionModel model)
        {
            SqlCommand comm = new SqlCommand();
            StringBuilder sql = new StringBuilder(C_SELECT_ALL);
            sql.Append(" WHERE 1=1 ");
            comm.CommandText = sql.ToString();
            return SqlHelper.PagerWithCommand(comm, pageIndex, pageCount, orderBy, ref TotalCount);
        }