Exemplo n.º 1
1
        public static void SetGridColumnEditSecond(GridColumn col, XElement xe)
        {
            //if (gbTrace) cTrace.StartNestedLevel("SetGridColumnEditSecond");

            RepositoryItemTextEdit edit = new RepositoryItemTextEdit();
            edit.Name = "PKT_Grid_SecondEdit";
            ((System.ComponentModel.ISupportInitialize)edit).BeginInit();
            col.View.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { edit });
            //edit.AutoHeight = false;

            string sFormat = xe.zAttribValue("Format");
            if (sFormat == "" || sFormat == null) sFormat = "hh:mm:ss";
            SecondEdit secondEdit = new SecondEdit();
            secondEdit.Format = sFormat;

            edit.MaskData.EditMask = secondEdit.EditMask;
            edit.MaskData.MaskType = MaskType.Simple;
            edit.FormatEditValue += new ConvertEditValueEventHandler(secondEdit.FormatEditValue);
            edit.ParseEditValue += new ConvertEditValueEventHandler(secondEdit.ParseEditValue);
            col.ColumnEdit = edit;
            ((System.ComponentModel.ISupportInitialize)edit).EndInit();

            //if (gbTrace) cTrace.StopNestedLevel("SetGridColumnEditSecond");
        }
Exemplo n.º 2
0
 public ImageHtml(XElement xe, string urlBase)
 {
     Source = zurl.GetUrl(urlBase, xe.zAttribValue("src"));
     Alt = xe.zAttribValue("alt");
     Title = xe.zAttribValue("title");
     Class = xe.zAttribValue("class");
 }
Exemplo n.º 3
0
 public XXNodeLink(XElement xe)
 {
     if (xe.Name != "a")
         throw new PBException("error creating XXNodeLink with wrong node type \"{0}\"", xe.Name);
     type = XXNodeType.Link;
     link = xe;
     url = xe.zAttribValue("href");
     relAttribute = xe.zAttribValue("rel");
     typeAttribute = xe.zAttribValue("type");
     text = xe.Value;
 }
Exemplo n.º 4
0
 public XXNodeImage(XElement xe)
 {
     if (xe.Name != "img")
         throw new PBException("error creating XXNodeImage with wrong node type \"{0}\"", xe.Name);
     type = XXNodeType.Image;
     img = xe;
     source = xe.zAttribValue("src");
     alt = xe.zAttribValue("alt");
     title = xe.zAttribValue("title");
     className = xe.zAttribValue("className");
 }
Exemplo n.º 5
0
        public void SetGridColumnEditCombo(GridColumn col, XElement colDefinition)
        {
            //if (gbTrace) cTrace.StartNestedLevel("SetGridColumnEditCombo");

            RepositoryItemComboBox combo = new RepositoryItemComboBox();
            combo.Name = "PKT_Grid_Combo";

            combo.AutoHeight = false;
            string sCmd = colDefinition.zAttribValue("Cmd");
            DataTable dt = null;
            if (sCmd != null) // la combo est rempli à partir d'une requête sql
                //dt = Ado.ExeCmd(gCon, sCmd);
                dt = _ado.ExeCmd(gCon, sCmd);
            else // sinon les valeurs de la combo sont la table fille "value"
                dt = colDefinition.zXmlToDataTable("value");
            for (int i = 0; i < dt.Rows.Count; i++) combo.Items.Add(dt.Rows[i][0]);
            combo.Name = "Combo_" + col.FieldName;
            combo.HotTrackDropDownItems = false;

            string sOption = colDefinition.zAttribValue("Option");
            bool bValueInListOnly;
            GetComboOptions(sOption, out bValueInListOnly);
            if (bValueInListOnly) combo.TextEditStyle = TextEditStyles.DisableTextEditor;

            combo.NullText = "";
            string sNullText = colDefinition.zAttribValue("NullText");
            if (sNullText != null) combo.NullText = sNullText;

            col.View.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { combo });
            col.ColumnEdit = combo;

            //if (gbTrace) cTrace.StopNestedLevel("SetGridColumnEditCombo");
        }
