public static void CreateDataSource(IDbConnection con, DataList dataList, string sXmlParam, out IDbDataAdapter da, out DataTable dt) { CreateDataSource(con, dataList, XDocument.Parse(sXmlParam).Element("def"), out da, out dt); }
public void AddDetailDataSource(IDbConnection con, DataList dataList, IDbDataAdapter da, DataTable dt, string sXmlParam) { AddDetailDataSource(con, dataList, da, dt, XDocument.Parse(sXmlParam).Element("def")); }
public void AddDetailDataSource(IDbConnection con, DataList dataList, IDbDataAdapter da, DataTable dt, XElement xe) { //string sDataName = Xml.GetAttribValue(xe, "def"); string sDataName = xe.zAttribValue("def"); if (sDataName == gsDetailName) return; //if (gbTrace) cTrace.StartNestedLevel("cGrid_AddDetailDataSource_2"); Update(); int iRow = 0; if (gGridMaster != null && gGridMaster.MainView != null) iRow = ((GridView)gGridMaster.MainView).FocusedRowHandle; ClearDetailDataSource(); if (xe == null) return; string sOption = xe.zAttribValue("Option"); XtraGridOption option = gOptionDetail = new XtraGridOption(sOption); gdaDetail = da; gdtDetail = dt; gbDetailDynamic = option.DetailDynamic; gsMasterId = xe.zAttribValue("MasterId"); gsDetailId = xe.zAttribValue("DetailId", gsMasterId); GridSetDataSource(gGridDetail, gdtDetail, xe, con, dataList, option); gViewDetail.OptionsView.ShowFilterPanel = false; DetailUpdateList(); gsDetailName = sDataName; //LoadDetailParameters(); if (gGridMaster != null && gGridMaster.MainView != null) ((GridView)gGridMaster.MainView).FocusedRowHandle = iRow; //if (gbTrace) cTrace.StopNestedLevel("cGrid_AddDetailDataSource_2"); }
public void SetMasterDataSource(IDbConnection con, DataList dataList, DataTable dt, IDbDataAdapter da, XElement xe) { //cTrace.StartNestedLevel("cGrid_SetMasterDataSource"); //string sDataName = Xml.GetAttribValue(xe, "def"); string sDataName = xe.zAttribValue("def"); if (sDataName == gsMasterName) return; //Update(); ClearDataSource(); //gsMasterId = null; //gsDetailId = null; //gbDetailDynamic = false; if (xe == null) return; gdaMaster = da; gdtMaster = dt; XtraGridOption option = gOptionMaster = new XtraGridOption(xe.zAttribValue("Option")); GridSetDataSource(gGridMaster, dt, xe, con, dataList, option); gdtMaster.RowDeleting += new DataRowChangeEventHandler(DataTableMaster_RowDeleting); gsMasterName = sDataName; //LoadMasterParameters(); //cTrace.StopNestedLevel("cGrid_SetMasterDataSource"); }
public void AddDetailDataSource(IDbConnection con, DataList dataList, XElement xe) { string sDetailName = GetSourceName(xe); if (sDetailName == gsDetailName) return; //if (gbTrace) cTrace.StartNestedLevel("cGrid_AddDetailDataSource_1"); IDbDataAdapter da; DataTable dt; CreateDataSource(con, dataList, xe, out da, out dt, gdtMaster); AddDetailDataSource(con, dataList, da, dt, xe); //if (gbTrace) cTrace.StopNestedLevel("cGrid_AddDetailDataSource_1"); }
public XtraGridTools(IDbConnection con, DataList dataList) { gCon = con; gDataList = dataList; }
public static void GridSetDataSource(GridControl dxGrid, DataTable dt, XElement xe, IDbConnection con, DataList dataList) { //if (xe == null) return; string sOption = null; if (xe != null) sOption = xe.zAttribValue("Option"); XtraGridOption option = new XtraGridOption(sOption); GridSetDataSource(dxGrid, dt, xe, con, dataList, option); }
public static void GridSetViewOption(GridView view, XElement xe, DataTable dt, IDbConnection con, DataList dataList) { string sOption = xe.zAttribValue("Option"); XtraGridOption option = new XtraGridOption(sOption); GridSetViewOption(view, xe, dt, con, dataList, option); }
private static void GridSetViewOption(GridView view, XElement xe, DataTable dt, IDbConnection con, DataList dataList, XtraGridOption option) { //if (gbTrace) cTrace.StartNestedLevel("GridSetViewOption"); //if (gbTrace) cTrace.StartNestedLevel("Columns_Clear"); view.Columns.Clear(); //if (gbTrace) cTrace.StopNestedLevel("Columns_Clear"); //if (gbTrace) cTrace.StartNestedLevel("PopulateColumns"); if (dt != null) view.PopulateColumns(dt); else view.PopulateColumns(); //if (gbTrace) cTrace.StopNestedLevel("PopulateColumns"); //((System.ComponentModel.ISupportInitialize)(dxGrid)).BeginInit(); //((System.ComponentModel.ISupportInitialize)(view)).BeginInit(); string sName = xe.zAttribValue("def"); if (sName != null) view.Name = sName; //if (gbTrace) cTrace.StartNestedLevel("SetGridColumn***"); string sColumn = xe.zAttribValue("Column"); //SetGridColumn(view, sColumn); XtraGridTools.SetGridColumn(view, sColumn); sColumn = xe.zAttribValue("ColumnCaption"); //SetGridColumnCaption(view, sColumn); XtraGridTools.SetGridColumnCaption(view, sColumn); sColumn = xe.zAttribValue("Update"); //SetGridColumnUpdate(view, sColumn); XtraGridTools.SetGridColumnUpdate(view, sColumn); sColumn = xe.zAttribValue("ReadOnly"); //SetGridColumnReadOnly(view, sColumn); XtraGridTools.SetGridColumnReadOnly(view, sColumn); sColumn = xe.zAttribValue("Hide"); //SetGridColumnHide(view, sColumn); XtraGridTools.SetGridColumnHide(view, sColumn); //if (gbTrace) cTrace.StopNestedLevel("SetGridColumn***"); // Filter string sFilter = xe.zAttribValue("Filter"); //SetGridFilter(view, sFilter); XtraGridTools.SetGridFilter(view, sFilter); view.OptionsView.ColumnAutoWidth = option.ColumnAutoWidth; view.OptionsView.ShowGroupPanel = option.ShowGroupPanel; view.OptionsView.ShowIndicator = !option.NoIndicator; view.OptionsView.ShowFilterPanel = !option.NoShowFilterPanel; view.OptionsView.ShowColumnHeaders = !option.NoShowColumnHeaders; view.OptionsCustomization.AllowFilter = !option.NoAllowFilter; view.OptionsCustomization.AllowGroup = !option.NoAllowGroup; view.OptionsCustomization.AllowRowSizing = !option.NoAllowRowSizing; view.OptionsCustomization.AllowSort = !option.NoAllowSort; //RowHeight //SetRowHeight(view, xe.zAttribValue("RowHeight")); XtraGridTools.SetRowHeight(view, xe.zAttribValue("RowHeight")); //Font font = GetFont(xe.zAttribValue("Font")); Font font = XtraGridTools.GetFont(xe.zAttribValue("Font")); if (font != null) { view.ViewStylesInfo.Row.Font = font; view.ViewStylesInfo.FocusedRow.Font = font; view.ViewStylesInfo.FocusedCell.Font = font; } StyleOptions style; //if (GetStyleOptions(xe.zAttribValue("StyleFocusedRow"), out style)) if (XtraGridTools.GetStyleOptions(xe.zAttribValue("StyleFocusedRow"), out style)) view.ViewStylesInfo.FocusedRow.Options = style; //if (GetStyleOptions(xe.zAttribValue("StyleSelectedRow"), out style)) if (XtraGridTools.GetStyleOptions(xe.zAttribValue("StyleSelectedRow"), out style)) view.ViewStylesInfo.SelectedRow.Options = style; //if (GetStyleOptions(xe.zAttribValue("StyleHideSelectionRow"), out style)) if (XtraGridTools.GetStyleOptions(xe.zAttribValue("StyleHideSelectionRow"), out style)) view.ViewStylesInfo.HideSelectionRow.Options = style; //OptionsDetail view.OptionsDetail.EnableMasterViewMode = option.MasterViewMode; view.OptionsDetail.AllowZoomDetail = option.AllowZoomDetail; view.OptionsDetail.SmartDetailExpand = option.SmartDetailExpand; view.OptionsDetail.AllowExpandEmptyDetails = option.AllowExpandEmptyDetails; view.OptionsDetail.AutoZoomDetail = option.AutoZoomDetail; view.OptionsDetail.EnableDetailToolTip = option.EnableDetailToolTip; view.OptionsDetail.ShowDetailTabs = option.ShowDetailTabs; view.OptionsDetail.SmartDetailHeight = option.SmartDetailHeight; view.OptionsBehavior.Editable = false; view.OptionsView.ShowNewItemRow = false; if (!option.ReadOnly) { if (!option.NoUpdate) view.OptionsBehavior.Editable = true; if (!option.NoInsert && !option.NoInsertButton) view.OptionsView.ShowNewItemRow = true; } if (!option.NoMultiSelect) view.OptionsSelection.MultiSelect = true; //if (gbTrace) cTrace.StartNestedLevel("GridSetViewOption_2"); IEnumerable<XElement> cols = null; if (xe != null) { cols = xe.Elements("col"); foreach (XElement col in cols) { string sColName = col.zAttribValue("Name"); GridColumn colGrid = view.Columns[sColName]; if (colGrid == null) { colGrid = view.Columns.Add(); colGrid.Name = sColName; colGrid.Caption = sColName; colGrid.FieldName = sColName; colGrid.VisibleIndex = view.VisibleColumns.Count; } if (colGrid != null) { string sOption = col.zAttribValue("Option", ""); string sCaption = col.zAttribValue("Caption"); if (sCaption != null) colGrid.Caption = sCaption; //SetGridColumnOption(colGrid, sOption); XtraGridTools.SetGridColumnOption(colGrid, sOption); //SetGridColumnStyle(colGrid, col.zAttribValue("Style")); XtraGridTools.SetGridColumnStyle(colGrid, col.zAttribValue("Style")); //SetGridColumnFormatDate(colGrid, col.zAttribValue("FormatDate")); XtraGridTools.SetGridColumnFormatDate(colGrid, col.zAttribValue("FormatDate")); //SetGridColumnFormatNum(colGrid, col.zAttribValue("FormatNum")); XtraGridTools.SetGridColumnFormatNum(colGrid, col.zAttribValue("FormatNum")); //SetGridColumnEdit(view, con, dataList, colGrid, col.zAttribValue("Edit"), col); XtraGridTools gridTools = new XtraGridTools(con, dataList, gStaticEditRepository); gridTools.SetColumnEdit(colGrid, col); } } } //SetGridColumnsDefaultEdit(view); XtraGridTools.SetGridColumnsDefaultEdit(view); //if (gbTrace) cTrace.StopNestedLevel("GridSetViewOption_2"); //((System.ComponentModel.ISupportInitialize)(view)).EndInit(); //if (gbTrace) cTrace.StartNestedLevel("BestFitColumns"); if (!option.NoBestFitColumns) { view.BestFitMaxRowCount = 50; view.BestFitColumns(); } //if (gbTrace) cTrace.StopNestedLevel("BestFitColumns"); if (cols != null) { foreach (XElement col in cols) { GridColumn colGrid = view.Columns[col.zAttribValue("Name")]; //XtraGridTools.SetGridColumnWidth(colGrid, col.zAttribValueInt("Width", -1)); XtraGridTools.SetGridColumnWidth(colGrid, col.zAttribValue("Width").zTryParseAs<int>(-1)); } } string sSort = xe.zAttribValue("Sort"); //SetGridSort(view, sSort); XtraGridTools.SetGridSort(view, sSort); //LoadParameters(view, xe); //XtraGridTools.LoadParameters(view, xe); //if (gbTrace) cTrace.StopNestedLevel("GridSetViewOption"); }
public static void GridCreateDetailView(GridControl dxGrid, DataTable dt, string sRelation, XElement xe, IDbConnection con, DataList dataList) { string sOption = xe.zAttribValue("Option"); XtraGridOption option = new XtraGridOption(sOption); GridView view = new GridView(); view.GridControl = dxGrid; dxGrid.LevelDefaults.Add(sRelation, view); GridSetViewOption(view, xe, dt, con, dataList, option); }
public static void GridSetViewOption(GridView view, string sXmlParam, DataTable dt, IDbConnection con, DataList dataList) { XElement xe = null; if (sXmlParam != null) xe = XDocument.Parse(sXmlParam).Element("def"); GridSetViewOption(view, xe, dt, con, dataList); }
public static void GridCreateDetailView(GridControl dxGrid, DataTable dt, string sRelation, string sXmlParam, IDbConnection con, DataList dataList) { GridCreateDetailView(dxGrid, dt, sRelation, XDocument.Parse(sXmlParam).Element("def"), con, dataList); }
public static void GridSetOption(GridControl dxGrid, XElement xe, DataTable dt, IDbConnection con, DataList dataList) { string sOption = xe.zAttribValue("Option"); XtraGridOption option = new XtraGridOption(sOption); dxGrid.ForceInitialize(); //GridSetNavigatorOption(dxGrid, option); XtraGridTools.SetNavigatorOption(dxGrid, option); GridSetViewOption((GridView)dxGrid.MainView, xe, dt, con, dataList, option); dxGrid.Leave += new EventHandler(GridControl_Leave); }
private static void GridSetDataSource(GridControl grid, DataTable dt, XElement xe, IDbConnection con, DataList dataList, XtraGridOption option) { //if (gbTrace) cTrace.StartNestedLevel("cGrid_GridSetDataSource"); //if (gbTrace) cTrace.StartNestedLevel("EndEvent"); if (grid.Tag is FormGridEvent) ((FormGridEvent)grid.Tag).End(); //if (gbTrace) cTrace.StopNestedLevel("EndEvent"); ((GridView)grid.MainView).CollapseAllDetails(); GridClearDataSource(grid); //if (option.MasterViewMode) GridCreateDetailViews(grid, dt); if (option.MasterViewMode) XtraGridTools.GridCreateDetailViews(grid, dt); //if (gbTrace) cTrace.StartNestedLevel("SetDataSource"); grid.DataSource = dt; grid.ForceInitialize(); //if (gbTrace) cTrace.StopNestedLevel("SetDataSource"); //GridSetNavigatorOption(grid, option); XtraGridTools.SetNavigatorOption(grid, option); GridSetViewOption((GridView)grid.MainView, xe, dt, con, dataList, option); grid.Leave += new EventHandler(GridControl_Leave); if (xe != null && option.MasterViewMode) { IEnumerator<XElement> xeDetailEnum = xe.Elements("def").GetEnumerator(); foreach (DataRelation r in dt.ChildRelations) { if (!xeDetailEnum.MoveNext()) break; XElement xeDetail = xeDetailEnum.Current; string sRelation = r.RelationName; if (sRelation == null) break; GridView view = (GridView)grid.LevelDefaults[sRelation]; GridSetViewOption(view, xeDetail, r.ChildTable, con, dataList); } } //if (option.ExpandAllMasterRows) GridExpandAllMasterRows(grid); if (option.ExpandAllMasterRows) XtraGridTools.GridExpandAllMasterRows((GridView)grid.MainView); grid.Tag = new FormGridEvent(grid, xe); //if (gbTrace) cTrace.StopNestedLevel("cGrid_GridSetDataSource"); }
public static void CreateDataSource(IDbConnection con, DataList dataList, XElement xe, out IDbDataAdapter da, out DataTable dt) { CreateDataSource(con, dataList, xe, out da, out dt, null); }
public void SetMasterDataSource(IDbConnection con, DataList dataList, XElement xe) { if (xe == null) return; string sMasterName = GetSourceName(xe); if (sMasterName == gsMasterName) return; //string sGridName = xe.zAttribValue("GridName"); //if (sGridName != null) //{ // GridControl grid; // if (gStaticGridControl.ContainsKey(sGridName)) // { // grid = gStaticGridControl[sGridName]; // SetMasterGrid(grid); // return; // } // else // { // grid = CreateGridControl(); // SetMasterGridEvent(grid); // gStaticGridControl.Add(sGridName, grid); // SetMasterGrid(grid); // } //} //else // SetMasterGrid(gGridMaster0); //cTrace.StartNestedLevel("cGrid_SetMasterDataSource"); DataTable dt; IDbDataAdapter da; CreateDataSource(con, dataList, xe, out da, out dt); SetMasterDataSource(con, dataList, dt, da, xe); //cTrace.StopNestedLevel("cGrid_SetMasterDataSource"); }
/**************** <def def="b_channel" Caption="Channel" Cmd="commande sql (select * from b_channel" CmdType="StoredProcedure | TableDirect | Text" UpdateCmd="update b_channel set shortname = @shortname, longname = @longname where channel_id = @channel_id" UpdateCmdType="StoredProcedure | TableDirect | Text" Option="" > <col Name="client_id" Option="ReadOnly, Hide"/> <!--<col Name="code" Edit="LookUp" Display="code" Value="code" Cmd="select code, longname channel from b_channel order by isnull(order_no, 9999), longname"/>--> </def> ****************/ public static void CreateDataSource(IDbConnection con, DataList dataList, XElement xe, out IDbDataAdapter da, out DataTable dt, DataTable dtMaster) { da = null; dt = null; bool bDetailDynamic = false; if (xe == null) return; //if (gbTrace) cTrace.StartNestedLevel("cGrid_CreateDataSource"); string sOption = xe.zAttribValue("Option"); XtraGridOption option = new XtraGridOption(sOption); bDetailDynamic = option.DetailDynamic; string sCmdType, sCmd; IDbCommand cmd = null; string sTableDef = xe.zAttribValue("TableDef"); if (sTableDef != null) { DataContainer data = dataList[sTableDef]; cmd = data.Command; dt = data.DataTable; //da = Ado.CreateDataAdapter(cmd); da = _ado.CreateDataAdapter(cmd); } else { sCmdType = xe.zAttribValue("CmdType", CommandType.Text.ToString()); sCmd = xe.zAttribValue("Cmd"); //cmd = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType)); cmd = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType)); if (bDetailDynamic) { string sMasterId = xe.zAttribValue("MasterId"); AddMasterIdParameter(cmd, dtMaster, sMasterId); } string sTable = GetTableName(xe); dt = new DataTable(sTable); //da = Ado.CreateDataAdapter(cmd); da = _ado.CreateDataAdapter(cmd); //Ado.DataAdapter_FillSchema(da, dt); _ado.DataAdapter_FillSchema(da, dt); string sPrimaryKey = xe.zAttribValue("PrimaryKey"); SetPrimaryKey(dt, sPrimaryKey); SetDataTableColumnOption(dt, xe); } ////////////////// Debug pb channel_id //if (dt.Columns.Contains("channel_id")) //{ // cTrace.Trace("PB_Grid.DataContainer.CreateDataTable() : après DataAdapter_FillSchema"); // DataColumn col = dt.Columns["channel_id"]; // cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, col {1}, AutoIncrementSeed = {2}, AutoIncrementStep = {3}", dt.TableName, col.ColumnName, col.AutoIncrementSeed, col.AutoIncrementStep); // dt.TableNewRow -= new DataTableNewRowEventHandler(Test_TableNewRow_Event); // dt.TableNewRow += new DataTableNewRowEventHandler(Test_TableNewRow_Event); // DataRow row = dt.NewRow(); // //col.AutoIncrementSeed = -20; // //cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, col {1}, AutoIncrementSeed = {2}, AutoIncrementStep = {3}", dt.TableName, col.ColumnName, col.AutoIncrementSeed, col.AutoIncrementStep); // //row = dt.NewRow(); // //col.AutoIncrementSeed = -1; // //cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, col {1}, AutoIncrementSeed = {2}, AutoIncrementStep = {3}", dt.TableName, col.ColumnName, col.AutoIncrementSeed, col.AutoIncrementStep); // //row = dt.NewRow(); //} sCmdType = xe.zAttribValue("UpdateCmdType", CommandType.Text.ToString()); sCmd = xe.zAttribValue("UpdateCmd"); if (sCmd != null) { //da.UpdateCommand = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType), dt); da.UpdateCommand = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType), dt); da.UpdateCommand.UpdatedRowSource = UpdateRowSource.Both; } bool bInsertCmdDefined = false; sCmdType = xe.zAttribValue("InsertCmdType", CommandType.Text.ToString()); sCmd = xe.zAttribValue("InsertCmd"); if (sCmd != null) { //da.InsertCommand = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType), dt); da.InsertCommand = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType), dt); da.InsertCommand.UpdatedRowSource = UpdateRowSource.Both; bInsertCmdDefined = true; } sCmdType = xe.zAttribValue("DeleteCmdType", CommandType.Text.ToString()); sCmd = xe.zAttribValue("DeleteCmd"); if (sCmd != null) { //da.DeleteCommand = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType), dt); da.DeleteCommand = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType), dt); da.DeleteCommand.UpdatedRowSource = UpdateRowSource.Both; } //object cb = Ado.CreateCommandBuilder(da); object cb = _ado.CreateCommandBuilder(da); //if (((!option.ReadOnly && !option.NoUpdate) || option.UpdateCommand) && da.UpdateCommand == null) da.UpdateCommand = Ado.CreateUpdateCommand(cb); if (((!option.ReadOnly && !option.NoUpdate) || option.UpdateCommand) && da.UpdateCommand == null) da.UpdateCommand = _ado.CreateUpdateCommand(cb); //if (((!option.ReadOnly && !option.NoInsert) || option.InsertCommand) && da.InsertCommand == null) da.InsertCommand = Ado.CreateInsertCommand(cb); if (((!option.ReadOnly && !option.NoInsert) || option.InsertCommand) && da.InsertCommand == null) da.InsertCommand = _ado.CreateInsertCommand(cb); //if (((!option.ReadOnly && !option.NoDelete) || option.DeleteCommand) && da.DeleteCommand == null) da.DeleteCommand = Ado.CreateDeleteCommand(cb); if (((!option.ReadOnly && !option.NoDelete) || option.DeleteCommand) && da.DeleteCommand == null) da.DeleteCommand = _ado.CreateDeleteCommand(cb); if (da.InsertCommand != null && !bInsertCmdDefined) { //string sPrimaryKeyTrace; //if (dt.PrimaryKey == null) sPrimaryKeyTrace = "null"; else sPrimaryKeyTrace = dt.PrimaryKey.zToStringValues(); //cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, PrimaryKey {1}", dt.TableName, sPrimaryKeyTrace); IDbCommand cmdInsert = GetCommandWithReturn(da.InsertCommand, dt.PrimaryKey); da.InsertCommand.Dispose(); da.InsertCommand = cmdInsert; } //if (sTableDef == null && !option.DetailDynamic) Ado.DataAdapter_Fill(da, dt); if (sTableDef == null && !option.DetailDynamic) _ado.DataAdapter_Fill(da, dt); //string sDataName = Xml.GetAttribValue(xe, "def"); string sDataName = xe.zAttribValue("def"); //if (gbTrace) cTrace.StopNestedLevel("cGrid_CreateDataSource"); }
public void SetMasterDataSource(IDbConnection con, DataList dataList, DataTable dt, IDbDataAdapter da, string sXmlParam) { SetMasterDataSource(con, dataList, dt, da, XDocument.Parse(sXmlParam).Element("def")); }
public XtraGridTools(IDbConnection con, DataList dataList, SortedList<string, RepositoryItem> editRepositoryList) { gCon = con; gDataList = dataList; gStaticEditRepositoryList = editRepositoryList; }
public static void GridSetDataSource(GridControl dxGrid, DataTable dt, string sXmlParam, IDbConnection con, DataList dataList) { XElement xe = null; if (sXmlParam != null) xe = XDocument.Parse(sXmlParam).Element("def"); GridSetDataSource(dxGrid, dt, xe, con, dataList); }