/// <summary> /// 获取合同信息 /// </summary> /// <param name="dr">dataRow</param> public ContractInfo(DataRow dr) : this() { this.ID = SQLUtil.ConvertInt(dr["ID"]); this.ContractNum = SQLUtil.TrimNull(dr["ContractNum"]); this.Name = SQLUtil.TrimNull(dr["Name"]); this.Type.ID = SQLUtil.ConvertInt(dr["TypeID"]); this.Type.Name = Manager.LookupManager.GetContractTypeDesc(this.Type.ID); this.Scope.ID = SQLUtil.ConvertInt(dr["ScopeID"]); this.Scope.Name = LookupManager.GetContractScopeDesc(this.Scope.ID); this.ScopeComments = SQLUtil.TrimNull(dr["ScopeComments"]); this.Amount = SQLUtil.ConvertDouble(dr["Amount"]); this.ProjectNum = SQLUtil.TrimNull(dr["ProjectNum"]); this.StartDate = SQLUtil.ConvertDateTime(dr["StartDate"]); this.EndDate = SQLUtil.ConvertDateTime(dr["EndDate"]); this.Comments = SQLUtil.TrimNull(dr["Comments"]); this.Supplier.ID = SQLUtil.ConvertInt(dr["SupplierID"]); this.Supplier.Name = SQLUtil.TrimNull(dr["supplierName"]); }
/// <summary> /// 获取修改的字段 /// </summary> /// <param name="newInfo">修改后的信息</param> /// <returns>修改的字段</returns> public DataTable GetChangedFields(ContractInfo newInfo) { DataTable dt = new DataTable(); dt.Columns.Add("FieldName"); dt.Columns.Add("OldValue"); dt.Columns.Add("NewValue"); if (this.Supplier.ID != newInfo.Supplier.ID) { dt.Rows.Add("SupplierName", this.Supplier.Name, newInfo.Supplier.Name); } if (GetStringFromObjectList(this.Equipments, "OID") != GetStringFromObjectList(newInfo.Equipments, "OID")) { dt.Rows.Add("EquipmentID", GetStringFromObjectList(this.Equipments, "OID"), GetStringFromObjectList(newInfo.Equipments, "OID")); } if (this.ContractNum != SQLUtil.TrimNull(newInfo.ContractNum)) { dt.Rows.Add("ContractNum", this.ContractNum, newInfo.ContractNum == null ? "" : newInfo.ContractNum); } if (this.Name != SQLUtil.TrimNull(newInfo.Name)) { dt.Rows.Add("ContractName", this.Name, newInfo.Name == null ? "" : newInfo.Name); } if (this.Type.ID != newInfo.Type.ID) { dt.Rows.Add("TypeDesc", this.Type.Name, Manager.LookupManager.GetContractTypeDesc(newInfo.Type.ID)); } if (this.Scope.ID != newInfo.Scope.ID) { dt.Rows.Add("ScopeDesc", this.Scope.Name, LookupManager.GetContractScopeDesc(newInfo.Scope.ID)); } if (this.ScopeComments != SQLUtil.TrimNull(newInfo.ScopeComments)) { dt.Rows.Add("ScopeComments", this.ScopeComments, newInfo.ScopeComments == null ? "" : newInfo.ScopeComments); } if (this.Amount != newInfo.Amount) { dt.Rows.Add("Amount", this.Amount, newInfo.Amount); } if (this.ProjectNum != SQLUtil.TrimNull(newInfo.ProjectNum)) { dt.Rows.Add("ProjectNum", this.ProjectNum, newInfo.ProjectNum == null ? "" : newInfo.ProjectNum); } if (this.StartDate != newInfo.StartDate) { dt.Rows.Add("ContractStartDate", SQLUtil.ConvertDateTime(this.StartDate) == DateTime.MinValue ? "" : this.StartDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.StartDate) == DateTime.MinValue ? "" : newInfo.StartDate.ToString("yyyy-MM-dd")); } if (this.EndDate != newInfo.EndDate) { dt.Rows.Add("ContractEndDate", SQLUtil.ConvertDateTime(this.EndDate) == DateTime.MinValue ? "" : this.EndDate.ToString("yyyy-MM-dd"), SQLUtil.ConvertDateTime(newInfo.EndDate) == DateTime.MinValue ? "" : newInfo.EndDate.ToString("yyyy-MM-dd")); } if (this.Comments != SQLUtil.TrimNull(newInfo.Comments)) { dt.Rows.Add("ContractComments", this.Comments, newInfo.Comments == null ? "" : newInfo.Comments); } return(dt); }