示例#1
0
        private void btnQrDownload_Click(object sender, EventArgs e)
        {
            try
            {
                if (grdQRcode.DataSource == null)
                {
                    MessageBox.Show("There is no code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                FolderBrowserDialog browser = new FolderBrowserDialog();

                if (browser.ShowDialog() == DialogResult.OK)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    string path = browser.SelectedPath;

                    foreach (var item in noteBookSerials)
                    {
                        QRcode.CreateQR(item.QRcode.ToString(), path);
                    }
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("operation accomplished successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                MessageBox.Show("There is no NoteBook Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        public void ComparateurInv()
        {
            QRcode a     = new QRcode("abcde");
            int    verif = 10;

            Assert.AreEqual(a.ComparateurInv(verif), "A");
        }
示例#3
0
        public void Comparateur()
        {
            QRcode a     = new QRcode("abcde");
            char   verif = 'A';

            Assert.AreEqual(a.comparateur(verif), 10);
        }
示例#4
0
 public DataTable ReadFromExcels(string namefile)
 {
     try
     {
         QRcode    qrcode       = new QRcode();
         string    fileLocation = txtDuongDanFile.Text;
         string    name         = Path.GetFileName(txtDuongDanFile.Text);
         DataTable sheet        = new DataTable();
         OleDbConnectionStringBuilder csbuilder = new OleDbConnectionStringBuilder();
         csbuilder.Provider   = "Microsoft.ACE.OLEDB.12.0";
         csbuilder.DataSource = fileLocation.Substring(0, fileLocation.LastIndexOf('\\'));
         csbuilder.Add("Extended Properties", "Text;Excel 12.0;HDR=No;IMEX=1;FMT=Delimited");
         string selectSql = @"SELECT * FROM [" + name + "]";
         using (OleDbConnection connection = new OleDbConnection(csbuilder.ConnectionString))
             using (OleDbDataAdapter adapter = new OleDbDataAdapter(selectSql, connection))
             {
                 connection.Open();
                 adapter.Fill(sheet);
                 connection.Close();
             }
         DataSet ds = TableVeSo();
         Decimal No = 1;
         foreach (DataRow row in sheet.Rows)
         {
             LotteryPattern lotteryPattern = new LotteryPattern();
             lotteryPattern.NO = No.ToString();
             if (row[0] != null)
             {
                 lotteryPattern.LoaiVe = row[0].ToString();
             }
             if (row[1] != null)
             {
                 lotteryPattern.KyVe = row[1].ToString();
             }
             if (row[2] != null)
             {
                 lotteryPattern.NgaySo = Convert.ToDateTime(row[2].ToString());
             }
             if (row[3] != null)
             {
                 lotteryPattern.So = row[3].ToString();
             }
             if (row[4] != null)
             {
                 lotteryPattern.SoMaHoa = row[4].ToString();
             }
             byte[] qrcodebyte       = qrcode.ConertArrayByte(qrcode.GenerateQRCode(lotteryPattern.SoMaHoa, 70, 70));
             byte[] qrcodebytebottom = qrcode.ConertArrayByte(qrcode.GenerateQRCode(lotteryPattern.SoMaHoa, 40, 40));
             ds.Tables[0].Rows.Add(lotteryPattern.NO, lotteryPattern.NgaySo, lotteryPattern.So, lotteryPattern.SoMaHoa, lotteryPattern.KyVe, qrcodebyte, qrcodebytebottom, qrcodebyte, lotteryPattern.LoaiVe);
             No++;
         }
         return(ds.Tables[0]);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(null);
     }
 }
示例#5
0
        static void Main(string[] args)
        {
            QRcode o = new QRcode("heyy.... toi! tu sais que t bg?");

            TD5();

            //Encodage("hello world");


            Console.ReadLine();
        }
示例#6
0
        public void ConvertisseurQRCodeDecEnbinaire()
        {
            QRcode a = new QRcode("abcde");

            int[] tab  = a.ConvertisseurDecenBinaireQR(123, 8);
            int[] test = { 0, 1, 1, 1, 1, 0, 1, 1 };
            Assert.AreEqual(test[0], tab[0]);
            Assert.AreEqual(test[1], tab[1]);
            Assert.AreEqual(test[2], tab[2]);
            Assert.AreEqual(test[3], tab[3]);
            Assert.AreEqual(test[4], tab[4]);
            Assert.AreEqual(test[5], tab[5]);
            Assert.AreEqual(test[6], tab[6]);
            Assert.AreEqual(test[7], tab[7]);
        }
示例#7
0
        static void MenuQrCode()
        {
            Console.WriteLine("Que vouelz vous faire");
            Console.WriteLine("1 - Faire un QR CODE V1");
            Console.WriteLine("2 - Décoder Un Qr CODE V1");
            Console.WriteLine("3 - Faire un QR CODE V2 (Pas fait)");
            Console.WriteLine("4 - Décoder Un Qr CODE V2 (Pas fait)");
            string check = Convert.ToString(Console.ReadLine());
            int    n     = 0;
            bool   verif = int.TryParse(check, out n);

            while ((n != 1 && n != 2) || (verif != true))
            {
                Console.WriteLine("Veuillez saisir soit 1 ou 2");
                check = Convert.ToString(Console.ReadLine());
                verif = int.TryParse(check, out n);
            }
            switch (n)
            {
            case 1:
                Console.WriteLine("ecrivez le mot à encoder max 19 caractère (V1)");
                string mot = Console.ReadLine();
                mot = mot.ToUpper();
                QRcode Qr    = new QRcode(mot);
                Bitmap Image = new Bitmap("coco.bmp");
                Image.Save("coco1.bmp");
                MyImage QRIm = new MyImage("coco1.bmp");
                QRIm = Qr.EcritureQRCodeMatrice(QRIm);
                QRIm.From_image_to_file("coco1.bmp");
                Process.Start("coco1.bmp");
                break;

            case 2:
                Console.WriteLine("ecrivez le mot à encoder max 19 caractère (V1) qui sera décoder par la suite");
                mot = Console.ReadLine();
                mot = mot.ToUpper();
                Qr  = new QRcode(mot);
                Console.WriteLine(Qr.DecodageQRV1(Qr));
                Console.ReadKey();
                break;

            default:
                break;
            }
        }
示例#8
0
        private void btnDownloadVideoQR_Click(object sender, EventArgs e)
        {
            if (chkVideos.Items.Count == 0)
            {
                MessageBox.Show("There is no Video", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            FolderBrowserDialog browser = new FolderBrowserDialog();

            if (browser.ShowDialog() == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                string path = browser.SelectedPath;
                foreach (var item in videos)
                {
                    QRcode.CreateQR(item.Id.ToString(), path, 10, item.Title);
                }
                Cursor.Current = Cursors.Default;
                MessageBox.Show("operation accomplished successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private string GenerateLP()
        {
            List <string> fileFragment = new List <string>();
            string        savePath     = "";
            string        filePath     = Server.MapPath("~/Document/Generate/");
            string        qrpath       = Server.MapPath("~/Document/QR/");
            string        qr           = QRcode.GenerateQR(txtNoOrder.Text.Replace(" ", ""), qrpath); //.Replace("/", "")
            string        fileName     = "";
            string        replaceName  = null;

            try
            {
                var ret   = orderControls.GetDataForPrint(txtNoOrder.Text);
                var order = ret.Result;
                replaceName = order.orderNo.Replace("/", "");
                var ordersample = order.ordersampletbls.ToList();
                var orderprice  = order.orderpricedetailtbls;

                SpreadsheetInfo.SetLicense(ConfigurationManager.AppSettings["GemboxLicense"]);
                bool isPackage = false;
                if (order.comoditytbl.isPackage == "1")
                {
                    isPackage = true;
                }
                // Load Excel file.
                var templateName = isPackage ? "/TemplateLP_Paket.xlsx" : "/TemplateLP.xlsx";
                var workbook     = ExcelFile.Load(Server.MapPath("~/Document/Template") + templateName);

                // Select active worksheet.
                var worksheet = workbook.Worksheets[0];

                worksheet.Cells["G9"].Value  = order.orderNo;
                worksheet.Cells["D12"].Value = order.sampleTotal;
                worksheet.Cells["D11"].Value = order.receiptDate;
                worksheet.Cells["F13"].Value = ordersample[0].village;
                worksheet.Cells["L13"].Value = ordersample[0].subDistrict;
                worksheet.Cells["F14"].Value = ordersample[0].district;
                worksheet.Cells["L14"].Value = ordersample[0].province;
                worksheet.Cells["F15"].Value = ordersample[0].longitude + "," + ordersample[0].latitude;
                worksheet.Cells["D16"].Value = order.customertbl.customerName;
                worksheet.Cells["D17"].Value = order.customertbl.companyName;
                worksheet.Cells["D18"].Value = order.customertbl.companyAddress;
                worksheet.Cells["M17"].Value = order.customertbl.companyPhone;
                // Insert Image
                worksheet.Pictures.Add(qr, "A49");
                //worksheet.Pictures.Add(qr, "N8", "N12");

                int     pages          = 1;
                int     startRow       = 22;
                int     row            = 0;
                int     rowLimit       = 21;
                int     totalPage      = decimal.ToInt32(Math.Ceiling(orderprice.Count() / (decimal)21));
                decimal pagetotalprice = 0;

                foreach (var item in orderprice)
                {
                    worksheet.Cells[row + startRow, 0].Value  = row + 1;
                    worksheet.Cells[row + startRow, 1].Value  = item.elementservicestbl.elementCode;
                    worksheet.Cells[row + startRow, 10].Value = item.price.Value <= 0 ? "-" : item.price.Value.ToString("N0");
                    worksheet.Cells[row + startRow, 12].Value = item.quantity;
                    worksheet.Cells[row + startRow, 13].Value = item.TotalPrice.Value <= 0 ? "-" : item.TotalPrice.Value.ToString("N0");

                    pagetotalprice = pagetotalprice + item.TotalPrice.Value;

                    row++;

                    if (row == rowLimit)
                    {
                        worksheet.Cells["N45"].Value = isPackage ? order.priceTotal?.ToString("N0") : pagetotalprice.ToString("N0");
                        worksheet.Cells["N46"].Value = "page" + pages + "/" + totalPage;
                        if (isPackage)
                        {
                            worksheet.Cells["B48"].Value = order.additionalPriceRemark;
                        }
                        // Save the file in PDF format.
                        CheckFolderExists(filePath);
                        fileName = replaceName + "_page" + pages + ".pdf";
                        savePath = filePath + fileName;
                        workbook.Save(savePath);
                        fileFragment.Add(savePath);

                        pages++;

                        for (int x = 1; x < 21; x++)
                        {
                            worksheet.Cells[row + startRow, 0].Value  = "";
                            worksheet.Cells[row + startRow, 1].Value  = "";
                            worksheet.Cells[row + startRow, 10].Value = "";
                            worksheet.Cells[row + startRow, 12].Value = "";
                            worksheet.Cells[row + startRow, 13].Value = "";
                        }
                        row            = 0;
                        pagetotalprice = 0;
                    }
                }

                if (pages > 1)
                {
                    worksheet.Cells["N45"].Value = isPackage ? order.priceTotal?.ToString("N0") : pagetotalprice.ToString("N0");
                    worksheet.Cells["N46"].Value = "page" + pages + "/" + totalPage;
                    if (isPackage)
                    {
                        worksheet.Cells["B48"].Value = order.additionalPriceRemark;
                    }
                    // Save the file in PDF format.
                    CheckFolderExists(filePath);
                    fileName = replaceName + "_page" + pages + ".pdf";
                    savePath = filePath + fileName;
                    fileFragment.Add(savePath);
                    workbook.Save(savePath);

                    #region Combine multiple pdf
                    // Open the output document
                    PdfSharp.Pdf.PdfDocument outputDocument = new PdfSharp.Pdf.PdfDocument();

                    // Iterate files
                    foreach (string file in fileFragment)
                    {
                        // Open the document to import pages from it.
                        PdfSharp.Pdf.PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);

                        // Iterate pages
                        int count = inputDocument.PageCount;
                        for (int idx = 0; idx < count; idx++)
                        {
                            // Get the page from the external document...
                            PdfSharp.Pdf.PdfPage page = inputDocument.Pages[idx];
                            // ...and add it to the output document.
                            outputDocument.AddPage(page);
                        }
                    }

                    // Save the document...
                    CheckFolderExists(filePath);
                    fileName = replaceName + ".pdf";
                    savePath = filePath + fileName;
                    outputDocument.Save(savePath);
                    #endregion
                }
                else
                {
                    worksheet.Cells["N45"].Value = isPackage ? order.priceTotal?.ToString("N0") : pagetotalprice.ToString("N0");
                    worksheet.Cells["N46"].Value = "page" + pages + "/" + totalPage;
                    if (isPackage)
                    {
                        worksheet.Cells["B48"].Value = order.additionalPriceRemark;
                    }
                    // Save the file in PDF format.
                    CheckFolderExists(filePath);
                    fileName = replaceName + ".pdf";
                    savePath = filePath + fileName;
                    workbook.Save(savePath);
                }

                return(savePath);
            }
            catch (Exception ex)
            {
            }
            return(null);
        }