/// <summary> /// 零件info /// </summary> /// <param name="dr">dr</param> public ComponentInfo(DataRow dr) : this() { this.ID = SQLUtil.ConvertInt(dr["ID"]); this.FujiClass2.ID = SQLUtil.ConvertInt(dr["FujiClass2ID"]); this.FujiClass2.Name = SQLUtil.TrimNull(dr["FujiClass2Name"]); this.Name = SQLUtil.TrimNull(dr["Name"]); this.Description = SQLUtil.TrimNull(dr["Description"]); this.Type.ID = SQLUtil.ConvertInt(dr["TypeID"]); this.Type.Name = LookupManager.GetComponentTypeDesc(this.Type.ID); this.StdPrice = SQLUtil.ConvertDouble(dr["StdPrice"]); this.Usage = SQLUtil.ConvertInt(dr["Usage"]); this.TotalSeconds = SQLUtil.ConvertInt(dr["TotalSeconds"]); this.SecondsPer = SQLUtil.ConvertDouble(dr["SecondsPer"]); this.IsIncluded = SQLUtil.ConvertBoolean(dr["IsIncluded"]); this.IncludeContract = SQLUtil.ConvertBoolean(dr["IncludeContract"]); this.Method = SQLUtil.ConvertEnum <FujiClass2Info.Method>(dr["MethodID"]); this.LifeTime = SQLUtil.ConvertInt(dr["LifeTime"]); this.IsActive = SQLUtil.ConvertBoolean(dr["IsActive"]); this.AddDate = SQLUtil.ConvertDateTime(dr["AddDate"]); this.UpdateDate = SQLUtil.ConvertDateTime(dr["UpdateDate"]); }
/// <summary> /// 零件库info /// </summary> /// <param name="dr">dr</param> public InvComponentInfo(DataRow dr) : this() { if (dr.Table.Columns.Contains("ID")) { this.ID = SQLUtil.ConvertInt(dr["ID"]); } this.Component.ID = SQLUtil.ConvertInt(dr["ComponentID"]); if (dr.Table.Columns.Contains("ComponentName")) { this.Component.Name = SQLUtil.TrimNull(dr["ComponentName"]); } if (dr.Table.Columns.Contains("ComponentDescription")) { this.Component.Description = SQLUtil.TrimNull(dr["ComponentDescription"]); } if (dr.Table.Columns.Contains("ComponentTypeID")) { this.Component.Type.ID = SQLUtil.ConvertInt(dr["ComponentTypeID"]); this.Component.Type.Name = LookupManager.GetComponentTypeDesc(this.Component.Type.ID); } this.Equipment.ID = SQLUtil.ConvertInt(dr["EquipmentID"]); if (dr.Table.Columns.Contains("EquipmentName")) { this.Equipment.Name = SQLUtil.TrimNull(dr["EquipmentName"]); } if (dr.Table.Columns.Contains("EquipmentFujiClass2ID")) { this.Equipment.FujiClass2.ID = SQLUtil.ConvertInt(dr["EquipmentFujiClass2ID"]); } if (dr.Table.Columns.Contains("SerialCode")) { this.SerialCode = SQLUtil.TrimNull(dr["SerialCode"]); } this.Specification = SQLUtil.TrimNull(dr["Specification"]); this.Model = SQLUtil.TrimNull(dr["Model"]); if (dr.Table.Columns.Contains("SupplierID")) { this.Supplier.ID = SQLUtil.ConvertInt(dr["SupplierID"]); } if (dr.Table.Columns.Contains("SupplierName")) { this.Supplier.Name = SQLUtil.TrimNull(dr["SupplierName"]); } this.Price = SQLUtil.ConvertDouble(dr["Price"]); if (dr.Table.Columns.Contains("PurchaseDate")) { this.PurchaseDate = SQLUtil.ConvertDateTime(dr["PurchaseDate"]); } this.Purchase.ID = SQLUtil.ConvertInt(dr["PurchaseID"]); this.Purchase.Name = LookupManager.GetObjectOID(ObjectTypes.PurchaseOrder, this.Purchase.ID); if (dr.Table.Columns.Contains("Comments")) { this.Comments = SQLUtil.TrimNull(dr["Comments"]); } if (dr.Table.Columns.Contains("AddDate")) { this.AddDate = SQLUtil.ConvertDateTime(dr["AddDate"]); } if (dr.Table.Columns.Contains("UpdateDate")) { this.UpdateDate = SQLUtil.ConvertDateTime(dr["UpdateDate"]); } if (dr.Table.Columns.Contains("StatusID")) { this.Status.ID = SQLUtil.ConvertInt(dr["StatusID"]); this.Status.Name = ComponentStatus.GetTypeDesc(this.Status.ID); } if (dr.Table.Columns.Contains("Qty")) { this.Qty = SQLUtil.ConvertInt(dr["Qty"]); } if (dr.Table.Columns.Contains("InboundQty")) { this.InboundQty = SQLUtil.ConvertInt(dr["InboundQty"]); } }
/// <summary> /// 更新日志 /// </summary> /// <param name="newInfo">修改后的零件信息</param> /// <param name="user">操作者</param> /// <returns>日志信息</returns> public AuditHdrInfo ConvertAudit(ComponentInfo newInfo, UserInfo user) { AuditHdrInfo audit = new AuditHdrInfo(); audit.ObjectType.ID = ObjectTypes.Component; audit.ObjectID = this.ID; audit.Operation.ID = AuditHdrInfo.AuditOperations.Update; audit.TransUser = user; List <AuditDetailInfo> infos = audit.DetailInfo; if (this.FujiClass2.ID != newInfo.FujiClass2.ID) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentFujiClass2", OldValue = this.FujiClass2.Name, NewValue = newInfo.FujiClass2.Name }); } if (this.Name != SQLUtil.TrimNull(newInfo.Name)) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentName", OldValue = this.Name, NewValue = newInfo.Name }); } if (this.Description != SQLUtil.TrimNull(newInfo.Description)) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentDescription", OldValue = this.Description, NewValue = newInfo.Description }); } if (this.Type.ID != newInfo.Type.ID) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentType", OldValue = this.Type.Name, NewValue = LookupManager.GetComponentTypeDesc(newInfo.Type.ID) }); } if (this.StdPrice != newInfo.StdPrice) { infos.Add(new AuditDetailInfo() { FieldName = "CompomemtStdPrice", OldValue = this.StdPrice.ToString(), NewValue = newInfo.StdPrice.ToString() }); } if (this.Usage != newInfo.Usage) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentUsage", OldValue = this.Usage.ToString(), NewValue = newInfo.Usage.ToString() }); } if (this.Method != newInfo.Method) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentMethodID", OldValue = this.Method.GetDescription(), NewValue = newInfo.Method.GetDescription() }); } if (this.TotalSeconds != newInfo.TotalSeconds) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentTotalSeconds", OldValue = this.TotalSeconds.ToString(), NewValue = newInfo.TotalSeconds.ToString() }); } if (this.SecondsPer != newInfo.SecondsPer) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentSecondsPer", OldValue = this.SecondsPer.ToString(), NewValue = newInfo.SecondsPer.ToString() }); } if (this.IsIncluded != newInfo.IsIncluded) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentIsIncluded", OldValue = this.IsIncluded ? "是" : "否", NewValue = newInfo.IsIncluded ? "是" : "否" }); } if (this.IncludeContract != newInfo.IncludeContract) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentIncludeContract", OldValue = this.IncludeContract ? "是" : "否", NewValue = newInfo.IncludeContract ? "是" : "否", }); } if (this.IsActive != newInfo.IsActive) { infos.Add(new AuditDetailInfo() { FieldName = "ComponentIsActive", OldValue = this.IsActive ? "是" : "否", NewValue = newInfo.IsActive ? "是" : "否" }); } return(audit); }
/// <summary> /// 获取修改的字段(日志) /// </summary> /// <param name="newInfo">修改后的信息</param> /// <returns>修改字段dt</returns> public DataTable GetChangedFields(ComponentInfo newInfo) { DataTable dt = new DataTable(); dt.Columns.Add("FieldName"); dt.Columns.Add("OldValue"); dt.Columns.Add("NewValue"); if (this.FujiClass2.ID != newInfo.FujiClass2.ID) { dt.Rows.Add("ComponentFujiClass2", SQLUtil.TrimNull(this.FujiClass2.Name), SQLUtil.TrimNull(newInfo.FujiClass2.Name)); } if (this.Name != SQLUtil.TrimNull(newInfo.Name)) { dt.Rows.Add("ComponentName", this.Name, newInfo.Name); } if (this.Description != SQLUtil.TrimNull(newInfo.Description)) { dt.Rows.Add("ComponentDescription", this.Description, SQLUtil.TrimNull(newInfo.Description)); } if (this.Type.ID != newInfo.Type.ID) { dt.Rows.Add("ComponentType", this.Type.Name, LookupManager.GetComponentTypeDesc(newInfo.Type.ID)); } if (this.StdPrice != newInfo.StdPrice) { dt.Rows.Add("CompomemtStdPrice", SQLUtil.ConvertDouble(this.StdPrice), SQLUtil.ConvertDouble(newInfo.StdPrice)); } if (this.Usage != newInfo.Usage) { dt.Rows.Add("ComponentUsage", SQLUtil.ConvertInt(this.Usage), SQLUtil.ConvertInt(newInfo.Usage)); } if (this.TotalSeconds != newInfo.TotalSeconds) { dt.Rows.Add("ComponentTotalSeconds", SQLUtil.ConvertDouble(this.TotalSeconds), SQLUtil.ConvertDouble(newInfo.TotalSeconds)); } if (this.SecondsPer != newInfo.SecondsPer) { dt.Rows.Add("ComponentSecondsPer", SQLUtil.ConvertDouble(this.SecondsPer), SQLUtil.ConvertDouble(newInfo.SecondsPer)); } if (this.IsIncluded != newInfo.IsIncluded) { dt.Rows.Add("ComponentIsIncluded", SQLUtil.ConvertBoolean(this.IsIncluded) ? "是" : "否", SQLUtil.ConvertBoolean(newInfo.IsIncluded) ? "是" : "否"); } if (this.IncludeContract != newInfo.IncludeContract) { dt.Rows.Add("ComponentIncludeContract", SQLUtil.ConvertBoolean(this.IncludeContract) ? "是" : "否", SQLUtil.ConvertBoolean(newInfo.IncludeContract) ? "是" : "否"); } if (this.Method != newInfo.Method) { dt.Rows.Add("ComponentMethodID", this.Method.GetDescription(), newInfo.Method.GetDescription()); } if (this.IsActive != newInfo.IsActive) { dt.Rows.Add("ComponentIsActive", SQLUtil.ConvertBoolean(this.IsActive) ? "启用" : "停用", SQLUtil.ConvertBoolean(newInfo.IsActive) ? "启用" : "停用"); } return(dt); }