Exemple #1
0
        public override void Setup()
        {
            var frame = new FrameView("MessageBox Options")
            {
                X      = Pos.Center(),
                Y      = 1,
                Width  = Dim.Percent(75),
                Height = 10
            };

            Win.Add(frame);

            var label = new Label("width:")
            {
                X             = 0,
                Y             = 0,
                Width         = 15,
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };

            frame.Add(label);
            var widthEdit = new TextField("0")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = 5,
                Height = 1
            };

            frame.Add(widthEdit);

            label = new Label("height:")
            {
                X             = 0,
                Y             = Pos.Bottom(label),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var heightEdit = new TextField("0")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = 5,
                Height = 1
            };

            frame.Add(heightEdit);

            frame.Add(new Label("If height & width are both 0,")
            {
                X = Pos.Right(widthEdit) + 2,
                Y = Pos.Top(widthEdit),
            });
            frame.Add(new Label("the MessageBox will be sized automatically.")
            {
                X = Pos.Right(heightEdit) + 2,
                Y = Pos.Top(heightEdit),
            });

            label = new Label("Title:")
            {
                X             = 0,
                Y             = Pos.Bottom(label),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var titleEdit = new TextField("Title")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = Dim.Fill(),
                Height = 1
            };

            frame.Add(titleEdit);

            label = new Label("Message:")
            {
                X             = 0,
                Y             = Pos.Bottom(label),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var messageEdit = new TextView()
            {
                Text        = "Message",
                X           = Pos.Right(label) + 1,
                Y           = Pos.Top(label),
                Width       = Dim.Fill(),
                Height      = 5,
                ColorScheme = Colors.Dialog,
            };

            frame.Add(messageEdit);

            label = new Label("Num Buttons:")
            {
                X             = 0,
                Y             = Pos.Bottom(messageEdit),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var numButtonsEdit = new TextField("3")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = 5,
                Height = 1
            };

            frame.Add(numButtonsEdit);

            label = new Label("Default Button:")
            {
                X             = 0,
                Y             = Pos.Bottom(label),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var defaultButtonEdit = new TextField("0")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = 5,
                Height = 1
            };

            frame.Add(defaultButtonEdit);

            label = new Label("Style:")
            {
                X             = 0,
                Y             = Pos.Bottom(label),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var styleRadioGroup = new RadioGroup(new ustring [] { "_Query", "_Error" })
            {
                X = Pos.Right(label) + 1,
                Y = Pos.Top(label),
            };

            frame.Add(styleRadioGroup);

            var border = new Border()
            {
                Effect3D    = true,
                BorderStyle = BorderStyle.Single
            };
            var ckbEffect3D = new CheckBox("Effect3D", true)
            {
                X = Pos.Right(label) + 1,
                Y = Pos.Top(label) + 2
            };

            ckbEffect3D.Toggled += (e) => {
                border.Effect3D = !e;
            };
            frame.Add(ckbEffect3D);

            void Top_Loaded()
            {
                frame.Height = Dim.Height(widthEdit) + Dim.Height(heightEdit) + Dim.Height(titleEdit) + Dim.Height(messageEdit)
                               + Dim.Height(numButtonsEdit) + Dim.Height(defaultButtonEdit) + Dim.Height(styleRadioGroup) + 2 + Dim.Height(ckbEffect3D);
                Top.Loaded -= Top_Loaded;
            }

            Top.Loaded += Top_Loaded;

            label = new Label("Button Pressed:")
            {
                X             = Pos.Center(),
                Y             = Pos.Bottom(frame) + 4,
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            Win.Add(label);
            var buttonPressedLabel = new Label(" ")
            {
                X             = Pos.Center(),
                Y             = Pos.Bottom(frame) + 5,
                Width         = 25,
                Height        = 1,
                ColorScheme   = Colors.Error,
                TextAlignment = Terminal.Gui.TextAlignment.Centered
            };

            //var btnText = new [] { "_Zero", "_One", "T_wo", "_Three", "_Four", "Fi_ve", "Si_x", "_Seven", "_Eight", "_Nine" };

            var showMessageBoxButton = new Button("Show MessageBox")
            {
                X         = Pos.Center(),
                Y         = Pos.Bottom(frame) + 2,
                IsDefault = true,
            };

            showMessageBoxButton.Clicked += () => {
                try {
                    int width         = int.Parse(widthEdit.Text.ToString());
                    int height        = int.Parse(heightEdit.Text.ToString());
                    int numButtons    = int.Parse(numButtonsEdit.Text.ToString());
                    int defaultButton = int.Parse(defaultButtonEdit.Text.ToString());

                    var btns = new List <ustring> ();
                    for (int i = 0; i < numButtons; i++)
                    {
                        //btns.Add(btnText[i % 10]);
                        btns.Add(NumberToWords.Convert(i));
                    }
                    if (styleRadioGroup.SelectedItem == 0)
                    {
                        buttonPressedLabel.Text = $"{MessageBox.Query (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, border, btns.ToArray ())}";
                    }
                    else
                    {
                        buttonPressedLabel.Text = $"{MessageBox.ErrorQuery (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, border, btns.ToArray ())}";
                    }
                } catch (FormatException) {
                    buttonPressedLabel.Text = "Invalid Options";
                }
            };
            Win.Add(showMessageBoxButton);

            Win.Add(buttonPressedLabel);
        }
        public void Run_WhenCalledWithNumberOutOfRange_ThrowsArgumentOutOfRangeException(decimal number)
        {
            Action actual = () => NumberToWords.Run(number);

            Assert.Throws <ArgumentOutOfRangeException>(actual);
        }
Exemple #3
0
        /// <summary>
        /// Format the letter for the donor with all the gifts
        ///
        /// Can also used for a single receipt.
        /// </summary>
        /// <returns>One or more html documents, each in its own body tag, for printing with the HTML printer</returns>
        private static string FormatLetter(Int64 ADonorKey,
                                           string ADonorName,
                                           DataTable ADonations,
                                           string ABaseCurrency,
                                           string AHTMLTemplate,
                                           string ALedgerCountryCode,
                                           TDBTransaction ATransaction)
        {
            // get details of the donor, and best address

            PLocationTable        Location;
            PPartnerLocationTable PartnerLocation;
            string CountryName;
            string EmailAddress;

            if (!TAddressTools.GetBestAddress(ADonorKey, out Location, out PartnerLocation, out CountryName, out EmailAddress, ATransaction))
            {
                return("");
            }

            bool TaxDeductiblePercentageEnabled = Convert.ToBoolean(
                TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_TAXDEDUCTIBLEPERCENTAGE, "FALSE"));

            string msg = AHTMLTemplate;

            if (ADonorName.Contains(","))
            {
                msg = msg.Replace("#TITLE", Calculations.FormatShortName(ADonorName, eShortNameFormat.eOnlyTitle));
            }
            else
            {
                // organisations have no title
                msg = msg.Replace("#TITLE", "");
            }

            msg = msg.Replace("#NAME", Calculations.FormatShortName(ADonorName, eShortNameFormat.eReverseWithoutTitle));
            msg = msg.Replace("#STREETNAME", GetStringOrEmpty(Location[0].StreetName));
            msg = msg.Replace("#LOCATION", GetStringOrEmpty(Location[0].Locality));
            msg = msg.Replace("#ADDRESS3", GetStringOrEmpty(Location[0].Address3));
            msg = msg.Replace("#BUILDING1", GetStringOrEmpty(Location[0].Building1));
            msg = msg.Replace("#BUILDING2", GetStringOrEmpty(Location[0].Building2));
            msg = msg.Replace("#CITY", GetStringOrEmpty(Location[0].City));
            msg = msg.Replace("#POSTALCODE", GetStringOrEmpty(Location[0].PostalCode));
            msg = msg.Replace("#DATE", DateTime.Now.ToString("d. MMMM yyyy"));

            // according to German Post, there is no country code in front of the post code
            // if country code is same for the address of the recipient and this office, then COUNTRYNAME is cleared
            if (GetStringOrEmpty(Location[0].CountryCode) != ALedgerCountryCode)
            {
                msg = msg.Replace("#COUNTRYNAME", CountryName);
            }
            else
            {
                msg = msg.Replace("#COUNTRYNAME", "");
            }

            // recognise detail lines automatically
            string RowTemplate;

            msg = TPrinterHtml.GetTableRow(msg, "#AMOUNT", out RowTemplate);
            string  OrigRowTemplate = RowTemplate;
            string  rowTexts        = "";
            decimal sum             = 0;
            decimal sumTaxDeduct    = 0;
            decimal sumNonDeduct    = 0;

            decimal  prevAmount          = 0.0M;
            decimal  prevAmountTaxDeduct = 0.0M;
            decimal  prevAmountNonDeduct = 0.0M;
            string   prevCurrency        = String.Empty;
            string   prevCommentOne      = String.Empty;
            string   prevAccountDesc     = String.Empty;
            string   prevCostCentreDesc  = String.Empty;
            string   prevgifttype        = string.Empty;
            DateTime prevDateEntered     = DateTime.MaxValue;

            foreach (DataRow rowGifts in ADonations.Rows)
            {
                DateTime dateEntered         = Convert.ToDateTime(rowGifts["DateEntered"]);
                decimal  amount              = Convert.ToDecimal(rowGifts["TransactionAmount"]);
                decimal  taxDeductibleAmount = 0;
                decimal  nonDeductibleAmount = 0;
                string   currency            = rowGifts["Currency"].ToString();
                string   commentOne          = rowGifts["CommentOne"].ToString();
                string   accountDesc         = rowGifts["AccountDesc"].ToString();
                string   costcentreDesc      = rowGifts["CostCentreDesc"].ToString();
                string   gifttype            = rowGifts["GiftType"].ToString();
                RowTemplate = OrigRowTemplate;

                sum += Convert.ToDecimal(rowGifts["AmountInBaseCurrency"]);

                if (TaxDeductiblePercentageEnabled)
                {
                    taxDeductibleAmount = Convert.ToDecimal(rowGifts["TaxDeductibleAmount"]);
                    nonDeductibleAmount = Convert.ToDecimal(rowGifts["NonDeductibleAmount"]);
                    sumTaxDeduct       += Convert.ToDecimal(rowGifts["TaxDeductibleAmountBase"]);
                    sumNonDeduct       += Convert.ToDecimal(rowGifts["NonDeductibleAmountBase"]);
                }

                // can we sum up donations on the same date, or do we need to print each detail with the account description?
                if (RowTemplate.Contains("#COMMENTONE") || RowTemplate.Contains("#ACCOUNTDESC") || RowTemplate.Contains("#COSTCENTREDESC"))
                {
                    if (gifttype == MFinanceConstants.GIFT_TYPE_GIFT_IN_KIND)
                    {
                        RowTemplate = TPrinterHtml.RemoveDivWithClass(RowTemplate, MFinanceConstants.GIFT_TYPE_GIFT);
                    }
                    else if (gifttype == MFinanceConstants.GIFT_TYPE_GIFT)
                    {
                        RowTemplate = TPrinterHtml.RemoveDivWithClass(RowTemplate, MFinanceConstants.GIFT_TYPE_GIFT_IN_KIND);
                    }

                    rowTexts += RowTemplate.
                                Replace("#DONATIONDATE", dateEntered.ToString("dd.MM.yyyy")).
                                Replace("#AMOUNTCURRENCY", currency).
                                Replace("#AMOUNT", StringHelper.FormatUsingCurrencyCode(amount, currency)).
                                Replace("#TAXDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(taxDeductibleAmount, currency)).
                                Replace("#TAXNONDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(nonDeductibleAmount, currency)).
                                Replace("#COMMENTONE", commentOne).
                                Replace("#ACCOUNTDESC", accountDesc).
                                Replace("#COSTCENTREDESC", costcentreDesc);
                }
                else
                {
                    if ((dateEntered != prevDateEntered) && (prevDateEntered != DateTime.MaxValue))
                    {
                        if (prevgifttype == MFinanceConstants.GIFT_TYPE_GIFT_IN_KIND)
                        {
                            RowTemplate = TPrinterHtml.RemoveDivWithClass(RowTemplate, MFinanceConstants.GIFT_TYPE_GIFT);
                        }
                        else if (prevgifttype == MFinanceConstants.GIFT_TYPE_GIFT)
                        {
                            RowTemplate = TPrinterHtml.RemoveDivWithClass(RowTemplate, MFinanceConstants.GIFT_TYPE_GIFT_IN_KIND);
                        }

                        rowTexts += RowTemplate.
                                    Replace("#DONATIONDATE", prevDateEntered.ToString("dd.MM.yyyy")).
                                    Replace("#AMOUNTCURRENCY", prevCurrency).
                                    Replace("#AMOUNT", StringHelper.FormatUsingCurrencyCode(prevAmount, prevCurrency)).
                                    Replace("#TAXDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(prevAmountTaxDeduct, prevCurrency)).
                                    Replace("#TAXNONDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(prevAmountNonDeduct, prevCurrency)).
                                    Replace("#COMMENTONE", prevCommentOne).
                                    Replace("#ACCOUNTDESC", prevAccountDesc).
                                    Replace("#COSTCENTREDESC", prevCostCentreDesc);
                        prevAmount = amount;

                        if (TaxDeductiblePercentageEnabled)
                        {
                            prevAmountTaxDeduct = taxDeductibleAmount;
                            prevAmountNonDeduct = nonDeductibleAmount;
                        }
                    }
                    else
                    {
                        prevAmount += amount;

                        if (TaxDeductiblePercentageEnabled)
                        {
                            prevAmountTaxDeduct += taxDeductibleAmount;
                            prevAmountNonDeduct += nonDeductibleAmount;
                        }
                    }

                    prevCurrency       = currency;
                    prevDateEntered    = dateEntered;
                    prevCommentOne     = commentOne;
                    prevAccountDesc    = accountDesc;
                    prevCostCentreDesc = costcentreDesc;
                    prevgifttype       = gifttype;
                }
            }

            if (prevDateEntered != DateTime.MaxValue)
            {
                RowTemplate = OrigRowTemplate;

                if (prevgifttype == MFinanceConstants.GIFT_TYPE_GIFT_IN_KIND)
                {
                    RowTemplate = TPrinterHtml.RemoveDivWithClass(RowTemplate, MFinanceConstants.GIFT_TYPE_GIFT);
                }
                else if (prevgifttype == MFinanceConstants.GIFT_TYPE_GIFT)
                {
                    RowTemplate = TPrinterHtml.RemoveDivWithClass(RowTemplate, MFinanceConstants.GIFT_TYPE_GIFT_IN_KIND);
                }

                rowTexts += RowTemplate.
                            Replace("#DONATIONDATE", prevDateEntered.ToString("dd.MM.yyyy")).
                            Replace("#AMOUNTCURRENCY", prevCurrency).
                            Replace("#AMOUNT", StringHelper.FormatUsingCurrencyCode(prevAmount, prevCurrency)).
                            Replace("#TAXDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(prevAmountTaxDeduct, prevCurrency)).
                            Replace("#TAXNONDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(prevAmountNonDeduct, prevCurrency)).
                            Replace("#COMMENTONE", prevCommentOne).
                            Replace("#ACCOUNTDESC", prevAccountDesc).
                            Replace("#COSTCENTREDESC", prevCostCentreDesc);
                prevAmount = 0.0M;

                if (TaxDeductiblePercentageEnabled)
                {
                    prevAmountTaxDeduct = 0.0M;
                    prevAmountNonDeduct = 0.0M;
                }
            }

            msg = msg.Replace("#OVERALLAMOUNTCURRENCY", ABaseCurrency).
                  Replace("#OVERALLAMOUNT", StringHelper.FormatUsingCurrencyCode(sum, ABaseCurrency)).
                  Replace("#OVERALLTAXDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(sumTaxDeduct, ABaseCurrency)).
                  Replace("#OVERALLTAXNONDEDUCTAMOUNT", StringHelper.FormatUsingCurrencyCode(sumNonDeduct, ABaseCurrency));

            if ((ADonations.Rows.Count == 1) && msg.Contains("#DONATIONDATE"))
            {
                // this is a receipt for just one gift
                msg = msg.Replace("#DONATIONDATE", Convert.ToDateTime(ADonations.Rows[0]["DateEntered"]).ToString("dd.MM.yyyy"));
            }

            // TODO allow other currencies. use a_currency table, and base currency
            msg = msg.Replace("#TOTALAMOUNTINWORDS", NumberToWords.AmountToWords(sum, "Euro", "Cent")).
                  Replace("#TOTALTAXDEDUCTAMOUNTINWORDS", NumberToWords.AmountToWords(sumTaxDeduct, "Euro", "Cent")).
                  Replace("#TOTALTAXNONDEDUCTAMOUNTINWORDS", NumberToWords.AmountToWords(sumNonDeduct, "Euro", "Cent"));

            return(msg.Replace("#ROWTEMPLATE", rowTexts));
        }
Exemple #4
0
        public void Test_Dollar_Separators_Valid()
        {
            Assert.AreEqual("ONE THOUSAND DOLLARS", NumberToWords.Wordify("1,000"));

            Assert.AreEqual("ONE MILLION DOLLARS", NumberToWords.Wordify("1 000 000"));
        }
        public void Run_WhenCalledWithNumberNotOutOfRange_ReturnsValidResult(decimal number, string expected)
        {
            var actual = NumberToWords.Run(number);

            Assert.Equal(expected, actual);
        }
Exemple #6
0
        public string GetInvoiceHtmlString(SalesInvoiceModel salesInvoiceModel)
        {
            var     sb       = new StringBuilder();
            decimal total    = (decimal)salesInvoiceModel.SalesInvoiceDetails.Count;
            int     totalRow = (int)total;
            decimal rowCount = total / 15;

            int noOfPages = (int)Math.Ceiling(rowCount);
            int limit = 15, start = 0;
            int logoTop = 35;

            //HTML
            sb.Append(@"<html><body style='font-family:Helvetica; font-size:16px;'>");

            for (int j = 1; j <= noOfPages; j++)
            {
                //Header Start
                string HtmlHeader = @"<table style='border:0px solid black;' width='1280' Height='200'>
                            <tr style='border:0px solid black;' align='center' Height='50'>
	                        <td style='font-size:20px; border:0px solid black; vertical-align:top;padding-top:15px;'>
                            <div style='text-align:center; padding-top:20px; position: rela1tive;'>
                            <img src='http://shayona.rocketpos.uk/img/clientlogo.jpg' width='350' height='140' style='position: absolute; left: 15px; top: " + logoTop + @"px' >" +
                                    @"<div style='font-size:28px; font-weigth:bold'><b>" + salesInvoiceModel.InvoiceHeader + @"</b></div>
                            <div style='font-size:22px;'>" + salesInvoiceModel.OutletAddress1 +
                                    "</br>" + salesInvoiceModel.OutletAddress2 +
                                    "</br>" + salesInvoiceModel.OutletEmail +
                                    "</br>" + salesInvoiceModel.OutletPhone +
                                    "</div></div></div>" +
                                    "</td></tr></table>";

                sb.Append(HtmlHeader);

                //Invoice Title
                sb.Append(@"<table style='border-right:1px solid;border-left:1px solid;border-top:1px solid' width='1280' Height='35'>
                            <tr  align='center'>
                            <td style='font-size:22px;'><b>INVOICE <b></td>
                            </tr>
                            </table>");

                //Buyer name & two empty column
                sb.Append(@"<table style='font-size:21px;border-right:1px solid;border-left:1px solid;border-top:1px solid' width='1280' Height='170'>
                            <tr>
                            <td style='padding-left:5px; border-right:1px solid;' width='398'> <b> Buyer</b></br>  " + salesInvoiceModel.CustomerName + "</br> " + salesInvoiceModel.CustomerAddress1 + "</br> " + salesInvoiceModel.CustomerAddress2 + "</br> " + salesInvoiceModel.CustomerEmail + @"</br></br></td>
                            <td style='padding-left:5px;border-right:1px solid;' width='397'></td>
                            <td width='400'></td>
                            </tr>
                            </table>");

                //Invoice no, Order No., Invoice Date, Page No
                sb.Append(@"<table style='font-size:20px;border-right:1px solid;border-left:1px solid;border-top:1px solid' width='1280' Height='50'>
                            <tr>
                                <td style='padding-left:5px; border-right:1px solid;' width='400'><b>Invoice No.</b></br> " + salesInvoiceModel.ReferenceNo + @"</td>");

                if (salesInvoiceModel.DeliveryNoteNumber != null)
                {
                    if (salesInvoiceModel.DeliveryNoteNumber != "")
                    {
                        sb.Append(@"<td style='padding-left:5px; border-right:1px solid;' width='400'><b>Order No. </b></br> " + salesInvoiceModel.DeliveryNoteNumber + @"</td>");
                    }
                    else
                    {
                        sb.Append(@"<td style='padding-left:5px; border-right:1px solid;' width='400'></td>");
                    }
                }
                else
                {
                    sb.Append(@"<td style='padding-left:5px; border-right:1px solid;' width='400'></td>");
                }

                sb.Append(@"<td width='400' style='padding-left:5px;'><b>Invoice Date </b></br><div style='float:left'>" + salesInvoiceModel.SalesInvoiceDate.ToShortDateString() + @"</div><div style='float:right'>" +
                          @"Page " + j.ToString() + @" of " + noOfPages.ToString() + @"</div>
                        </tr> 
                        </table>");

                //Item List
                sb.Append(@"<table style='font-size:20px;border-right:1px solid;border-left:1px solid;border-top:1px solid' width='1280'>
                            <tr Height='42' >
                                    <td style='padding-left:5px;;width:1.5%;text-align: right; padding-right:15px'><b>No</b></td>
                                    <td style='width:66.5%;text-align: left; padding-right:15px'><b>Description of Goods</b></td>
                                    <td style='width:7%;text-align: right; padding-right:40px'><b>Quantity</b></td>
                                    <td style='width:7%;text-align: left; padding-right:20px'><b>UoM</b></td>
                                    <td style='width:8%;text-align: right; padding-right:30px'><b>Rate</b></td>
                                    <td style='width:10%;text-align: right; padding-right:15px'><b>Amount</b></td>
                            </tr>");

                if (noOfPages == 1)
                {
                    limit = 15;
                    if (totalRow < limit)
                    {
                        limit = totalRow;
                    }
                }
                else
                {
                    limit = (j * 15);
                    if (totalRow < limit)
                    {
                        limit = totalRow - ((j - 1) * 15);
                    }

                    if (limit > 15)
                    {
                        limit = 15;
                    }
                }

                int i = 1;
                for (; i <= limit; i++)
                {
                    var item = salesInvoiceModel.SalesInvoiceDetails[start];
                    start++;
                    sb.AppendFormat(@"<tr Height='42'>
                                    <td style='padding-left:5px; width:1.5%;text-align: right; padding-right:15px'>{0}</td>
                                    <td style='width:66.5%;text-align: left; padding-right:15px'>{1}</td>
                                    <td style='width:7%;text-align: right; padding-right:40px'>{2}</td>
                                    <td style='width:7%;text-align: left; padding-right:20px'>{3}</td>
                                    <td style='width:8%;text-align: right; padding-right:30px'>{4}</td>
                                    <td style='width:10%;text-align: right; padding-right:15px'>{5}</td>
                                 </tr>",
                                    item.SrNumber, item.FoodMenuName, item.InvoiceQty.ToString("0.00"), item.UnitName, item.UnitPrice, item.GrossAmount);
                }

                for (; i <= 15; i++)
                {
                    sb.AppendFormat(@"<tr Height='42'>
                                    <td style='padding-left:5px; width:1.5%;text-align: right; padding-right:5px'></td>
                                    <td style='width:58.5%;text-align: left; padding-right:5px'></td>
                                    <td style='width:10%;text-align: right; padding-right:20px'></td>
                                    <td style='width:12%;text-align: left; padding-right:20px'></td>
                                    <td style='width:8%;text-align: right; padding-right:20px'></td>
                                    <td style='width:10%;text-align: right; padding-right:15px'></td>
                                 </tr>");
                }

                //emplty row
                sb.AppendFormat(@"<table style='border-right:1px solid;border-left:1px solid;border-top:0px' Height='42' width = '1280'><tr></tr></table>");

                string strAmountWord = "", VatableAmount = "", NonVatableAmount = "", TaxAmount = "", TotalAmount = "";

                if (j == noOfPages)
                {
                    strAmountWord = NumberToWords.ConvertAmount((double)salesInvoiceModel.TotalAmount) + " KENYAN SHILLINGS";

                    if (salesInvoiceModel.CustomerTaxInclusive)
                    {
                        VatableAmount    = salesInvoiceModel.VatableAmount.ToString("0.00");
                        NonVatableAmount = salesInvoiceModel.NonVatableAmount.ToString("0.00");
                        TaxAmount        = salesInvoiceModel.TaxAmount.ToString("0.00");
                    }
                    TotalAmount = salesInvoiceModel.TotalAmount.ToString("0.00");
                }

                //Reamrks & Totals
                sb.Append(@"<table  style='font-size:22px;border-right:1px solid;border-left:1px solid;border-top:1px solid' width = '1280' Height = '119' >
                        <tr  Height='40'>
                            <td rowspan=2 style='padding-left:5px; width:76%; vertical-align:top; text-align : left;font-size:12px'>
                                    <b>Remarks : </b></br>" + salesInvoiceModel.Notes + @"</td>
                            <td style='width:12%;  text-align:right; border-left:1px solid; border-right:1px solid; border-bottom:1px solid; padding-right:15px;font-size:20px'><b>Vatable:</b></td >
                            <td style='width:12%;  text-align:right;; border-bottom:1px solid; padding-right:15px;font-size:20px'><b>" + VatableAmount + @"</b></td>
                        </tr>
                        <tr Height='40'>
                            <td style='width:12%;  text-align:right; border-right:1px solid; border-left:1px solid; border-bottom:1px solid; padding-right:15px;font-size:20px'><b>NON-VAT:</b></td>
                            <td style='width:12%;  text-align:right;; border-bottom:1px solid; padding-right:15px;font-size:20px'><b>" + NonVatableAmount + @"</b></td>
                        </tr>
                        <tr Height='40'>
                            <td rowspan=2><div style='vertical-align:bottom;text-align:left;padding-left:5px; '>" + strAmountWord.ToString().ToUpper() + @"</div></td>
                            <td style='width:12%;  text-align:right; border-right:1px solid; border-left:1px solid; border-bottom:1px solid; padding-right:15px;font-size:20px'><b>VAT Total:</b></td>
                            <td style='width:12%;  text-align:right; border-bottom:1px solid; padding-right:15px;font-size:20px'><b>" + TaxAmount + @"</b></td>
                        </tr>
                        <tr Height='40' style='border:0px'>
                            <td style='width:12%;  text-align:right; border-left:1px solid; border-right:1px solid;; padding-right:15px;font-size:20px'><b>Total</b></td>
                            <td style='width:12%;  text-align:right; padding-right:15px;font-size:20px'><b>" + TotalAmount + @"</b></td>
                        </tr>
                    </table>");

                //Terms and condition
                sb.Append(@"<table style='font-size:20px;border:1px solid; ' width = '1280' Height = '220'>
                            <tr Height='50'>
                                <td colspan='7' style='padding-left:5px; vertical-align:top;'><b>Terms and Conditions: </b>");

                string   strInvoiceTerms = LoginInfo.InvoiceTerms;
                string[] strSplit        = strInvoiceTerms.Split('\n');

                for (i = 0; i < strSplit.Length; i++)
                {
                    sb.Append(@"</br>" + strSplit[i]);
                }

                sb.Append(@"</td>
                        </tr>
                        </table>");

                //emplty row
                sb.AppendFormat(@"<table style='border:0px solid;' Height='40'></table>");

                //logo at header settings
                logoTop = logoTop + 1654 + (j * 14);
            }

            //end of body and html
            sb.Append(@"</body></html>");

            return(sb.ToString());
        }
Exemple #7
0
        private static void IntegerToEnglishWords()
        {
            var c = new NumberToWords();

            c.Run();
        }
Exemple #8
0
 public void Test_Cent_Character_Invalid()
 {
     NumberToWords.Wordify(".g");
 }
Exemple #9
0
 public void Test_Cent_Separator_Invalid_2()
 {
     NumberToWords.Wordify(".,");
 }
Exemple #10
0
 public void Test_Dollar_Length_Invalid()
 {
     NumberToWords.Wordify("1234000000000000");
 }
Exemple #11
0
 public void Test_Cent_Length_Invalid()
 {
     NumberToWords.Wordify(".123");
 }
Exemple #12
0
 public void Test_Dollar_Length_Valid()
 {
     Assert.AreEqual("ONE HUNDRED AND TWENTY-THREE TRILLION DOLLARS",
                     NumberToWords.Wordify("123000000000000"));
 }
Exemple #13
0
 public void Test_Dollar_Characters_Invalid()
 {
     NumberToWords.Wordify("5c");
 }
 public void CanConvertNumbersUpToOneMillionToWordsCorrectly(uint inputNumber, string outputText)
 {
     Assert.Equal(outputText, NumberToWords.ConvertWholeNumberToWords(inputNumber));
 }
 public void Convert_Returns_Expected_String_Successfully(long number, string expected)
 {
     Assert.Equal(expected, NumberToWords.Convert(number));
 }
Exemple #16
0
 public void Test_Null()
 {
     NumberToWords.Wordify(null);
 }
Exemple #17
0
        public override void Setup()
        {
            var frame = new FrameView("Dialog Options")
            {
                X      = Pos.Center(),
                Y      = 1,
                Width  = Dim.Percent(75),
                Height = 10
            };

            Win.Add(frame);

            var label = new Label("width:")
            {
                X             = 0,
                Y             = 0,
                Width         = 15,
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };

            frame.Add(label);
            var widthEdit = new TextField("0")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = 5,
                Height = 1
            };

            frame.Add(widthEdit);

            label = new Label("height:")
            {
                X             = 0,
                Y             = Pos.Bottom(label),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var heightEdit = new TextField("0")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = 5,
                Height = 1
            };

            frame.Add(heightEdit);

            frame.Add(new Label("If height & width are both 0,")
            {
                X = Pos.Right(widthEdit) + 2,
                Y = Pos.Top(widthEdit),
            });
            frame.Add(new Label("the Dialog will size to 80% of container.")
            {
                X = Pos.Right(heightEdit) + 2,
                Y = Pos.Top(heightEdit),
            });

            label = new Label("Title:")
            {
                X             = 0,
                Y             = Pos.Bottom(label),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var titleEdit = new TextField("Title")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = Dim.Fill(),
                Height = 1
            };

            frame.Add(titleEdit);

            label = new Label("Num Buttons:")
            {
                X             = 0,
                Y             = Pos.Bottom(titleEdit),
                Width         = Dim.Width(label),
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            frame.Add(label);
            var numButtonsEdit = new TextField("3")
            {
                X      = Pos.Right(label) + 1,
                Y      = Pos.Top(label),
                Width  = 5,
                Height = 1
            };

            frame.Add(numButtonsEdit);

            void Top_Loaded()
            {
                frame.Height = Dim.Height(widthEdit) + Dim.Height(heightEdit) + Dim.Height(titleEdit)
                               + Dim.Height(numButtonsEdit) + 2;
                Top.Loaded -= Top_Loaded;
            }

            Top.Loaded += Top_Loaded;

            label = new Label("Button Pressed:")
            {
                X             = Pos.Center(),
                Y             = Pos.Bottom(frame) + 4,
                Height        = 1,
                TextAlignment = Terminal.Gui.TextAlignment.Right,
            };
            Win.Add(label);
            var buttonPressedLabel = new Label(" ")
            {
                X           = Pos.Center(),
                Y           = Pos.Bottom(frame) + 5,
                Width       = 25,
                Height      = 1,
                ColorScheme = Colors.Error,
            };

            //var btnText = new [] { "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
            var showDialogButton = new Button("Show Dialog")
            {
                X         = Pos.Center(),
                Y         = Pos.Bottom(frame) + 2,
                IsDefault = true,
            };

            showDialogButton.Clicked += () => {
                try {
                    int width      = int.Parse(widthEdit.Text.ToString());
                    int height     = int.Parse(heightEdit.Text.ToString());
                    int numButtons = int.Parse(numButtonsEdit.Text.ToString());

                    var buttons = new List <Button> ();
                    var clicked = -1;
                    for (int i = 0; i < numButtons; i++)
                    {
                        var buttonId = i;
                        //var button = new Button (btnText [buttonId % 10],
                        //	is_default: buttonId == 0);
                        var button = new Button(NumberToWords.Convert(buttonId),
                                                is_default: buttonId == 0);
                        button.Clicked += () => {
                            clicked = buttonId;
                            Application.RequestStop();
                        };
                        buttons.Add(button);
                    }

                    // This tests dynamically adding buttons; ensuring the dialog resizes if needed and
                    // the buttons are laid out correctly
                    var dialog = new Dialog(titleEdit.Text, width, height,
                                            buttons.ToArray());
                    var add = new Button("Add a button")
                    {
                        X = Pos.Center(),
                        Y = Pos.Center()
                    };
                    add.Clicked += () => {
                        var buttonId = buttons.Count;
                        //var button = new Button (btnText [buttonId % 10],
                        //	is_default: buttonId == 0);
                        var button = new Button(NumberToWords.Convert(buttonId),
                                                is_default: buttonId == 0);
                        button.Clicked += () => {
                            clicked = buttonId;
                            Application.RequestStop();
                        };
                        buttons.Add(button);
                        dialog.AddButton(button);
                        button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1;
                    };
                    dialog.Add(add);

                    Application.Run(dialog);
                    buttonPressedLabel.Text = $"{clicked}";
                } catch (FormatException) {
                    buttonPressedLabel.Text = "Invalid Options";
                }
            };
            Win.Add(showDialogButton);

            Win.Add(buttonPressedLabel);
        }
Exemple #18
0
 public void Test_Dollar_LeadingZeroes()
 {
     Assert.AreEqual("ONE HUNDRED AND TWENTY-THREE DOLLARS",
                     NumberToWords.Wordify("000123"));
 }
Exemple #19
0
        private void RecieptPrint_Load(object sender, EventArgs e)
        {
            int CBId = new DAO().getLastCBId();

            DataTable ds = new DAO().getRecieptReportData(CBId);


            foreach (DataRow row in ds.Rows)
            {
                //crPaymentVoucher1.SetDataSource(lstInvoice);

                string InvoiceNo = "";
                string To        = row[0].ToString();

                try
                {
                    InvoiceNo = row[8].ToString();
                }
                catch (Exception ex)
                {
                }
                DateTime Date      = DateTime.Parse(row[2].ToString());
                string   VoucherNo = row[10].ToString();

                //string BrokerAmount = row["BrokeryAmount"].ToString();

                //string BrokerName = row["BrokerName"].ToString();
                string  Cash     = " ";
                decimal Amount   = 0;
                string  ChequeNo = "";
                string  BankCode = "";
                string  Expense  = row[13].ToString();
                if (Expense == "Purchase")
                {
                    Expense = "";
                }
                else
                {
                    To = "";
                }


                string AmountType = row["AmountType"].ToString();
                if (AmountType == "Cash")
                {
                    Cash = "\u221A";
                }
                else
                {
                    ChequeNo = row[11].ToString();
                    BankCode = row[12].ToString();
                }

                Amount = decimal.Parse(row[7].ToString());
                string SumOf = NumberToWords.ConvertToWords(Amount.ToString());

                string Narrative = row[4].ToString();


                crPaymentVoucher1.SetParameterValue("To", To);
                crPaymentVoucher1.SetParameterValue("InvoiceNo", InvoiceNo);
                crPaymentVoucher1.SetParameterValue("Date", Date.Date);
                crPaymentVoucher1.SetParameterValue("Cash", Cash);
                crPaymentVoucher1.SetParameterValue("Amount", Amount);
                crPaymentVoucher1.SetParameterValue("PVNo", VoucherNo);
                crPaymentVoucher1.SetParameterValue("SumOf", SumOf);
                crPaymentVoucher1.SetParameterValue("Cheque", ChequeNo);
                crPaymentVoucher1.SetParameterValue("BankCode", BankCode);
                crPaymentVoucher1.SetParameterValue("Narrative", Narrative);
                crPaymentVoucher1.SetParameterValue("Expense", Expense);
            }


            crystalReportViewer1.ReportSource = crPaymentVoucher1;
        }
Exemple #20
0
        public ActionResult InvoicePrintold(int id)
        {
            int           branchid   = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int           companyid  = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            NumberToWords _numtoword = new NumberToWords();

            ViewBag.Customer = db.CustomerMasters.ToList();
            ViewBag.Movement = db.CourierMovements.ToList();
            var _invoice = db.CustomerInvoices.Find(id);
            CustomerInvoiceVM _custinvoice = new CustomerInvoiceVM();

            _custinvoice.CustomerInvoiceID = _invoice.CustomerInvoiceID;
            _custinvoice.InvoiceDate       = _invoice.InvoiceDate;
            _custinvoice.CustomerInvoiceNo = _invoice.CustomerInvoiceNo;
            _custinvoice.CustomerID        = _invoice.CustomerID;
            var _cust = db.CustomerMasters.Find(_invoice.CustomerID);

            _custinvoice.CustomerName        = _cust.CustomerName;
            _custinvoice.CustomerCountryName = _cust.CountryName;
            _custinvoice.CustomerCityName    = _cust.CityName;
            _custinvoice.CustomerPhoneNo     = _cust.Phone;
            _custinvoice.CustomerCode        = _cust.CustomerCode;
            _custinvoice.CustomerTRNNo       = _cust.VATTRN;
            _custinvoice.InvoiceTotal        = _invoice.InvoiceTotal;
            //_custinvoice.invoiceFooter = (from c in db.GeneralSetups join d in db.GeneralSetupTypes on c.SetupID equals d.ID where d.TypeName == "Invoicefooter" select c.Text1).FirstOrDefault();
            _custinvoice.generalSetup = (from c in db.GeneralSetups join d in db.GeneralSetupTypes on c.SetupID equals d.ID where d.TypeName == "InvoiceFooter" && c.BranchId == branchid select c).FirstOrDefault();
            var comp = db.AcCompanies.Find(companyid);

            _custinvoice.CurrencyName = db.CurrencyMasters.Find(comp.CurrencyID).Symbol;
            if (comp.LogoFileName == "" || comp.LogoFileName == null)
            {
                ViewBag.LogoPath = "/UploadFiles/" + "defaultlogo.png";
            }
            else
            {
                ViewBag.LogoPath = "/UploadFiles/" + comp.LogoFileName;
            }
            string monetaryunit = Session["MonetaryUnit"].ToString();

            _custinvoice.InvoiceTotalInWords = NumberToWords.ConvertAmount(Convert.ToDouble(_custinvoice.InvoiceTotal), monetaryunit);

            List <CustomerInvoiceDetailVM> _details = new List <CustomerInvoiceDetailVM>();

            _details = RevenueDAO.GenerateInvoice(DateTime.Now, DateTime.Now, _invoice.CustomerID, 0, _invoice.CustomerInvoiceID);

            int _index = 0;

            foreach (var item in _details)
            {
                _details[_index].AWBChecked = true;

                _custinvoice.TotalCharges += _details[_index].TotalCharges;
                _index++;
            }

            _custinvoice.CustomerInvoiceDetailsVM = _details;

            _custinvoice.CustomerInvoiceDetailsVM = _details;

            Session["InvoiceListing"] = _details;
            return(View(_custinvoice));
        }