public static void FillProductsComboBox(InvoiceForm f)
        {
            DataTable medecines;

            try
            {
                if (f.comboBox1.SelectedValue == null)
                {
                    MessageBox.Show("please select a Supplier");
                }
                else
                {
                    object[,] Params = new object[2, 1];
                    Params[0, 0]     = "@S_ID";
                    Params[1, 0]     = f.comboBox1.SelectedValue;
                    medecines        = dt.GetData_StoredProcedure("GetMedecinesINDVBySupplier", Params, "medecines");
                    medecines.Columns.Add("Info");
                    foreach (DataRow item in medecines.Rows)
                    {
                        item["Info"] = item["Name"].ToString() + "  -  " + item["Dosage"].ToString() + "  -  " + item["Volume"].ToString();
                    }
                    Filling.FillComboBox(f.myComboBox11, medecines, "ID", "Info");
                }
            }
            catch { MessageBox.Show("ERROR!!"); }
        }
        public static void FillSupplierComboBox(InvoiceForm f)
        {
            DataTable suppliers;

            suppliers = dt.GetData_StoredProcedure("GetSuppliersNames", "suppliers");
            Filling.FillComboBox(f.comboBox1, suppliers, "ID", "Supplier");
        }
Beispiel #3
0
        public IActionResult CreateInvoice([FromBody] InvoiceForm form)
        {
            Error error     = new Error();
            var   invoiceId = _invoiceManager.CreateInvoice(form.MapToCore(), ref error);

            if (error.ErrorCode != ErrorCode.OKAY)
            {
                return(BadRequest(error.Message));
            }

            return(Ok(new { InvoiceId = invoiceId }));
        }
Beispiel #4
0
 private void Invoice_Click(object sender, EventArgs e)
 {
     if (invoiceForm == null || invoiceForm.IsDisposed)
     {
         invoiceForm = new InvoiceForm();
         invoiceForm.Show();
         invoiceForm.MdiParent = this;
     }
     else
     {
         invoiceForm.Activate();
     }
 }
Beispiel #5
0
        public bool WritePDFReport(string FilePath)
        {
            //try
            //{
                // Create a invoice form with the sample invoice data

               InvoiceForm invoice = new InvoiceForm(FilePath + "\\Invoice.xml");

                // Create a MigraDoc document
                Document document = invoice.CreateDocument();
                document.UseCmykColor = true;

                //        #if DEBUG
                //                // for debugging only...
                //                MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");
                //                document = MigraDoc.DocumentObjectModel.IO.DdlReader.DocumentFromFile("MigraDoc.mdddl");
                //        #endif

                // Create a renderer for PDF that uses Unicode font encoding
                PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

                // Set the MigraDoc document
                pdfRenderer.Document = document;

                // Create the PDF document
                pdfRenderer.RenderDocument();

                // Save the PDF document...
                string filename = FilePath + "\\Invoice.pdf";

                //#if DEBUG
                //                // I don't want to close the document constantly...
                //                filename = "Invoice-" + Guid.NewGuid().ToString("N").ToUpper() + ".pdf";
                //#endif
                pdfRenderer.Save(filename);
                // ...and start a viewer.
                //  Process.Start(filename);

            //}
            //catch (Exception ex)
            //{
            //    ex.
            //    //Console.WriteLine(ex.Message);
            //    //Console.ReadLine();
            //}

            return true;
        }
