コード例 #1
0
        public String generateNewBarcodeNumeric(BarcodeTypeEnum in_barcodeType = BarcodeTypeEnum.EAN13)
        {
            String           valueToReturn = "";
            List <String>    allStringies  = new List <string>();
            String           dbQuery       = "Select Barcode from Parts WHERE BARCODETYPE = @BarcodeTypeIn";
            SQLiteConnection sql_con       = new SQLiteConnection("Data Source=" + newconfig.pathToDatabase);

            sql_con.Open();
            using (SQLiteCommand cmd = new SQLiteCommand(sql_con))
            {
                cmd.CommandText = dbQuery;
                cmd.Parameters.AddWithValue("@BarcodeTypeIn", (int)in_barcodeType);
                SQLiteDataReader sqlite_datareader = cmd.ExecuteReader();
                while (sqlite_datareader.Read())
                {
                    string RCode_ = sqlite_datareader.GetString(0);
                    allStringies.Add(RCode_);
                }
            }
            bool valueGenerated = false;

            do
            {
                valueToReturn  = this.RandomString(12);
                valueGenerated = !(allStringies.Contains(valueToReturn));
            } while (!valueGenerated);
            sql_con.Close();
            return(valueToReturn);
        }
コード例 #2
0
        /// <summary>
        /// Add new entry to list of parts. Or find its ID if this entry already exists
        /// </summary>
        /// <param name="in_newPart"></param>
        /// <param name="in_rawGenValue"></param>
        /// <param name="in_barcodeType"></param>
        /// <param name="entryAdded">is entry with this part name already available in database, or no...</param>
        /// <returns> ID of entry in parts list: either found or newly added</returns>
        public int insertNewEntryToPartsList(String in_newPart, String in_rawGenValue, ref bool entryAdded, BarcodeTypeEnum in_barcodeType = BarcodeTypeEnum.EAN13)
        {
            int IDwasAdded = -1;

            entryAdded = true;
            String           dbquerySelect = "Select ID from Parts where BarcodePart = @inPartName";
            String           dbqueryInsert = "Insert into Parts(Barcode, BarcodePart, BARCODETYPE) VALUES (@in_NewBarcode, @in_BarcodePart, @in_BarcodeType)";
            SQLiteConnection sql_con       = new SQLiteConnection("Data Source=" + newconfig.pathToDatabase);

            sql_con.Open();
            using (SQLiteCommand cmd = new SQLiteCommand(sql_con))
            {
                cmd.CommandText = dbquerySelect;
                cmd.Parameters.AddWithValue("@inPartName", in_newPart);
                long?foundID = (long?)cmd.ExecuteScalar();
                if (foundID != null)
                {
                    IDwasAdded = (int)foundID.Value;
                    entryAdded = false;
                }
                else
                {
                    cmd.CommandText = dbqueryInsert;
                    cmd.Parameters.AddWithValue("@in_NewBarcode", in_rawGenValue);
                    cmd.Parameters.AddWithValue("@in_BarcodePart", in_newPart);
                    cmd.Parameters.AddWithValue("@in_BarcodeType", in_barcodeType);
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = dbquerySelect;
                    cmd.Parameters.AddWithValue("@inPartName", in_newPart);
                    long?foundID2 = (long?)cmd.ExecuteScalar();
                    if (foundID2 != null)
                    {
                        IDwasAdded = (int)foundID2.Value;
                    }
                }
            }
            sql_con.Close();
            return(IDwasAdded);
        }
コード例 #3
0
        public static bool ParseVoucherImage(ref Bitmap bmp, ref Bitmap bmpBarcode, out Rectangle rect, ref string barcode, BarcodeTypeEnum barcodeType = BarcodeTypeEnum.BT_All)
        {
            lock (typeof(BarcodeReader))
            {
                rect       = Rectangle.Empty;
                bmpBarcode = null;
                barcode    = null;

                BarcodeReader reader = new BarcodeReader(Strings.VScan_BarcodeReaderSDKDeveloperLicenseKey);
                reader.LicenseManager.AddLicenseKey(Strings.VScan_BarcodeReaderSDKUnlimitedRuntimeLicenseKey);
                reader.BarcodesToRead = 1;
                reader.BarcodeTypes   = barcodeType;
                var barcodes = reader.ReadFromBitmapRotateAll(ref bmp, out bmpBarcode, out rect);
                if (barcodes != null && barcodes.Length > 0)
                {
                    barcode = barcodes[0].BarcodeString;
                    return(true);
                }
                return(false);
            }
        }