示例#1
0
        private void gvEmployee_CustomRowCellEditForEditing(object sender, CustomRowCellEditEventArgs e)
        {
            DataRow row = gvLabour.GetDataRow(e.RowHandle);

            if (e.Column == colLevel1Code)
            {
                var codeList = LevelOneCode.ListForProject(_headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
            else if (e.Column == colLevel2Code)
            {
                int level1Id = row[colLevel1Code.FieldName] == DBNull.Value ? -1 : (int)row[colLevel1Code.FieldName];
                var codeList = LevelTwoCode.SubList(level1Id, _headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
            else if (e.Column == colLevel3Code)
            {
                int level2Id = row[colLevel2Code.FieldName] == DBNull.Value ? -1 : (int)row[colLevel2Code.FieldName];
                var codeList = LevelThreeCode.SubList(level2Id, _headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
            else if (e.Column == colLevel4Code)
            {
                int level3Id = row[colLevel3Code.FieldName] == DBNull.Value ? -1 : (int)row[colLevel3Code.FieldName];
                var codeList = LevelFourCode.SubList(level3Id, _headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
        }
示例#2
0
        private void gvDetail_CustomRowCellEditForEditing(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            int projectId = (int)gvPO.GetFocusedDataRow()[colProjectCode.FieldName];

            DataRow row = gvDetail.GetDataRow(e.RowHandle);

            if (e.Column == colDetailLevel1Code)
            {
                var codeList = LevelOneCode.ListForProject(projectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luDetailLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem         = luDetailLevel;
            }
            else if (e.Column == colDetailLevel2Code)
            {
                int level1Id = row[colDetailLevel1Code.FieldName] == DBNull.Value ? -1 : (int)row[colDetailLevel1Code.FieldName];
                var codeList = LevelTwoCode.SubList(level1Id, projectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luDetailLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem         = luDetailLevel;
            }
            else if (e.Column == colDetailLevel3Code)
            {
                int level2Id = row[colDetailLevel2Code.FieldName] == DBNull.Value ? -1 : (int)row[colDetailLevel2Code.FieldName];
                var codeList = LevelThreeCode.SubList(level2Id, projectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luDetailLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem         = luDetailLevel;
            }
            else if (e.Column == colDetailLevel4Code)
            {
                int level3Id = row[colDetailLevel3Code.FieldName] == DBNull.Value ? -1 : (int)row[colDetailLevel3Code.FieldName];
                var codeList = LevelFourCode.SubList(level3Id, projectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luDetailLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem         = luDetailLevel;
            }
        }
示例#3
0
        public ucEquipmentEntry()
        {
            InitializeComponent();

            luColEquipNum.DataSource = Equipment.ListForCompany().Select(e => new
            {
                EqpNum      = e.EqpNum,
                AssetCode   = e.AssetCode,
                DisplayName = e.DisplayName,
                Class       = EquipmentClass.GetEquipmentClass(e.ClassCode)?.Desc,
                Category    = EquipmentCategory.GetEquipmentCategory(e.CategoryCode)?.Desc
            }).ToList();

            luColAssertNum.DataSource = Equipment.ListForCompany().Select(e => new
            {
                EqpNum      = e.EqpNum,
                AssetCode   = e.AssetCode,
                DisplayName = e.DisplayName,
                Class       = EquipmentClass.GetEquipmentClass(e.ClassCode)?.Desc,
                Category    = EquipmentCategory.GetEquipmentCategory(e.CategoryCode)?.Desc
            }).ToList();

            var level1CodeList = LevelOneCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel1All.DataSource = level1CodeList.OrderBy(x => x.MatchId);

            var level2CodeList = LevelTwoCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel2All.DataSource = level2CodeList.OrderBy(x => x.MatchId);

            var level3CodeList = LevelThreeCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel3All.DataSource = level3CodeList.OrderBy(x => x.MatchId);

            var level4CodeList = LevelFourCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel4All.DataSource = level4CodeList.OrderBy(x => x.MatchId);

            luColBillCycleAll.DataSource = Enum.GetValues(typeof(EnumBillCycle)).Cast <EnumBillCycle>().Select(x => new { Enum = (char)x, Desc = Enum.GetName(typeof(EnumBillCycle), x) });

            int maxLevel  = Company.GetCurrCompany().MaxLevelCode;
            var SetColumn = new Action <GridColumn, int, string>((col, level, caption) =>
            {
                col.Visible = maxLevel >= level;
                col.OptionsColumn.ShowInCustomizationForm = maxLevel >= level;
                col.Caption = caption;
            });

            SetColumn(colLevel4Code, 4, Company.GetCurrCompany().Level4CodeDesc);
            SetColumn(colLevel3Code, 3, Company.GetCurrCompany().Level3CodeDesc);
            SetColumn(colLevel2Code, 2, Company.GetCurrCompany().Level2CodeDesc);
            SetColumn(colLevel1Code, 1, Company.GetCurrCompany().Level1CodeDesc);
        }
示例#4
0
        public ucFieldPO()
        {
            InitializeComponent();

            btnSubmit.Enabled = false;

            _fileMgr                     = new ucFileManager(MobileCommon.HMCon, GuiCommon.HMDevXManager, DocumentViewerMode.All, false, "F", true);
            _fileMgr.Dock                = DockStyle.Fill;
            _fileMgr.Parent              = dpAttachment;
            _fileMgr.AttachmentsRemoved += AttachmentsRemoved;
            _fileMgr.AttachmentsAdded   += AttachmentsAdded;
            _fileMgr.AttachmentsEdited  += AttachmentsEdited;
            _fileMgr.Enabled             = false;

            luColSupplier.DataSource     = Supplier.ListForCompany().Select(s => new { SupplierCode = s.SupplierCode, SupplierName = s.SupplierName });
            luColSupplierName.DataSource = Supplier.ListForCompany().Select(s => new { SupplierCode = s.SupplierCode, SupplierName = s.SupplierName });

            luColProjectCode.DataSource = Project.AccessibleList().Select(p => new { MatchId = p.MatchId, Code = p.Code, Project = p.Name }).ToList();
            luColProjectName.DataSource = Project.AccessibleList().Select(p => new { MatchId = p.MatchId, Code = p.Code, Project = p.Name }).ToList();

            var level1CodeList = LevelOneCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luDetailLevel1All.DataSource = level1CodeList.OrderBy(x => x.MatchId);

            var level2CodeList = LevelTwoCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luDetailLevel2All.DataSource = level2CodeList.OrderBy(x => x.MatchId);

            var level3CodeList = LevelThreeCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luDetailLevel3All.DataSource = level3CodeList.OrderBy(x => x.MatchId);

            var level4CodeList = LevelFourCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luDetailLevel4All.DataSource = level4CodeList.OrderBy(x => x.MatchId);

            luDetailComponent.DataSource = Enum.GetValues(typeof(EnumComponentType)).Cast <EnumComponentType>().Select(x => new { Type = Enum.GetName(typeof(EnumComponentType), x), Enum = (char)x });

            int maxLevel  = Company.GetCurrCompany().MaxLevelCode;
            var SetColumn = new Action <GridColumn, int, string>((col, level, caption) =>
            {
                col.Visible = maxLevel >= level;
                col.OptionsColumn.ShowInCustomizationForm = maxLevel >= level;
                col.Caption = caption;
            });

            SetColumn(colDetailLevel4Code, 4, Company.GetCurrCompany().Level4CodeDesc);
            SetColumn(colDetailLevel3Code, 3, Company.GetCurrCompany().Level3CodeDesc);
            SetColumn(colDetailLevel2Code, 2, Company.GetCurrCompany().Level2CodeDesc);
            SetColumn(colDetailLevel1Code, 1, Company.GetCurrCompany().Level1CodeDesc);
        }
示例#5
0
        private void gvEquipment_CustomRowCellEditForEditing(object sender, CustomRowCellEditEventArgs e)
        {
            DataRow row = gvEquipment.GetDataRow(e.RowHandle);

            if (e.Column == colBillCycle)
            {
                var equip = Equipment.GetEquipment(Convert.ToString(row[colEqpNum.FieldName]));
                var list  = equip.GetBillRateList(_headerRecord.ProjectId);
                list.Add(new EquipmentBillRate {
                    BillCycle = EnumBillCycle.Unknown, BillRate = 0, IsDefault = false
                });

                luColBillCycle.DataSource = list.Select(x => new
                {
                    Enum      = (char)x.BillCycle,
                    Cycle     = Enum.GetName(typeof(EnumBillCycle), x.BillCycle),
                    BillRate  = (x.BillRate == 0 ? "" : x.BillRate.ToString("N2")),
                    IsDefault = x.IsDefault ? "*" : ""
                });
                e.RepositoryItem = luColBillCycle;
            }
            else if (e.Column == colLevel1Code)
            {
                var codeList = LevelOneCode.ListForProject(_headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
            else if (e.Column == colLevel2Code)
            {
                int level1Id = row[colLevel1Code.FieldName] == DBNull.Value ? -1 : (int)row[colLevel1Code.FieldName];
                var codeList = LevelTwoCode.SubList(level1Id, _headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
            else if (e.Column == colLevel3Code)
            {
                int level2Id = row[colLevel2Code.FieldName] == DBNull.Value ? -1 : (int)row[colLevel2Code.FieldName];
                var codeList = LevelThreeCode.SubList(level2Id, _headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
            else if (e.Column == colLevel4Code)
            {
                int level3Id = row[colLevel3Code.FieldName] == DBNull.Value ? -1 : (int)row[colLevel3Code.FieldName];
                var codeList = LevelThreeCode.SubList(level3Id, _headerRecord.ProjectId).Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();
                luColLevel.DataSource = codeList.OrderBy(x => x.MatchId);
                e.RepositoryItem      = luColLevel;
            }
        }
示例#6
0
        public ucLabourEntry()
        {
            InitializeComponent();

            luColEmpNum.DataSource  = Employee.ListForCompany().Select(emp => new { EmpNum = emp.EmpNum, DisplayName = emp.DisplayName }).Distinct().ToList();
            luColEmpName.DataSource = Employee.ListForCompany().Select(emp => new { EmpNum = emp.EmpNum, DisplayName = emp.DisplayName }).Distinct().ToList();

            var wcList = WorkClass.ListForCompany().Select(wc => new { Code = wc.Code, DisplayName = wc.DisplayName }).Distinct().ToList();

            luColWorkClass.DataSource = wcList;

            var codeLevel1List = LevelOneCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel1All.DataSource = codeLevel1List.OrderBy(x => x.MatchId);

            var codeLevel2List = LevelTwoCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel2All.DataSource = codeLevel2List.OrderBy(x => x.MatchId);

            var level3CodeList = LevelThreeCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel3All.DataSource = level3CodeList.OrderBy(x => x.MatchId);

            var level4CodeList = LevelFourCode.ListForCompany().Select(code => new { MatchId = code.MatchId, Code = code.Code, Desc = code.Desc, DisplayName = code.DisplayName }).Distinct().ToList();

            luColLevel4All.DataSource = level4CodeList.OrderBy(x => x.MatchId);

            Func <string, string, int, GridColumn> CreateColumn = new Func <string, string, int, GridColumn>((field, caption, visibleIndex) =>
            {
                GridColumn column   = gvLabour.Columns.AddVisible(field, caption);
                column.VisibleIndex = visibleIndex;
                return(column);
            });

            int visionIndex = 0;

            new List <GridColumn> {
                colEmpNum, colEmployeeName, colWorkClass, colChangeOrder, colLevel1Code, colLevel2Code, colLevel3Code, colLevel4Code, colBillable, colManual
            }
            .ForEach(x => x.VisibleIndex = visionIndex++);

            foreach (var timecode in TimeCode.SubList(TimeCode.EnumValueType.Hours))
            {
                tableLabour.Columns.Add(BillRateI(timecode), Type.GetType("System.Decimal"));
                var rateCol = CreateColumn(BillRateI(timecode), $"{timecode.Desc} Bill Rate", visionIndex++);
                rateCol.DisplayFormat.FormatType   = FormatType.Numeric;
                rateCol.DisplayFormat.FormatString = "c2";
                rateCol.OptionsColumn.AllowEdit    = false;

                tableLabour.Columns.Add(EnterHoursI(timecode), Type.GetType("System.Decimal"));
                var hourCol = CreateColumn(EnterHoursI(timecode), $"{timecode.Desc} Hours", visionIndex++);
                hourCol.ColumnEdit = textColHours;
                hourCol.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
                    new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, hourCol.FieldName, "{0:n2}")
                });
            }

            foreach (var timecode in TimeCode.SubList(TimeCode.EnumValueType.Dollars))
            {
                tableLabour.Columns.Add(EnterAmountI(timecode), Type.GetType("System.Decimal"));
                var amountCol = CreateColumn(EnterAmountI(timecode), timecode.Desc, visionIndex++);
                amountCol.ColumnEdit = textColAmount;
            }

            colTotalHours.VisibleIndex = visionIndex++;
            colBillAmount.VisibleIndex = visionIndex++;

            int maxLevel  = Company.GetCurrCompany().MaxLevelCode;
            var SetColumn = new Action <GridColumn, int, string>((col, level, caption) =>
            {
                col.Visible = maxLevel >= level;
                col.OptionsColumn.ShowInCustomizationForm = maxLevel >= level;
                col.Caption = caption;
            });

            SetColumn(colLevel4Code, 4, Company.GetCurrCompany().Level4CodeDesc);
            SetColumn(colLevel3Code, 3, Company.GetCurrCompany().Level3CodeDesc);
            SetColumn(colLevel2Code, 2, Company.GetCurrCompany().Level2CodeDesc);
            SetColumn(colLevel1Code, 1, Company.GetCurrCompany().Level1CodeDesc);
        }
示例#7
0
        public void SetData(List <LemHeader> headerList)
        {
            tableLabour.Clear();

            var table = LemHeader.GetCostCodeSummary(headerList.Select(x => x.Id).ToList());
            var list  = table.Select().Select(r => new
            {
                EmpNum        = Convert.ToInt32(r["EmpNum"]),
                WorkClassCode = Convert.ToString(r["WorkClassCode"]),
                Billable      = Convert.ToBoolean(r["Billable"]),
                ProjectId     = Convert.ToInt32(r["ProjectId"]),
                ChangeOrderId = ConvertEx.ToNullable <int>(r["ChangeOrderId"]),
                Level1Id      = ConvertEx.ToNullable <int>(r["Level1Id"]),
                Level2Id      = ConvertEx.ToNullable <int>(r["Level2Id"]),
                Level3Id      = ConvertEx.ToNullable <int>(r["Level3Id"]),
                Level4Id      = ConvertEx.ToNullable <int>(r["Level4Id"]),
                TimeCodeId    = Convert.ToInt32(r["TimeCodeId"]),
                SumWorkHour   = ConvertEx.ToNullable <decimal>(r["SumWorkHour"]),
                SumAmount     = ConvertEx.ToNullable <decimal>(r["SumAmount"]),
            });

            var groupList = list.ToLookup(x => new
            {
                x.EmpNum,
                x.WorkClassCode,
                x.Billable,
                x.ProjectId,
                x.ChangeOrderId,
                x.Level1Id,
                x.Level2Id,
                x.Level3Id,
                x.Level4Id,
                EmpName     = Employee.GetEmployee(x.EmpNum)?.DisplayName,
                WorkClass   = WorkClass.GetWorkClass(x.WorkClassCode).DisplayName,
                Project     = Project.GetProject(x.ProjectId),
                ChangeOrder = ChangeOrder.GetChangeOrder(x.ProjectId, x.ChangeOrderId)?.DisplayName,
                Level1      = LevelOneCode.GetLevelCode(x.Level1Id)?.DisplayName,
                Level2      = LevelTwoCode.GetLevelCode(x.Level2Id)?.DisplayName,
                Level3      = LevelThreeCode.GetLevelCode(x.Level3Id)?.DisplayName,
                Level4      = LevelFourCode.GetLevelCode(x.Level4Id)?.DisplayName
            }).OrderBy(x => x.Key.Level1).ThenBy(x => x.Key.Level2).ThenBy(x => x.Key.Level3).ThenBy(x => x.Key.Level4).ThenBy(x => x.Key.EmpName).ThenBy(x => x.Key.Project).ThenBy(x => x.Key.ChangeOrder).ThenBy(x => x.Key.WorkClass).ThenBy(x => x.Key.Billable).ToList();

            groupList.ForEach(g =>
            {
                DataRow row = tableLabour.Rows.Add(
                    g.Key.EmpNum,
                    g.Key.EmpName,
                    g.Key.WorkClass,
                    g.Key.Project,
                    g.Key.ChangeOrder,
                    g.Key.Level1,
                    g.Key.Level2,
                    g.Key.Level3,
                    g.Key.Level4,
                    g.Key.Billable,
                    null,
                    null);

                decimal?billRate;
                decimal totalHours  = 0;
                decimal billAmounts = 0;
                foreach (var timecode in TimeCode.ListForCompany())
                {
                    if (timecode.ValueType == EnumValueType.Hours)
                    {
                        billRate = ProjectWorkClass.GetBillRate(g.Key.ProjectId, timecode.MatchId, g.Key.WorkClassCode);
                        row[ColName.BillRateI(timecode)] = (object)billRate ?? DBNull.Value;

                        decimal hours = g.Where(x => x.TimeCodeId == timecode.MatchId).Sum(x => x.SumWorkHour) ?? 0;
                        row[ColName.EnterValueI(timecode)] = hours != 0 ? (object)hours : DBNull.Value;

                        totalHours  += hours;
                        billAmounts += (billRate ?? 0) * hours;
                    }
                    else
                    {
                        decimal amount = g.Where(x => x.TimeCodeId == timecode.MatchId).Sum(x => x.SumAmount) ?? 0;
                        row[ColName.EnterValueI(timecode)] = amount != 0 ? (object)amount : DBNull.Value;
                        billAmounts += amount;
                    }

                    row[ColName.TotalHours] = totalHours != 0 ? (object)totalHours : DBNull.Value;
                    row[ColName.BillAmount] = billAmounts != 0 ? (object)billAmounts : DBNull.Value;
                }
            });
        }