Beispiel #6
0
        public IActionResult EditInvoice([FromBody] InvoiceForm form)
        {
            Error error = new Error();

            _invoiceManager.RemoveCityExpensesFromInvoice(form.CityExpensesToRemove);
            _invoiceManager.RemoveInvoiceAccounts(form.InvoiceAccountsToRemove);

            var invoice = _invoiceManager.EditInvoice(form.MapToCore(), ref error);

            if (error.ErrorCode != ErrorCode.OKAY)
            {
                return(BadRequest(error.Message));
            }

            var response = InvoiceDetails.MapFromObject(invoice);

            return(Ok(response));
        }
        public static void AddRow_InvoiceDataGridView(InvoiceForm f)
        {
            DataTable medecinesData;

            object[,] Params = new object[2, 1];
            Params[0, 0]     = "@M_ID";
            Params[1, 0]     = f.myComboBox11.ComboBoxSelectedValue;
            medecinesData    = dt.GetData_StoredProcedure("GetMedecineByID_Invoice", Params, "medecines");
            string id         = medecinesData.Rows[0]["ID"].ToString();
            string name       = (string)medecinesData.Rows[0]["Name"];
            string Price      = medecinesData.Rows[0]["Price"].ToString();
            string Discount   = medecinesData.Rows[0]["Discount"].ToString() + "%";
            string quantity   = "1";
            string VAT        = "0";
            string TotalPrice = ((float.Parse(Price)) * ((100 - float.Parse(Discount.Replace("%", ""))) / 100) * (int.Parse(quantity))).ToString();

            f.dataGridView11.Rows.Add(id, name, "", VAT, quantity, Price, Discount, TotalPrice);
        }
            private static void Main()
            {
                try
                {
                    // Create a invoice form with the sample invoice data
                    InvoiceForm invoice = new InvoiceForm("../../invoice.xml");

                    // Create a MigraDoc document
                    Document document = invoice.CreateDocument();
                    document.UseCmykColor = true;

#if DEBUG
                    // for debugging only...
                    MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");
                    document = MigraDoc.DocumentObjectModel.IO.DdlReader.DocumentFromFile("MigraDoc.mdddl");
#endif

                    // Create a renderer for PDF that uses Unicode font encoding
                    PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

                    // Set the MigraDoc document
                    pdfRenderer.Document = document;

                    // Create the PDF document
                    pdfRenderer.RenderDocument();

                    // Save the PDF document...
                    string filename = "Invoice.pdf";
#if DEBUG
                    // I don't want to close the document constantly...
                    filename = "Invoice-" + Guid.NewGuid().ToString("N").ToUpper() + ".pdf";
#endif
                    pdfRenderer.Save(filename);

                    // ...and start a viewer.
                    //Process.Start(filename)
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.ReadLine();
                }
            }
 public static void Save_Invoice(InvoiceForm f)
 {
     //save Invoice
     try
     {
         if (f.bunifuDatepicker1.Value != null && (f.Textbox1ID.Text != "" || f.Textbox1ID.Text != null))
         {
             //save Invoiec
             int      InvID       = int.Parse(f.Textbox1ID.Text);
             DateTime InvDate     = f.bunifuDatepicker1.Value;
             int      InvSupplier = int.Parse(f.comboBox1.SelectedValue.ToString());
             Invoice  inv         = new Invoice(InvID, InvDate, InvSupplier);
             inv.AddInvoice(dt);
             //save InvoiceDetails
             InvoiceDetails invDetails;
             foreach (DataGridViewRow r in f.dataGridView11.Rows)
             {
                 string MedecineID = r.Cells["ProductID"].Value.ToString();
                 string VAT        = r.Cells["VAT"].Value.ToString();
                 string Price      = r.Cells["Price"].Value.ToString();
                 string Discount   = r.Cells["Discount"].Value.ToString();
                 string quantity   = r.Cells["Quantity"].Value.ToString();
                 string expiryDate = r.Cells["Date"].Value.ToString();
                 invDetails = new InvoiceDetails(MedecineID, InvID, quantity, Price, VAT.Replace("%", ""), expiryDate, Discount.Replace("%", ""));
                 invDetails.AddInvoiceDetails(dt);
                 Stocks.UpdateStocks(dt, int.Parse(MedecineID), int.Parse(quantity));
             }
         }
         else
         {
             MessageBox.Show("Please Fill ID and Date ");
         }
     }
     catch
     {
         //ADD DELETE FUNCTION
         MessageBox.Show("ERROR!!");
     }
 }
Beispiel #10
0
        public override void Run()
        {
            InvoiceForm     invoiceForm = new InvoiceForm();
            InvoiceItemForm itemForm    = new InvoiceItemForm();

            IInvoiceRepository     invoiceDao  = new NHibernateInvoiceRepository();
            IVehicleTripRepository tripDao     = new NHibernateVehicleTripRepository();
            ICustomerRepository    customerDao = new NHibernateCustomerRepository();
            IItemRepository        itemDao     = new NHibernateItemRepository();
            IAccountRepository     accountDao  = new NHibernateAccountRepository();

            invoiceForm.VehicleTripsList += delegate { invoiceForm.VehicleTrips = tripDao.FindAll(); };
            invoiceForm.AccountsList     += delegate { invoiceForm.Accounts = accountDao.FindAccountsReceivables(); };
            invoiceForm.CustomersList    += delegate { invoiceForm.Customers = customerDao.FindActive(); };
            itemForm.ItemFind            += delegate(object sender, ItemEventArgs e) {
                IList <Item> items = itemDao.FindByName(e.Item.Name);
                if (items.Count == 1)
                {
                    itemForm.InvoiceItem.Item = items[0];
                }
                else
                {
                    // TODO: Add item list of value!
                }
            };
            invoiceForm.ItemAdding += delegate(object sender, InvoiceItemEventArgs e) {
                itemForm.InvoiceItem = e.InvoiceItem;
                if (WorkbenchSingleton.AddDialog(itemForm) == DialogResult.OK)
                {
                    invoiceForm.Invoice.AddItem(itemForm.InvoiceItem);
                }
            };
            invoiceForm.InvoiceSaveAndClose += delegate(object sender, InvoiceEventArgs e) {
                invoiceDao.SaveOrUpdate(e.Invoice);
                invoiceForm.Close();
            };
            WorkbenchSingleton.AddChild(invoiceForm);
        }
