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); }
public List <BudModifyTask> GetInModifyTask(string taskId) { BudModifyService service = new BudModifyService(); return((from mt in this join m in service on mt.ModifyId equals m.ModifyId into m where (mt.TaskId == taskId) && (mt.ModifyType == 1) select mt).ToList <BudModifyTask>()); }
public string GetOrderNumber(string prjId, string parentId) { string str = "001"; BudModifyService source = new BudModifyService(); if (string.IsNullOrEmpty(parentId)) { int num; int.TryParse((from mts in this join ms in source.AsQueryable <BudModify>() on mts.ModifyId equals ms.ModifyId into ms where (ms.PrjId == prjId) && (mts.TaskId == null) select mts.OrderNumber).Max <string>(), out num); string str2 = (num + 1).ToString(); if (str2.Length == 1) { str2 = "00" + str2; } if (str2.Length == 2) { str2 = "0" + str2; } return(str2); } IQueryable <string> queryable2 = from mts in this where mts.ParentId == parentId select mts.OrderNumber; if (queryable2.Count <string>() > 0) { string str3 = queryable2.Max <string>(); string str4 = str3.Substring(0, str3.Length - 3); string str6 = (Convert.ToInt32(str3.Substring(str3.Length - 3, 3)) + 1).ToString(); if (str6.Length == 1) { str6 = "00" + str6; } if (str6.Length == 2) { str6 = "0" + str6; } return(str4 + str6); } IQueryable <string> queryable3 = from mts in this where mts.ModifyTaskId == parentId select mts.OrderNumber; if (queryable3.Count <string>() > 0) { str = queryable3.First <string>() + "001"; } return(str); }
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 BudTask GetTaskById(string taskId) { BudTask task = (from t in this where t.TaskId == taskId select t).FirstOrDefault <BudTask>(); if (task == null) { BudModifyTask byTaskId = new BudModifyTaskService().GetByTaskId(taskId); if (byTaskId != null) { BudModify byId = new BudModifyService().GetById(byTaskId.ModifyId); task = new BudTask { TaskId = byTaskId.ModifyTaskId, ParentId = byTaskId.TaskId, OrderNumber = byTaskId.OrderNumber, Version = 1, PrjId = byId.PrjId, TaskCode = byTaskId.ModifyTaskCode, TaskName = byTaskId.ModifyTaskContent, Unit = byTaskId.Unit, Quantity = new decimal?(byTaskId.Quantity), UnitPrice = new decimal?(byTaskId.UnitPrice), Total = new decimal?(byTaskId.Total), StartDate = byTaskId.StartDate, EndDate = byTaskId.EndDate, ConstructionPeriod = byTaskId.ConstructionPeriod, Note = byTaskId.Note, InputDate = DateTime.Now, InputUser = byId.InputUser, TaskType = string.Empty, IsValid = true, Total2 = byTaskId.Total2 }; } } return(task); }
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); }