Exemplo n.º 1
0
        public string getShipperReportHTML(List <ShipperReport> data,
                                           int shipperID,
                                           ref decimal totalMoneyCollection,
                                           ref int totalCODOrder,
                                           ref decimal totalMoneyReceived)
        {
            var     html                  = new StringBuilder();
            var     index                 = 0;
            decimal totalPayment          = 0;
            decimal totalRequestCOD       = 0;
            decimal moneyCollection       = 0;
            decimal totalPrice            = 0;
            int     totalOrderCOD         = 0;
            int     totalOrderShippingFee = 0;
            string  shipperName           = ShipperController.getShipperNameByID(shipperID);

            html.AppendLine("<h1>NHÂN VIÊN GIAO</h1>");

            html.AppendLine("<div class='delivery shipper-list'>");
            html.AppendLine("    <div class='all'>");
            html.AppendLine("        <div class='body'>");
            html.AppendLine("            <div class='table-2'>");
            html.AppendLine("               <div class='info'>");
            html.AppendLine(String.Format(" <p>Ngày giao: {0}</p>", string.Format("{0:dd/MM HH:mm}", DateTime.Now)));
            html.AppendLine(String.Format(" <p>Người giao: {0}</p>", shipperName));
            html.AppendLine("               </div>");
            html.AppendLine("                <table>");
            html.AppendLine("                    <colgroup>");
            html.AppendLine("                        <col />");
            html.AppendLine("                        <col />");
            html.AppendLine("                        <col />");
            html.AppendLine("                        <col />");
            html.AppendLine("                    </colgroup>");
            html.AppendLine("                    <thead>");
            html.AppendLine("                        <tr>");
            html.AppendLine("                            <th>#</th>");
            html.AppendLine("                            <th>Số tiền</th>");
            html.AppendLine("                            <th>Đã thu</th>");
            html.AppendLine("                            <th>Phí</th>");
            html.AppendLine("                        </tr>");
            html.AppendLine("                    </thead>");
            html.AppendLine("                    <tbody>");

            foreach (var item in data)
            {
                index           += 1;
                totalPayment    += item.Payment >= 0 ? item.Payment : 0;
                moneyCollection += item.MoneyCollection >= 0 ? item.MoneyCollection : 0;
                totalPrice      += item.Price >= 0 ? item.Price : 0;
                html.AppendLine("                        <tr>");
                html.AppendLine(String.Format("                            <td rowspan='2' style='text-align: center;'>{0:#,###}</td>", index));
                html.AppendLine(String.Format("                            <td colspan='3' style='border-bottom: 0;'><strong>{0}</strong> - {1}</td>", item.CustomerName.ToTitleCase(), item.OrderID));
                html.AppendLine("                        </tr>");

                html.AppendLine("                        <tr>");
                if (item.MoneyCollection > 0)
                {
                    totalRequestCOD += item.Payment >= 0 ? item.Payment : 0;
                    if (item.Payment >= 0)
                    {
                        html.AppendLine(String.Format("                            <td style='border-top: 0; font-weight: bold;'>{0:#,###}</td>", item.Payment));
                    }
                    else
                    {
                        html.AppendLine(String.Format("                            <td style='border-top: 0; font-weight: bold;'>0({0:#,###})</td>", item.Payment));
                    }
                    totalOrderCOD++;
                    html.AppendLine(String.Format("                            <td style='border-top: 0;'>{0:#,###}</td>", item.MoneyCollection));
                }
                else
                {
                    if (item.Payment > 0)
                    {
                        html.AppendLine(String.Format("                            <td style='border-top: 0;'>{0:#,###}</td>", item.Payment));
                    }
                    else
                    {
                        html.AppendLine(String.Format("                            <td style='border-top: 0;'>0({0:#,###})</td>", item.Payment));
                    }
                    if (item.MoneyCollection < 0)
                    {
                        html.AppendLine(String.Format("                            <td style='border-top: 0;'>0({0:#,###})</td>", item.MoneyCollection));
                    }
                    else
                    {
                        html.AppendLine(String.Format("                            <td style='border-top: 0;'>-</td>"));
                    }
                }

                if (item.Price > 0)
                {
                    totalOrderShippingFee++;
                    html.AppendLine(String.Format("                            <td style='border-top: 0;'>{0:#,###}</td>", item.Price));
                }
                else if (item.Price < 0)
                {
                    html.AppendLine(String.Format("                            <td style='border-top: 0;'>0({0:#,###})</td>", item.Price));
                }
                else
                {
                    html.AppendLine(String.Format("                            <td style='border-top: 0;'>-</td>"));
                }
                html.AppendLine("                        </tr>");
            }
            html.AppendLine("                        <tr>");
            html.AppendLine("                            <td colspan='3' style='text-align: right'>Tổng số đơn</td>");
            html.AppendLine(String.Format("                            <td style='text-align: right'>{0:#,###}&nbsp;&nbsp;&nbsp;</td>", data.Count));
            html.AppendLine("                        </tr>");
            html.AppendLine("                        <tr>");
            html.AppendLine("                            <td colspan='3' style='text-align: right'>Tổng tiền đơn hàng</td>");
            html.AppendLine(String.Format("                            <td style='text-align: right'>{0:#,###}&nbsp;</td>", totalPayment));
            html.AppendLine("                        </tr>");
            if (moneyCollection > 0)
            {
                html.AppendLine("                        <tr>");
                html.AppendLine("                            <td colspan='3' style='text-align: right'>Số đơn thu hộ</td>");
                html.AppendLine(String.Format("                            <td style='text-align: right'>{0}&nbsp;&nbsp;&nbsp;</td>", totalOrderCOD));
                html.AppendLine("                        </tr>");
                html.AppendLine("                        <tr>");
                html.AppendLine("                            <td colspan='3' style='text-align: right'>Tổng tiền thu hộ</td>");
                html.AppendLine(String.Format("                            <td style='text-align: right'>{0:#,###}&nbsp;</td>", totalRequestCOD));
                html.AppendLine("                        </tr>");
                html.AppendLine("                        <tr>");
                html.AppendLine("                            <td colspan='3' style='text-align: right'>Tổng tiền đã thu</td>");
                html.AppendLine(String.Format("                            <td style='text-align: right'>{0:#,###}&nbsp;</td>", moneyCollection));
                html.AppendLine("                        </tr>");

                // cộng dồn
                totalCODOrder        += totalOrderCOD;
                totalMoneyCollection += totalRequestCOD;
                totalMoneyReceived   += moneyCollection;
            }
            if (totalPrice > 0)
            {
                html.AppendLine("                        <tr>");
                html.AppendLine("                            <td colspan='3'  style='text-align: right'>Số đơn có phí</td>");
                html.AppendLine(String.Format("                            <td style='text-align: right'>{0:#,###}&nbsp;&nbsp;&nbsp;</td>", totalOrderShippingFee));
                html.AppendLine("                        </tr>");
                html.AppendLine("                        <tr>");
                html.AppendLine("                            <td colspan='3'  style='text-align: right'>Tổng phí</td>");
                html.AppendLine(String.Format("                            <td style='text-align: right'>{0:#,###}&nbsp;</td>", totalPrice));
                html.AppendLine("                        </tr>");
            }
            html.AppendLine("                    </tbody>");
            html.AppendLine("                </table>");
            html.AppendLine("            </div>");
            html.AppendLine("        </div>");
            html.AppendLine("    </div>");
            html.AppendLine("</div>");

            return(html.ToString());
        }
