Example #1
0
        /// <summary>
        /// 修改设备信息
        /// </summary>
        /// <param name="newInfo">设备信息</param>
        /// <returns>设备信息</returns>
        public DataTable GetChangedFields(EquipmentInfo newInfo)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("FieldName");
            dt.Columns.Add("OldValue");
            dt.Columns.Add("NewValue");

            if (this.EquipmentLevel.ID != newInfo.EquipmentLevel.ID)
            {
                dt.Rows.Add("EquipmentLevelDesc", this.EquipmentLevel.Name, EquipmentLevels.GetEquipmentLevelDesc(newInfo.EquipmentLevel.ID));
            }

            if (this.Name != SQLUtil.TrimNull(newInfo.Name))
            {
                dt.Rows.Add("EquipmentName", this.Name, newInfo.Name);
            }

            if (this.EquipmentCode != SQLUtil.TrimNull(newInfo.EquipmentCode))
            {
                dt.Rows.Add("EquipmentCode", this.EquipmentCode, newInfo.EquipmentCode);
            }

            if (this.SerialCode != SQLUtil.TrimNull(newInfo.SerialCode))
            {
                dt.Rows.Add("SerialCode", this.SerialCode, newInfo.SerialCode);
            }

            if (this.Manufacturer.ID != newInfo.Manufacturer.ID)
            {
                dt.Rows.Add("EquipmentManufacturerName", this.Manufacturer.Name, newInfo.Manufacturer.Name);
            }

            if (this.EquipmentClass1.Code != SQLUtil.TrimNull(newInfo.EquipmentClass1.Code))
            {
                dt.Rows.Add("EquipmentClass1Name", this.EquipmentClass1.Description, Manager.LookupManager.GetEquipmentClassDesc(newInfo.EquipmentClass1.Code, 1));
            }

            if (this.EquipmentClass2.Code != SQLUtil.TrimNull(newInfo.EquipmentClass2.Code) || this.EquipmentClass1.Code != SQLUtil.TrimNull(newInfo.EquipmentClass1.Code))
            {
                dt.Rows.Add("EquipmentClass2Name", this.EquipmentClass2.Description, Manager.LookupManager.GetEquipmentClassDesc(newInfo.EquipmentClass2.Code, 2, newInfo.EquipmentClass1.Code));
            }

            if (this.EquipmentClass3.Code != SQLUtil.TrimNull(newInfo.EquipmentClass3.Code) || (this.EquipmentClass2.Code != SQLUtil.TrimNull(newInfo.EquipmentClass2.Code) || this.EquipmentClass1.Code != SQLUtil.TrimNull(newInfo.EquipmentClass1.Code)))
            {
                dt.Rows.Add("EquipmentClass3Name", this.EquipmentClass3.Description, Manager.LookupManager.GetEquipmentClassDesc(newInfo.EquipmentClass3.Code, 3, newInfo.EquipmentClass1.Code + newInfo.EquipmentClass2.Code));
            }

            if (this.ResponseTimeLength != newInfo.ResponseTimeLength)
            {
                dt.Rows.Add("ResponseTimeLength", this.ResponseTimeLength, newInfo.ResponseTimeLength);
            }

            if (this.ServiceScope != newInfo.ServiceScope)
            {
                dt.Rows.Add("ServiceScopeDesc", SQLUtil.ConvertBoolean(this.ServiceScope) ? "是" : "否", SQLUtil.ConvertBoolean(newInfo.ServiceScope) ? "是" : "否");
            }

            if (this.Brand != SQLUtil.TrimNull(newInfo.Brand))
            {
                dt.Rows.Add("Brand", this.Brand, newInfo.Brand == null ? "" : newInfo.Brand);
            }

            if (this.Comments != SQLUtil.TrimNull(newInfo.Comments))
            {
                dt.Rows.Add("EquipmentComments", this.Comments, newInfo.Comments == null ? "" : newInfo.Comments);
            }

            if (this.ManufacturingDate != newInfo.ManufacturingDate)
            {
                dt.Rows.Add("ManufacturingDate", SQLUtil.ConvertDateTime(this.ManufacturingDate) == DateTime.MinValue ? "" : this.ManufacturingDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.ManufacturingDate) == DateTime.MinValue ? "" : newInfo.ManufacturingDate.ToString("yyyy-MM-dd"));
            }

            if (this.FixedAsset != newInfo.FixedAsset)
            {
                dt.Rows.Add("FixedAsset", SQLUtil.ConvertBoolean(this.FixedAsset) ? "是" : "否", SQLUtil.ConvertBoolean(newInfo.FixedAsset) ? "是" : "否");
            }

            if (this.AssetCode != SQLUtil.TrimNull(newInfo.AssetCode))
            {
                dt.Rows.Add("AssetCode", this.AssetCode, newInfo.AssetCode);
            }

            if (this.AssetLevel.ID != newInfo.AssetLevel.ID)
            {
                dt.Rows.Add("AssetLevel", this.AssetLevel.Name, AssetLevels.GetAssetLevelDesc(newInfo.AssetLevel.ID));
            }

            if (this.DepreciationYears != newInfo.DepreciationYears)
            {
                dt.Rows.Add("DepreciationYears", this.DepreciationYears, newInfo.DepreciationYears);
            }

            if (this.ValidityStartDate != newInfo.ValidityStartDate)
            {
                dt.Rows.Add("ValidityStartDate", SQLUtil.ConvertDateTime(this.ValidityStartDate) == DateTime.MinValue ? "" : this.ValidityStartDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.ValidityStartDate) == DateTime.MinValue ? "" : newInfo.ValidityStartDate.ToString("yyyy-MM-dd"));
            }

            if (this.ValidityEndDate != newInfo.ValidityEndDate)
            {
                dt.Rows.Add("ValidityEndDate", SQLUtil.ConvertDateTime(this.ValidityEndDate) == DateTime.MinValue ? "" : this.ValidityEndDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.ValidityEndDate) == DateTime.MinValue ? "" : newInfo.ValidityEndDate.ToString("yyyy-MM-dd"));
            }

            if (this.SaleContractName != SQLUtil.TrimNull(newInfo.SaleContractName))
            {
                dt.Rows.Add("SaleContractName", this.SaleContractName, newInfo.SaleContractName == null ? "" : newInfo.SaleContractName);
            }

            if (this.Supplier.ID != newInfo.Supplier.ID)
            {
                dt.Rows.Add("DealerName", this.Supplier.Name, newInfo.Supplier.Name);
            }

            if (this.PurchaseWay != SQLUtil.TrimNull(newInfo.PurchaseWay))
            {
                dt.Rows.Add("PurchaseWay", this.PurchaseWay, newInfo.PurchaseWay == null ? "" : newInfo.PurchaseWay);
            }

            if (this.PurchaseAmount != newInfo.PurchaseAmount)
            {
                dt.Rows.Add("EquipmentPurchaseAmount", this.PurchaseAmount, newInfo.PurchaseAmount == null ? 0 : newInfo.PurchaseAmount);
            }

            if (this.PurchaseDate != newInfo.PurchaseDate)
            {
                dt.Rows.Add("PurchaseDate", SQLUtil.ConvertDateTime(this.PurchaseDate) == DateTime.MinValue ? "" : this.PurchaseDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.PurchaseDate) == DateTime.MinValue ? "" : newInfo.PurchaseDate.ToString("yyyy-MM-dd"));
            }

            if (this.IsImport != newInfo.IsImport)
            {
                dt.Rows.Add("IsImport", SQLUtil.ConvertBoolean(this.IsImport) ? "国产" : "进口", SQLUtil.ConvertBoolean(newInfo.IsImport) ? "国产" : "进口");
            }

            if (this.Department.ID != newInfo.Department.ID)
            {
                dt.Rows.Add("DepartmentName", this.Department.Name, Manager.LookupManager.GetDepartmentDesc(newInfo.Department.ID));
            }

            if (this.InstalSite != SQLUtil.TrimNull(newInfo.InstalSite))
            {
                dt.Rows.Add("InstalSite", this.InstalSite, newInfo.InstalSite == null ? "" : newInfo.InstalSite);
            }

            if (this.InstalDate != newInfo.InstalDate)
            {
                dt.Rows.Add("InstalDate", SQLUtil.ConvertDateTime(this.InstalDate) == DateTime.MinValue ? "" : this.InstalDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.InstalDate) == DateTime.MinValue ? "" : newInfo.InstalDate.ToString("yyyy-MM-dd"));
            }

            if (this.UseageDate != newInfo.UseageDate)
            {
                dt.Rows.Add("UseageDate", SQLUtil.ConvertDateTime(this.UseageDate) == DateTime.MinValue ? "" : this.UseageDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.UseageDate) == DateTime.MinValue ? "" : newInfo.UseageDate.ToString("yyyy-MM-dd"));
            }

            if (this.Accepted != newInfo.Accepted)
            {
                dt.Rows.Add("Accepted", SQLUtil.ConvertBoolean(this.Accepted) ? "已验收" : "未验收", SQLUtil.ConvertBoolean(newInfo.Accepted) ? "已验收" : "未验收");
            }

            if (this.AcceptanceDate != newInfo.AcceptanceDate)
            {
                dt.Rows.Add("AcceptanceDate", SQLUtil.ConvertDateTime(this.AcceptanceDate) == DateTime.MinValue ? "" : this.AcceptanceDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.AcceptanceDate) == DateTime.MinValue ? "" : newInfo.AcceptanceDate.ToString("yyyy-MM-dd"));
            }

            if (this.UsageStatus.ID != newInfo.UsageStatus.ID)
            {
                dt.Rows.Add("UsageStatusDesc", this.UsageStatus.Name, Manager.LookupManager.GetUsageStatusDesc(newInfo.UsageStatus.ID));
            }

            if (this.EquipmentStatus.ID != newInfo.EquipmentStatus.ID)
            {
                dt.Rows.Add("EquipmentStatusDesc", this.EquipmentStatus.Name, Manager.LookupManager.GetEquipmentStatusDesc(newInfo.EquipmentStatus.ID));
            }

            if (this.ScrapDate != newInfo.ScrapDate)
            {
                dt.Rows.Add("ScrapDate", SQLUtil.ConvertDateTime(this.ScrapDate) == DateTime.MinValue ? "" : this.ScrapDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.ScrapDate) == DateTime.MinValue ? "" : newInfo.ScrapDate.ToString("yyyy-MM-dd"));
            }

            if (this.MaintenancePeriod != newInfo.MaintenancePeriod || this.MaintenanceType.ID != newInfo.MaintenanceType.ID)
            {
                dt.Rows.Add("MaintenancePeriod", this.MaintenancePeriod == 0 ? "无保养" : this.MaintenancePeriod + this.MaintenanceType.Name, newInfo.MaintenancePeriod == 0 ? "无保养" : SQLUtil.ConvertInt(newInfo.MaintenancePeriod) + Manager.LookupManager.GetPeriodTypeDesc(newInfo.MaintenanceType.ID));
            }

            if (this.PatrolPeriod != newInfo.PatrolPeriod || this.PatrolType.ID != newInfo.PatrolType.ID)
            {
                dt.Rows.Add("PatrolPeriod", this.PatrolPeriod == 0 ? "无巡检" : this.PatrolPeriod + this.PatrolType.Name, newInfo.PatrolPeriod == 0 ? "无巡检" : newInfo.PatrolPeriod + Manager.LookupManager.GetPeriodTypeDesc(newInfo.PatrolType.ID));
            }

            if (this.CorrectionPeriod != newInfo.CorrectionPeriod || this.CorrectionType.ID != newInfo.CorrectionType.ID)
            {
                dt.Rows.Add("CorrectionPeriod", this.CorrectionPeriod == 0 ? "无校准" : this.CorrectionPeriod + this.CorrectionType.Name, newInfo.CorrectionPeriod == 0 ? "无校准" : newInfo.CorrectionPeriod + Manager.LookupManager.GetPeriodTypeDesc(newInfo.CorrectionType.ID));
            }

            if (this.MandatoryTestStatus.ID != newInfo.MandatoryTestStatus.ID)
            {
                dt.Rows.Add("MandatoryTestStatusDesc", this.MandatoryTestStatus.Name, MandatoryTestStatuses.GetMandatoryTestStatusDesc(newInfo.MandatoryTestStatus.ID));
            }

            if (this.MandatoryTestDate != newInfo.MandatoryTestDate)
            {
                dt.Rows.Add("MandatoryTestDate", SQLUtil.ConvertDateTime(this.MandatoryTestDate) == DateTime.MinValue ? "" : this.MandatoryTestDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.MandatoryTestDate) == DateTime.MinValue ? "" : newInfo.MandatoryTestDate.ToString("yyyy-MM-dd"));
            }

            if (this.RecallFlag != newInfo.RecallFlag)
            {
                dt.Rows.Add("RecallFlag", SQLUtil.ConvertBoolean(this.RecallFlag) ? "是" : "否", SQLUtil.ConvertBoolean(newInfo.RecallFlag) ? "是" : "否");
            }

            if (this.RecallDate != newInfo.RecallDate)
            {
                dt.Rows.Add("RecallDate", SQLUtil.ConvertDateTime(this.RecallDate) == DateTime.MinValue ? "" : this.RecallDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.RecallDate) == DateTime.MinValue ? "" : newInfo.RecallDate.ToString("yyyy-MM-dd"));
            }

            return(dt);
        }
