Пример #1
0
    private bool FillExportVista(string ProcedureName, DataAccess DA)
    {
        ClearDataSet.RemoveConstraints(ExportVista);
        GetData MyGetData = new GetData();

        MyGetData.InitClass(ExportVista, DA, "exportfunction");
        DataRow DR = ExportVista.Tables["exportfunction"].NewRow();

        ExportName = HelpForm.GetField(ProcedureName, 0);
        // title.reportname
        //DR["procedurename"] = ProcedureName;
        DR["procedurename"] = ExportName;

        MyGetData.SEARCH_BY_KEY(DR);
        MyGetData.DO_GET(false, null);
        MyGetData.DO_GET_TABLE(ExportVista.customselection, null, null, false, null);

        ExportDescription = ExportVista.Tables["exportfunction"].Rows[0]["description"].ToString();

        return(true);
    }
Пример #2
0
        /// <summary>
        /// Gets current row from ComboBox, Grids and tree-views, return false on errors
        /// </summary>
        /// <param name="C">Control to analyze</param>
        /// <param name="T">Table containing rows</param>
        /// <param name="R">Current selected row (null if none)</param>
        /// <returns>false on errors</returns>
        public static bool GetCurrentRow(DataSet DS, Control C, out DataTable T, out DataRow R)
        {
            R = null;           //in case of errors, always return a value
            T = null;
            if (typeof(ComboBox).IsAssignableFrom(C.GetType()))
            {
                ComboBox CParent = (ComboBox)C;
                if (CParent.DataSource == null)
                {
                    return(false);
                }
                T = DS.Tables[((DataTable)(CParent.DataSource)).TableName];

                if (CParent.SelectedIndex <= 0)                 //index 0 is used for blank row
                {
                    R = null;
                    return(true);
                }
                DataRowView RV = ((DataRowView)((ComboBox)C).Items[CParent.SelectedIndex]);
                if (RV == null)
                {
                    return(true);
                }
                R = RV.Row;
                if (R.Table == T)
                {
                    return(true);
                }
                R = FindExternalRow(T, R);
                return(true);
            }

            //T is taken from DS, using TAG Table
            //Row is taken from T, using a filter using current grid row
            if (typeof(DataGrid).IsAssignableFrom(C.GetType()))
            {
                if (C.Tag == null)
                {
                    return(false);
                }
                string tablename = HelpForm.GetField(C.Tag.ToString(), 0);
                if (tablename == null)
                {
                    return(false);
                }
                T = DS.Tables[tablename];

                DataGrid GParent = (DataGrid)C;

                DataSet DSV = (DataSet)GParent.DataSource;
                if (DSV == null)
                {
                    return(false);
                }
                DataTable TV = DSV.Tables[GParent.DataMember];
                if (TV == null)
                {
                    return(false);
                }

                if (TV.Rows.Count == 0)
                {
                    return(true);
                }
                DataRowView DV = null;
                try {
                    DV = (DataRowView)GParent.BindingContext[DSV, TV.TableName].Current;
                }
                catch {
                    DV = null;
                }
                if (DV == null)
                {
                    return(true);
                }

                R = DV.Row;
                if (TV.Equals(T))
                {
                    return(true);
                }

                R = FindExternalRow(T, R);
                return(true);
            }

            if (typeof(TreeView).IsAssignableFrom(C.GetType()))
            {
                TreeView TParent   = (TreeView)C;
                string   tablename = HelpForm.GetField(TParent.Tag.ToString(), 0);
                if (tablename == null)
                {
                    return(false);
                }
                T = DS.Tables[tablename];

                TreeNode N = (TreeNode)TParent.SelectedNode;
                try {
                    tree_node treenode = (tree_node)(N.Tag);
                    T = treenode.Row.Table;
                    R = treenode.Row;
                    return(true);
                }
                catch {
                    return(true);
                }
            }
            return(false);
        }