Beispiel #1
0
        public static decimal GetTypePrice(string taskId, string priceType, string resourceTypeId)
        {
            System.Func <ResPrice, bool> predicate = null;
            decimal num = 0M;

            if (BudTask.GetById(taskId) != null)
            {
                foreach (TaskResource resource in BudTask.GetResourcesByTaskId(taskId))
                {
                    System.Func <ResPrice, bool> func = null;
                    string  resourceId = resource.Resource.Id;
                    decimal quantity   = resource.Quantity;
                    decimal num3       = resource.Price;
                    if (GetFirstResourceType(GetById(resourceId).ResourceType.Id) == resourceTypeId)
                    {
                        if (func == null)
                        {
                            func = m => m.ResourceId == resourceId;
                        }
                        if (predicate == null)
                        {
                            predicate = m => m.PriceTypeId == priceType;
                        }
                        List <ResPrice> list2 = ResPrice.GetAll().Where <ResPrice>(func).Where <ResPrice>(predicate).ToList <ResPrice>();
                        if (list2.Count > 0)
                        {
                            foreach (ResPrice price in list2)
                            {
                                num += price.PriceValue * quantity;
                            }
                        }
                        else
                        {
                            num += num3 * quantity;
                        }
                    }
                }
            }
            return(num);
        }
Beispiel #2
0
 public static void GetResTypeTotal(string taskId, string priceType, DataTable dtrcj)
 {
     if (BudTask.GetById(taskId) != null)
     {
         foreach (TaskResource resource in BudTask.GetResourcesByTaskId(taskId))
         {
             string  resourceId        = resource.Resource.Id;
             decimal quantity          = resource.Quantity;
             decimal price             = resource.Price;
             string  firstResourceType = GetFirstResourceType(GetById(resourceId).ResourceType.Id);
             decimal num3 = 0M;
             if (string.IsNullOrEmpty(priceType))
             {
                 num3 = price * quantity;
             }
             else
             {
                 using (pm2Entities entities = new pm2Entities())
                 {
                     using (List <ResPrice> .Enumerator enumerator2 = (from m in entities.Res_Price
                                                                       where (m.ResourceId == resourceId) && (m.PriceTypeId == priceType)
                                                                       select new ResPrice {
                         PriceValue = m.PriceValue
                     }).ToList <ResPrice>().GetEnumerator())
                     {
                         while (enumerator2.MoveNext())
                         {
                             ResPrice current = enumerator2.Current;
                             num3 = price * quantity;
                         }
                     }
                 }
             }
             object obj2 = dtrcj.Rows[0][firstResourceType];
             obj2 = (obj2 == null) ? 0 : obj2;
             dtrcj.Rows[0][firstResourceType] = Convert.ToInt32(obj2) + num3;
         }
     }
 }
