public BudTask GetBudTask(string taskId) { BudModifyService service = new BudModifyService(); BudModifyTask byId = this.GetById(taskId); BudTask task2 = new BudTask(); if (byId != null) { BudModify modify = service.GetById(byId.ModifyId); task2.TaskId = byId.ModifyTaskId; task2.ParentId = byId.TaskId; task2.OrderNumber = byId.OrderNumber; task2.Version = 1; task2.PrjId = modify.PrjId; task2.TaskCode = byId.ModifyTaskCode; task2.TaskName = byId.ModifyTaskContent; task2.Unit = byId.Unit; task2.Quantity = new decimal?(byId.Quantity); task2.UnitPrice = new decimal?(byId.UnitPrice); task2.Total = new decimal?(byId.Total); task2.StartDate = byId.StartDate; task2.EndDate = byId.EndDate; task2.ConstructionPeriod = byId.ConstructionPeriod; task2.Note = byId.Note; task2.InputDate = DateTime.Now; task2.InputUser = modify.InputUser; task2.TaskType = string.Empty; task2.IsValid = true; } //List<BudModifyTask> inModifyTask = this.GetInModifyTask(taskId); DataSet dsTask = this.GetInModifyTask2(taskId); //if (inModifyTask != null) if (dsTask.Tables[0].Rows.Count > 0) { //foreach (BudModifyTask task3 in inModifyTask) foreach (DataRow dr in dsTask.Tables[0].Rows) { decimal?quantity = task2.Quantity; decimal num3 = Convert.ToDecimal(dr["Quantity"]); //task3.Quantity; task2.Quantity = quantity.HasValue ? new decimal?(quantity.GetValueOrDefault() + num3) : null; decimal?total = task2.Total; decimal num4 = Convert.ToDecimal(dr["Total"]); //task3.Total; task2.Total = total.HasValue ? new decimal?(total.GetValueOrDefault() + num4) : null; } decimal num = 0M; decimal num2 = 0M; if (task2.Total.HasValue) { num2 = 0M; } if (task2.Quantity.HasValue && (task2.Quantity.Value != 0M)) { num = num2 / task2.Quantity.Value; } task2.UnitPrice = new decimal?(num); } return(task2); }
private List <BudTaskResource> GetAllRes(string prjId, int version) { List <BudTaskResource> list = (from taskRes in this join task in this.tSer on taskRes.TaskId equals task.TaskId where (task.PrjId == prjId) && (task.TaskType == "") select taskRes).ToList <BudTaskResource>(); BudModifyTaskResService service = new BudModifyTaskResService(); BudModifyTaskService service2 = new BudModifyTaskService(); BudModifyService service3 = new BudModifyService(); using (List <BudModifyTaskRes> .Enumerator enumerator = (from mtr in service join mt in service2 on mtr.ModifyTaskId equals mt.ModifyTaskId join m in service3 on mt.ModifyId equals m.ModifyId where (m.PrjId == prjId) && (m.Flowstate == 1) select mtr).ToList <BudModifyTaskRes>().GetEnumerator()) { BudModifyTaskRes modifyTaskRes; while (enumerator.MoveNext()) { modifyTaskRes = enumerator.Current; BudModify byId = service3.GetById(modifyTaskRes.ModifyId); BudModifyTask task = (from mts in service2 where mts.ModifyTaskId == modifyTaskRes.ModifyTaskId select mts).FirstOrDefault <BudModifyTask>(); BudTaskResource item = new BudTaskResource { TaskResourceId = modifyTaskRes.ModifyTaskResId }; if (task.ModifyType == 0) { item.TaskId = modifyTaskRes.ModifyTaskId; } else { item.TaskId = task.TaskId; } item.ResourceId = modifyTaskRes.ResourceId; item.ResourceQuantity = new decimal?(modifyTaskRes.ResourceQuantity); item.ResourcePrice = new decimal?(modifyTaskRes.ResourcePrice); item.InputDate = DateTime.Now; item.InputUser = byId.InputUser; item.PrjGuid = prjId; item.Versions = new int?(version); list.Add(item); } } return(list); }
public IList <BudTask> GetByProject(string prjId, int level = 0x3e7) { int orderNumberLen = level * 3; List <BudTask> source = (from t in this where ((t.PrjId == prjId) && (t.TaskType == string.Empty)) && (t.OrderNumber.Length <= orderNumberLen) orderby t.OrderNumber select t).ToList <BudTask>(); BudModifyTaskService service = new BudModifyTaskService(); BudModifyService service2 = new BudModifyService(); foreach (BudModifyTask task in (from mt in service join m in service2 on mt.ModifyId equals m.ModifyId where ((m.PrjId == prjId) && (m.Flowstate == 1)) && (mt.ModifyType == 0) select mt).ToList <BudModifyTask>()) { BudModify byId = service2.GetById(task.ModifyId); BudTask item = new BudTask { TaskId = task.ModifyTaskId, ParentId = task.TaskId, OrderNumber = task.OrderNumber, Version = 1, PrjId = prjId, TaskCode = task.ModifyTaskCode, TaskName = task.ModifyTaskContent, Unit = task.Unit, Quantity = new decimal?(task.Quantity), UnitPrice = new decimal?(task.UnitPrice), Total = new decimal?(task.Total), StartDate = task.StartDate, EndDate = task.EndDate, ConstructionPeriod = task.ConstructionPeriod, Note = task.Note, InputDate = DateTime.Now, InputUser = byId.InputUser, TaskType = string.Empty, IsValid = true }; source.Add(item); } using (List <BudModifyTask> .Enumerator enumerator2 = (from mt in service join m in service2 on mt.ModifyId equals m.ModifyId where ((m.PrjId == prjId) && (m.Flowstate == 1)) && (mt.ModifyType == 1) select mt).ToList <BudModifyTask>().GetEnumerator()) { Func <BudTask, bool> predicate = null; BudModifyTask modifyTask; while (enumerator2.MoveNext()) { modifyTask = enumerator2.Current; if (predicate == null) { predicate = t => t.TaskId == modifyTask.TaskId; } BudTask task3 = source.Where <BudTask>(predicate).FirstOrDefault <BudTask>(); if (task3 != null) { decimal?quantity = task3.Quantity; decimal num = modifyTask.Quantity; task3.Quantity = quantity.HasValue ? new decimal?(quantity.GetValueOrDefault() + num) : null; decimal?total = task3.Total; decimal num2 = modifyTask.Total; task3.Total = total.HasValue ? new decimal?(total.GetValueOrDefault() + num2) : null; } } } return(source); }