private void AddTaskResource(string resCode, string resName, decimal price, decimal quanity, string taskId, List <string> errors) { Resource byId = Resource.GetById(Resource.GetResourceId(resCode)); if (byId != null) { TaskResource taskResource = new TaskResource { Resource = byId, InputUser = this.inputUser, InputDate = new DateTime?(DateTime.Now), Price = price, Quantity = quanity }; BudTask.AddResource(taskId, taskResource); } else { string item = "资源编号:" + resCode + " 在资源库不存在,已添加到资源映射!"; if (!errors.Contains(item)) { errors.Add(item); ResourceTemp.Add(ResourceTemp.Create(string.Empty, taskId, resCode, resName, new decimal?(price), new decimal?(quanity), new decimal?(price * quanity), this.prjId)); } } }
public void AddConResource(string[] colArray, string inputUser, List <string> errors, string prjId) { IDictionary <string, int> relation = ExcelUtility.GetRelation(colArray); this.ParseResourceTable(relation); string name = string.Empty; string brand = string.Empty; string specification = string.Empty; string modelNumber = string.Empty; string str5 = string.Empty; decimal resPrice = 0M; decimal resQuantity = 0M; 0; string str6 = string.Empty; string item = string.Empty; string str8 = string.Empty; foreach (DataRow row in this.dtResource.Rows) { name = (row[this.nameIndex] == null) ? null : row[this.nameIndex].ToString(); if (this.taskCodeIndex != -1) { str6 = (row[this.taskCodeIndex] == null) ? null : row[this.taskCodeIndex].ToString().Trim(); } if (this.serialNoIndex != -1) { str8 = (row[this.serialNoIndex] == null) ? null : row[this.serialNoIndex].ToString().Trim(); } if (this.brandIndex != -1) { brand = row[this.brandIndex].ToString(); } if (this.specificationIndex != -1) { specification = row[this.specificationIndex].ToString().Trim(); } if (this.ModelNumberIndex != -1) { modelNumber = row[this.ModelNumberIndex].ToString().Trim(); } if (this.technicalParameterIndex != -1) { row[this.technicalParameterIndex].ToString().Trim(); } if ((this.unitIndex != -1) && (row[this.unitIndex].ToString().Trim().Length == 0)) { str5 = null; } if (this.unitPriceIndex != -1) { try { resPrice = decimal.Parse(row[this.unitPriceIndex].ToString()); } catch { if (!string.IsNullOrEmpty(str6)) { item = "在您的Excel中:任务编码" + str6 + ",存在非有效数字,请修改!"; } else { item = "在您的Excel中:序号" + str8 + ",存在非有效数字,请修改!"; } errors.Add(item); } } if (this.quantityIndex != -1) { try { resQuantity = decimal.Parse(row[this.quantityIndex].ToString()); } catch { if (!string.IsNullOrEmpty(str6)) { item = "在您的Excel中:任务编码" + str6 + ",存在非有效数字,请修改!"; } else { item = "在您的Excel中:序号" + str8 + ",存在非有效数字,请修改!"; } errors.Add(item); } } if (this.noteIndex != -1) { row[this.noteIndex].ToString().Trim(); } if (this.codeIndex != -1) { row[this.codeIndex].ToString(); } if (this.amountIndex != -1) { try { new decimal?(decimal.Parse(row[this.amountIndex].ToString())); } catch { if (!string.IsNullOrEmpty(str6)) { item = "在您的Excel中:任务编码" + str6 + ",存在非有效数字,请修改!"; } else { item = "在您的Excel中:序号" + str8 + ",存在非有效数字,请修改!"; } errors.Add(item); } } string str9 = Resource.GetResourceId(name, specification, modelNumber, brand); string taskId = string.Empty; if (string.IsNullOrEmpty(str9)) { if (!string.IsNullOrEmpty(str6)) { item = "在您的Excel中:任务编码" + str6 + ",在资源库中不存在,请修改!"; } else { item = "在您的Excel中:序号" + str8 + ",在资源库中不存在,请修改!"; } errors.Add(item); try { if (!string.IsNullOrEmpty(str6)) { taskId = this.GetRelationTaskId(str6); } if (!string.IsNullOrEmpty(str8)) { taskId = this.GetRelationTaskId(str8); } } catch { } } else { try { if (!string.IsNullOrEmpty(str6)) { taskId = this.GetRelationTaskId(str6); } if (!string.IsNullOrEmpty(str8)) { taskId = this.GetRelationTaskId(str8); } if (!cn.justwin.Domain.BudContractTask.IsLeaf(taskId)) { if (!string.IsNullOrEmpty(str6)) { item = "在您的Excel中:任务编码" + str6 + ",不允许配置资源,请修改!"; } else { item = "在您的Excel中:序号" + str8 + ",不允许配置资源,请修改!"; } errors.Add(item); } else if (!string.IsNullOrEmpty(taskId)) { decimal?repeatResQuantity = cn.justwin.Domain.BudContractResource.GetRepeatResQuantity(str9, taskId); if (!repeatResQuantity.HasValue) { cn.justwin.Domain.BudContractResource.Add(cn.justwin.Domain.BudContractResource.Create(Guid.NewGuid().ToString(), taskId, str9, resPrice, resQuantity, inputUser, DateTime.Now)); } else { this.MergeResQuantity(taskId, str9, repeatResQuantity, resQuantity); } } } catch { if (!string.IsNullOrEmpty(str6)) { item = "在您的Excel中:任务编码" + str6 + ",在WBS信息中的不存在,请修改!"; } else { item = "在您的Excel中:序号" + str8 + ",在WBS信息中的不存在,请修改!"; } errors.Add(item); } } } BudTaskServices.codeAndTaskId.Clear(); }