Beispiel #1
0
    protected void btnSaveTemplate_Click(object sender, System.EventArgs e)
    {
        string   text     = string.Empty;
        CheckBox checkBox = this.gvBudget.HeaderRow.Cells[0].FindControl("cbAllBox") as CheckBox;

        if (checkBox != null)
        {
            if (checkBox.Checked)
            {
                BudTaskService budTaskService = new BudTaskService();
                System.Collections.Generic.IList <cn.justwin.Domain.Entities.BudTask> byProject = budTaskService.GetByProject(this.prjId, 999);
                foreach (cn.justwin.Domain.Entities.BudTask current in byProject)
                {
                    text = text + "\"" + current.TaskId + "\",";
                }
                if (byProject.Count == 1)
                {
                    text = text.Substring(1, text.Length - 2);
                }
                else
                {
                    text = "[" + text.Substring(0, text.Length - 1) + "]";
                }
            }
            else
            {
                text = this.hfldCheckedIds.Value;
            }
        }
        this.Session["taskIds"] = text;
        base.RegisterScript("saveTem()");
    }
Beispiel #2
0
    private string GetParentId(string taskId)
    {
        BudTaskService budTaskService = new BudTaskService();

        cn.justwin.Domain.Entities.BudTask byId = budTaskService.GetById(taskId);
        return(byId.ParentId);
    }
Beispiel #3
0
        public static void ClearTotal2(object o)
        {
            Log4netHelper.Error(new Exception("clearTotal2 开始执行"), "clearTotal2", "bery");
            BasicConfigService service = new BasicConfigService();
            BasicConfig        byName  = service.GetByName("IsClearTaskTotal2");

            if (byName.ParaValue != "1")
            {
                try
                {
                    BudTaskService       service2 = new BudTaskService();
                    BudModifyTaskService source   = new BudModifyTaskService();
                    new PTPrjInfoService();
                    foreach (BudModifyTask task in source.ToList <BudModifyTask>())
                    {
                        source.UpdateTotal2(task.ModifyTaskId);
                    }
                    string    cmdText = string.Format("\r\n\t\t\t\t\tSELECT TaskId FROM Bud_Task\r\n\t\t\t\t\tWHERE TaskId IN ( SELECT TaskId FROM Bud_TaskResource )\r\n\t\t\t\t", new object[0]);
                    DataTable table   = SqlHelper.ExecuteQuery(CommandType.Text, cmdText, new SqlParameter[0]);
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        string taskId = table.Rows[i][0].ToString();
                        service2.UpdateTotal2(taskId);
                    }
                    byName.ParaValue = "1";
                    service.Update(byName);
                    Log4netHelper.Error(new Exception("clearTotal2 执行成功"), "clearTotal2", "bery");
                }
                catch (Exception exception)
                {
                    Log4netHelper.Error(exception, "clearTotal2", "bery");
                }
            }
        }
