public List <InfoColumn> GetDisplayCol(int AD_Table_ID, string AD_Language, bool IsBaseLangage, string _tableName)
        {
            try
            {
                bool _trlTableExist = false;
                if (!IsBaseLangage)
                {
                    VAdvantage.DataBase.VConnection con = new VAdvantage.DataBase.VConnection();
                    string owner = con.Db_uid;
                    if (Util.GetValueOfInt(DB.ExecuteQuery("SELECT count(*) FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'TABLE' AND OWNER =upper( '" + owner + "') AND OBJECT_NAME =upper( '" + _tableName + "_TRL')", null, null)) > 0)
                    {
                        _trlTableExist = true;
                    }
                }

                //Change by mohit-to handle translation in general info.
                //Added 2 new parametere- string AD_Language, bool IsBaseLangage.
                //Asked by mukesh sir - 09/03/2018

                string sql = string.Empty;
                if (IsBaseLangage)
                {
                    sql = @"SELECT c.ColumnName,c.Name,
                              c.AD_Reference_ID,
                              c.IsKey,
                              f.IsDisplayed,
                              c.AD_Reference_Value_ID,
                              c.ColumnSQL,
                              C.IsTranslated
                            FROM AD_Column c
                            INNER JOIN AD_Table t
                            ON (c.AD_Table_ID=t.AD_Table_ID)                            
                            INNER JOIN AD_Tab tab
                            ON (t.AD_Window_ID=tab.AD_Window_ID)
                            INNER JOIN AD_Field f
                            ON (tab.AD_Tab_ID  =f.AD_Tab_ID
                            AND f.AD_Column_ID =c.AD_Column_ID)
                            WHERE t.AD_Table_ID=" + AD_Table_ID + @"
                            AND (c.IsKey       ='Y'
                            OR (f.IsEncrypted  ='N'
                            AND f.ObscureType IS NULL))                            
                            ORDER BY c.IsKey DESC,
                              f.SeqNo";
                }
                else
                {
                    sql = @"SELECT c.ColumnName,trl.Name,
                              c.AD_Reference_ID,
                              c.IsKey,
                              f.IsDisplayed,
                              c.AD_Reference_Value_ID,
                              c.ColumnSQL,
                              C.IsTranslated
                            FROM AD_Column c
                            INNER JOIN AD_Table t
                            ON (c.AD_Table_ID=t.AD_Table_ID)
                            INNER JOIN AD_Column_Trl trl
                            ON (c.ad_column_ID=trl.AD_Column_ID)
                            INNER JOIN AD_Tab tab
                            ON (t.AD_Window_ID=tab.AD_Window_ID)
                            INNER JOIN AD_Field f
                            ON (tab.AD_Tab_ID  =f.AD_Tab_ID
                            AND f.AD_Column_ID =c.AD_Column_ID)
                            WHERE t.AD_Table_ID=" + AD_Table_ID + @"
                            AND trl.AD_Language='" + AD_Language + @"'
                            AND (c.IsKey       ='Y'
                            OR (f.IsEncrypted  ='N'
                            AND f.ObscureType IS NULL))                            
                            ORDER BY c.IsKey DESC,
                              f.SeqNo";
                }
                DataSet ds = DB.ExecuteDataset(sql);

                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return(null);
                }
                List <InfoColumn> lstCols = new List <InfoColumn>();
                InfoColumn        item    = null;
                int displayType           = 0;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    item             = new InfoColumn();
                    item.IsKey       = ds.Tables[0].Rows[i]["IsKey"].ToString() == "Y" ? true : false;
                    item.IsDisplayed = ds.Tables[0].Rows[i]["IsDisplayed"].ToString() == "Y" ? true : false;


                    displayType = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Reference_ID"]);

                    if (item.IsKey)
                    {
                    }
                    else if (!item.IsDisplayed)
                    {
                        continue;
                    }
                    else if (!(displayType == DisplayType.YesNo ||
                               displayType == DisplayType.Amount ||
                               displayType == DisplayType.Number ||
                               displayType == DisplayType.Quantity ||
                               displayType == DisplayType.Integer ||
                               displayType == DisplayType.String ||
                               displayType == DisplayType.Text ||
                               displayType == DisplayType.Memo ||
                               DisplayType.IsDate(displayType) ||
                               displayType == DisplayType.List))
                    {
                        continue;
                    }
                    else if (!(ds.Tables[0].Rows[i]["ColumnSQL"] == null || ds.Tables[0].Rows[i]["ColumnSQL"] == DBNull.Value))
                    {
                        continue;
                    }

                    item.ColumnName      = ds.Tables[0].Rows[i]["ColumnName"].ToString();
                    item.Name            = ds.Tables[0].Rows[i]["Name"].ToString();
                    item.AD_Reference_ID = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Reference_ID"]);
                    item.IsKey           = ds.Tables[0].Rows[i]["IsKey"].ToString() == "Y" ? true : false;
                    item.IsDisplayed     = ds.Tables[0].Rows[i]["IsDisplayed"].ToString() == "Y" ? true : false;
                    if (!(ds.Tables[0].Rows[i]["AD_Reference_Value_ID"] == null || ds.Tables[0].Rows[i]["AD_Reference_Value_ID"] == DBNull.Value))
                    {
                        item.AD_Reference_Value_ID = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Reference_Value_ID"]);
                        item.RefList = GetRefList(item.AD_Reference_Value_ID);
                    }
                    item.ColumnSQL = ds.Tables[0].Rows[i]["ColumnSQL"].ToString();
                    // Change done by mohit asked by mukesh sir to show the data on info window from translated tab if logged in with langauge other than base language- 22/03/2018
                    item.IsTranslated  = ds.Tables[0].Rows[i]["IsTranslated"].ToString() == "Y" ? true : false;
                    item.trlTableExist = _trlTableExist;

                    lstCols.Add(item);
                }

                return(lstCols);
            }
            catch
            {
                return(null);
            }
        }