Example #2
0
 /// <summary>
 /// 设备信息
 /// </summary>
 /// <param name="dr">dataRow</param>
 public EquipmentInfo(DataRow dr)
     : this()
 {
     this.ID = SQLUtil.ConvertInt(dr["ID"]);
     this.EquipmentLevel.ID   = SQLUtil.ConvertInt(dr["EquipmentLevel"]);
     this.EquipmentLevel.Name = EquipmentLevels.GetEquipmentLevelDesc(this.EquipmentLevel.ID);
     this.Name            = SQLUtil.TrimNull(dr["Name"]);
     this.EquipmentCode   = SQLUtil.TrimNull(dr["EquipmentCode"]);
     this.SerialCode      = SQLUtil.TrimNull(dr["SerialCode"]);
     this.Manufacturer.ID = SQLUtil.ConvertInt(dr["ManufacturerID"]);
     if (dr.Table.Columns.Contains("ManufacturerName"))
     {
         this.Manufacturer.Name = SQLUtil.TrimNull(dr["ManufacturerName"]);
     }
     this.EquipmentClass1.Code        = SQLUtil.TrimNull(dr["EquipmentClass1"]);
     this.EquipmentClass1.Description = Manager.LookupManager.GetEquipmentClassDesc(this.EquipmentClass1.Code, 1);
     this.EquipmentClass2.Code        = SQLUtil.TrimNull(dr["EquipmentClass2"]);
     this.EquipmentClass2.Description = Manager.LookupManager.GetEquipmentClassDesc(this.EquipmentClass2.Code, 2, this.EquipmentClass1.Code);
     this.EquipmentClass3.Code        = SQLUtil.TrimNull(dr["EquipmentClass3"]);
     this.EquipmentClass3.Description = Manager.LookupManager.GetEquipmentClassDesc(this.EquipmentClass3.Code, 3, this.EquipmentClass1.Code + this.EquipmentClass2.Code);
     this.ResponseTimeLength          = SQLUtil.ConvertInt(dr["ResponseTimeLength"]);
     this.ServiceScope      = SQLUtil.ConvertBoolean(dr["ServiceScope"]);
     this.Brand             = SQLUtil.TrimNull(dr["Brand"]);
     this.Comments          = SQLUtil.TrimNull(dr["Comments"]);
     this.ManufacturingDate = SQLUtil.ConvertDateTime(dr["ManufacturingDate"]);
     this.FixedAsset        = SQLUtil.ConvertBoolean(dr["FixedAsset"]);
     this.AssetCode         = SQLUtil.TrimNull(dr["AssetCode"]);
     this.AssetLevel.ID     = SQLUtil.ConvertInt(dr["AssetLevel"]);
     this.AssetLevel.Name   = AssetLevels.GetAssetLevelDesc(this.AssetLevel.ID);
     this.DepreciationYears = SQLUtil.ConvertInt(dr["DepreciationYears"]);
     this.ValidityStartDate = SQLUtil.ConvertDateTime(dr["ValidityStartDate"]);
     this.ValidityEndDate   = SQLUtil.ConvertDateTime(dr["ValidityEndDate"]);
     this.SaleContractName  = SQLUtil.TrimNull(dr["SaleContractName"]);
     this.Supplier.ID       = SQLUtil.ConvertInt(dr["SupplierID"]);
     if (dr.Table.Columns.Contains("SupplierName"))
     {
         this.Supplier.Name = SQLUtil.TrimNull(dr["SupplierName"]);
     }
     this.PurchaseWay              = SQLUtil.TrimNull(dr["PurchaseWay"]);
     this.PurchaseAmount           = SQLUtil.ConvertDouble(dr["PurchaseAmount"]);
     this.PurchaseDate             = SQLUtil.ConvertDateTime(dr["PurchaseDate"]);
     this.IsImport                 = SQLUtil.ConvertBoolean(dr["IsImport"]);
     this.Department.ID            = SQLUtil.ConvertInt(dr["DepartmentID"]);
     this.Department.Name          = Manager.LookupManager.GetDepartmentDesc(this.Department.ID);
     this.InstalSite               = SQLUtil.TrimNull(dr["InstalSite"]);
     this.InstalDate               = SQLUtil.ConvertDateTime(dr["InstalDate"]);
     this.UseageDate               = SQLUtil.ConvertDateTime(dr["UseageDate"]);
     this.Accepted                 = SQLUtil.ConvertBoolean(dr["Accepted"]);
     this.AcceptanceDate           = SQLUtil.ConvertDateTime(dr["AcceptanceDate"]);
     this.UsageStatus.ID           = SQLUtil.ConvertInt(dr["UsageStatusID"]);
     this.UsageStatus.Name         = Manager.LookupManager.GetUsageStatusDesc(this.UsageStatus.ID);
     this.EquipmentStatus.ID       = SQLUtil.ConvertInt(dr["EquipmentStatusID"]);
     this.EquipmentStatus.Name     = Manager.LookupManager.GetEquipmentStatusDesc(this.EquipmentStatus.ID);
     this.ScrapDate                = SQLUtil.ConvertDateTime(dr["ScrapDate"]);
     this.MaintenancePeriod        = SQLUtil.ConvertInt(dr["MaintenancePeriod"]);
     this.MaintenanceType.ID       = SQLUtil.ConvertInt(dr["MaintenanceTypeID"]);
     this.MaintenanceType.Name     = Manager.LookupManager.GetPeriodTypeDesc(this.MaintenanceType.ID);
     this.LastMaintenanceDate      = SQLUtil.ConvertDateTime(dr["LastMaintenanceDate"]);
     this.PatrolPeriod             = SQLUtil.ConvertInt(dr["PatrolPeriod"]);
     this.PatrolType.ID            = SQLUtil.ConvertInt(dr["PatrolTypeID"]);
     this.PatrolType.Name          = Manager.LookupManager.GetPeriodTypeDesc(this.PatrolType.ID);
     this.LastPatrolDate           = SQLUtil.ConvertDateTime(dr["LastPatrolDate"]);
     this.CorrectionPeriod         = SQLUtil.ConvertInt(dr["CorrectionPeriod"]);
     this.CorrectionType.ID        = SQLUtil.ConvertInt(dr["CorrectionTypeID"]);
     this.CorrectionType.Name      = Manager.LookupManager.GetPeriodTypeDesc(this.CorrectionType.ID);
     this.LastCorrectionDate       = SQLUtil.ConvertDateTime(dr["LastCorrectionDate"]);
     this.MandatoryTestStatus.ID   = SQLUtil.ConvertInt(dr["MandatoryTestStatus"]);
     this.MandatoryTestStatus.Name = MandatoryTestStatuses.GetMandatoryTestStatusDesc(this.MandatoryTestStatus.ID);
     this.MandatoryTestDate        = SQLUtil.ConvertDateTime(dr["MandatoryTestDate"]);
     this.RecallFlag               = SQLUtil.ConvertBoolean(dr["RecallFlag"]);
     this.RecallDate               = SQLUtil.ConvertDateTime(dr["RecallDate"]);
     this.CreateDate               = SQLUtil.ConvertDateTime(dr["CreateDate"]);
     this.CreateUser.ID            = SQLUtil.ConvertInt(dr["CreateUserID"]);
     this.UpdateDate               = SQLUtil.ConvertDateTime(dr["UpdateDate"]);
     if (dr.Table.Columns.Contains("ScopeID"))
     {
         this.ContractScope.ID   = SQLUtil.ConvertInt(dr["ScopeID"]);
         this.ContractScope.Name = this.ContractScope.ID == 0 ? "" : Manager.LookupManager.GetContractScopeDesc(this.ContractScope.ID);
         if (this.ContractScope.ID == ContractInfo.Scopes.Other)
         {
             this.ContractScope.Name = SQLUtil.TrimNull(dr["ScopeComments"]);
         }
     }
     if (dr.Table.Columns.Contains("ContractID"))
     {
         this.WarrantyStatus = SQLUtil.ConvertInt(dr["ContractID"]) == 0 ? "保外" : "保内";
     }
     if (dr.Table.Columns.Contains("ConfigLicenceID"))
     {
         this.ConfigLicenceID = SQLUtil.ConvertInt(dr["ConfigLicenceID"]);
     }
     if (dr.Table.Columns.Contains("ConfigLicenceName"))
     {
         this.ConfigLicenceName = SQLUtil.TrimNull(dr["ConfigLicenceName"]);
     }
 }