Exemplo n.º 2
0
        public string getTransportReportHTML(TransportReport data,
                                             int shipperID,
                                             int deliveryTimes,
                                             ref decimal totalMoneyCollection,
                                             ref int totalCODOrder,
                                             ref decimal totalMoneyReceived)
        {
            var    html            = new StringBuilder();
            int    index           = 0;
            double totalQuantity   = 0;
            double totalCollection = 0;
            string shipperName     = ShipperController.getShipperNameByID(shipperID);

            html.AppendLine("<h1>GỬI XE</h1>");

            html.AppendLine("<div class='delivery'>");
            html.AppendLine("    <div class='all'>");
            html.AppendLine("        <div class='body'>");
            html.AppendLine("            <div class='table-2'>");
            html.AppendLine("               <div class='info'>");
            html.AppendLine(String.Format(" <p>Ngày giao: {0}</p>", string.Format("{0:dd/MM HH:mm}", DateTime.Now)));
            html.AppendLine(String.Format(" <p>Người giao: {0}</p>", shipperName));
            html.AppendLine(String.Format(" <p>Đợt giao: Đợt {0}</p>", deliveryTimes));
            html.AppendLine("               </div>");
            html.AppendLine("                <table>");
            html.AppendLine("                    <colgroup>");
            html.AppendLine("                        <col />");
            html.AppendLine("                        <col />");
            html.AppendLine("                        <col />");
            html.AppendLine("                    </colgroup>");
            html.AppendLine("                    <thead>");
            html.AppendLine("                        <th>Nhà xe</th>");
            html.AppendLine("                        <th>SL</th>");
            html.AppendLine("                        <th>Thu hộ</th>");
            html.AppendLine("                    </thead>");
            html.AppendLine("                    <tbody>");
            foreach (var item in data.Transports)
            {
                index           += 1;
                totalQuantity   += item.Quantity;
                totalCollection += item.Collection >= 0 ? item.Collection : 0;

                html.AppendLine("                        <tr>");
                html.AppendLine(String.Format("                            <td><strong>{0}</strong></td>", item.TransportName.ToLower().ToTitleCase()));
                html.AppendLine(String.Format("                            <td>{0:#,###}</td>", item.Quantity));
                if (item.Collection >= 0)
                {
                    html.AppendLine(String.Format("                            <td>{0:#,###}</td>", item.Collection));
                }
                else
                {
                    html.AppendLine(String.Format("                            <td>0({0:#,###})</td>", item.Collection));
                }
                html.AppendLine("                        </tr>");
            }
            html.AppendLine("                        <tr>");
            html.AppendLine("                            <td colspan='1' style='text-align: right'>Tổng số đơn</td>");
            html.AppendLine(String.Format("                            <td colspan='2'>{0:#,###}&nbsp;&nbsp;&nbsp;</td>", totalQuantity));
            html.AppendLine("                        </tr>");
            if (totalCollection > 0)
            {
                html.AppendLine("                        <tr>");
                html.AppendLine("                            <td colspan='1'  style='text-align: right'>Số đơn thu hộ</td>");
                html.AppendLine(String.Format("                            <td colspan='2'>{0:#,###}&nbsp;&nbsp;&nbsp;</td>", totalCollection));
                html.AppendLine("                        </tr>");
            }
            html.AppendLine("                    </tbody>");
            html.AppendLine("                </table>");
            html.AppendLine("            </div>");
            html.AppendLine("        </div>");
            html.AppendLine("    </div>");
            html.AppendLine("</div>");

            // Thông tin bổ xung cho giao hàng thu hộ
            if (data.Collections.Count > 0)
            {
                totalCODOrder += data.Collections.Count;
                html.AppendLine("<h1>Danh sách đơn thu hộ</h1>");
                html.AppendLine("<div class='delivery cod-list'>");
                html.AppendLine("    <div class='all'>");
                html.AppendLine("        <div class='body'>");
                html.AppendLine("            <div class='table-2'>");
                html.AppendLine("                <table>");
                html.AppendLine("                    <colgroup>");
                html.AppendLine("                        <col />");
                html.AppendLine("                        <col />");
                html.AppendLine("                        <col />");
                html.AppendLine("                    </colgroup>");
                html.AppendLine("                    <thead>");
                html.AppendLine("                        <th>Nhà xe</th>");
                html.AppendLine("                        <th>Thu hộ</th>");
                html.AppendLine("                        <th>Đã thu</th>");
                html.AppendLine("                    </thead>");
                html.AppendLine("                    <tbody>");
                foreach (var item in data.Collections)
                {
                    html.AppendLine("                        <tr>");
                    html.AppendLine(String.Format("                            <td colspan='3'><strong>{0}</strong> - {1}</td>", item.OrderID, item.CustomerName.ToTitleCase()));
                    html.AppendLine("                        </tr>");
                    html.AppendLine("                        <tr>");
                    html.AppendLine(String.Format("                            <td>{0}</td>", item.TransportName.ToLower().ToTitleCase()));
                    if (item.Collection >= 0)
                    {
                        html.AppendLine(String.Format("                            <td>{0:#,###}</td>", item.Collection));
                    }
                    else
                    {
                        html.AppendLine(String.Format("                            <td>0({0:#,###})</td>", item.Collection));
                    }
                    if (item.MoneyReceived >= 0)
                    {
                        html.AppendLine(String.Format("                            <td>{0:#,###}</td>", item.MoneyReceived));
                    }
                    else
                    {
                        html.AppendLine(String.Format("                            <td>0({0:#,###})</td>", item.MoneyReceived));
                    }
                    html.AppendLine("                        </tr>");
                }
                if (totalCollection > 0)
                {
                    var moneyCollection = data.Collections.Sum(x => x.Collection >= 0 ? x.Collection : 0);
                    var moneyReceived   = data.Collections.Sum(x => x.MoneyReceived >= 0 ? x.MoneyReceived : 0);

                    html.AppendLine("                        <tr>");
                    html.AppendLine("                            <td colspan='2' style='text-align: right'>Tổng tiền thu hộ</td>");
                    html.AppendLine(String.Format("                            <td>{0:#,###}&nbsp;</td>", moneyCollection));
                    html.AppendLine("                        </tr>");
                    html.AppendLine("                        <tr>");
                    html.AppendLine("                            <td colspan='2' style='text-align: right'>Tổng tiền đã thu</td>");
                    html.AppendLine(String.Format("                            <td>{0:#,###}&nbsp;</td>", moneyReceived));
                    html.AppendLine("                        </tr>");

                    // cộng dồn
                    totalMoneyCollection += moneyCollection;
                    totalMoneyReceived   += moneyReceived;
                }
                html.AppendLine("                    </tbody>");
                html.AppendLine("                </table>");
                html.AppendLine("            </div>");
                html.AppendLine("        </div>");
                html.AppendLine("    </div>");
                html.AppendLine("</div>");
            }

            return(html.ToString());
        }