public W49020(string programID, string programName) : base(programID, programName) { InitializeComponent(); this.Text = _ProgramID + "─" + _ProgramName; dao49020 = new D49020(); }
protected override ResultStatus Retrieve() { try { DataTable dt = new D49020().ListData(); //0.check (沒有資料時,則自動新增一筆) if (dt.Rows.Count <= 0) { InsertRow(); } //1. 設定gvMain gvMain.Columns.Clear(); gvMain.OptionsBehavior.AutoPopulateColumns = true; gcMain.DataSource = dt; string[] showColCaption = { "商品", $"對外{Environment.NewLine}商品", $"順{Environment.NewLine}序", "商品別", $"契約{Environment.NewLine}類別", "簡稱", "全稱", "群組", $"標的{Environment.NewLine}現貨", $"下市日期{Environment.NewLine}yyyymmdd", "商品狀態", $"SMA{Environment.NewLine}調整標準", $"風險價格係數{Environment.NewLine}計算方式", $"國內/國外{Environment.NewLine}類別", "MGT2_W_TIME", "MGT2_W_USER_ID", $"最大振幅MaxVol{Environment.NewLine}調整標準", $"EWMA{Environment.NewLine}調整標準", "Is_NewRow" }; //1.1 設定欄位caption foreach (DataColumn dc in dt.Columns) { gvMain.SetColumnCaption(dc.ColumnName, showColCaption[dt.Columns.IndexOf(dc)]); gvMain.Columns[dc.ColumnName].AppearanceHeader.TextOptions.WordWrap = WordWrap.Wrap; gvMain.Columns[dc.ColumnName].AppearanceCell.TextOptions.WordWrap = WordWrap.Wrap; //設定合併欄位(一樣的值不顯示) gvMain.OptionsView.AllowCellMerge = true; gvMain.Columns[dc.ColumnName].AppearanceCell.TextOptions.VAlignment = VertAlignment.Center; gvMain.Columns[dc.ColumnName].OptionsColumn.AllowMerge = DefaultBoolean.False; gvMain.Columns[dc.ColumnName].AppearanceCell.Font = new Font("微軟正黑體", 10f); //設定column style gvMain.Columns[dc.ColumnName].AppearanceHeader.BackColor = (dc.ColumnName.AsString() == "MGT2_KIND_ID" ? GridHelper.PK : GridHelper.NORMAL); } //1.2 設定隱藏欄位 gvMain.Columns["MGT2_W_TIME"].Visible = false; gvMain.Columns["MGT2_W_USER_ID"].Visible = false; gvMain.Columns["IS_NEWROW"].Visible = false; //1.3 設定dropdownlist gvMain.Columns["MGT2_PROD_TYPE"].ColumnEdit = lupProdType; gvMain.Columns["MGT2_PROD_TYPE"].ShowButtonMode = ShowButtonModeEnum.ShowAlways; gvMain.Columns["MGT2_PROD_SUBTYPE"].ColumnEdit = lupProdSubtypeCod; gvMain.Columns["MGT2_PROD_SUBTYPE"].ShowButtonMode = ShowButtonModeEnum.ShowAlways; gvMain.Columns["MGT2_DATA_TYPE"].ColumnEdit = lupDataType; gvMain.Columns["MGT2_DATA_TYPE"].ShowButtonMode = ShowButtonModeEnum.ShowAlways; gvMain.Columns["MGT2_CP_KIND"].ColumnEdit = lupCpKind; gvMain.Columns["MGT2_CP_KIND"].ShowButtonMode = ShowButtonModeEnum.ShowAlways; gvMain.Columns["MGT2_ABROAD"].ColumnEdit = lupAbroad; gvMain.Columns["MGT2_ABROAD"].ShowButtonMode = ShowButtonModeEnum.ShowAlways; gvMain.AppearancePrint.HeaderPanel.Options.UseTextOptions = true; gvMain.AppearancePrint.HeaderPanel.TextOptions.WordWrap = WordWrap.Wrap; gvMain.ColumnPanelRowHeight = 40; gvMain.AppearancePrint.Row.Font = new Font("Microsoft YaHei", 10); gvMain.OptionsPrint.AllowMultilineHeaders = true; gvMain.AppearancePrint.GroupRow.Font = new Font("Microsoft YaHei", 10); gvMain.BestFitColumns(); GridHelper.SetCommonGrid(gvMain); gcMain.Focus(); return(ResultStatus.Success); } catch (Exception ex) { WriteLog(ex); } return(ResultStatus.Fail); }