protected void btnSave_ServerClick(object sender, System.EventArgs e) { try { BudTemplateItem byId = BudTemplateItem.GetById(this.itemId, this.tempId); System.Collections.Generic.List <TaskResource> resources = new System.Collections.Generic.List <TaskResource>(); byId.Resources = resources; for (int i = 0; i < this.gvResource.Rows.Count; i++) { cn.justwin.Domain.Resource byId2 = cn.justwin.Domain.Resource.GetById(this.gvResource.DataKeys[i].Values[0].ToString()); decimal quantity = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtNumber")).Text); decimal price = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtPrice")).Text); decimal lossCoefficient = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtLossCoefficient")).Text); byId.AddResource(byId2, quantity, price, PageHelper.QueryUser(this, base.UserCode), System.DateTime.Now, "save", lossCoefficient); } BudTemplateItem.AddResource(byId); base.RegisterScript("$('#btnBindResource').hide(); top.ui.show('保存成功!')"); base.RegisterScript(string.Concat(new string[] { "winclose('ResourceList', 'BudTemplateList.aspx?tempId=", this.tempId, "&tempType=", this.tempType, "', true)" })); this.BindGv(); } catch (System.Exception) { } }
public System.Collections.Generic.List <BudTemplateItem> ChangeId(System.Collections.Generic.List <string> lstIds, string templateId) { System.Collections.Generic.List <BudTemplateItem> list = new System.Collections.Generic.List <BudTemplateItem>(); foreach (string current in lstIds) { BudTemplateItem byId = BudTemplateItem.GetById(current, templateId); list.Add(byId); } foreach (string current2 in lstIds) { string text = System.Guid.NewGuid().ToString(); foreach (BudTemplateItem current3 in list) { if (current3.Id == current2) { current3.Id = text; } if (current3.ParentId == current2) { current3.ParentId = text; } } } return(list); }
public System.Collections.Generic.List <string> GetOrderNumbers(System.Collections.Generic.List <string> lstIds) { System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); foreach (string current in lstIds) { string orderNumber = BudTemplateItem.GetById(current, this.tvBudget.SelectedValue).OrderNumber; list.Add(orderNumber); } list.Sort(); return(list); }
protected void BindHtmlData() { string text = base.Request["type"]; string text2 = base.Request["id"]; if (text.ToLower() == "edit") { string a = base.Request["page"]; if (a == "BudTemplateList.aspx") { BudTemplateItem byId = BudTemplateItem.GetById(text2, base.Request["tempType"]); if (byId != null) { this.txtTaskCode.Text = byId.Code; this.ViewState["oldCode"] = byId.Code; this.txtTaskName.Text = byId.Name; this.txtUnit.Text = byId.Unit; this.txtQuantity.Text = byId.Quantity.ToString(); this.ddlTaskType.SelectedValue = byId.Layer.ToString(); this.txtNote.Text = byId.Note; this.txtDescription.Text = byId.FeatureDescription; } } else { if (a == "BudgetPlaitList.aspx" || a == "BudgetChange.aspx") { cn.justwin.Domain.Entities.BudTask budTask = null; BudTaskService budTaskService = new BudTaskService(); string arg_145_0 = string.Empty; if (text.ToLower() == "edit") { budTask = budTaskService.GetById(text2); } if (budTask != null) { this.txtTaskCode.Text = budTask.TaskCode; this.ViewState["oldCode"] = budTask.TaskCode; this.txtTaskName.Text = budTask.TaskName; this.txtStartDate.Text = ((!budTask.StartDate.HasValue) ? string.Empty : budTask.StartDate.Value.ToString("yyyy-M-d")); this.txtEndDate.Text = ((!budTask.EndDate.HasValue) ? string.Empty : budTask.EndDate.Value.ToString("yyyy-M-d")); if (budTask.ConstructionPeriod.HasValue) { this.txtConstructionPeriod.Text = budTask.ConstructionPeriod.Value.ToString(); } this.txtUnit.Text = budTask.Unit; this.txtQuantity.Text = budTask.Quantity.ToString(); this.txtUnitPrice.Text = ((!budTask.UnitPrice.HasValue) ? 0m.ToString("0.00") : budTask.UnitPrice.Value.ToString("0.00")); this.txtTotal.Value = ((!budTask.Total.HasValue) ? 0m.ToString("0.00") : budTask.Total.Value.ToString("0.00")); this.ddlTaskType.SelectedValue = (budTask.OrderNumber.Length / 3).ToString(); this.txtNote.Text = budTask.Note; this.txtDescription.Text = budTask.FeatureDescription; } } } if (a == "BudgetChange.aspx") { this.hfldState.Value = "edit"; return; } } else { string text3 = base.Request["layer"]; if (text3 == "") { this.ddlTaskType.SelectedValue = "1"; return; } if (text3 == "0") { this.ddlTaskType.SelectedValue = string.Empty; return; } this.ddlTaskType.SelectedValue = text3; } }
protected void btnImport_Click(object sender, System.EventArgs e) { System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); CheckBox checkBox = this.gvBudget.HeaderRow.Cells[0].FindControl("cbAllBox") as CheckBox; if (checkBox != null) { if (checkBox.Checked) { list = BudTemplateItem.GetTemplateItemIds(this.tvBudget.SelectedValue); } else { string value = this.hfldCheckedIds.Value; if (value.Contains('[')) { list = JsonHelper.GetListFromJson(value); } else { list.Add(value); } } } string text = base.Request["prjId"]; if (!string.IsNullOrEmpty(text)) { string text2 = base.Request["taskId"]; bool flag = true; if (string.IsNullOrEmpty(text2)) { text2 = null; Project.CoverVersion(text); } else { flag = (BudTask.GetById(text2) != null); } bool flag2 = false; if (flag) { System.Collections.Generic.List <BudTemplateItem> list2 = new System.Collections.Generic.List <BudTemplateItem>(); foreach (string current in list) { BudTemplateItem byId = BudTemplateItem.GetById(current, this.tvBudget.SelectedValue); list2.Add(byId); if (byId != null) { flag2 = BudTask.CheckCode(byId.Code, text); if (flag2) { break; } } } if (flag2) { base.RegisterScript("alert('系统提示:\\n导入失败!\\n导入的模版中有节点的任务编码与已有的节点出现重复!');"); return; } list2 = ( from t in list2 orderby t.OrderNumber select t).ToList <BudTemplateItem>(); list.Clear(); foreach (BudTemplateItem current2 in list2) { list.Add(current2.Id.ToString()); } bool flag3 = BudTask.IsStructured(this.GetOrderNumbers(list)); int num = 0; string start = string.Empty; System.Collections.Generic.List <BudTemplateItem> list3 = null; if (flag3) { num = this.GetOrderNumbers(list).Min((string m) => m.Length); start = BudTask.GetOrderNumber(text, text2); list3 = this.ChangeId(list, this.tvBudget.SelectedValue); } string inputUser = PageHelper.QueryUser(this, base.UserCode); int num2 = 0; foreach (string current3 in list) { BudTemplateItem budTemplateItem; if (flag3) { budTemplateItem = list3[num2]; } else { budTemplateItem = BudTemplateItem.GetById(current3, this.tvBudget.SelectedValue); budTemplateItem.Id = System.Guid.NewGuid().ToString(); } string id = budTemplateItem.Id; string parentTaskId = string.Empty; if (flag3) { parentTaskId = budTemplateItem.ParentId; } else { parentTaskId = text2; } BudTask budTask = BudTask.Create(id, parentTaskId, null, text, budTemplateItem.Code, budTemplateItem.Name, budTemplateItem.Unit, budTemplateItem.Quantity, null, null, true, budTemplateItem.Note, inputUser, System.DateTime.Now, null, null); if (flag3) { if (budTemplateItem.OrderNumber.Length == num) { start = BudTask.GetOrderNumber(text, text2); budTask.ParentId = text2; } budTask.OrderNumber = this.GetNewOrderNumber(start, budTemplateItem.OrderNumber, num); } BudTask.Add(budTask, false); System.Collections.Generic.List <TaskResource> list4 = BudTemplateItem.GetResourcesByTempItemId(current3).ToList <TaskResource>(); if (list4.Count > 0) { foreach (TaskResource current4 in list4) { budTask.AddResource(current4.Resource, current4.Quantity, current4.Price, 1m, "add"); BudTask.AddResource(budTask); } } num2++; } string arg_3F6_0 = base.Request["year"]; this.strJS.Append("top.ui.tabSuccess({ parentName: '_BudgetPlaitList' });"); } else { this.strJS.Append("alert('系统提示:\\n导入失败!\\n导入的根节点已不存在!');"); } } base.RegisterScript(this.strJS.ToString()); }