Beispiel #4
0
 public static void ClearBudTask(object o)
 {
     try
     {
         new PTPrjInfoZTBDetailService();
         BudTaskService service = new BudTaskService();
         if ((from t in service select t.Version.Value).Max <int>() != 1)
         {
             using (List <string> .Enumerator enumerator = (from t in service
                                                            where t.Version >= 1
                                                            select t.PrjId).Distinct <string>().ToList <string>().GetEnumerator())
             {
                 string prjId;
                 while (enumerator.MoveNext())
                 {
                     prjId = enumerator.Current;
                     int num2 = (from t in service
                                 where t.PrjId == prjId
                                 select t.Version.Value).Max <int>();
                     if (num2 > 1)
                     {
                         string cmdText = string.Format("DELETE FROM Bud_Task WHERE PrjId = '{0}' AND Version < {1}", prjId, num2);
                         SqlHelper.ExecuteNonQuery(CommandType.Text, cmdText, new SqlParameter[0]);
                         cmdText = string.Format("UPDATE Bud_Task SET Version = 1 WHERE PrjId = '{0}' AND Version = {1}", prjId, num2);
                         SqlHelper.ExecuteNonQuery(CommandType.Text, cmdText, new SqlParameter[0]);
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #5
0
        public void CommitEvent(object key)
        {
            string str = ConfigHelper.Get("IsWBSRelevance");
            BudTaskChangeService   service  = new BudTaskChangeService();
            BudTaskService         service2 = new BudTaskService();
            BudTaskResourceService service3 = new BudTaskResourceService();

            cn.justwin.Domain.Entities.BudTaskChange   byId      = service.GetById(key.ToString());
            IList <cn.justwin.Domain.Entities.BudTask> byProject = service2.GetByProject(byId.PrjId, 0x3e7);
            IList <int> years = service2.GetYears(byId.PrjId);

            if (years != null)
            {
                foreach (int num in years)
                {
                    IList <cn.justwin.Domain.Entities.BudTask> yearTask = service2.GetYearTask(byProject, num);
                    foreach (cn.justwin.Domain.Entities.BudTask task in yearTask)
                    {
                        service2.Add(task);
                    }
                    foreach (int num2 in service2.GetMonths(yearTask, num))
                    {
                        foreach (cn.justwin.Domain.Entities.BudTask task2 in service2.GetMonthTasks(yearTask, num, num2))
                        {
                            service2.Add(task2);
                        }
                    }
                }
            }
            if (str == "1")
            {
                service3.AddTaskResource(byId.PrjId);
            }
        }
Beispiel #6
0
 protected void btnSave_ServerClick(object sender, System.EventArgs e)
 {
     try
     {
         System.Collections.Generic.List <TaskResource> list = new System.Collections.Generic.List <TaskResource>();
         cn.justwin.Domain.BudTask budTask = null;
         if (this.hfldIsWBSRelevance.Value == "1")
         {
             budTask           = cn.justwin.Domain.BudTask.GetById(this.taskId);
             budTask.Resources = list;
         }
         for (int i = 0; i < this.gvResource.Rows.Count; i++)
         {
             cn.justwin.Domain.Resource byId = 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 num      = System.Convert.ToDecimal(((TextBox)this.gvResource.Rows[i].FindControl("txtLoss")).Text);
             if (this.hfldIsWBSRelevance.Value == "1")
             {
                 budTask.AddResource(byId, quantity, price, num, "save");
             }
             else
             {
                 list.Add(new TaskResource
                 {
                     Resource        = byId,
                     Quantity        = quantity,
                     Price           = price,
                     PrjGuid         = this.prjId,
                     Versions        = System.Convert.ToInt32(this.hfldVersion.Value.Trim()),
                     InputDate       = new System.DateTime?(System.DateTime.Now),
                     InputUser       = PageHelper.QueryUser(this, base.UserCode),
                     LossCoefficient = new decimal?(num)
                 });
             }
         }
         if (this.hfldIsWBSRelevance.Value == "1")
         {
             budTask.InputUser = PageHelper.QueryUser(this, base.UserCode);
             budTask.InputDate = System.DateTime.Now;
             cn.justwin.Domain.BudTask.AddResource(budTask);
             BudTaskService budTaskService = new BudTaskService();
             budTaskService.UpdateTotal2(this.taskId);
         }
         else
         {
             TaskResource.AddResource(list, this.prjId, System.Convert.ToInt32(this.hfldVersion.Value));
         }
         base.RegisterScript("top.ui.tabSuccess({ parentName: '_ResourceDeploy' });");
     }
     catch (System.Exception)
     {
     }
 }
Beispiel #7
0
 protected void BindTaskInfo()
 {
     if (this.hfldIsWBSRelevance.Value == "1")
     {
         BudTaskService budTaskService           = new BudTaskService();
         cn.justwin.Domain.Entities.BudTask byId = budTaskService.GetById(this.taskId);
         this.lblTaskCode.Text = byId.TaskCode;
         this.lblTaskName.Text = byId.TaskName;
         this.lblDesc.Text     = byId.FeatureDescription;
         this.lblQu.Text       = byId.Quantity.Value.ToString();
     }
 }
Beispiel #8
0
    private void BindYear()
    {
        this.dropYear.Items.Clear();
        this.dropYear.Items.Add(new ListItem("选择年份", ""));
        BudTaskService budTaskService = new BudTaskService();

        System.Collections.Generic.IList <int> years = budTaskService.GetYears(this.prjId);
        if (years != null)
        {
            foreach (int current in years)
            {
                this.dropYear.Items.Add(new ListItem(current.ToString() + "年", current.ToString("0000")));
            }
        }
    }
Beispiel #9
0
    private void BindMonth()
    {
        this.dropMonth.Items.Clear();
        this.dropMonth.Items.Add(new ListItem("选择月份", ""));
        BudTaskService budTaskService = new BudTaskService();

        if (!string.IsNullOrEmpty(this.dropYear.SelectedValue))
        {
            System.Collections.Generic.IList <int> months = budTaskService.GetMonths(this.prjId, this.dropYear.SelectedValue);
            if (months != null)
            {
                foreach (int current in months)
                {
                    this.dropMonth.Items.Add(new ListItem(current.ToString() + "月", current.ToString("00")));
                }
            }
        }
    }
Beispiel #10
0
 protected void btnBindResource_Click(object sender, System.EventArgs e)
 {
     if (this.hfldType.Value == "task")
     {
         if (!string.IsNullOrEmpty(this.hfldTaskId.Value))
         {
             ResourceTemp byId = ResourceTemp.GetById(this.hfldPurchaseChecked.Value.ToString());
             byId.BudTask = BudTask.GetById(this.hfldTaskId.Value.Trim());
             string inputUser = PageHelper.QueryUser(this, base.UserCode);
             ResourceTemp.Delete(byId, inputUser, this.hfldIsWBSRelevance.Value);
             this.BindGv();
             BudTaskService budTaskService = new BudTaskService();
             budTaskService.UpdateTotal2(this.hfldTaskId.Value.Trim());
         }
     }
     else
     {
         if (this.hfldType.Value == "resource" && !string.IsNullOrEmpty(this.hfldResourceIds.Value))
         {
             ResourceTemp byId2 = ResourceTemp.GetById(this.hfldPurchaseChecked.Value.ToString());
             byId2.ResourceId = this.hfldResourceIds.Value.Trim();
             byId2.BudTask    = BudTask.GetById(this.hfldTaskId.Value);
             string inputUser2 = PageHelper.QueryUser(this, base.UserCode);
             if (this.hfldIsWBSRelevance.Value == "1")
             {
                 byId2.BudTask = BudTask.GetById(this.hfldTaskId.Value);
             }
             ResourceTemp.Delete(byId2, inputUser2, this.hfldIsWBSRelevance.Value);
             this.BindGv();
             BudTaskService budTaskService2 = new BudTaskService();
             budTaskService2.UpdateTotal2(this.hfldTaskId.Value.Trim());
         }
     }
     this.hfldTaskId.Value            = "";
     this.hfldResourceIds.Value       = "";
     this.SelectResource1.ResourceId  = string.Empty;
     this.SelectResource1.ResTempType = string.Empty;
 }
Beispiel #11
0
    private void GenerageBudgetByParent(string prjId)
    {
        PTPrjInfoService pTPrjInfoService = new PTPrjInfoService();
        PTPrjInfo        byId             = pTPrjInfoService.GetById(prjId);
        PTPrjInfo        parent           = pTPrjInfoService.GetParent(prjId);
        string           str            = byId.TypeCode.Substring(6, 4);
        BudTaskService   budTaskService = new BudTaskService();

        budTaskService.DeleteByProject(prjId);
        System.Collections.Generic.IList <cn.justwin.Domain.Entities.BudTask> byProject = budTaskService.GetByProject(parent.PrjGuid.Value.ToString(), 999);
        for (int i = 0; i < byProject.Count; i++)
        {
            cn.justwin.Domain.Entities.BudTask budTask = byProject[i];
            budTask.PrjId  = byId.PrjGuid.Value.ToString();
            budTask.TaskId = budTask.TaskId.Substring(0, 9) + str + budTask.TaskId.Substring(13);
            if (!string.IsNullOrEmpty(budTask.ParentId))
            {
                budTask.ParentId = budTask.ParentId.Substring(0, 9) + str + budTask.ParentId.Substring(13);
            }
            budTaskService.Add(budTask);
        }
        this.BindGv();
    }
Beispiel #12
0
    protected void btnDel_Click(object sender, System.EventArgs e)
    {
        if (this.gvBudget.Rows.Count == 0)
        {
            return;
        }
        BudTaskService budTaskService = new BudTaskService();
        CheckBox       checkBox       = this.gvBudget.HeaderRow.Cells[0].FindControl("cbAllBox") as CheckBox;

        if (checkBox != null && checkBox.Checked)
        {
            budTaskService.SuperDel(this.prjId);
            base.RegisterScript(string.Concat(new string[]
            {
                "location='BudgetPlaitList.aspx?prjId=",
                this.prjId,
                "&year=",
                this.year,
                "';"
            }));
            return;
        }
        System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
        string value = this.hfldCheckedIds.Value;

        if (value.Contains('['))
        {
            list = JsonHelper.GetListFromJson(value);
        }
        else
        {
            list.Add(value);
        }
        if (!cn.justwin.Domain.BudTask.CheckDel(list, this.prjId))
        {
            base.RegisterScript("top.ui.alert('请先删除子项')");
        }
        else
        {
            PayoutTarget payoutTarget = new PayoutTarget();
            payoutTarget.DelByTaskId(list);
            foreach (string current in list)
            {
                try
                {
                    cn.justwin.Domain.BudTask.DeleteReourceByTaskId(current);
                    cn.justwin.Domain.BudTask.Delete(current);
                }
                catch
                {
                }
            }
        }
        base.RegisterScript(string.Concat(new string[]
        {
            "location='BudgetPlaitList.aspx?prjId=",
            this.prjId,
            "&year=",
            this.year,
            "';"
        }));
    }
Beispiel #13
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        string value = this.txtQuantity.Text.Trim();
        string text  = string.Empty;
        string text2 = string.Empty;

        if (string.IsNullOrEmpty(value))
        {
            base.RegisterScript("alert('工程量必须输入');");
            this.txtQuantity.Focus();
            return;
        }
        if (this.hfldIsWBSRelevance.Value == "0" && base.Request["page"].ToString() != "BudTemplateList.aspx" && string.IsNullOrEmpty(this.txtUnitPrice.Text.Trim()))
        {
            base.RegisterScript("alert('综合单价必须输入');");
            this.txtUnitPrice.Focus();
            return;
        }
        if (this.hfldIsWBSRelevance.Value == "0" && base.Request["page"].ToString() != "BudTemplateList.aspx")
        {
            text  = System.Convert.ToDecimal(this.txtUnitPrice.Text.Trim()).ToString();
            text2 = System.Convert.ToDecimal(this.txtTotal.Value.Trim()).ToString();
        }
        string text3     = this.txtTaskCode.Text.Trim();
        bool   flag      = false;
        string text4     = base.Request["type"];
        string arg_14E_0 = base.Request["isBudTask"];

        if (this.ViewState["oldCode"] != null)
        {
            this.ViewState["oldCode"].ToString();
        }
        else
        {
            string arg_17E_0 = string.Empty;
        }
        if (flag)
        {
            base.RegisterScript("top.ui.alert('清单编码不能重复');");
            this.txtTaskCode.Focus();
            return;
        }
        string text5     = System.Guid.NewGuid().ToString();
        string text6     = this.txtTaskName.Text.Trim();
        string text7     = this.txtStartDate.Text;
        string text8     = this.txtEndDate.Text;
        string text9     = this.txtUnit.Text.Trim();
        string arg_1F9_0 = this.ddlTaskType.SelectedValue;
        string text10    = this.txtNote.Text.Trim();
        string text11    = this.txtConstructionPeriod.Text.Trim();
        string text12    = this.txtDescription.Text.Trim();
        string a         = base.Request["page"];

        if (a == "BudgetPlaitList.aspx")
        {
            BudTaskService budTaskService = new BudTaskService();
            string         text13         = string.Empty;
            text13 = base.Request["prjId"];
            string text14 = base.Request["id"];
            cn.justwin.Domain.Entities.BudTask budTask;
            if (text4.ToLower() == "edit")
            {
                budTask = budTaskService.GetById(text14);
            }
            else
            {
                budTask             = new cn.justwin.Domain.Entities.BudTask();
                budTask.TaskId      = text5;
                budTask.OrderNumber = cn.justwin.Domain.BudTask.GetOrderNumber(text13, text14);
                if (string.IsNullOrEmpty(text14))
                {
                    budTask.ParentId = null;
                }
                else
                {
                    budTask.ParentId = text14;
                }
                budTask.PrjId     = text13;
                budTask.InputUser = base.UserCode;
                budTask.InputDate = System.DateTime.Now;
                budTask.IsValid   = new bool?(true);
                budTask.Version   = new int?(1);
                budTask.Modified  = null;
            }
            budTask.TaskCode = text3;
            budTask.TaskName = text6;
            System.DateTime?startDate = null;
            if (!string.IsNullOrEmpty(text7))
            {
                startDate = new System.DateTime?(System.Convert.ToDateTime(text7));
            }
            budTask.StartDate = startDate;
            System.DateTime?endDate = null;
            if (!string.IsNullOrEmpty(text8))
            {
                endDate = new System.DateTime?(System.Convert.ToDateTime(text8));
            }
            budTask.EndDate = endDate;
            if (!string.IsNullOrEmpty(value))
            {
                budTask.Quantity = new decimal?(System.Convert.ToDecimal(value));
            }
            if (!string.IsNullOrEmpty(text))
            {
                budTask.UnitPrice = new decimal?(System.Convert.ToDecimal(text));
            }
            if (!string.IsNullOrEmpty(text2))
            {
                budTask.Total = new decimal?(System.Convert.ToDecimal(text2));
            }
            budTask.Unit = text9;
            budTask.Note = text10;
            if (!string.IsNullOrEmpty(text11))
            {
                budTask.ConstructionPeriod = new int?(System.Convert.ToInt32(text11));
            }
            budTask.TaskType           = "";
            budTask.FeatureDescription = this.txtDescription.Text.Trim();
            if (text4.ToLower() == "edit")
            {
                budTaskService.Update(budTask);
            }
            else
            {
                budTaskService.Add(budTask);
            }
            string str  = "resetData();";
            string str2 = "top.ui.winSuccess({ parentName: '_BudTaskEdit' });";
            base.RegisterScript(str + str2);
        }
        if (a == "BudTemplateList.aspx")
        {
            string message = string.Concat(new string[]
            {
                "closeDial('",
                text3,
                "','",
                text6,
                "','",
                text9,
                "','",
                System.Convert.ToDecimal(value).ToString(),
                "','",
                text10,
                "','",
                this.ddlTaskType.SelectedItem.Text,
                "','",
                text7,
                "','",
                text8,
                "','",
                text,
                "','",
                text2,
                "','",
                text11,
                "','",
                text5,
                "','",
                text12,
                "');"
            });
            string str3 = "/BudgetManage/Template/BudTemplateList.aspx?tempId=" + this.hfldTempId.Value;
            //"top.ui.winSuccess({ parentName: '_BudTaskEdit',url:" + str3 + " });";
            base.RegisterScript(message);
        }
    }
Beispiel #14
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;
        }
    }
Beispiel #15
0
        public void CommitEvent(object key)
        {
            BudModifyService       service  = new BudModifyService();
            BudTaskService         service2 = new BudTaskService();
            BudModifyTaskService   service3 = new BudModifyTaskService();
            BudTaskResourceService service4 = new BudTaskResourceService();
            ConPayoutModifyService service5 = new ConPayoutModifyService();
            string    modifyId  = key.ToString();
            BudModify budmodify = (from r in service
                                   where r.ModifyId == modifyId
                                   select r).FirstOrDefault <BudModify>();
            ConPayoutModify item = (from r in service5
                                    where r.BudModifyId == modifyId
                                    select r).FirstOrDefault <ConPayoutModify>();

            if (item != null)
            {
                item.FlowState = 1;
                service5.Update(item);
            }
            using (List <BudModifyTask> .Enumerator enumerator = (from p in service3
                                                                  where p.ModifyId == budmodify.ModifyId
                                                                  select p).ToList <BudModifyTask>().GetEnumerator())
            {
                BudModifyTask taskx;
                while (enumerator.MoveNext())
                {
                    taskx = enumerator.Current;
                    cn.justwin.Domain.Entities.BudTask task = (from p in service2
                                                               where p.TaskId == taskx.TaskId
                                                               select p).FirstOrDefault <cn.justwin.Domain.Entities.BudTask>();
                    if ((task != null) && (budmodify.Flowstate == 1))
                    {
                        if (taskx.ModifyType == 0)
                        {
                            task.IsValid = true;
                            service2.Update(task);
                            service3.UpdateTotal2(taskx.ModifyTaskId);
                        }
                        if ((task.ModifyId != task.ModifyId) || (taskx.ModifyType == 1))
                        {
                            task.ModifyId = task.ModifyId;
                            if (!task.Total2.HasValue)
                            {
                                task.Total2 = 0;
                            }
                            if (!task.Quantity.HasValue)
                            {
                                task.Quantity = 0;
                            }
                            task.Total2   = new decimal?(Convert.ToDecimal(task.Total2) + Convert.ToDecimal(task.Total2));
                            task.Quantity = new decimal?(Convert.ToDecimal(task.Quantity) + Convert.ToDecimal(task.Quantity));
                            if (task.Quantity != 0M)
                            {
                                task.UnitPrice = task.Total2 / task.Quantity;
                            }
                            service2.Update(task);
                            service3.UpdateTotal2(taskx.ModifyTaskId);
                        }
                    }
                }
            }
            if (ConfigHelper.Get("BudgetRequireDiff") != "0")
            {
                string    str2 = ConfigHelper.Get("IsWBSRelevance");
                BudModify byId = service.GetById(key.ToString());
                service2.DeleteYearMonthByPrj(byId.PrjId);
                IList <cn.justwin.Domain.Entities.BudTask> byProject = service2.GetByProject(byId.PrjId, 0x3e7);
                IList <int> years = service2.GetYears(byId.PrjId);
                if (years != null)
                {
                    foreach (int num in years)
                    {
                        IList <cn.justwin.Domain.Entities.BudTask> yearTask = service2.GetYearTask(byProject, num);
                        foreach (cn.justwin.Domain.Entities.BudTask task2 in yearTask)
                        {
                            service2.Add(task2);
                        }
                        foreach (int num2 in service2.GetMonths(yearTask, num))
                        {
                            foreach (cn.justwin.Domain.Entities.BudTask task3 in service2.GetMonthTasks(yearTask, num, num2))
                            {
                                service2.Add(task3);
                            }
                        }
                    }
                    if (str2 == "1")
                    {
                        service4.AddTaskResource(byId.PrjId);
                    }
                }
            }
        }
Beispiel #16
0
        public int ConverBudTaskList(string[] colArray, string inputUser, List <string> errors, string IsWBSRelevance)
        {
            int num = 0;
            List <cn.justwin.Domain.BudTask> list     = new List <cn.justwin.Domain.BudTask>();
            IDictionary <string, int>        relation = ExcelUtility.GetRelation(colArray);
            List <string> orderNumberByLayer          = new List <string>();

            try
            {
                this.ParseTaskTable(relation);
                List <int> layerList = new List <int>();
                if (this.rankIndex == -1)
                {
                    List <string> codeList = this.GetCodeList();
                    layerList = this.GetLayersByCode(codeList);
                }
                else
                {
                    layerList = this.GetLayers();
                }
                orderNumberByLayer = this.GetOrderNumberByLayer(layerList);
            }
            catch (Exception exception)
            {
                errors.Add(exception.Message);
            }
            string   code        = string.Empty;
            string   name        = string.Empty;
            string   unit        = string.Empty;
            decimal  quantity    = 0M;
            decimal  num3        = 0M;
            decimal  num4        = 0M;
            DateTime?startDate   = null;
            DateTime?endDate     = null;
            string   note        = string.Empty;
            string   orderNumber = cn.justwin.Domain.BudTask.GetOrderNumber(this.prjId, this.taskId);
            string   str6        = string.Empty;
            int      num5        = 0;
            string   str7        = string.Empty;
            string   str8        = string.Empty;

            for (int i = this.startIndex; i < this.taskTable.Rows.Count; i++)
            {
                bool    flag = true;
                DataRow row  = this.taskTable.Rows[i];
                code = (row[this.codeIndex] == null) ? "" : row[this.codeIndex].ToString();
                string item = string.Empty;
                name     = (row[this.nameIndex] == null) ? "" : row[this.nameIndex].ToString();
                quantity = 0M;
                if (this.quantityIndex != -1)
                {
                    try
                    {
                        string str10 = row[this.quantityIndex].ToString().Trim();
                        if (!string.IsNullOrEmpty(str10))
                        {
                            quantity = decimal.Parse(str10);
                        }
                    }
                    catch
                    {
                        item = "在您的Excel中:编码" + code + ",工程量存在非有效的数字,请修改!";
                        errors.Add(item);
                        flag = false;
                    }
                }
                if (IsWBSRelevance == "0")
                {
                    if (this.unitPriceIndex != -1)
                    {
                        try
                        {
                            string str11 = row[this.unitPriceIndex].ToString().Trim();
                            if (!string.IsNullOrEmpty(str11))
                            {
                                num3 = decimal.Parse(str11);
                            }
                        }
                        catch
                        {
                            item = "在您的Excel中:编码" + code + ",综合单价存在非有效的数字,请修改!";
                            errors.Add(item);
                            flag = false;
                        }
                    }
                    if (this.totalIndex != -1)
                    {
                        try
                        {
                            num4 = quantity * num3;
                        }
                        catch
                        {
                            item = "在您的Excel中:编码" + code + ",综合单价存在非有效的数字,请修改!";
                            errors.Add(item);
                            flag = false;
                        }
                    }
                }
                unit = string.Empty;
                if (this.unitIndex != -1)
                {
                    unit = row[this.unitIndex].ToString();
                }
                if (this.startDateIndex != -1)
                {
                    try
                    {
                        string str12 = row[this.startDateIndex].ToString().Trim();
                        if (!string.IsNullOrEmpty(str12))
                        {
                            startDate = new DateTime?(Convert.ToDateTime(str12));
                        }
                        else
                        {
                            startDate = null;
                        }
                    }
                    catch
                    {
                        item = "在您的Excel中:编码" + code + ",存在非有效时间类型,请修改!";
                        errors.Add(item);
                        flag = false;
                    }
                }
                if (this.endDateIndex != -1)
                {
                    try
                    {
                        string str13 = row[this.endDateIndex].ToString();
                        if (!string.IsNullOrEmpty(str13))
                        {
                            endDate = new DateTime?(Convert.ToDateTime(str13));
                        }
                        else
                        {
                            endDate = null;
                        }
                    }
                    catch
                    {
                        item = "在您的Excel中:编码" + code + ",存在非有效时间类型,请修改!";
                        errors.Add(item);
                        flag = false;
                    }
                }
                if (this.noteIndex != -1)
                {
                    note = row[this.noteIndex].ToString();
                }
                if (this.constructionPeriodIndex != -1)
                {
                    try
                    {
                        num5 = Convert.ToInt32(row[this.constructionPeriodIndex]);
                    }
                    catch
                    {
                    }
                }
                if (this.featureDescriptionIndex != -1)
                {
                    str7 = row[this.featureDescriptionIndex].ToString();
                }
                if (row.Table.Columns.Contains("序号"))
                {
                    str8 = row["序号"].ToString();
                }
                if (!flag)
                {
                    item = "在您的Excel中:编码" + code + ",存在错误数据导致其子节点不能导入!";
                    errors.Add(item);
                    int    num7  = 0;
                    string str14 = orderNumberByLayer[i];
                    for (int j = i + 1; j < orderNumberByLayer.Count; j++)
                    {
                        if (orderNumberByLayer[j].StartsWith(str14))
                        {
                            num7++;
                        }
                    }
                    i += num7;
                }
                else
                {
                    num++;
                    string id                      = Guid.NewGuid().ToString();
                    string parentTaskId            = (this.taskId == "") ? null : this.taskId;
                    cn.justwin.Domain.BudTask task = null;
                    if (IsWBSRelevance == "1")
                    {
                        decimal?unitPrice = null;
                        decimal?total     = null;
                        task = cn.justwin.Domain.BudTask.Create(id, parentTaskId, null, this.prjId, code, name, unit, quantity, startDate, endDate, true, note, inputUser, DateTime.Now, unitPrice, total);
                    }
                    else
                    {
                        task = cn.justwin.Domain.BudTask.Create(id, parentTaskId, null, this.prjId, code, name, unit, quantity, startDate, endDate, true, note, inputUser, DateTime.Now, new decimal?(num3), new decimal?(num4));
                    }
                    string str17 = orderNumberByLayer[i].Substring(3);
                    if (string.IsNullOrEmpty(str17))
                    {
                        if (i > this.startIndex)
                        {
                            orderNumber = cn.justwin.Domain.BudTask.GetOrderNumber(this.prjId, this.taskId);
                        }
                        task.OrderNumber = orderNumber;
                    }
                    else
                    {
                        task.OrderNumber = orderNumber + str17;
                    }
                    if (i > 0)
                    {
                        int count = list.Count;
                        if (count > 0)
                        {
                            if ((orderNumberByLayer[i].Length - str6.Length) == 3)
                            {
                                task.ParentId = list[count - 1].Id;
                            }
                            else if ((orderNumberByLayer[i].Length - str6.Length) == 0)
                            {
                                task.ParentId = list[count - 1].ParentId;
                            }
                            else
                            {
                                int length = orderNumberByLayer[i].Length;
                                if (length == 3)
                                {
                                    task.ParentId = list[0].ParentId;
                                }
                                else if (length > 3)
                                {
                                    int differOrderNumber = list[0].OrderNumber.Length - orderNumberByLayer[0].Length;
                                    int num10             = list.FindLastIndex(t => t.OrderNumber.Length == (length + differOrderNumber));
                                    task.ParentId = list[num10].ParentId;
                                }
                            }
                        }
                    }
                    str6 = orderNumberByLayer[i];
                    list.Add(task);
                    cn.justwin.Domain.Entities.BudTask task2 = null;
                    BudTaskService service = new BudTaskService();
                    task2 = new cn.justwin.Domain.Entities.BudTask {
                        TaskId             = task.Id,
                        ParentId           = task.ParentId,
                        OrderNumber        = task.OrderNumber,
                        PrjId              = task.Prj,
                        InputUser          = task.InputUser,
                        InputDate          = task.InputDate,
                        IsValid            = true,
                        Version            = 1,
                        Modified           = null,
                        TaskCode           = task.Code,
                        TaskName           = task.Name,
                        StartDate          = task.StartDate,
                        EndDate            = task.EndDate,
                        Quantity           = new decimal?(task.Quantity),
                        UnitPrice          = task.UnitPrice,
                        Total              = task.Total,
                        Unit               = task.Unit,
                        Note               = task.Note,
                        ConstructionPeriod = new int?(num5),
                        FeatureDescription = str7,
                        TaskType           = "",
                        Total2             = 0
                    };
                    service.Add(task2);
                    if (!string.IsNullOrEmpty(str8))
                    {
                        this.AddSerialNoAndTaskId(str8, task.Id);
                    }
                    else
                    {
                        this.AddCodeAndTaskId(task.Code, task.Id);
                    }
                }
            }
            return(num);
        }