Exemplo n.º 6
0
        public static RepositoryItemLookUpEdit CreateEditLookUp(string sFieldName, XElement colDefinition, DataTable dt, bool bReadOnlyDataTable)
        {
            //if (col == null) return;

            //if (gbTrace) cTrace.StartNestedLevel("SetGridColumnEditLookUp2");

            RepositoryItemLookUpEdit look = new RepositoryItemLookUpEdit();
            string sLookUpName = colDefinition.zAttribValue("LookUpName");
            //if (sLookUpName == null) sLookUpName = "PKT_Grid_LookUp_" + col.FieldName;
            if (sLookUpName == null) sLookUpName = "PKT_Grid_LookUp_" + sFieldName;
            look.Name = sLookUpName;
            ((System.ComponentModel.ISupportInitialize)look).BeginInit();
            //view.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { look });
            look.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            //col.ColumnEdit = look;
            look.AutoHeight = false;

            look.NullText = "";
            string sNullText = colDefinition.zAttribValue("NullText");
            if (sNullText != null) look.NullText = sNullText;

            //if (gbTrace) cTrace.StartNestedLevel("SetDataSource");
            look.DataSource = dt;
            look.PopulateColumns();
            if (look.Columns.Count == 0)
                throw new GridException("Error in lookup \"{0}\" no column in data source", sFieldName);
            //if (gbTrace) cTrace.StopNestedLevel("SetDataSource");

            //if (gbTrace) cTrace.StartNestedLevel("SetLookUpGridColumn");
            string sColumn = colDefinition.zAttribValue("Column");
            SetLookUpGridColumn(look, sColumn);
            //if (gbTrace) cTrace.StopNestedLevel("SetLookUpGridColumn");

            //if (gbTrace) cTrace.StartNestedLevel("BestFit");
            look.BestFit();
            //if (gbTrace) cTrace.StopNestedLevel("BestFit");

            //if (gbTrace) cTrace.StartNestedLevel("DisplayMember");
            // définition de look.DisplayMember
            string sDisplay = colDefinition.zAttribValue("Display");
            if (sDisplay != null)
            {
                if (look.Columns[sDisplay] != null)
                    look.DisplayMember = sDisplay;
                else
                    throw new GridException("Error in lookup \"{0}\" no display column, column {0} does'nt exist in data source", sFieldName, sDisplay);
            }
            else
            {
                look.DisplayMember = look.Columns[0].FieldName;
                for (int i = 0; i < look.Columns.Count; i++)
                    if (look.Columns[i].FieldName != sFieldName) { look.DisplayMember = look.Columns[i].FieldName; break; }
            }
            //if (gbTrace) cTrace.StopNestedLevel("DisplayMember");

            if (look.DisplayMember != sFieldName)
            {
                if (look.Columns[sFieldName] != null)
                    look.Columns[sFieldName].Visible = false;
            }

            //if (gbTrace) cTrace.StartNestedLevel("ValueMember");
            // définition de look.ValueMember
            string sValue = colDefinition.zAttribValue("Value");
            if (sValue != null)
            {
                if (look.Columns[sValue] != null)
                    look.ValueMember = sValue;
                else
                    throw new GridException("Error in lookup \"{0}\" no value column, column {0} does'nt exist in data source", sFieldName, sValue);
            }
            else
            {
                if (look.Columns[sFieldName] != null)
                    look.ValueMember = sFieldName;
                else
                    look.ValueMember = look.DisplayMember;
            }
            //if (gbTrace) cTrace.StopNestedLevel("ValueMember");

            //if (gbTrace) cTrace.StartNestedLevel("AddNullRow");
            string sAddNullRow = colDefinition.zAttribValue("AddNullRow");
            if (!bReadOnlyDataTable && sAddNullRow != null && sAddNullRow.ToLower() == "true")
            {
                DataRow dataRow = dt.NewRow();
                if (look.DisplayMember != look.ValueMember) dataRow[look.DisplayMember] = look.NullText;
                dt.Rows.InsertAt(dataRow, 0);
            }
            //if (gbTrace) cTrace.StopNestedLevel("AddNullRow");

            //look.TextEditStyle = TextEditStyles.Standard;
            look.SearchMode = SearchMode.OnlyInPopup;
            ((System.ComponentModel.ISupportInitialize)look).EndInit();

            //if (gbTrace) cTrace.StopNestedLevel("SetGridColumnEditLookUp2");

            return look;
        }
