Exemple #1
0
        public void PrintRaportPDFTest()
        {
            PrintPdf pdf = new PrintPdf();

            ProcessStartInfo info = new ProcessStartInfo();

            info.Verb           = "print";
            info.FileName       = @"d:\raport.pdf";
            info.CreateNoWindow = true;
            info.WindowStyle    = ProcessWindowStyle.Hidden;


            pdf.PrintRaportPDF();


            Assert.AreEqual(pdf.p.StartInfo, info);
        }
Exemple #2
0
    public string SendOrder(NewOrder x, string lang)
    {
        Global.Response resp = new Global.Response();
        try {
            Invoice.NewInvoice i = new Invoice.NewInvoice();
            i.dateAndTime = DateTime.Now.ToString("dd.MM.yyyy, HH:mm");
            i.year        = DateTime.Now.Year;
            i.orderNumber = I.GetNextOrderNumber();
            x.orderNumber = i.orderNumber;
            i.firstName   = x.firstName;
            i.lastName    = x.lastName;
            i.companyName = x.companyName;
            i.address     = x.address;
            i.postalCode  = x.postalCode;
            i.city        = x.city;
            i.country     = x.country;
            i.pin         = x.pin;
            i.note        = x.note;
            i.items       = new List <Invoice.Item>();
            Invoice.Item item = new Invoice.Item();
            item.title = string.Format(@"{0} - {1} {2} {3}"
                                       , x.application
                                       , x.version
                                       , x.maxNumberOfUsers > 5 ? string.Format("({0} korisnika)", x.maxNumberOfUsers) : ""
                                       , string.Format("- {0} god. licenca", x.licence));
            item.qty       = Convert.ToInt32(x.licenceNumber);
            item.unitPrice = x.price;
            i.items.Add(item);

            if (x.discountCoeff > 0)
            {
                item           = new Invoice.Item();
                item.title     = string.Format(@"Popust -{0}%", Math.Round(x.discountCoeff * 100, 0));
                item.qty       = 1;
                item.unitPrice = -Math.Round(x.price - x.priceWithDiscount, 2);
                i.items.Add(item);
            }

            i.total = x.discountCoeff > 0 ? x.priceWithDiscount * item.qty : x.price * item.qty;

            i.showSignature = true;
            i.isForeign     = x.isForeign;
            i.docType       = (int)Invoice.DocType.offer;
            if (x.maxNumberOfUsers > 5)
            {
                x.note = string.Format("{0}Pod-licence: {1}"
                                       , !string.IsNullOrWhiteSpace(x.note) ? string.Format("{0};", x.note) : ""
                                       , x.maxNumberOfUsers);
            }
            if (x.eInvoice)
            {
                x.note = string.Format("{0}e-Račun"
                                       , !string.IsNullOrWhiteSpace(x.note) ? string.Format("{0};", x.note) : "");
            }


            if (string.IsNullOrEmpty(x.id))
            {
                x.id = Guid.NewGuid().ToString();
            }
            string path = HttpContext.Current.Server.MapPath("~/App_Data/" + dataBase);
            //db.CreateGlobalDataBase(path, db.orders);
            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + dataBase))) {
                connection.Open();
                string sql = @"INSERT INTO orders VALUES  
                       (@id, @orderNumber, @firstName, @lastName, @companyName, @address, @postalCode, @city, @country, @pin, @email, @ipAddress, @application, @version, @licence, @licenceNumber, @price, @priceEur, @orderDate, @additionalService, @note, @userGroupId, @discountCoeff)";
                using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                    command.Parameters.Add(new SQLiteParameter("id", x.id));
                    command.Parameters.Add(new SQLiteParameter("orderNumber", x.orderNumber));
                    command.Parameters.Add(new SQLiteParameter("firstName", x.firstName));
                    command.Parameters.Add(new SQLiteParameter("lastName", x.lastName));
                    command.Parameters.Add(new SQLiteParameter("companyName", x.companyName));
                    command.Parameters.Add(new SQLiteParameter("address", x.address));
                    command.Parameters.Add(new SQLiteParameter("postalCode", x.postalCode));
                    command.Parameters.Add(new SQLiteParameter("city", x.city));
                    command.Parameters.Add(new SQLiteParameter("country", x.country));
                    command.Parameters.Add(new SQLiteParameter("pin", x.pin));
                    command.Parameters.Add(new SQLiteParameter("email", x.email));
                    command.Parameters.Add(new SQLiteParameter("ipAddress", x.ipAddress));
                    command.Parameters.Add(new SQLiteParameter("application", x.application));
                    command.Parameters.Add(new SQLiteParameter("version", x.version));
                    command.Parameters.Add(new SQLiteParameter("licence", x.licence));
                    command.Parameters.Add(new SQLiteParameter("licenceNumber", x.licenceNumber));
                    command.Parameters.Add(new SQLiteParameter("price", x.price));
                    command.Parameters.Add(new SQLiteParameter("priceEur", x.priceEur));
                    command.Parameters.Add(new SQLiteParameter("orderDate", Convert.ToString(x.orderDate)));
                    command.Parameters.Add(new SQLiteParameter("additionalService", x.additionalService));
                    command.Parameters.Add(new SQLiteParameter("note", x.note));
                    command.Parameters.Add(new SQLiteParameter("userGroupId", x.userGroupId));
                    command.Parameters.Add(new SQLiteParameter("discountCoeff", x.discountCoeff));
                    command.ExecuteNonQuery();
                }
            }

            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + usersDataBase))) {
                connection.Open();
                string sql1 = string.Format(@"UPDATE Users SET  
                            CompanyName='{0}', Address='{1}', PostalCode='{2}', City='{3}', Country='{4}', Pin='{5}'
                            WHERE email='{6}'", x.companyName, x.address, x.postalCode, x.city, x.country, x.pin, x.email);
                using (SQLiteCommand command = new SQLiteCommand(sql1, connection)) {
                    command.ExecuteNonQuery();
                }
            }

            PrintPdf PDF = new PrintPdf();
            i.docType = (int)Invoice.DocType.offer;
            // i.totPrice_eur = x.priceEur;
            i.totPrice_eur = x.discountCoeff > 0 ? x.priceWithDiscountEur : x.priceEur;
            string offerPdf     = PDF.CreateInvoicePdf(i);
            string offerPdfPath = !string.IsNullOrEmpty(offerPdf) ? string.Format("~/upload/invoice/temp/{0}.pdf", offerPdf) : null;
            Mail   m            = new Mail();
            resp = m.SendOrder(x, lang, offerPdfPath);
            return(JsonConvert.SerializeObject(resp, Formatting.None));
        } catch (Exception e) {
            resp.isSuccess = false;
            resp.msg       = e.Message;
            L.SendErrorLog(e, x.id, x.email, "Orders", "SendOrder");
            return(JsonConvert.SerializeObject(resp, Formatting.None));
        }
    }
 private void button2_Click_2(object sender, EventArgs e)
 {
     //utilisation de pdfium sans dépendances ghostscript
     PrintPdf.PrintPDF("Microsoft Print to PDF", "test", "ETQ_arrivage_200529094813.pdf", 1);
     MessageBox.Show("fin de l'impression");
 }