Пример #1
0
 public BarcodeGenerator(MPrintFormatItem item)
 {
     width         = item.GetMaxWidth();
     height        = item.GetMaxHeight();
     humanReadable = true;
     fontSize      = 12;
     fontName      = "Courier New";
     centered      = false;
 }
Пример #2
0
        }       //	createFromColumn

        /// <summary>
        /// Copy existing Definition To Client
        /// </summary>
        /// <param name="To_Client_ID">to client</param>
        /// <param name="AD_PrintFormat_ID">parent print format</param>
        /// <returns>format item</returns>
        public MPrintFormatItem CopyToClient(int To_Client_ID, int AD_PrintFormat_ID)
        {
            MPrintFormatItem to = new MPrintFormatItem(Env.GetContext(), 0, null);

            MPrintFormatItem.CopyValues(this, to);
            to.SetClientOrg(To_Client_ID, 0);
            to.SetAD_PrintFormat_ID(AD_PrintFormat_ID);
            to.Save();
            return(to);
        }       //	copyToClient
Пример #3
0
 public BoxElement(MPrintFormatItem item, Color color)
     : base()
 {
     if (item != null && item.IsTypeBox())
     {
         m_item  = item;
         m_color = color;
         p_info  = item.ToString();
     }
 }       //	BoxElement
Пример #4
0
 public BarcodeElement(String code, MPrintFormatItem item)
     : base()
 {
     if (code == null || code.Length == 0 ||
         item == null ||
         item.GetBarcodeType() == null || item.GetBarcodeType().Length == 0)
     {
         m_valid = false;
     }
     m_barcode = new BarcodeGenerator(item);
     if (m_barcode == null)
     {
         m_valid = false;
     }
 }       //	BarcodeElement
Пример #5
0
        }       //	addMissingColumns

        /// <summary>
        ///
        /// </summary>
        /// <param name="pf"></param>
        /// <returns></returns>
        public int AddMissingColumns(MPrintFormat pf)
        {
            String sql = "SELECT c.AD_Column_ID, c.ColumnName "
                         + "FROM AD_Column c "
                         + "WHERE NOT EXISTS "
                         + "(SELECT * "
                         + "FROM AD_PrintFormatItem pfi"
                         + " INNER JOIN AD_PrintFormat pf ON (pfi.AD_PrintFormat_ID=pf.AD_PrintFormat_ID) "
                         + "WHERE pf.AD_Table_ID=c.AD_Table_ID"
                         + " AND pfi.AD_Column_ID=c.AD_Column_ID"
                         + " AND pfi.AD_PrintFormat_ID='" + pf.GetAD_PrintFormat_ID() + "')" //	1
                         + " AND c.AD_Table_ID='" + pf.GetAD_Table_ID() + "' "               //	2
                         + "ORDER BY 1";
            int         counter = 0;
            IDataReader dr      = null;

            try
            {
                dr = DataBase.DB.ExecuteReader(sql);
                while (dr.Read())
                {
                    int              AD_Column_ID = Utility.Util.GetValueOfInt(dr[0].ToString());
                    String           ColumnName   = dr.GetString(1);
                    MPrintFormatItem pfi          = MPrintFormatItem.CreateFromColumn(pf, AD_Column_ID, 0);
                    if (pfi.Get_ID() != 0)
                    { //log
                    }
                    else
                    { //log
                    }
                }
                dr.Close();
            }
            catch (Exception e)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                log.Severe(e.ToString());
            }

            return(counter);
        }       //	addMissingColumns
Пример #6
0
        }       //	setItems

        /// <summary>
        /// Copy Items
        /// </summary>
        /// <param name="fromFormat">from print format</param>
        /// <param name="toFormat">to print format (client, id)</param>
        /// <returns>items</returns>
        static private MPrintFormatItem[] CopyItems(MPrintFormat fromFormat, MPrintFormat toFormat)
        {
            List <MPrintFormatItem> list = new List <MPrintFormatItem>();

            MPrintFormatItem[] items = fromFormat.GetItems();
            for (int i = 0; i < items.Length; i++)
            {
                MPrintFormatItem pfi = items[i].CopyToClient(toFormat.GetAD_Client_ID(), toFormat.Get_ID());
                if (pfi != null)
                {
                    list.Add(pfi);
                }
            }
            //
            MPrintFormatItem[] retValue = new MPrintFormatItem[list.Count];
            retValue = list.ToArray();
            CopyTranslationItems(items, retValue); //	JTP fix
            return(retValue);
        }                                          //	copyItems