Exemplo n.º 7
0
        public void SetColumnEditLookUp(GridColumn col, XElement colDefinition)
        {
            //GridView view, IDbConnection con, DataList dataList, 
            //if (gbTrace) cTrace.StartNestedLevel("SetGridColumnEditLookUp");

            string sLookUpName = colDefinition.zAttribValue("LookUpName");
            if (sLookUpName != null && gStaticEditRepositoryList != null && gStaticEditRepositoryList.ContainsKey(sLookUpName))
            {
                //cTrace.Trace("Use LookUp Repository : {0}", sLookUpName);
                RepositoryItem item = gStaticEditRepositoryList[sLookUpName];
                col.ColumnEdit = item;
                goto fin;
            }

            bool bReadOnlyDataTable;
            DataTable dt = null;
            string sTableDef = colDefinition.zAttribValue("TableDef");
            if (sTableDef != null)
            {
                dt = gDataList[sTableDef].DataTable;
                bReadOnlyDataTable = true;
            }
            else
            {
                string sCmd = colDefinition.zAttribValue("Cmd");
                if (sCmd != null) // les valeurs du lookup viennent de la base
                {
                    //if (gbTrace) cTrace.StartNestedLevel("LoadData");
                    //dt = Ado.ExeCmd(gCon, sCmd);
                    dt = _ado.ExeCmd(gCon, sCmd);
                    //if (gbTrace) cTrace.StopNestedLevel("LoadData");
                }
                else // sinon les valeurs du lookup sont la table fille "value"
                {
                    dt = colDefinition.zXmlToDataTable("value");
                    //dt = zdt.ChangeColumnType(dt, col.FieldName, col.ColumnType);
                    dt = dt.zChangeColumnType(col.FieldName, col.ColumnType);
                }
                bReadOnlyDataTable = false;
            }

            RepositoryItemLookUpEdit look = CreateEditLookUp(col.FieldName, colDefinition, dt, bReadOnlyDataTable);
            //view.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { look });
            col.View.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { look });
            col.ColumnEdit = look;

            if (sLookUpName != null && gStaticEditRepositoryList != null)
            {
                //cTrace.Trace("Add LookUp Repository : {0}", sLookUpName);
                gStaticEditRepositoryList.Add(sLookUpName, col.ColumnEdit);
            }

        fin:;
            //if (gbTrace) cTrace.StopNestedLevel("SetGridColumnEditLookUp");
        }
Exemplo n.º 8
0
 public void SetColumnEdit(GridColumn col, XElement colDefinition)
 {
     if (col == null) return;
     //string sEdit = colDefinition.zAttribValue("Edit");
     //if (sEdit == null || sEdit == "") return;
     // modif le 27/03/2013 column edit Mask par defaut pour pouvoir afficher les valeurs nulles --null--
     string sEdit = colDefinition.zAttribValue("Edit", "Mask");
     switch (sEdit.ToLower())
     {
         case "lookup":
             SetColumnEditLookUp(col, colDefinition);
             break;
         case "combo":
             SetGridColumnEditCombo(col, colDefinition);
             break;
         case "mask":
             SetGridColumnEditMask(col, colDefinition);
             break;
         case "memo":
             SetGridColumnEditMemo(col);
             break;
         case "heuresec":
         case "second":
             SetGridColumnEditSecond(col, colDefinition);
             break;
     }
 }
Exemplo n.º 9
0
 public XtraGridControlManager GetGrid(XElement xe, GridControl grid, XtraGridControlManager parentGrid)
 {
     if (xe == null) return null;
     string sName = xe.zAttribValue("Name");
     if (sName == null || sName == "") throw new XtraGridException("error creating grid name is not defined");
     if (gGridControls.ContainsKey(sName)) return gGridControls[sName];
     XtraGridControlManager gridManager = new XtraGridControlManager(this, xe, grid, parentGrid);
     gGridControls.Add(sName, gridManager);
     return gridManager;
 }
