public List<Assetmaintain> RetrieveAssetmaintainsPaging(AssetmaintainSearch info,int pageIndex, int pageSize,out int count)
        {
            try
            {
                StringBuilder sqlCommand = new StringBuilder(@" SELECT ""ASSETMAINTAIN"".""ASSETMAINTAINID"",""ASSETMAINTAIN"".""ASSETCATEGORYID"",""ASSETMAINTAIN"".""MAINTAINTYPE""
                                                                      ,""ASSETMAINTAIN"".""APPLYDATE"",""ASSETMAINTAIN"".""APPLYUSERID"",""ASSETMAINTAIN"".""APPLYCONTENT"",""ASSETMAINTAIN"".""APPROVEUSER""
                                                                      ,""ASSETMAINTAIN"".""APPROVEDATE"",""ASSETMAINTAIN"".""APPROVERESULT"",""ASSETMAINTAIN"".""REJECTREASON"",""ASSETMAINTAIN"".""PLANMAINTAINDATE""
                                                                      ,""ASSETMAINTAIN"".""ACTUALMAINTAINDATE"",""ASSETMAINTAIN"".""CONFIRMDATE"",""ASSETMAINTAIN"".""CONFIRMUSER"",""ASSETMAINTAIN"".""MAINTAINCONTENT""
                                                                      ,""ASSETMAINTAIN"".""STORAGETITLE"",""ASSETMAINTAIN"".""STORAGEID"",""ASSETMAINTAIN"".""SUBCOMPANY"",""ASSETMAINTAIN"".""SUBCOMPANYCONTACTORID""
                                                                      ,""ASSETMAINTAIN"".""CONTACTPHONE"", ""ASSETMAINTAIN"".""PROJECTCONTACTORID"",""ASSETMAINTAIN"".""PROJECTCONTACTORPHONE""
                                                                      ,""ASSETMAINTAIN"".""CREATOR"",""ASSETMAINTAIN"".""CREATEDDATE"",TU.USERNAME AS Applyusername
                                                                      ,SYSTEM,c.StorageName,c.subcompanyname
                     FROM ASSETMAINTAIN inner join ASSETCATEGORY ON ASSETMAINTAIN.ASSETCATEGORYID=ASSETCATEGORY.ASSETCATEGORYID
                     Inner join  v_storage_address c on c.StorageTitle=ASSETMAINTAIN.STORAGETITLE and c.StorageId=ASSETMAINTAIN.STORAGEID
                     INNER JOIN T_USER TU ON TU.ID=ASSETMAINTAIN.APPLYUSERID
                     WHERE 1=1");

                #region ά�޵����
                if (!string.IsNullOrEmpty(info.Assetmaintainid))
                {
                    this.Database.AddInParameter(":Assetmaintainid",DbType.AnsiString,"%"+info.Assetmaintainid+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""ASSETMAINTAINID"" LIKE :Assetmaintainid");
                }
                #endregion

                #region ��Ŀ��ID��ֹ�˾ID
                if (!string.IsNullOrEmpty(info.Storageid) && !string.IsNullOrEmpty(info.Storagetitle))
                {
                    this.Database.AddInParameter(":Storagetitle", DbType.AnsiString, info.Storagetitle);
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""STORAGETITLE"" = :Storagetitle");
                    this.Database.AddInParameter(":Storageid", DbType.AnsiString, info.Storageid);
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""STORAGEID"" = :Storageid");
                }
                #endregion

                #region (ϵͳ)�豸����
                if (!string.IsNullOrEmpty(info.Assetcategoryid))
                {
                    this.Database.AddInParameter(":Assetcategoryid",DbType.AnsiString,"%"+info.Assetcategoryid+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""ASSETCATEGORYID"" LIKE :Assetcategoryid");
                }
                #endregion

                #region ������Դ��(��Ŀ�塢�Լ졢�¼죩�����ֵ�
                if (!string.IsNullOrEmpty(info.Maintaintype))
                {
                    this.Database.AddInParameter(":Maintaintype",DbType.AnsiString,"%"+info.Maintaintype+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""MAINTAINTYPE"" LIKE :Maintaintype");
                }
                #endregion

                #region ����������
                if (info.StartApplydate.HasValue)
                {
                    this.Database.AddInParameter(":StartApplydate",info.StartApplydate.Value.Date);
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""APPLYDATE"" >= :StartApplydate");
                }
                if (info.EndApplydate.HasValue)
                {
                    this.Database.AddInParameter(":EndApplydate",info.EndApplydate.Value.Date.AddDays(1).AddSeconds(-1));
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""APPLYDATE"" <= :EndApplydate");
                }
                #endregion

                #region ������
                if (!string.IsNullOrEmpty(info.Applyuserid))
                {
                    this.Database.AddInParameter(":Applyuserid",DbType.AnsiString,"%"+info.Applyuserid+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""APPLYUSERID"" LIKE :Applyuserid");
                }
                #endregion

                #region �����
                if (!string.IsNullOrEmpty(info.Approveuser))
                {
                    this.Database.AddInParameter(":Approveuser", "%"+info.Approveuser+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""APPROVEUSER"" LIKE :Approveuser");
                }
                #endregion

                #region �������
                if (info.StartApprovedate.HasValue)
                {
                    this.Database.AddInParameter(":StartApprovedate",info.StartApprovedate.Value.Date);
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""APPROVEDATE"" >= :StartApprovedate");
                }
                if (info.EndApprovedate.HasValue)
                {
                    this.Database.AddInParameter(":EndApprovedate",info.EndApprovedate.Value.Date.AddDays(1).AddSeconds(-1));
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""APPROVEDATE"" <= :EndApprovedate");
                }
                #endregion

                #region �ƻ�ά������
                if (info.StartPlanmaintaindate.HasValue)
                {
                    this.Database.AddInParameter(":StartPlanmaintaindate",info.StartPlanmaintaindate.Value.Date);
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""PLANMAINTAINDATE"" >= :StartPlanmaintaindate");
                }
                if (info.EndPlanmaintaindate.HasValue)
                {
                    this.Database.AddInParameter(":EndPlanmaintaindate",info.EndPlanmaintaindate.Value.Date.AddDays(1).AddSeconds(-1));
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""PLANMAINTAINDATE"" <= :EndPlanmaintaindate");
                }
                #endregion

                #region ʵ��ά������
                if (info.StartActualmaintaindate.HasValue)
                {
                    this.Database.AddInParameter(":StartActualmaintaindate",info.StartActualmaintaindate.Value.Date);
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""ACTUALMAINTAINDATE"" >= :StartActualmaintaindate");
                }
                if (info.EndActualmaintaindate.HasValue)
                {
                    this.Database.AddInParameter(":EndActualmaintaindate",info.EndActualmaintaindate.Value.Date.AddDays(1).AddSeconds(-1));
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""ACTUALMAINTAINDATE"" <= :EndActualmaintaindate");
                }
                #endregion

                #region ȷ������
                if (info.StartConfirmdate.HasValue)
                {
                    this.Database.AddInParameter(":StartConfirmdate",info.StartConfirmdate.Value.Date);
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""CONFIRMDATE"" >= :StartConfirmdate");
                }
                if (info.EndConfirmdate.HasValue)
                {
                    this.Database.AddInParameter(":EndConfirmdate",info.EndConfirmdate.Value.Date.AddDays(1).AddSeconds(-1));
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""CONFIRMDATE"" <= :EndConfirmdate");
                }
                #endregion

                #region ȷ����
                if (!string.IsNullOrEmpty(info.Confirmuser))
                {
                    this.Database.AddInParameter(":Confirmuser",DbType.AnsiString,"%"+info.Confirmuser+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""CONFIRMUSER"" LIKE :Confirmuser");
                }
                #endregion

                #region �ֹ�˾��ϵ��
                if (!string.IsNullOrEmpty(info.Subcompanycontactorid))
                {
                    this.Database.AddInParameter(":Subcompanycontactorid",DbType.AnsiString,"%"+info.Subcompanycontactorid+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""SUBCOMPANYCONTACTORID"" LIKE :Subcompanycontactorid");
                }
                #endregion

                #region ��ϵ�绰
                if (!string.IsNullOrEmpty(info.Contactphone))
                {
                    this.Database.AddInParameter(":Contactphone",DbType.AnsiString,"%"+info.Contactphone+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""CONTACTPHONE"" LIKE :Contactphone");
                }
                #endregion

                #region ��Ŀ����ϵ��
                if (!string.IsNullOrEmpty(info.Projectcontactorid))
                {
                    this.Database.AddInParameter(":Projectcontactorid",DbType.AnsiString,"%"+info.Projectcontactorid+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""PROJECTCONTACTORID"" LIKE :Projectcontactorid");
                }
                #endregion

                #region ��Ŀ����ϵ�绰
                if (!string.IsNullOrEmpty(info.Projectcontactorphone))
                {
                    this.Database.AddInParameter(":Projectcontactorphone",DbType.AnsiString,"%"+info.Projectcontactorphone+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""PROJECTCONTACTORPHONE"" LIKE :Projectcontactorphone");
                }
                #endregion

                #region ������
                if (!string.IsNullOrEmpty(info.Creator))
                {
                    this.Database.AddInParameter(":Creator",DbType.AnsiString,"%"+info.Creator+"%");
                    sqlCommand.AppendLine(@" AND ""ASSETMAINTAIN"".""CREATOR"" LIKE :Creator");
                }
                #endregion

                #region ά�޵�״̬
                if (info.AssetMaintainStates.Count > 0)
                {
                    this.Database.AddInParameter(":APPROVERESULT", info.AssetMaintainStates[0]);
                    sqlCommand.AppendLine(@" AND (""ASSETMAINTAIN"".""APPROVERESULT""=:APPROVERESULT");
                    for (int i = 1; i < info.AssetMaintainStates.Count; i++)
                    {
                        this.Database.AddInParameter(":APPROVERESULT" + i.ToString(), info.AssetMaintainStates[i]);
                        sqlCommand.AppendLine(@" OR ""ASSETMAINTAIN"".""APPROVERESULT""=:APPROVERESULT" + i.ToString());
                    }
                    sqlCommand.AppendLine(@" )");
                }

                #endregion

                sqlCommand.AppendLine(@"  ORDER BY ""ASSETMAINTAIN"".""ASSETMAINTAINID"" DESC");
                return this.ExecuteReaderPaging<Assetmaintain>(sqlCommand.ToString(), pageIndex, pageSize, out count);
            }
            finally
            {
                this.Database.ClearParameter();
            }
        }
        protected void LoadData(int pageIndex)
        {
            var search = new AssetmaintainSearch();
            search.Assetmaintainid = txtSrchAssetmaintainid.Text;//维修单编号
            //search.Assetcategoryid = txtSrchAssetcategoryid.Text;//(系统)设备大类
            //search.Maintaintype = txtSrchMaintaintype.Text;//保修来源:(项目体、自检、月检)数据字典
            if (ucSrchStartApplydate.DateValue.HasValue)
            {
                search.StartApplydate = ucSrchStartApplydate.DateValue.Value;//申请维修日期
            }
            if (ucSrchEndApplydate.DateValue.HasValue)
            {
                search.EndApplydate = ucSrchEndApplydate.DateValue.Value;//申请维修日期
            }

            search.Storagetitle = ucSelectProject.Storagetitle;//区分字段:分公司或项目体
            search.Storageid = ucSelectProject.StorageId;//项目体ID或分公司ID

            #region deleted Code
            //search.Applyuserid = txtSrchApplyuserid.Text;//申请人
            //search.Applycontent = txtSrchApplycontent.Text;//申请内容
            //search.Approveuser = txtSrchApproveuser.Text;//审核人
            //if (ucSrchStartApprovedate.DateValue.HasValue)
            //{
            //    search.StartApprovedate = ucSrchStartApprovedate.DateValue.Value;//审核日期
            //}
            //if (ucSrchEndApprovedate.DateValue.HasValue)
            //{
            //    search.EndApprovedate = ucSrchEndApprovedate.DateValue.Value;//审核日期
            //}
            //search.Rejectreason = txtSrchRejectreason.Text;//拒绝理由
            //if (ucSrchStartPlanmaintaindate.DateValue.HasValue)
            //{
            //    search.StartPlanmaintaindate = ucSrchStartPlanmaintaindate.DateValue.Value;//计划维修日期
            //}
            //if (ucSrchEndPlanmaintaindate.DateValue.HasValue)
            //{
            //    search.EndPlanmaintaindate = ucSrchEndPlanmaintaindate.DateValue.Value;//计划维修日期
            //}
            //if (ucSrchStartActualmaintaindate.DateValue.HasValue)
            //{
            //    search.StartActualmaintaindate = ucSrchStartActualmaintaindate.DateValue.Value;//实际维修日期
            //}
            //if (ucSrchEndActualmaintaindate.DateValue.HasValue)
            //{
            //    search.EndActualmaintaindate = ucSrchEndActualmaintaindate.DateValue.Value;//实际维修日期
            //}
            //if (ucSrchStartConfirmdate.DateValue.HasValue)
            //{
            //    search.StartConfirmdate = ucSrchStartConfirmdate.DateValue.Value;//确认日期
            //}
            //if (ucSrchEndConfirmdate.DateValue.HasValue)
            //{
            //    search.EndConfirmdate = ucSrchEndConfirmdate.DateValue.Value;//确认日期
            //}
            //search.Confirmuser = txtSrchConfirmuser.Text;//确认人
            //search.Maintaincontent = txtSrchMaintaincontent.Text;//已维修明细
            //search.Subcompany = txtSrchSubcompany.Text;//分公司
            //search.Subcompanycontactorid = txtSrchSubcompanycontactorid.Text;//分公司联系人
            //search.Contactphone = txtSrchContactphone.Text;//联系电话
            //search.Projectcontactorid = txtSrchProjectcontactorid.Text;//项目体联系人
            //search.Projectcontactorphone = txtSrchProjectcontactorphone.Text;//项目体联系电话
            //search.Creator = txtSrchCreator.Text;//创建人
            //if (ucSrchStartCreateddate.DateValue.HasValue)
            //{
            //    search.StartCreateddate = ucSrchStartCreateddate.DateValue.Value;//创建日期
            //}
            //if (ucSrchEndCreateddate.DateValue.HasValue)
            //{
            //    search.EndCreateddate = ucSrchEndCreateddate.DateValue.Value;//创建日期
            //}
            #endregion

            int recordCount = 0;
            var list = this.AssetmaintainService.RetrieveAssetmaintainsPaging(search, pageIndex, pcData.PageSize, out recordCount);
            rptRepairList.DataSource = list;
            rptRepairList.DataBind();
            pcData.RecordCount = recordCount;
            pcData.CurrentIndex = pageIndex;
        }
 public List<Assetmaintain> RetrieveAssetmaintainsPaging(AssetmaintainSearch info,int pageIndex, int pageSize,out int count)
 {
     return Management.RetrieveAssetmaintainsPaging(info,pageIndex,pageSize,out count);
 }