Пример #2
0
        public List <InfoColumn> GetDisplayCol(int AD_Table_ID)
        {
            try
            {
                string sql = @"SELECT c.ColumnName,c.Name,
                              c.AD_Reference_ID,
                              c.IsKey,
                              f.IsDisplayed,
                              c.AD_Reference_Value_ID,
                              c.ColumnSQL
                            FROM AD_Column c
                            INNER JOIN AD_Table t
                            ON (c.AD_Table_ID=t.AD_Table_ID)
                            INNER JOIN AD_Tab tab
                            ON (t.AD_Window_ID=tab.AD_Window_ID)
                            INNER JOIN AD_Field f
                            ON (tab.AD_Tab_ID  =f.AD_Tab_ID
                            AND f.AD_Column_ID =c.AD_Column_ID)
                            WHERE t.AD_Table_ID=" + AD_Table_ID + @"
                            AND (c.IsKey       ='Y'
                            OR (f.IsEncrypted  ='N'
                            AND f.ObscureType IS NULL))                            
                            ORDER BY c.IsKey DESC,
                              f.SeqNo";

                DataSet ds = DB.ExecuteDataset(sql);

                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return(null);
                }
                List <InfoColumn> lstCols = new List <InfoColumn>();
                InfoColumn        item    = null;
                int displayType           = 0;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    item             = new InfoColumn();
                    item.IsKey       = ds.Tables[0].Rows[i]["IsKey"].ToString() == "Y" ? true : false;
                    item.IsDisplayed = ds.Tables[0].Rows[i]["IsDisplayed"].ToString() == "Y" ? true : false;


                    displayType = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Reference_ID"]);

                    if (item.IsKey)
                    {
                    }
                    else if (!item.IsDisplayed)
                    {
                        continue;
                    }
                    else if (!(displayType == DisplayType.YesNo ||
                               displayType == DisplayType.Amount ||
                               displayType == DisplayType.Number ||
                               displayType == DisplayType.Quantity ||
                               displayType == DisplayType.Integer ||
                               displayType == DisplayType.String ||
                               displayType == DisplayType.Text ||
                               displayType == DisplayType.Memo ||
                               DisplayType.IsDate(displayType) ||
                               displayType == DisplayType.List))
                    {
                        continue;
                    }
                    else if (!(ds.Tables[0].Rows[i]["ColumnSQL"] == null || ds.Tables[0].Rows[i]["ColumnSQL"] == DBNull.Value))
                    {
                        continue;
                    }

                    item.ColumnName      = ds.Tables[0].Rows[i]["ColumnName"].ToString();
                    item.Name            = ds.Tables[0].Rows[i]["Name"].ToString();
                    item.AD_Reference_ID = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Reference_ID"]);
                    item.IsKey           = ds.Tables[0].Rows[i]["IsKey"].ToString() == "Y" ? true : false;
                    item.IsDisplayed     = ds.Tables[0].Rows[i]["IsDisplayed"].ToString() == "Y" ? true : false;
                    if (!(ds.Tables[0].Rows[i]["AD_Reference_Value_ID"] == null || ds.Tables[0].Rows[i]["AD_Reference_Value_ID"] == DBNull.Value))
                    {
                        item.AD_Reference_Value_ID = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Reference_Value_ID"]);
                        item.RefList = GetRefList(item.AD_Reference_Value_ID);
                    }
                    item.ColumnSQL = ds.Tables[0].Rows[i]["ColumnSQL"].ToString();

                    lstCols.Add(item);
                }

                return(lstCols);
            }
            catch
            {
                return(null);
            }
        }