Пример #7
0
        }       //	getItem

        /// <summary>
        /// Get active Items
        /// </summary>
        /// <returns>items</returns>
        private MPrintFormatItem[] GetItems()
        {
            List <MPrintFormatItem> list = new List <MPrintFormatItem>();
            String sql = "SELECT * FROM AD_PrintFormatItem pfi "
                         + "WHERE pfi.AD_PrintFormat_ID=@AD_PrintFormat_ID AND pfi.IsActive='Y'"
                         //	Display restrictions - Passwords, etc.
                         + " AND NOT EXISTS (SELECT * FROM AD_Field f "
                         + "WHERE pfi.AD_Column_ID=f.AD_Column_ID"
                         + " AND (f.IsEncrypted='Y' OR f.ObscureType IS NOT NULL))"
                         + "ORDER BY SeqNo";
            MRole role = MRole.GetDefault(GetCtx(), false);

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@AD_PrintFormat_ID", Get_ID());
                DataSet ds = SqlExec.ExecuteQuery.ExecuteDataset(sql, param);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    MPrintFormatItem pfi = new MPrintFormatItem(Env.GetContext(), dr, Get_TrxName());
                    if (role.IsColumnAccess(GetAD_Table_ID(), pfi.GetAD_Column_ID(), true))
                    {
                        list.Add(pfi);
                    }
                }
            }
            catch (Exception e)
            {
                log.Severe(e.ToString());
                //log entry, if any
            }
            //
            MPrintFormatItem[] retValue = new MPrintFormatItem[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }       //	getItems
Пример #8
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
Пример #9
0
        }       //	copy

        /// <summary>
        /// Create Items.
        /// Using the display order of Fields in some Tab
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="format">format</param>
        /// <returns>items</returns>
        static private MPrintFormatItem[] CreateItems(Ctx ctx, MPrintFormat format)
        {
            List <MPrintFormatItem> list = new List <MPrintFormatItem>();
            //	Get Column List from Tab
            String sql = "SELECT AD_Column_ID " //, Name, IsDisplayed, SeqNo
                         + "FROM AD_Field "
                         + "WHERE AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=@AD_Table_ID)"
                         + " AND IsEncrypted='N'  AND IsDisplayed='Y'  AND ObscureType IS NULL "
                         + "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, COALESCE(MRSeqNo, SeqNo), Name";
            IDataReader dr = null;

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@AD_Table_ID", format.GetAD_Table_ID());
                dr       = SqlExec.ExecuteQuery.ExecuteReader(sql, param);
                int seqNo = 1;
                while (dr.Read())
                {
                    MPrintFormatItem pfi = MPrintFormatItem.CreateFromColumn(format, Utility.Util.GetValueOfInt(dr[0].ToString()), seqNo++);
                    if (pfi != null)
                    {
                        list.Add(pfi);
                    }
                }
                dr.Close();
            }
            catch (Exception e)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                s_log.Severe(e.ToString());
                //log, if any
            }
            //	No Tab found for Table
            if (list.Count == 0)
            {
                sql = "SELECT AD_Column_ID "
                      + "FROM AD_Column "
                      + "WHERE AD_Table_ID='" + format.GetAD_Table_ID() + "' "
                      + "ORDER BY IsIdentifier DESC, SeqNo, Name";
                IDataReader idr = null;
                try
                {
                    idr = SqlExec.ExecuteQuery.ExecuteReader(sql);
                    // DataTable dt = new DataTable();
                    //dt.Load(idr);

                    int seqNo = 1;
                    while (idr.Read())
                    {
                        MPrintFormatItem pfi = MPrintFormatItem.CreateFromColumn(format, Utility.Util.GetValueOfInt(idr[0].ToString()), seqNo++);
                        if (pfi != null)
                        {
                            list.Add(pfi);
                        }
                    }
                    idr.Close();
                }
                catch (Exception e)
                {
                    if (idr != null)
                    {
                        idr.Close();
                    }
                    s_log.Severe(e.ToString());
                    //log, if any
                }
            }

            //
            MPrintFormatItem[] retValue = new MPrintFormatItem[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }       //	createItems