Beispiel #3
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 #4
0
    private void DisplayPhoto()
    {
        string selectedValue = this.trvwBudget.SelectedValue;

        if (!string.IsNullOrEmpty(selectedValue))
        {
            BudTask        byId = BudTask.GetById(selectedValue);
            IList <string> reportImgPathList = byId.GetReportImgPathList();
            using (IEnumerator <string> enumerator = reportImgPathList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string        current       = enumerator.Current;
                    string        path          = HttpContext.Current.Server.MapPath(current);
                    DirectoryInfo directoryInfo = new DirectoryInfo(path);
                    if (directoryInfo.Exists)
                    {
                        FileInfo[] files = directoryInfo.GetFiles("*.*");
                        FileInfo[] array = files;
                        for (int i = 0; i < array.Length; i++)
                        {
                            FileInfo fileInfo = array[i];
                            string   text     = current + "/" + fileInfo.ToString();
                            string   text2    = fileInfo.ToString().Substring(0, fileInfo.ToString().IndexOf('.'));
                            string   text3    = this.imaStr;
                            this.imaStr = string.Concat(new string[]
                            {
                                text3,
                                "<SPAN class=\"photo\"><a href=\"",
                                text,
                                "\" title=\"",
                                text2,
                                "\"><IMG src=\"",
                                text,
                                "\" width=\"100\" height=\"100\" alt=\"\" ></A></a></SPAN>"
                            });
                        }
                    }
                }
                return;
            }
        }
        string value = this.hdnProjectCode.Value;
        IList <ConstructReport>         auditedByPrj = ConstructReport.GetAuditedByPrj(value);
        Dictionary <string[], DateTime> dictionary   = new Dictionary <string[], DateTime>();

        foreach (ConstructReport current2 in auditedByPrj)
        {
            foreach (ConstructTask current3 in current2.ConstructTaskList)
            {
                string        text4          = BudgetManage_Construct_ReportPhoto.constructReport + "/" + current3.Id;
                string        path2          = HttpContext.Current.Server.MapPath(text4);
                DirectoryInfo directoryInfo2 = new DirectoryInfo(path2);
                if (directoryInfo2.Exists)
                {
                    FileInfo[] files2 = directoryInfo2.GetFiles("*.*");
                    FileInfo[] array2 = files2;
                    for (int j = 0; j < array2.Length; j++)
                    {
                        FileInfo fileInfo2    = array2[j];
                        string[] array3       = new string[2];
                        DateTime creationTime = fileInfo2.CreationTime;
                        string   text5        = text4 + "/" + fileInfo2.ToString();
                        string   text6        = fileInfo2.ToString().Substring(0, fileInfo2.ToString().IndexOf('.'));
                        array3[0] = text5;
                        array3[1] = text6;
                        dictionary.Add(array3, creationTime);
                    }
                }
            }
        }
        IOrderedEnumerable <KeyValuePair <string[], DateTime> > orderedEnumerable =
            from s in dictionary
            orderby s.Value descending
            select s;
        int num = 0;

        foreach (KeyValuePair <string[], DateTime> current4 in orderedEnumerable)
        {
            if (num >= 9)
            {
                break;
            }
            string[] key       = current4.Key;
            DateTime arg_2DD_0 = current4.Value;
            string   text7     = this.imaStr;
            this.imaStr = string.Concat(new string[]
            {
                text7,
                "<SPAN class=\"photo\"><a href=\"",
                key[0],
                "\" title=\"",
                key[1],
                "\"><IMG src=\"",
                key[0],
                "\" width=\"100\" height=\"100\" alt=\"\" ></A></a></SPAN>"
            });
            num++;
        }
    }
Beispiel #5
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++;
            }
        }
 protected void btnImport_Click(object sender, System.EventArgs e)
 {
     this.taskArray = this.hfldExcelColumns.Value.Split(new char[]
     {
         ','
     });
     this.resourceArray = this.hfldResource.Value.Split(new char[]
     {
         ','
     });
     this.hfldExcelColumns.Value = string.Empty;
     this.hfldResource.Value     = string.Empty;
     if (this.ViewState["ExcelName"] != null && !string.IsNullOrEmpty(this.ViewState["ExcelName"].ToString()))
     {
         bool flag = true;
         if (string.IsNullOrEmpty(this.taskId))
         {
             this.dtWBS = (this.ViewState["dtwbs"] as DataTable);
             if (this.dtWBS.Rows.Count > 0)
             {
                 Project.CoverVersion(this.prjId);
             }
         }
         else
         {
             flag = (BudTask.GetById(this.taskId) != null);
         }
         if (flag)
         {
             this.inputUser = PageHelper.QueryUser(this, base.UserCode);
             BudTaskSpecial budTaskSpecial = new BudTaskSpecial(this.taskId, this.prjId, this.inputUser, this.dtWBS);
             int            num            = budTaskSpecial.ConverBudTaskList(this.errors);
             string         text           = "成功";
             if (num == 0)
             {
                 text = "失败";
             }
             string text2 = string.Empty;
             if (this.errors.Count > 0)
             {
                 this.ViewState["errors"] = this.errors;
                 this.ShowErrors();
                 text2 = "\\n详见“警告信息”!";
             }
             else
             {
                 this.CloseSkip();
             }
             base.RegisterScript(string.Concat(new string[]
             {
                 "alert('系统提示:\\nExcel导入",
                 text,
                 "!",
                 text2,
                 "');"
             }));
             return;
         }
         base.RegisterScript("alert('系统提示:\\nExcel导入失败!\\n你选择要导入的上级节点已不存在!');");
     }
 }
