Пример #1
0
 protected void btnBindResource_Click(object sender, System.EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.hfldResourceId.Value))
     {
         ISerializable serializable = new JsonSerializer();
         string[]      array        = serializable.Deserialize <string[]>(this.hfldResourceId.Value);
         if (array != null)
         {
             DataTable dataTable  = BudTemplateItem.showMaterialListForAdd(DBHelper.GetInParameterSql(array), this.itemId);
             DataTable dataTable2 = this.ViewState["ResourcesTable"] as DataTable;
             if (dataTable2 != null)
             {
                 dataTable2.PrimaryKey = new DataColumn[]
                 {
                     dataTable2.Columns["ResourceCode"]
                 };
                 dataTable.PrimaryKey = new DataColumn[]
                 {
                     dataTable.Columns["ResourceCode"]
                 };
                 dataTable2.Merge(dataTable, true);
                 dataTable = dataTable2;
             }
             this.ViewState["ResourcesTable"] = dataTable;
             this.gvResource.DataSource       = dataTable;
             this.gvResource.DataBind();
         }
     }
     this.hfldResourceId.Value = string.Empty;
 }
Пример #2
0
 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)
     {
     }
 }
Пример #3
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        System.Collections.Generic.IList <BudTemplate> byName = BudTemplate.GetByName(this.txtTypeName.Text.Trim());
        if (byName.Count > 0)
        {
            base.RegisterScript("alert('系统提示:\\n\\n此名称已存在!!请重新定义!!')");
            return;
        }
        string empty = string.Empty;

        this.AddTemplate(ref empty);
        BudTemplate.GetById(empty);
        string text = (this.Session["taskIds"] == null) ? "" : this.Session["taskIds"].ToString();

        if (!string.IsNullOrEmpty(text))
        {
            System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
            if (text.Contains("["))
            {
                list = JsonHelper.GetListFromJson(text);
            }
            else
            {
                list.Add(text);
            }
            string inputUser = PageHelper.QueryUser(this, base.UserCode);
            BudTemplateItem.SaveTemplate(list, empty, "", inputUser);
            base.RegisterScript("alert('系统提示:\\n\\n保存成功!!');");
        }
    }
Пример #4
0
 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);
 }
Пример #5
0
    protected void BindGv()
    {
        DataTable resourcesByItemId = BudTemplateItem.GetResourcesByItemId(this.itemId);

        this.ViewState["ResourcesTable"] = resourcesByItemId;
        this.gvResource.DataSource       = resourcesByItemId;
        this.gvResource.DataBind();
    }
Пример #6
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());
    }
Пример #7
0
 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);
 }
Пример #8
0
    protected void btnSave_Click1(object sender, System.EventArgs e)
    {
        string value = this.hfldCheckedIds.Value;
        int    count = BudTemplateItem.GetResourcesByTempItemId(value).Count;

        if (count > 0)
        {
            this.strJS.Append("alert('系统提示:\\n此节点已配置资源,不能保存在此节点下!');");
        }
        else
        {
            bool flag = base.Request["save"] != null;
            if (flag)
            {
                this.strJS.Append("alert('系统提示:\\n已保存,不能重复保存!');");
            }
            else
            {
                string text = (this.Session["taskIds"] == null) ? "" : this.Session["taskIds"].ToString();
                if (!string.IsNullOrEmpty(text))
                {
                    System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
                    if (text.Contains("["))
                    {
                        list = JsonHelper.GetListFromJson(text);
                    }
                    else
                    {
                        list.Add(text);
                    }
                    string inputUser = PageHelper.QueryUser(this, base.UserCode);
                    BudTemplateItem.SaveTemplate(list, this.tvBudget.SelectedValue, value, inputUser);
                    this.ViewState["save"] = true;
                    this.btnSave.Enabled   = false;
                    this.strJS.Append("alert('系统提示:\\n保存成功!');");
                    this.strJS.Append(string.Concat(new string[]
                    {
                        "location='SelectTemplate.aspx?type=",
                        this.ddlType.SelectedValue,
                        "&template=",
                        this.tvBudget.SelectedValue,
                        "&save=1';"
                    }));
                }
            }
        }
        base.RegisterScript(this.strJS.ToString());
    }
Пример #9
0
    protected void btnSaveTemplate_Click(object sender, System.EventArgs e)
    {
        bool flag = base.Request["saveAs"] != null;

        if (flag)
        {
            this.strJS.Append("alert('系统提示:\\n已保存为新模板,不能重复保存!');");
        }
        else
        {
            string text = (this.Session["taskIds"] == null) ? "" : this.Session["taskIds"].ToString();
            if (!string.IsNullOrEmpty(text))
            {
                System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
                if (text.Contains("["))
                {
                    list = JsonHelper.GetListFromJson(text);
                }
                else
                {
                    list.Add(text);
                }
                BudTask.GetOrderNumberById(list);
                this.hdtemplateName.Value.Trim();
                string empty = string.Empty;
                this.AddTemplate(ref empty);
                string inputUser = PageHelper.QueryUser(this, base.UserCode);
                BudTemplateItem.SaveTemplate(list, empty, "", inputUser);
                this.strJS.Append("alert('系统提示:\\n保存成功!');");
                this.strJS.Append(string.Concat(new string[]
                {
                    "location='SelectTemplate.aspx?type=",
                    this.ddlType.SelectedValue,
                    "&template=",
                    empty,
                    "&saveAs=1';"
                }));
                this.ViewState["saveAs"] = true;
                this.btnSaveAs.Disabled  = true;
            }
        }
        base.RegisterScript(this.strJS.ToString());
    }
Пример #10
0
    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;
        }
    }
Пример #11
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());
    }