Пример #10
0
        }       //	copy

        /// <summary>
        /// Create Items.
        /// Using the display order of Fields in some Tab
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="format">format</param>
        /// <returns>items</returns>
        /// <summary>
        /// Create Items.
        /// Using the display order of Fields in some Tab
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="format">format</param>
        /// <returns>items</returns>
        static private MPrintFormatItem[] CreateItems(Ctx ctx, MPrintFormat format, int AD_tab_ID, bool isMRSeq = false)
        {
            List <MPrintFormatItem> list = new List <MPrintFormatItem>();
            bool runOldCode = true;
            //	Get Column List from Tab
            String sql = "SELECT AD_Column_ID " //, Name, IsDisplayed, SeqNo
                         + "FROM AD_Field "
                         + "WHERE ";

            if (AD_tab_ID == 0)
            {
                sql += " AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=@AD_Table_ID)";
            }
            else
            {
                sql += " AD_Tab_ID=@AD_Table_ID";
            }
            //added check on 03/12/14 - "AND IsDisplayed='Y' AND IsActive='Y'"
            sql += " AND IsEncrypted='N' AND (IsDisplayed='Y' OR MRISDISPLAYED='Y') AND IsActive='Y' AND ObscureType IS NULL ";
            //Lakhwinder
            if (isMRSeq)
            {
                try
                {
                    runOldCode = false;
                    sql        = "SELECT AD_Column_ID,Ad_Field_ID  FROM AD_Field WHERE ";
                    if (AD_tab_ID == 0)
                    {
                        sql += " AD_Tab_ID=(SELECT MIN(AD_Tab_ID) FROM AD_Tab WHERE AD_Table_ID=@AD_Table_ID)";
                    }
                    else
                    {
                        sql += " AD_Tab_ID=@AD_Table_ID";
                    }
                    //added check on 03/12/14 - "AND IsDisplayed='Y' AND IsActive='Y'"
                    sql += " AND IsEncrypted='N' AND (IsDisplayed='Y' OR MRISDISPLAYED='Y') AND IsActive='Y' AND ObscureType IS NULL ";
                    bool isMESeqDefined = false;
                    //if multirow sequence is set on tab then MRIsDisplayed Column does have non null value
                    int count = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(*) FROM AD_Field WHERE AD_Tab_ID =" + AD_tab_ID + " AND MRIsDisplayed IS NOT NULL"));
                    if (count > 0)//tab has defined multirow sequence
                    {
                        isMESeqDefined = true;
                        sql           += " ORDER BY MRSeqNo ";
                    }
                    else//tab has undefined multirow sequence
                    {
                        sql += " ORDER BY NVL(MRSeqNo,999999),Name ";
                    }

                    SqlParameter[] param = new SqlParameter[1];
                    if (AD_tab_ID == 0)
                    {
                        param[0] = new SqlParameter("@AD_Table_ID", format.GetAD_Table_ID());
                    }
                    else
                    {
                        param[0] = new SqlParameter("@AD_Table_ID", AD_tab_ID);
                    }
                    DataSet ds = DB.ExecuteDataset(sql, param);
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            MPrintFormatItem pfi = MPrintFormatItem.CreateFromColumn(format, Util.GetValueOfInt(ds.Tables[0].Rows[i]["AD_Column_ID"]), Util.GetValueOfInt(ds.Tables[0].Rows[i]["AD_Field_ID"]), i + 1, isMESeqDefined);
                            if (pfi != null)
                            {
                                list.Add(pfi);
                            }
                        }
                    }
                }
                catch
                {
                    runOldCode = true;
                    sql       += " ORDER BY  COALESCE(MRISDISPLAYED,IsDisplayed) DESC, SortNo, MRSeqNo, COALESCE(IsDisplayed,'N'), SeqNo";
                }
            }
            else
            {
                sql += " ORDER BY  COALESCE(MRISDISPLAYED,IsDisplayed) DESC, SortNo, MRSeqNo, COALESCE(IsDisplayed,'N'), SeqNo";
            }
            // + "ORDER BY COALESCE(IsDisplayed,'N') DESC, SortNo, COALESCE(MRSeqNo, SeqNo), Name";
            if (runOldCode)
            {
                IDataReader dr = null;
                try
                {
                    SqlParameter[] param = new SqlParameter[1];
                    if (AD_tab_ID == 0)
                    {
                        param[0] = new SqlParameter("@AD_Table_ID", format.GetAD_Table_ID());
                    }
                    else
                    {
                        param[0] = new SqlParameter("@AD_Table_ID", AD_tab_ID);
                    }
                    dr = SqlExec.ExecuteQuery.ExecuteReader(sql, param);
                    int seqNo = 1;
                    while (dr.Read())
                    {
                        MPrintFormatItem pfi = MPrintFormatItem.CreateFromColumn(format, Utility.Util.GetValueOfInt(dr[0].ToString()), seqNo++);
                        if (pfi != null)
                        {
                            list.Add(pfi);
                        }
                    }
                    dr.Close();
                }
                catch (Exception e)
                {
                    if (dr != null)
                    {
                        dr.Close();
                    }
                    s_log.Severe(e.ToString());
                    //log, if any
                }
            }
            //	No Tab found for Table
            if (list.Count == 0)
            {
                sql = "SELECT AD_Column_ID "
                      + "FROM AD_Column "
                      + "WHERE AD_Table_ID='" + format.GetAD_Table_ID() + "' "
                      + "ORDER BY IsIdentifier DESC, SeqNo, Name";
                IDataReader idr = null;
                try
                {
                    idr = SqlExec.ExecuteQuery.ExecuteReader(sql);
                    // DataTable dt = new DataTable();
                    //dt.Load(idr);

                    int seqNo = 1;
                    while (idr.Read())
                    {
                        MPrintFormatItem pfi = MPrintFormatItem.CreateFromColumn(format, Utility.Util.GetValueOfInt(idr[0].ToString()), seqNo++);
                        if (pfi != null)
                        {
                            list.Add(pfi);
                        }
                    }
                    idr.Close();
                }
                catch (Exception e)
                {
                    if (idr != null)
                    {
                        idr.Close();
                    }
                    s_log.Severe(e.ToString());
                    //log, if any
                }
            }

            //
            MPrintFormatItem[] retValue = new MPrintFormatItem[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }       //	createItems
