예제 #1
0
    protected void btnDel_Click(object sender, System.EventArgs e)
    {
        CheckBox checkBox = this.gvBudget.HeaderRow.Cells[0].FindControl("cbAllBox") as CheckBox;

        if (checkBox != null && checkBox.Checked)
        {
            BudTemplateItem.Delete(this.tvBudget.SelectedValue);
            this.strJS.Append(string.Concat(new string[]
            {
                "location='BudTemplateList.aspx?tempId=",
                this.tvBudget.SelectedValue,
                "&tempType=",
                this.ddlType.SelectedValue,
                "';"
            }));
            base.RegisterScript(this.strJS.ToString());
            return;
        }
        System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
        if (this.hfldCheckedIds.Value.Contains("["))
        {
            list = JsonHelper.GetListFromJson(this.hfldCheckedIds.Value);
        }
        else
        {
            list.Add(this.hfldCheckedIds.Value);
        }
        bool flag = false;

        System.Collections.Generic.List <string> orderNumberById = BudTemplateItem.GetOrderNumberById(list);
        if (orderNumberById.Count > 1)
        {
            flag = BudTask.IsStructured(orderNumberById);
        }
        try
        {
            if (flag)
            {
                list.Reverse();
            }
            BudTemplateItem.Delete(list);
            this.strJS.Append("alert('系统提示:\\n删除成功!');");
            this.strJS.Append(string.Concat(new string[]
            {
                "location='BudTemplateList.aspx?tempId=",
                this.tvBudget.SelectedValue,
                "&tempType=",
                this.ddlType.SelectedValue,
                "';"
            }));
        }
        catch
        {
            this.strJS.Append("alert('系统提示:\\n请先删除子项!')");
        }
        base.RegisterScript(this.strJS.ToString());
    }
예제 #2
0
        public static void SaveTemplate(List <string> lsttaskIds, string templateId, string saveNodeId, string inputUser)
        {
            if (!string.IsNullOrEmpty(saveNodeId) && (((GetById(saveNodeId, templateId) == null) ? 0 : 1) == 0))
            {
                throw new Exception("你选择的根节点不存在,请刷新查看!");
            }
            bool          flag2           = true;
            List <string> orderNumberList = new List <string>();

            orderNumberList = BudTask.GetOrderNumberById(lsttaskIds);
            if (lsttaskIds.Count > 1)
            {
                flag2 = BudTask.IsStructured(orderNumberList);
            }
            List <BudTask> list2  = null;
            int            length = 0;
            string         start  = string.Empty;

            if (flag2)
            {
                list2  = BudTask.ChangeId(lsttaskIds);
                start  = GetNextOrderNumber(templateId, saveNodeId);
                length = orderNumberList.Min <string>((System.Func <string, int>)(m => m.Length));
            }
            int num2 = 0;

            foreach (string str2 in lsttaskIds)
            {
                BudTask task = null;
                if (flag2)
                {
                    task = list2[num2];
                }
                else
                {
                    task    = BudTask.GetById(str2);
                    task.Id = Guid.NewGuid().ToString();
                }
                string id       = task.Id;
                string parentId = string.Empty;
                if (flag2)
                {
                    parentId = task.ParentId;
                }
                else
                {
                    parentId = saveNodeId;
                }
                cn.justwin.Domain.BudTemplate byId = cn.justwin.Domain.BudTemplate.GetById(templateId);
                BudTemplateItem budTemplateItem    = Create(id, parentId, byId, task.Code, task.Name, task.Unit, task.Quantity, task.UnitPrice, task.Note, "");
                if (flag2)
                {
                    if (task.OrderNumber.Length == length)
                    {
                        start = GetNextOrderNumber(templateId, saveNodeId);
                        budTemplateItem.ParentId = (saveNodeId == "") ? null : saveNodeId;
                    }
                    budTemplateItem.OrderNumber = GetNewOrderNumber(start, task.OrderNumber, length);
                }
                Add(budTemplateItem);
                List <TaskResource> list3 = BudTask.GetResourcesByTaskId(str2).ToList <TaskResource>();
                if (list3.Count > 0)
                {
                    foreach (TaskResource resource in list3)
                    {
                        budTemplateItem.AddResource(resource.Resource, budTemplateItem.Quantity, resource.Price, inputUser, DateTime.Now, "add", 0M);
                        AddResource(budTemplateItem);
                    }
                }
                num2++;
            }
        }
예제 #3
0
    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());
    }