Exemplo n.º 10
0
        private void GridSetViewOption(GridView view, XtraGridOption option, XElement definition, DataTable dt)
        {
            //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 = definition.zAttribValue("def");
            string sName = definition.zAttribValue("Name");
            if (sName != null) view.Name = sName;
            view.Name = sName;

            //if (gbTrace) cTrace.StartNestedLevel("SetGridColumn***");
            string sColumn = definition.zAttribValue("Column");
            XtraGridTools.SetGridColumn(view, sColumn);

            sColumn = definition.zAttribValue("ColumnCaption");
            XtraGridTools.SetGridColumnCaption(view, sColumn);

            sColumn = definition.zAttribValue("Update");
            XtraGridTools.SetGridColumnUpdate(view, sColumn);

            sColumn = definition.zAttribValue("ReadOnly");
            XtraGridTools.SetGridColumnReadOnly(view, sColumn);

            sColumn = definition.zAttribValue("Hide");
            XtraGridTools.SetGridColumnHide(view, sColumn);
            //if (gbTrace) cTrace.StopNestedLevel("SetGridColumn***");

            // Filter
            string sFilter = definition.zAttribValue("Filter");
            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
            XtraGridTools.SetRowHeight(view, definition.zAttribValue("RowHeight"));

            Font font = XtraGridTools.GetFont(definition.zAttribValue("Font"));
            if (font != null)
            {
                view.ViewStylesInfo.Row.Font = font;
                view.ViewStylesInfo.FocusedRow.Font = font;
                view.ViewStylesInfo.FocusedCell.Font = font;
            }

            StyleOptions style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleFocusedRow"), out style))
                view.ViewStylesInfo.FocusedRow.Options = style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleSelectedRow"), out style))
                view.ViewStylesInfo.SelectedRow.Options = style;
            if (XtraGridTools.GetStyleOptions(definition.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> colDefinitions = null;
            if (definition != null)
            {
                colDefinitions = definition.Elements("col");
                foreach (XElement colDefinition in colDefinitions)
                {
                    string sColName = colDefinition.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 = colDefinition.zAttribValue("Option", "");
                        string sCaption = colDefinition.zAttribValue("Caption");
                        if (sCaption != null) colGrid.Caption = sCaption;
                        XtraGridTools.SetGridColumnOption(colGrid, sOption);
                        XtraGridTools.SetGridColumnStyle(colGrid, colDefinition.zAttribValue("Style"));
                        XtraGridTools.SetGridColumnFormatDate(colGrid, colDefinition.zAttribValue("FormatDate"));
                        XtraGridTools.SetGridColumnFormatNum(colGrid, colDefinition.zAttribValue("FormatNum"));
                        //////////SetGridColumnEdit(view, con, dataList, colGrid, col.zAttribValue("Edit"), col);
                        IDbConnection con = GetConnection();
                        DataList dataList = GetDataList();
                        SortedList<string, RepositoryItem> editRepositoryList = GetEditRepositoryList();
                        XtraGridTools gridTools = new XtraGridTools(con, dataList, editRepositoryList);
                        gridTools.SetColumnEdit(colGrid, colDefinition);
                    }
                }
            }
            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 (colDefinitions != null)
            {
                foreach (XElement col in colDefinitions)
                {
                    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 = definition.zAttribValue("Sort");
            XtraGridTools.SetGridSort(view, sSort);

            //XtraGridTools.LoadParameters(view, definition);
            //LoadParameters(view);

            //if (gbTrace) cTrace.StopNestedLevel("GridSetViewOption");
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
 public XtraGridControlManager(XtraGridFormManager formManager, XElement xe)
 {
     gFormManager = formManager;
     gsName = xe.zAttribValue("Name");
     gGridDefinition = xe;
     Init();
 }
Exemplo n.º 13
0
        /****************
		<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");
        }
Exemplo n.º 14
0
        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");
        }
Exemplo n.º 15
0
        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");
        }
Exemplo n.º 16
0
 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);
 }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        public static void SetGridColumnEditMask(GridColumn col, XElement colDefinition)
        {
            if (col == null) return;

            //if (gbTrace) cTrace.StartNestedLevel("SetGridColumnEditMask");

            RepositoryItemTextEdit edit = new RepositoryItemTextEdit();
            edit.Name = "PKT_Grid_Mask_Edit";
            ((System.ComponentModel.ISupportInitialize)edit).BeginInit();
            col.View.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { edit });

            string s = colDefinition.zAttribValue("Mask");
            if (s != null) edit.MaskData.EditMask = s;
            s = colDefinition.zAttribValue("MaskBlank");
            if (s != null) edit.MaskData.Blank = s;
            edit.MaskData.MaskType = MaskType.Simple;
            edit.MaskData.SaveLiteral = true;
            edit.MaskData.IgnoreMaskBlank = true;
            edit.MaskData.BeepOnError = false;
            // modif le 27/03/2013 column edit Mask par defaut pour pouvoir afficher les valeurs nulles --null--
            string sNullText = colDefinition.zAttribValue("NullText", "--null--");
            edit.NullText = sNullText;
            s = colDefinition.zAttribValue("MaskOption");
            SetTextEditOption(edit, s);
            col.ColumnEdit = edit;
            ((System.ComponentModel.ISupportInitialize)edit).EndInit();

            //if (gbTrace) cTrace.StopNestedLevel("SetGridColumnEditMask");
        }
Exemplo n.º 19
0
 public static string GetTableName(XElement xe)
 {
     //string sTableName = Xml.GetAttribValue(xe, "Table");
     string sTableName = xe.zAttribValue("Table");
     if (sTableName == null)
         //sTableName = Xml.GetAttribValue(xe, "def");
         sTableName = xe.zAttribValue("def");
     return sTableName;
 }
Exemplo n.º 20
0
 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);
 }
Exemplo n.º 21
0
 public XtraGridControlManager(XtraGridFormManager formManager, XElement xe, GridControl grid, XtraGridControlManager parentGrid)
 {
     gFormManager = formManager;
     gsName = xe.zAttribValue("Name");
     gGridDefinition = xe;
     gGridControl = grid;
     gParentGrid = parentGrid;
     Init();
 }
Exemplo n.º 22
0
        public static XFormat CreateXFormat(XElement xe)
        {
            XFormat xf = new XFormat();
            xf.gsName = xe.Name.LocalName;
            xf.gsFormat = xe.zAttribValue("format");
            if (xf.gsFormat != null)
            {
                xf.gFormats = StringZones.SplitZone(xf.gsFormat, new char[,] { { '{', '}' } });
                string sFormat = "";
                int i = 0;
                xf.gFormatValues = new List<XValueFormat>();
                foreach (StringZone format in xf.gFormats)
                {
                    if (format.BeginZoneChar == '{')
                    {
                        sFormat += "{" + i++.ToString() + "}";

                        XValueFormat valueFormat = null;

                        //{Node(Phone) - {@PhoneType} {@Phone}}

                        StringZone[] zones = StringZones.SplitZone(format.ContentString, new char[,] { { '(', ')' }, { '{', '}' } });
                        if (zones.Length >= 2 && zones[0].BeginZoneChar == (char)0 && zones[1].BeginZoneChar == '(')
                        {
                            if (zones[0].String.ToLower() == "node")
                            {
                                valueFormat = new XValueFormat();
                                valueFormat.XPath = zones[1].ContentString;
                                valueFormat.Values = new List<XValueFormat>();
                                string sFormat2 = "";
                                int i2 = 0;
                                for (int j = 2; j < zones.Length; j++)
                                {
                                    if (zones[j].BeginZoneChar == '{')
                                    {
                                        sFormat2 += "{" + i2++.ToString() + "}";
                                        valueFormat.Values.Add(new XValueFormat() { XPath = zones[j].ContentString });
                                    }
                                    else
                                        sFormat2 += zones[j].String;
                                }
                                valueFormat.Format = sFormat2;
                            }
                        }
                        else
                            valueFormat = new XValueFormat() { XPath = format.ContentString };
                        if (valueFormat != null) xf.gFormatValues.Add(valueFormat);
                    }
                    else
                        sFormat += format.String;
                }
                xf.gsStringFormat = sFormat;
            }
            xf.SetOptions(xe.zAttribValue("option"));
            return xf;
        }