Пример #11
0
        private void CreateBarcode(String code, MPrintFormatItem item)
        {
            String type = item.GetBarcodeType();

            try
            {
                if (type.Equals(MPrintFormatItem.BARCODETYPE_Codabar2Of7Linear))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_CodabarMonarchLinear))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_CodabarNW_7Linear))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_CodabarUSD_4Linear))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code128ACharacterSet))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code128BCharacterSet))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code128CCharacterSet))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code128DynamicallySwitching))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code393Of9LinearWithChecksum))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code393Of9LinearWOChecksum))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code39LinearWithChecksum))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code39LinearWOChecksum))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code39USD3WithChecksum))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_Code39USD3WOChecksum))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_CodeabarLinear))
                {
                }

                //	http://www.idautomation.com/code128faq.html
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_EAN128))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_GlobalTradeItemNoGTINUCCEAN128))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_PDF417TwoDimensional))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_SCC_14ShippingCodeUCCEAN128))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_ShipmentIDNumberUCCEAN128))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_SSCC_18NumberUCCEAN128))
                {
                }
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_UCC128))
                {
                }

                //	http://www.usps.com/cpim/ftp/pubs/pub97/97apxs_006.html#_Toc481397331
                else if (type.Equals(MPrintFormatItem.BARCODETYPE_USPostalServiceUCCEAN128))
                {
                    //m_barcode = BarcodeFactory.createUSPS(code);
                    //m_barcode.setDrawingText(false);
                }
                else
                {
                    log.Warning("Invalid Type" + type);
                }
            }
            catch (Exception e)
            {
                log.Warning(code + " - " + e.ToString());
                m_valid = false;
            }

            //if (m_valid && m_barcode != null)
            //{
            //    p_info = "BarCodeType=" + type;
            //    if (item.GetAD_PrintFont_ID() != 0)
            //    {
            //        MPrintFont mFont = MPrintFont.Get(item.GetAD_PrintFont_ID());
            //        if (mFont != null)
            //        {
            //            m_barcode.FontName = mFont.GetFont().Name;
            //            //m_barcode.FontName = mFont.GetFont().Size;
            //        }
            //    }
            //    if (item.GetMaxWidth() > 0)
            //        m_barcode.setBarWidth(item.getMaxWidth());
            //    if (item.getMaxHeight() > 0)
            //        m_barcode.setBarHeight(item.getMaxHeight());
            //    //	m_barcode.setResolution(72);
            //    //
            //    p_width = m_barcode.getWidth();
            //    p_height = m_barcode.getHeight();
            //    log.fine(type + " height=" + p_height + ", width=" + p_width);
            //}
        }       //	createBarcode