private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) { var LoadAttachments = new Action <int>((poId) => { _fileMgr.DocumentFileLink = new FileLink[] { new FileLink(Attachment.LemHeaderId, poId, Company.CurrentId, FileLink.Database.TR, 0, true) }; }); DataRow row = gridView1.GetDataRow(e.FocusedRowHandle); if (row != null && row.GetValue(colId) != DBNull.Value) { LoadAttachments(row.GetValue <int>(colId)); btnEmail.Enabled = true; btnPrint.Enabled = true; btnSubmit.Enabled = GetEnumName(EnumSubmitStatus.Open) == row.GetValueString(colSubmitStatus); _fileMgr.Enabled = LemHeader.CheckEditable(row.GetCharEnumValue <EnumLogStatus>(colLogStatus)); _fileMgr.ReadOnly = !_fileMgr.Enabled; } else { LoadAttachments(-1); btnEmail.Enabled = false; btnPrint.Enabled = false; btnSubmit.Enabled = false; _fileMgr.Enabled = false; _fileMgr.ReadOnly = true; } }
public void RefreshCurrentRowStatus() { var row = gridView1.GetDataRow(gridView1.FocusedRowHandle); if (row != null) { int id = row.GetValue <int>(colId); LemHeader data = LemHeader.GetLogHeader(id); row.SetValue(colSubmitStatus, GetEnumName(data.SubmitStatus)); btnSubmit.Enabled = GetEnumName(EnumSubmitStatus.Open) == row.GetValueString(colSubmitStatus); _fileMgr.Enabled = LemHeader.CheckEditable(row.GetCharEnumValue <EnumLogStatus>(colLogStatus)); } }
public void SetCurrent(LemHeader header) { _headerRecord = header; SetEnabled(_headerRecord.CheckEditable()); var changeOrderList = ChangeOrder.ListForProject(_headerRecord.ProjectId).Select(cs => new { EstimateId = cs.EstimateId, DisplayName = cs.DisplayName }).Distinct().ToList(); changeOrderList.Add(new { EstimateId = -1, DisplayName = "" }); luChangeOrder.DataSource = changeOrderList; tableLabour.Clear(); var list = LabourTimeEntry.GetLabourEntryList(header.Id).ToList(); list.ForEach(lte => { DataRow row = tableLabour.Rows.Add( lte.Id, lte.EmpNum, lte.EmpNum, lte.WorkClassCode, lte.ChangeOrderId, lte.Level1Id, lte.Level2Id, lte.Level3Id, lte.Level4Id, lte.Billable, lte.Manual, lte.IncludedHours, lte.TotalHours, lte.BillAmount); foreach (var timecode in TimeCode.SubList(TimeCode.EnumValueType.Hours)) { row[BillRateI(timecode)] = (object)ProjectWorkClass.GetBillRate(_headerRecord.ProjectId, timecode.MatchId, (string)row[colWorkClass.FieldName]) ?? DBNull.Value; row[EnterHoursI(timecode)] = (object)list.Find(x => x.Id == (int)row[colId.FieldName]).DetailList.SingleOrDefault(d => d.TimeCodeId == timecode.MatchId)?.WorkHours ?? DBNull.Value; } foreach (var timecode in TimeCode.SubList(TimeCode.EnumValueType.Dollars)) { row[EnterAmountI(timecode)] = (object)list.Find(x => x.Id == (int)row[colId.FieldName]).DetailList.SingleOrDefault(d => d.TimeCodeId == timecode.MatchId)?.Amount ?? DBNull.Value; } }); tableLabour.AcceptChanges(); gvLabour.BestFitColumns(true); }
private void gridView1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) { var row = gridView1.GetDataRow(gridView1.FocusedRowHandle); if (!LemHeader.CheckEditable(row.GetCharEnumValue <EnumLogStatus>(colLogStatus))) { e.Cancel = true; return; } if (new GridColumn[] { colProjectCode, colProjectName }.Contains(gridView1.FocusedColumn)) { if (row.GetValue(colId) != DBNull.Value && LemHeader.CheckHasEntry(row.GetValue <int>(colId))) { ShowMessage("This LEM Header contains Entries, cannot change the Project."); e.Cancel = true; return; } } }
public void SetCurrent(LemHeader header) { _headerRecord = header; SetEnabled(_headerRecord.CheckEditable()); tableAP.Clear(); LemAP.GetLemAP(header.ProjectId, header.Id).ForEach(x => tableAP.Rows.Add( x.Id, x.InvoiceDate, x.HeaderId == header.Id, x.InvoiceNum, Supplier.GetSupplier(x.SupplierCode).SupplierName, x.PONum, Project.GetProject(x.ProjectId).DisplayName, x.InvoiceAmount, x.MarkupAmount, x.BillAmount) ); tableAP.AcceptChanges(); }
public void SetCurrent(LemHeader header) { _headerRecord = header; SetEnabled(_headerRecord.CheckEditable()); var changeOrderList = ChangeOrder.ListForProject(_headerRecord.ProjectId).Select(cs => new { EstimateId = cs.EstimateId, DisplayName = cs.DisplayName }).Distinct().ToList(); luChangeOrder.DataSource = changeOrderList; tableEquipEntry.Clear(); EquipTimeEntry.GetEquipEntryList(header.Id).ToList().ForEach(x => { var equip = Equipment.GetEquipment(x.EqpNum); double?billRate = null; if (equip != null) { var list = equip.GetBillRateList(_headerRecord.ProjectId); billRate = (double?)list.SingleOrDefault(c => c.BillCycle == x.BillCycle)?.BillRate; } tableEquipEntry.Rows.Add( x.Id, x.EqpNum, x.EqpNum, EquipmentClass.GetEquipmentClass(equip.ClassCode)?.DisplayName ?? "", x.EmpNum, x.EmpNum != null ? Employee.GetEmployee(x.EmpNum.Value).DisplayName : "", x.ChangeOrderId, x.Level1Id, x.Level2Id, x.Level3Id, x.Level4Id, x.Billable, x.Quantity, (char)x.BillCycle, billRate, x.BillAmount); }); tableEquipEntry.AcceptChanges(); }
public void SetCurrentHeader(LemHeader header) { _headerRecord = header; var project = Project.GetProject(header.ProjectId); labelProject.Text = project.DisplayName; labelDate.Text = header.LogDate.ToString("yyyy/MM/dd"); labelCustName.Text = project.CustomerName; labelCustAddress.Text = project.CustomerAddress; labelSheetNum.Text = header.LemNum; labelReference.Text = project.POReference ?? ""; SetEnabled(_headerRecord.CheckEditable()); if (tabControl1.SelectedTabPage == tpLabour) { SetCurrentPage(tpLabour); } else { tabControl1.SelectedTabPage = tpLabour; } }