Beispiel #7
0
 protected void btnImport_Click(object sender, System.EventArgs e)
 {
     this.taskArray = this.hfldExcelColumns.Value.Split(new char[]
     {
         ','
     });
     this.resourceArray = this.hfldResource.Value.Split(new char[]
     {
         ','
     });
     this.hfldExcelColumns.Value = string.Empty;
     this.hfldResource.Value     = string.Empty;
     if (this.ViewState["ExcelName"] != null && !string.IsNullOrEmpty(this.ViewState["ExcelName"].ToString()))
     {
         bool flag = true;
         if (string.IsNullOrEmpty(this.taskId))
         {
             this.dtWBS = (this.ViewState["dtwbs"] as DataTable);
             if (this.dtWBS.Rows.Count > 0)
             {
                 if (this.hfldIsWBSRelevance.Value == "1")
                 {
                     Project.CoverVersion(this.prjId);
                 }
                 else
                 {
                     Project.CoverVersionNew(this.prjId, this.version);
                 }
             }
         }
         else
         {
             flag = (BudTask.GetById(this.taskId) != null);
         }
         if (flag)
         {
             BudTaskServices budTaskServices = new BudTaskServices(this.taskId, this.prjId, this.version, this.dtWBS);
             bool            flag2           = false;
             System.Collections.Generic.IDictionary <string, int> relation = ExcelUtility.GetRelation(this.taskArray);
             int    num  = -1;
             int    num2 = -1;
             string str  = string.Empty;
             if (relation.Keys.Contains("TaskCode"))
             {
                 num2 = relation["TaskCode"];
             }
             if (relation.Keys.Contains("SerialNo"))
             {
                 num = relation["SerialNo"];
             }
             if (num != -1)
             {
                 str = this.dtWBS.Columns[num].ColumnName;
                 this.dtWBS.DefaultView.Sort = str + " DESC";
                 for (int i = 1; i < this.dtWBS.Rows.Count; i++)
                 {
                     if (this.dtWBS.Rows[i][num].ToString().Trim() == this.dtWBS.Rows[i - 1][num].ToString().Trim())
                     {
                         flag2 = true;
                         break;
                     }
                 }
             }
             else
             {
                 if (num2 != -1)
                 {
                     str = this.dtWBS.Columns[num2].ColumnName;
                     this.dtWBS.DefaultView.Sort = str + " DESC";
                     for (int j = 1; j < this.dtWBS.Rows.Count; j++)
                     {
                         if (this.dtWBS.Rows[j][num2].ToString().Trim() == this.dtWBS.Rows[j - 1][num2].ToString().Trim())
                         {
                             flag2 = true;
                             break;
                         }
                     }
                 }
             }
             if (flag2)
             {
                 base.RegisterScript("top.ui.alert('导入失败!\\n导入的Excel中有节点的任务编码出现重复,请修改!');");
                 return;
             }
             if (num == -1 && num2 != -1)
             {
                 foreach (DataRow dataRow in this.dtWBS.Rows)
                 {
                     string code = (dataRow[num2] == null) ? "" : dataRow[num2].ToString();
                     flag2 = BudTask.CheckCode(code, this.prjId);
                     if (flag2)
                     {
                         break;
                     }
                 }
             }
             if (flag2)
             {
                 base.RegisterScript("top.ui.alert('导入失败!\\n导入的Excel中有节点的任务编码与已有的节点出现重复,请修改!');");
                 base.RegisterScript("top.ui._BudgetPlaitList.location.href = top.ui._BudgetPlaitList.location.href;");
                 return;
             }
             this.inputUser = PageHelper.QueryUser(this, base.UserCode);
             int num3 = budTaskServices.ConverBudTaskList(this.taskArray, this.inputUser, this.errors, this.hfldIsWBSRelevance.Value);
             this.AddResource();
             string text = "成功";
             if (num3 == 0)
             {
                 text = "失败";
             }
             string text2 = string.Empty;
             if (this.errors.Count > 0)
             {
                 this.ViewState["errors"] = this.errors;
                 this.ShowErrors();
                 text2 = "\\n部分节点导入失败,详见“警告信息”!";
                 base.RegisterScript(string.Concat(new string[]
                 {
                     "top.ui.show('Excel导入",
                     text,
                     "!",
                     text2,
                     "');"
                 }));
                 return;
             }
             base.RegisterScript("top.ui._BudgetPlaitList.location.href = top.ui._BudgetPlaitList.location.href;");
             base.RegisterScript(string.Concat(new string[]
             {
                 "top.ui.show('Excel导入",
                 text,
                 "!",
                 text2,
                 "');"
             }));
             base.RegisterScript("top.ui.closeTab();");
             return;
         }
         else
         {
             base.RegisterScript("top.ui.alert('Excel导入失败!\\n你选择要导入的上级节点已不存在!');");
             base.RegisterScript("top.ui._BudgetPlaitList.location.href = top.ui._BudgetPlaitList.location.href;");
         }
     }
 }
Beispiel #8
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());
    }