private void tabBOQSheets_Selected(object sender, KryptonPageEventArgs e) { try { if (e.Item.Controls[0].GetType() == typeof(ControlSalesQuotationBOQSheet)) { ControlSalesQuotationBOQSheet sheet = (ControlSalesQuotationBOQSheet)e.Item.Controls[0]; sheet.SetBOQItemsGridColumnSettings(); sheet.SetBOQItemsGridColumnFormatting(); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ControlSalesQuotationBOQ::tabBOQSheets_Selected", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void PopulateSalesQuotationBOQ() { MODEL = null; tabBOQSheets.Pages.Clear(); Application.DoEvents(); try { // check if to be set readonly TBL_MP_CRM_SalesQuotation dbQuotation = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(SalesQuotationID); this.ReadOnly = (dbQuotation.FK_BOQRepresentativeID != Program.CURR_USER.EmployeeID); headerBOQMenu.Values.Heading = String.Empty; MODEL = (new ServiceSalesQuotationBOQ()).GetBOQViewModelForQuotation(this.SalesQuotationID); if (MODEL == null) { MODEL = (new ServiceSalesQuotationBOQ()).GenerateDefaultBOQForSalesQuotation(this.SalesQuotationID); } if (MODEL != null) { headerBOQMenu.Values.Heading = MODEL.BOQ_NUMBER; // CREATE ALL SHEETS foreach (SalesQuotationBOQSheet sheet in MODEL.SHEETS) { KryptonPage pageBOQSheet = new KryptonPage() { Text = sheet.SheetName, Name = string.Format("page{0}", tabBOQSheets.Pages.Count + 1) }; ControlSalesQuotationBOQSheet _sheetControl = new ControlSalesQuotationBOQSheet(sheet); _sheetControl.OnValueChanged += _sheetControl_OnValueChanged; _sheetControl.BOQ_MODEL = MODEL; pageBOQSheet.Controls.Add(_sheetControl); _sheetControl.Dock = DockStyle.Fill; tabBOQSheets.Pages.Add(pageBOQSheet); _sheetControl.ParentTabPage = pageBOQSheet; _sheetControl.PopulateBOQItemsGrid(); _sheetControl.Visible = true; _sheetControl.ReadOnly = this._ReadOnly; //pageBOQSheet.Show(); _sheetControl.SetBOQItemsGridColumnSettings(); _sheetControl.SetBOQItemsGridColumnFormatting(); pageBOQSheet.Refresh(); tabBOQSheets.SelectedPage = pageBOQSheet; Application.DoEvents(); } // ADD BOQ SUMMARY TAB pageBOQsummary = new KryptonPage() { Text = "SUMMARY", Name = "tabPageBOQSummary" }; _BOQSummaryControl = new ControlSalesQuotationBOQSummary(MODEL); _BOQSummaryControl.Dock = DockStyle.Fill; pageBOQsummary.Controls.Add(_BOQSummaryControl); tabBOQSheets.Pages.Add(pageBOQsummary); _BOQSummaryControl.PopulateBOQSummaryControl(); _BOQSummaryControl.ReadOnly = this._ReadOnly; } // perform grid formatting and column settings again foreach (KryptonPage page in tabBOQSheets.Pages) { if (page.Controls[0].GetType() == typeof(ControlSalesQuotationBOQSheet)) { ControlSalesQuotationBOQSheet sheet = (ControlSalesQuotationBOQSheet)page.Controls[0]; sheet.SetBOQItemsGridColumnSettings(); sheet.SetBOQItemsGridColumnFormatting(); } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ControlSalesQuotationBOQ::PopulateSalesQuotationBOQ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }