Example #1
0
 public frmProject(InvoiceSystemEntities entities, project project)
 {
     InitializeComponent();
     this.entities = entities;
     this.project  = project;
     FillProjectData();
 }
Example #2
0
 public frmInvoice(InvoiceSystemEntities entities, invoiceheader invoiceheader)
 {
     InitializeComponent();
     this.entities      = entities;
     this.invoiceheader = invoiceheader;
     FillInvoiceData();
 }
Example #3
0
 public frmClient(InvoiceSystemEntities entities, client client)
 {
     InitializeComponent();
     this.entities = entities;
     this.client   = client;
     FillClientData();
 }
Example #4
0
        static void Main()
        {
            InvoiceSystemEntities entities = new InvoiceSystemEntities();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain(entities));
        }
Example #5
0
        public void GeneratePDF(invoiceheader invoice)
        {
            using (var entities = new InvoiceSystemEntities())
            {
                var me     = entities.clients.Where(item => item.isme == true).First();
                var client = invoice.client;

                string templateText = System.IO.File.ReadAllText(@"Templates\template_base.html");
                templateText = templateText.Replace("<%name%>", me.clientname);
                templateText = templateText.Replace("<%address%>", me.address);
                templateText = templateText.Replace("<%phonenumber%>", me.phonenumber);
                templateText = templateText.Replace("<%abn%>", me.abn);
                templateText = templateText.Replace("<%email%>", me.email);
                templateText = templateText.Replace("<%clientname%>", client.clientname);
                templateText = templateText.Replace("<%invoicedate%>", invoice.datecreated.ToString("dd/MM/yyyy"));
                templateText = templateText.Replace("<%invoicenumber%>", invoice.number.ToString());
                templateText = templateText.Replace("<%invoicelines%>", ConvertInvoiceLinesToTableHTML(invoice));
                templateText = templateText.Replace("<%totalextax%>", (invoice.invoicelines.Sum(item => (item.hours * item.project.hourlyrate))).ToString());
                templateText = templateText.Replace("<%tax%>", client.taxrate.ToString());
                templateText = templateText.Replace("<%totalinctax%>", ((invoice.invoicelines.Sum(item => (item.hours * item.project.hourlyrate))) + client.taxrate * (invoice.invoicelines.Sum(item => (item.hours * item.project.hourlyrate)))).ToString());

                File.WriteAllText("output.html", templateText);
                string invoiceFile;

                if (invoice.invoicelines.Count > 0)
                {
                    invoiceFile = "TaxInvoice" + client.clientname.Split(' ').First().ToString() + invoice.invoicelines.Last().datecompleted.ToString("MMMM") + ".pdf";
                }
                else
                {
                    invoiceFile = "TaxInvoice" + client.clientname.Split(' ').First().ToString() + "EMPTY" + ".pdf";
                }


                ProcessStartInfo psi = new ProcessStartInfo();
                psi.Arguments       = "output.html " + invoiceFile;
                psi.UseShellExecute = false;
                psi.CreateNoWindow  = true;
                psi.FileName        = @"Plugins\wkhtmltopdf.exe";
                Process.Start(psi);
                Process.Start("explorer.exe", @".");
            }
        }
Example #6
0
 public frmSearchInvoices(InvoiceSystemEntities entities)
 {
     this.entities = entities;
     InitializeComponent();
 }
Example #7
0
 public frmInvoice(InvoiceSystemEntities entities)
 {
     InitializeComponent();
     this.entities = entities;
     FillInvoiceData();
 }
Example #8
0
 public frmMain(InvoiceSystemEntities entities)
 {
     InitializeComponent();
     this.entities = entities;
 }