Пример #1
0
        }       //	getColumnName

        /// <summary>
        /// Create Print Format Item from Column
        /// </summary>
        /// <param name="format">parent</param>
        /// <param name="AD_Column_ID">column</param>
        /// <param name="seqNo">sequence of display if 0 it is not printed</param>
        /// <returns>Format Item</returns>
        public static MPrintFormatItem CreateFromColumn(MPrintFormat format, int AD_Column_ID, int seqNo)
        {
            MPrintFormatItem pfi = new MPrintFormatItem(format.GetCtx(), 0, null);

            pfi.SetAD_PrintFormat_ID(format.GetAD_PrintFormat_ID());
            pfi.SetClientOrg(format);
            pfi.SetAD_Column_ID(AD_Column_ID);
            pfi.SetPrintFormatType(PRINTFORMATTYPE_Field);
            //SqlParameter[] param = null;

            //	translation is dome by trigger
            String sql = "SELECT c.ColumnName,e.Name,e.PrintName, "             //	1..3
                         + "c.AD_Reference_ID,c.IsKey,c.SeqNo "                 //	4..6
                         + "FROM AD_Column c, AD_Element e "
                         + "WHERE c.AD_Column_ID='" + AD_Column_ID + "'"
                         + " AND c.AD_Element_ID=e.AD_Element_ID";
            //	translate base entry if single language - trigger copies to trl tables

            //Boolean trl = !Env.IsMultiLingualDocument(format.GetCtx()) && !GlobalVariable.IsBaseLanguage();
            Boolean trl = !Env.IsMultiLingualDocument(format.GetCtx()) && !Language.IsBaseLanguage(Login.Language.GetBaseAD_Language());

            if (trl)
            {
                sql = "SELECT c.ColumnName,e.Name,e.PrintName, "                //	1..3
                      + "c.AD_Reference_ID,c.IsKey,c.SeqNo "                    //	4..6
                      + "FROM AD_Column c, AD_Element_Trl e "
                      + "WHERE c.AD_Column_ID='" + AD_Column_ID + "'"
                      + " AND c.AD_Element_ID=e.AD_Element_ID"
                      + " AND e.AD_Language='" + GlobalVariable.GetLanguageCode() + "'";
            }
            IDataReader dr = null;

            try
            {
                dr = SqlExec.ExecuteQuery.ExecuteReader(sql);
                if (dr.Read())
                {
                    String ColumnName = dr[0].ToString();
                    pfi.SetName(dr[1].ToString());
                    pfi.SetPrintName(dr[2].ToString());
                    int displayType = dr[3].ToString() != "" ? Utility.Util.GetValueOfInt(dr[3].ToString()) : 0;
                    if (DisplayType.IsNumeric(displayType))
                    {
                        pfi.SetFieldAlignmentType(FIELDALIGNMENTTYPE_TrailingRight);
                    }
                    else if (displayType == DisplayType.Text || displayType == DisplayType.Memo)
                    {
                        pfi.SetFieldAlignmentType(FIELDALIGNMENTTYPE_Block);
                    }
                    else
                    {
                        pfi.SetFieldAlignmentType(FIELDALIGNMENTTYPE_LeadingLeft);
                    }
                    Boolean isKey = "Y".Equals(dr[4].ToString());
                    //
                    if (isKey ||
                        ColumnName.StartsWith("Created") || ColumnName.StartsWith("Updated") ||
                        ColumnName.Equals("AD_Client_ID") || ColumnName.Equals("AD_Org_ID") ||
                        ColumnName.Equals("IsActive") || ColumnName.Equals("Export_ID") ||
                        displayType == DisplayType.Button || displayType == DisplayType.Binary ||
                        displayType == DisplayType.ID || displayType == DisplayType.Image ||
                        displayType == DisplayType.RowID ||
                        seqNo == 0)
                    {
                        pfi.SetIsPrinted(false);
                        pfi.SetSeqNo(0);
                    }
                    else
                    {
                        pfi.SetIsPrinted(true);
                        pfi.SetSeqNo(seqNo);
                    }
                    int idSeqNo = dr[5].ToString() != "" ? Utility.Util.GetValueOfInt(dr[5].ToString()) : 0;    //	IsIdentifier SortNo
                    if (idSeqNo > 0)
                    {
                        pfi.SetIsOrderBy(true);
                        pfi.SetSortNo(idSeqNo);
                    }
                }
                dr.Close();
            }
            catch (Exception e)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                s_log.Severe(e.ToString());
            }
            if (!pfi.Save())
            {
                return(null);
            }
            //	pfi.dump();
            return(pfi);
        }       //	createFromColumn