Beispiel #11
0
        // Make a new invoice with the products in the room.
        private void nieuweOfferteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool inactiveProducts = false;

            for (int i = 0; i < DesignPanel1.rDesign.productList.Count; i++)
            {
                if (!DesignPanel1.rDesign.productList[i].active)
                {
                    inactiveProducts = true;
                }
            }
            if (!inactiveProducts)
            {
                InvoiceForm ivf = new InvoiceForm(DesignPanel1.rDesign, this);
                ivf.InstantiateAutocompleteLists();
                ivf.FillExistingCustomerList();
                ivf.ShowDialog();
            }
            else
            {
                MessageBox.Show("Er staan inactieve producten in uw ontwerp. Wilt u deze verwijderen?", "Foutmelding", MessageBoxButtons.OK);
            }
        }
        internal static string CreateInvoice(long userId, string status, string transid, string paymentmethod, ProductInfo productInfo, ProductPriceInfo ppi)
        {
            string companyName = string.Empty;
            string userPath = String.Empty;
            string password = HttpContext.Current.Session["access"] as string;
            UserInfo userInfo = null;
            ClientInfo clientInfo = null;
            using (Database db = new MySqlDatabase())
            {
                userPath = db.GetUserDocumentPath(userId, password);

                userPath = userPath.Replace("\\", "/");

                if (!Directory.Exists(userPath))
                    Directory.CreateDirectory(userPath);

                userInfo = db.GetUser(userId, password);
                clientInfo = db.GetClientInfo(userId);

                companyName = clientInfo.CompanyName;
            }
            // complete userPath with document name
            string filename = String.Format("INV{0}.pdf", transid);
            userPath = Path.Combine(userPath, filename);

            // Get the invoice template from the proper location
            string templatePath = Resource.InvoiceTemplate;
            string invoiceTemplate = HttpContext.Current.Server.MapPath(templatePath);
            try
            {
                InvoiceForm form = new InvoiceForm(invoiceTemplate);
                string culture = "nl-NL";
                if (HttpContext.Current.Session["culture"] != null)
                    culture = HttpContext.Current.Session["culture"] as string;
                CultureInfo cultureInfo = new CultureInfo(culture);

                List<string> fields = new List<string>();
                fields.Add(clientInfo.GetFullName());
                fields.Add(clientInfo.AddressLine1);
                if (!string.IsNullOrEmpty(clientInfo.AddressLine2))
                    fields.Add(clientInfo.AddressLine2);
                string tmpResidence = clientInfo.ZipCode + " " + clientInfo.City.ToUpper();
                if (!string.IsNullOrEmpty(tmpResidence))
                    fields.Add(tmpResidence);
                if (!string.IsNullOrEmpty(clientInfo.Country))
                    fields.Add(clientInfo.Country);
                while (fields.Count < 5)
                    fields.Add(" ");

                form.ClientAddress = fields.ToArray();
                form.InvoiceDate = DateTime.Now.ToString("d", cultureInfo);
                form.InvoiceNumber = transid;
                using (Database db = new MySqlDatabase())
                {
                    Transaction transaction = db.GetTransaction(Util.UserId, transid);
                    foreach (TransactionLine tl in transaction.TransactionLines)
                    {
                        form.InvoiceLines.Add(new PdfInvoiceLine()
                        {
                            Description = tl.Description,
                            Quantity = tl.Quantity,
                            UnitPrice = tl.Price,
                            VatRate = tl.VatPercentage
                        });
                    }
                }
                form.GenerateInvoice(userPath, companyName);
            }
            catch (Exception ex)
            {
                Logger.Instance.Write(LogLevel.Error, ex, "[CreateInvoice]");
            }

            SendInvoice(userId, userPath);

            return userPath;
        }
Beispiel #13
0
        public override void Run()
        {
            var form = new InvoiceForm(invoice);

            WorkbenchSingleton.AddChild(form);
        }