Пример #1
0
 private void OutputDocPdf(ORDERS Order)
 {
     using (var memoryF = BL.PDF.PdfGenerator.DocPDF(Order))
     {
         Response.Clear();
         Response.ContentType = "application/pdf";
         Response.OutputStream.Write(memoryF.GetBuffer(), 0, memoryF.GetBuffer().Length);
         Response.OutputStream.Close();
         HttpContext.Current.ApplicationInstance.CompleteRequest();
     }
 }
Пример #2
0
        public List<ORDERS> Search(ORDERS Order, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.ORDERS.Include("CUSTOMER").Include("D_ORDER_STATUS").AsQueryable();

            if (Order != null)
            {
                if (!String.IsNullOrWhiteSpace(Order.CustomerName))
                {
                    result = result.Where(o => (o.CUSTOMER.Name + " " + o.CUSTOMER.Surname).Contains(Order.CustomerName));
                }

                if (Order.ID != 0)
                {
                    result = result.Where(o => o.ID == Order.ID);
                }

                if (Order.SearchStartDate.HasValue)
                {
                    result = result.Where(o => o.DateCreated >= Order.SearchStartDate.Value);
                }

                if (Order.SearchEndDate.HasValue)
                {
                    result = result.Where(o => o.DateCreated <= Order.SearchEndDate.Value);
                }

                if (Order.Status.HasValue)
                {
                    result = result.Where(o => o.Status == Order.Status.Value);
                }
            }

            TotalRecords = result.Count();

            if (!String.IsNullOrEmpty(OrderExp) && OrderExp.Equals("CustomerName"))
            {
                if (SortDirection == SortDirection.Ascending)
                    result = result.OrderBy(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
                else
                    result = result.OrderByDescending(c => c.CUSTOMER.Name).ThenBy(c => c.CUSTOMER.Surname);
            }
            else
            {
                GenericSorterCaller<ORDERS> sorter = new GenericSorterCaller<ORDERS>();
                result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);
            }
            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
Пример #3
0
        private void FixupORDERS(ORDERS previousValue)
        {
            if (previousValue != null && ReferenceEquals(previousValue.PAYMENT, this))
            {
                previousValue.PAYMENT = null;
            }

            if (ORDERS != null)
            {
                ORDERS.PAYMENT = this;
                if (ID != ORDERS.ID)
                {
                    ID = ORDERS.ID;
                }
            }
        }
Пример #4
0
        private void FixupORDERS(ORDERS previousValue)
        {
            if (previousValue != null && previousValue.ORDER_DETAIL.Contains(this))
            {
                previousValue.ORDER_DETAIL.Remove(this);
            }

            if (ORDERS != null)
            {
                if (!ORDERS.ORDER_DETAIL.Contains(this))
                {
                    ORDERS.ORDER_DETAIL.Add(this);
                }
                if (OrderID != ORDERS.ID)
                {
                    OrderID = ORDERS.ID;
                }
            }
        }
Пример #5
0
        private void FixupORDERS(ORDERS previousValue)
        {
            if (previousValue != null && previousValue.RETURN.Contains(this))
            {
                previousValue.RETURN.Remove(this);
            }

            if (ORDERS != null)
            {
                if (!ORDERS.RETURN.Contains(this))
                {
                    ORDERS.RETURN.Add(this);
                }
                if (OrderID != ORDERS.ID)
                {
                    OrderID = ORDERS.ID;
                }
            }
            else if (!_settingFK)
            {
                OrderID = null;
            }
        }
Пример #6
0
        private static void CreateBillingTab(ORDERS order, Document doc, float totalWidth)
        {
            var nrFatFontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD, BaseColor.PINK);
            var datFatFontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 7, Font.NORMAL, BaseColor.BLACK);
            var headStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, BaseColor.WHITE);
            var itemsStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL, BaseColor.BLACK);
            var emptyStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 1, Font.NORMAL, BaseColor.BLACK);

            #region Nr & data
            var tblFatturaAllContent = new PdfPTable(1);
            var cF1 = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = GrayColor.WHITE,
                BorderWidthTop = 1f,
                BorderColorTop = BaseColor.GRAY,
                BorderWidthRight = 1f,
                BorderColorRight = BaseColor.GRAY,
                BorderWidthLeft = 1f,
                BorderColorLeft = BaseColor.GRAY
            };
            var fatPh = new Phrase { Leading = 20f };
            var fatCh =
                new Chunk(ConfigurationManager.AppSettings["TitFatPDF"] + String.Format(Configuration.OrderNrFormatting, order.ID),
                          nrFatFontStyle);
            fatPh.Add(fatCh);
            fatCh = new Chunk("          ");
            fatPh.Add(fatCh);
            fatCh = new Chunk("data: " + order.DateCreated.ToString("d"), datFatFontStyle);
            fatPh.Add(fatCh);
            cF1.AddElement(fatPh);
            cF1.AddElement(new Paragraph(10, " "));
            tblFatturaAllContent.AddCell(cF1);
            doc.Add(tblFatturaAllContent);
            #endregion

            var tblFattura = new PdfPTable(10) { TotalWidth = totalWidth };
            var widths = new float[] { 5f, 25f, 60f, 220f, 70f, 45f, 50f, 40f, 55f, 5f }; //total575
            tblFattura.SetWidths(widths);
            #region Header LEFT
            //cell spacer Left
            var cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.WHITE,
                BorderWidthLeft = 1f,
                BorderColorLeft = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.DARK_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase("Nr.", headStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitArtPDF"], headStyle));
            tblFattura.AddCell(cellFat);


            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.DARK_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitDeskPDF"], headStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitSum-VatPDF"], headStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.DARK_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitVATPDF"], headStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitSum+VatPDF"], headStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.DARK_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitQuantPDF"], headStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                //BorderWidthBottom = 1f,
                //BorderColorBottom = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitTotPDF"], headStyle));
            tblFattura.AddCell(cellFat);

            //CELL spacer
            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.WHITE,
                BorderWidthRight = 1f,
                BorderColorRight = BaseColor.GRAY,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment = Element.ALIGN_CENTER
            };
            cellFat.AddElement(new Phrase(" "));
            tblFattura.AddCell(cellFat);
            #endregion

            #region BODY
            int count = 1;
            int num = 1;
            foreach (var singleDett in order.ORDER_DETAIL)
            {
                while (count < 11)
                {
                    switch (count)
                    {
                        case 1:
                            FirstColumnInvoice(tblFattura);
                            break;
                        case 10:
                            LastColumnInvoice(tblFattura);
                            break;
                        default:
                            WriteBodyDettailOrder(singleDett, tblFattura, count, itemsStyle, ref num);
                            break;
                    }
                    count += 1;
                }
                count = 1;
            }
            #endregion

            #region Shippemnt

            decimal ShppingCost = order.SHIPPING.ShippingCost;
            FirstColumnInvoice(tblFattura);
            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
                Colspan = 3
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["ShippingMsgPDF"], itemsStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            cellFat.AddElement(new Phrase(CalcTvsh(ShppingCost) + " €", itemsStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TVSHPDF"] + "%", itemsStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            cellFat.AddElement(new Phrase(ShppingCost.ToString() + " €", itemsStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.LIGHT_GRAY,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            cellFat.AddElement(new Phrase(" "));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.WHITE,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            cellFat.AddElement(new Phrase(ShppingCost.ToString() + "€", itemsStyle));
            tblFattura.AddCell(cellFat);

            LastColumnInvoice(tblFattura);

            #endregion

            #region Summ row
            FirstColumnInvoice(tblFattura);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.WHITE,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
                Colspan = 5
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            cellFat.AddElement(new Phrase(" "));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.WHITE,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
                Colspan = 2
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            if (order.BonusUsed.HasValue && order.BonusUsed.Value != 0)
            {
                string totPlusBonus = string.Format(
@"{0} 
{1}
{2}
{3}", ConfigurationManager.AppSettings["TitTotPDF"],
    ConfigurationManager.AppSettings["BonusPDF"], 
    ConfigurationManager.AppSettings["TitTotPagPDF"], 
    " ");
                cellFat.AddElement(new Phrase(totPlusBonus, itemsStyle));
            }
            else
            cellFat.AddElement(new Phrase(ConfigurationManager.AppSettings["TitTotPDF"], itemsStyle));
            tblFattura.AddCell(cellFat);

            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.WHITE,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY
            };
            cellFat.HorizontalAlignment = Rectangle.ALIGN_RIGHT;
            if (order.BonusUsed.HasValue && order.BonusUsed.Value != 0)
            {
                string totPlusBonus = string.Format(
@"{0} 
-{1}€ 
{2}€
{3}", order.TotalAmount, 
     order.BonusUsed.Value, 
     order.AmountPaid, 
     " ");
                cellFat.AddElement(new Phrase(totPlusBonus, itemsStyle));
            }
            else
                cellFat.AddElement(new Phrase(order.TotalAmount + " €", itemsStyle));
            tblFattura.AddCell(cellFat);

            LastColumnInvoice(tblFattura);
            #endregion

            #region footer
            cellFat = new PdfPCell
            {
                Border = Rectangle.NO_BORDER,
                BackgroundColor = BaseColor.WHITE,
                BorderWidthRight = 1f,
                BorderColorRight = BaseColor.GRAY,
                BorderWidthBottom = 1f,
                BorderColorBottom = BaseColor.GRAY,
                BorderWidthLeft = 1f,
                BorderColorLeft = BaseColor.GRAY,
                Colspan = 10
            };
            cellFat.AddElement(new Phrase(" "));
            tblFattura.AddCell(cellFat);
            #endregion

            doc.Add(tblFattura);
        }
        protected void saveEasyPayOrder(EasyPayData data, List<SHOPPING_CART> carts, string originalResponse, decimal charge)
        {
            if (carts != null && carts.Count > 0)
            {
                int addrId, bonId = 0;
                decimal bonusUsed = 0;
                if (Session["AddrForEasyPay"] != null)
                {
                    addrId = (int)Session["AddrForEasyPay"];
                }
                else
                {
                    BasePage.Log(null, "EasyPay save - null address.", "", "EasyPay.saveOrder");
                }

                CultureInfo ci = new CultureInfo("en-US");
                string cartID = data.OrderId;

                decimal total = ApplicationContext.Current.Carts.GetShoppingCartTotalAmount(cartID).Value;

                ORDERS order = new ORDERS();

                int addrID = 0;
                // Bonus has been used
                decimal rate = ApplicationContext.Current.Payments.GetLastConversionRate().CurrencyRate + Configuration.CurrencyDelta;
                decimal amount = data.Amount / rate;
                if (total != amount)
                {
                    if (Session["BonForEasyPay"] != null && Session["BonIdForEasyPay"] != null && !String.IsNullOrWhiteSpace(Session["BonIdForEasyPay"].ToString()))
                    {
                        bonusUsed = (decimal)Session["BonForEasyPay"];
                        bonId = (int)Session["BonIdForEasyPay"];
                    }
                    if (bonusUsed == total - amount)
                    {
                        setBonus(order, bonId, bonusUsed);
                    }
                    else
                    {
                        BasePage.Log(null, "EasyPay order save - bonus MANIPULATION. Original:" + (total - amount) + " new: " + bonusUsed +
                            " - txnID: " + data.TransactionId, "", "EasyPay order save");
                        return;
                    }
                }

                order.TotalAmount = total;
                order.AmountPaid = amount;
                order.Verified = false;
                order.Canceled = false;

                order.Completed = true;
                order.Status = 1;

                try
                {
                    order.CustomerID = carts.First().CustomerID;

                    order.PAYMENT = new PAYMENT() { Type = 3 };
                    originalResponse = originalResponse.Replace("&", "\n");
                    order.PAYMENT.EASYPAY_PAYMENT = new EASYPAY_PAYMENT()
                    {
                        Amount = data.Amount,
                        MerchantUsername = Configuration.EasyPayMerchantUser,
                        TransactionID = data.TransactionId,
                        ResponseCode = data.ErrorCode,
                        Rate = rate,
                        OriginalResponse = originalResponse,
                        TransactionStatus = data.ErrorCodeS,
                        Date = DateTime.Now,
                        Fee = charge
                    };

                    // TODO for now it is set to carrier without a fee
                    order.ShippingID = 3;

                    order.DateCreated = DateTime.Now;
                    ADDRESS addr = ApplicationContext.Current.Customers.GetAddressById(addrID);
                    // addresses
                    if (addr != null)
                    {
                        ADDRESSINFO shipping = new ADDRESSINFO(addr);
                        order.ADDRESSINFO = shipping;
                    }
                    //inserting and not saving as the saving will be done in the details insertion
                    ApplicationContext.Current.Orders.Insert(order, true, false);

                    // inserting the products of this order

                    ApplicationContext.Current.Orders.InsertDetailsFromCart(order, carts, false);

                    List<ORDER_DETAIL> details = ApplicationContext.Current.Orders.GetDetails(order.ID);

                    CUSTOMER customer = ApplicationContext.Current.Customers.GetById(carts[0].CustomerID);

                    Thread thread = new Thread(() => BasePage.sendOrderMailToAdmins(details, "EasyPay", "EasyPay Order", order.TotalAmount, customer.Name + " " + customer.Surname));
                    thread.Start();

                    Thread thread2 = new Thread(() => BasePage.sendOrderMailToCustomer(customer, details, "Porosia ne FZone.al"));
                    thread2.Start();

                    lblResult.Text = "<b>" + Resources.Lang.PayPalThankyouLabel + "</b> <br/><br/>" +
                    Resources.Lang.SaveTransactionID + "<b>" + data.TransactionId + "</b>";
                }
                catch (System.Threading.ThreadAbortException ex)
                {
                }
                catch (Exception e)
                {
                    //TODO log exception
                    BasePage.Log(e, e.Message, e.StackTrace, "easyPay.Save");
                    lblResult.Text = Resources.Lang.PaymentProblemLiteral + "</b> <br/><br/>" +
                    Resources.Lang.SaveTransactionID + "<b>" + data.TransactionId + "</b>"; ;
                }
            }
        }
Пример #8
0
        private void setBonus(ORDERS order)
        {
            int bonusID = 0;

            if (Int32.TryParse(ddlBonus.SelectedValue, out bonusID) && bonusID != -1)
            {
                BONUS bonus = new BONUS() { ID = bonusID, Version = Version.Where(b => b.Key == bonusID).FirstOrDefault().Value };

                ORDER_BONUS ordBonus = new ORDER_BONUS() { OrderID = order.ID, BonusID = bonusID, Value = BonusUsed, ORDERS = order, BONUS = bonus };

                order.BonusUsed = BonusUsed;
                order.ORDER_BONUS.Add(ordBonus);
            }
        }
Пример #9
0
 public void Insert(ORDERS Order)
 {
     Insert(Order, true);
 }
Пример #10
0
 public void Update(ORDERS Order, bool Attach = true)
 {
     if (Attach)
     {
         Context.ORDERS.Attach(Order);
     }
     var entry = Context.ObjectStateManager.GetObjectStateEntry(Order);
     // excluding datecreated from the updatable fields
     entry.SetModifiedProperty("DateShipped");
     entry.SetModifiedProperty("Verified");
     entry.SetModifiedProperty("Completed");
     entry.SetModifiedProperty("Canceled");
     entry.SetModifiedProperty("Comments");
     entry.SetModifiedProperty("ShippingID");
     entry.SetModifiedProperty("ShippingAddress");
     entry.SetModifiedProperty("BillingAddress");
     entry.SetModifiedProperty("Status");
     entry.SetModifiedProperty("ShippingDetails");
     entry.SetModifiedProperty("TrackingNumber");
     entry.SetModifiedProperty("DateDelivered");
 }
Пример #11
0
 public List<ORDER_BONUS> GetOrderBonuses(ORDERS Order)
 {
     return Context.ORDER_BONUS.Where(b => b.OrderID == Order.ID).ToList();
 }
Пример #12
0
     private void FixupORDERS(ORDERS previousValue)
     {
         if (previousValue != null && ReferenceEquals(previousValue.PAYMENT, this))
         {
             previousValue.PAYMENT = null;
         }
 
         if (ORDERS != null)
         {
             ORDERS.PAYMENT = this;
             if (ID != ORDERS.ID)
             {
                 ID = ORDERS.ID;
             }
         }
     }
Пример #13
0
        /// <summary>
        /// Writes the info order.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <param name="phOrd">The ph ord.</param>
        /// <param name="miniTitlesFontStyleIns">The mini titles font style ins.</param>
        private static void WriteInfoOrder(ORDERS order, ref Phrase phOrd, Font miniTitlesFontStyleIns)
        {
            string paymentOrder = String.Empty;
            decimal paid = 0;
            switch (order.PAYMENT.Type)
            {
                case (int)PaymentType.CA :
                    paymentOrder = "Cash";
                    paid = order.PAYMENT.CASH_PAYMENT.Amount.Value;
                    break;
                case (int)PaymentType.PP:
                    paymentOrder = "PayPal";
                    paid = order.PAYMENT.PAYPAL_PAYMENT.Amount.Value;
                    break;
                case (int)PaymentType.EP:
                    paymentOrder = "EasyPay";
                    paid = order.PAYMENT.EASYPAY_PAYMENT.Amount;
                    break;
            }
            if (order != null)
            {
                string addSh = string.Format(
@"Fatura nr: {0}
Data faturës: {1}
Tipi i pagimit: {2}
Paguar: {3}
Blerësi:{4}
{5}
Kodi: {6}",
                    String.Format(FashionZone.BL.Configuration.OrderNrFormatting, order.ID),
                    order.DateCreated.ToString("dd/MM/yyyy hh:mm"),
                    paymentOrder, paid.ToString("N2") + (order.PAYMENT.Type == (int)PaymentType.EP ? " Lek" : " €"), order.CustomerName, order.CUSTOMER.Email,
                    order.VerificationNumber);
                phOrd = new Phrase(addSh, miniTitlesFontStyleIns);
            }
        }
Пример #14
0
        /// <summary>
        /// Creates the usr info tab.
        /// </summary>
        /// <param name="OrderDett">The order dett.</param>
        /// <param name="doc">The doc.</param>
        /// <param name="_miniTitlesFontStyle">The _mini titles font style.</param>
        /// <param name="_miniTitlesFontStyleIns">The _mini titles font style ins.</param>
        private static void CreateUsrInfoTab(ORDERS OrderDett, Document doc, Font _miniTitlesFontStyle, Font _miniTitlesFontStyleIns)
        {
            PdfPTable tblUsrInfo = new PdfPTable(3);
            #region HeaderTable
            PdfPCell cU1 = new PdfPCell(new Phrase(ConfigurationManager.AppSettings["TabH1PDF"], _miniTitlesFontStyle));
            cU1.Border = Rectangle.NO_BORDER;
            cU1.FixedHeight = 20f;
            cU1.VerticalAlignment = Element.ALIGN_CENTER;
            cU1.HorizontalAlignment = Element.ALIGN_CENTER;
            cU1.BackgroundColor = BaseColor.GRAY;
            //cU1.Border = Rectangle.RIGHT_BORDER;
            //cU1.BorderColor = GrayColor.WHITE;
            //cU1.BorderWidth = 3f;
            tblUsrInfo.AddCell(cU1);

            cU1 = new PdfPCell(new Phrase(ConfigurationManager.AppSettings["TabH2PDF"], _miniTitlesFontStyle));
            cU1.Border = Rectangle.RIGHT_BORDER;
            cU1.BorderWidthRight = 3f;
            cU1.BorderColorRight = BaseColor.WHITE;
            cU1.Border = Rectangle.LEFT_BORDER;
            cU1.BorderWidthLeft = 3f;
            cU1.BorderColorLeft = BaseColor.WHITE;
            cU1.FixedHeight = 20f;
            cU1.VerticalAlignment = Element.ALIGN_CENTER;
            cU1.HorizontalAlignment = Element.ALIGN_CENTER;
            cU1.BackgroundColor = BaseColor.GRAY;
            tblUsrInfo.AddCell(cU1);

            cU1 = new PdfPCell(new Phrase(ConfigurationManager.AppSettings["TabH3PDF"], _miniTitlesFontStyle));
            cU1.Border = Rectangle.LEFT_BORDER;
            cU1.BorderWidthLeft = 3f;
            cU1.FixedHeight = 20f;
            cU1.VerticalAlignment = Element.ALIGN_CENTER;
            cU1.HorizontalAlignment = Element.ALIGN_CENTER;
            cU1.BackgroundColor = BaseColor.GRAY;
            cU1.BorderColor = BaseColor.WHITE;
            tblUsrInfo.AddCell(cU1);

            doc.Add(tblUsrInfo);
            #endregion

            doc.Add(new Paragraph(3, " "));

            #region BodyTable
            tblUsrInfo = new PdfPTable(3);
            PdfPCell cU2 = new PdfPCell();

            var phOrd = new Phrase();
            WriteInfoOrder(OrderDett, ref phOrd, _miniTitlesFontStyleIns);
            cU2.AddElement(phOrd);
            cU2.Border = Rectangle.NO_BORDER;
            cU2.FixedHeight = 110f;
            cU2.PaddingLeft = 10f;
            cU2.BorderWidthLeft = 6f;
            cU1.BorderColorLeft = BaseColor.GRAY;
            cU2.VerticalAlignment = Element.ALIGN_TOP;
            cU2.HorizontalAlignment = Element.ALIGN_LEFT;
            tblUsrInfo.AddCell(cU2);

            cU2 = new PdfPCell();
            WriteAddress(OrderDett.ShippingAddress, ref phOrd, _miniTitlesFontStyleIns);
            cU2.AddElement(phOrd);
            cU2.Border = Rectangle.NO_BORDER;
            cU2.BorderWidthLeft = 3f;
            cU1.BorderColorLeft = BaseColor.GRAY;
            cU2.PaddingLeft = 10f;
            cU2.VerticalAlignment = Element.ALIGN_TOP;
            cU2.HorizontalAlignment = Element.ALIGN_LEFT;
            tblUsrInfo.AddCell(cU2);

            cU2 = new PdfPCell();
            WriteAddress(OrderDett.BillingAddress, ref phOrd, _miniTitlesFontStyleIns);
            cU2.AddElement(phOrd);
            cU2.Border = Rectangle.NO_BORDER;
            cU2.PaddingLeft = 10f;
            cU2.BorderWidthLeft = 3f;
            cU1.BorderColorLeft = BaseColor.GRAY;
            cU2.BorderWidthRight = 6f;
            cU1.BorderColorRight = BaseColor.GRAY;
            cU2.VerticalAlignment = Element.ALIGN_TOP;
            cU2.HorizontalAlignment = Element.ALIGN_LEFT;
            tblUsrInfo.AddCell(cU2);

            doc.Add(tblUsrInfo);
            #endregion
        }
Пример #15
0
        /// <summary>
        /// Docs the PDF.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <returns></returns>
        public static MemoryStream DocPDF(ORDERS order)
        {
            #region Stili e Margini del documento PDF
            // bordi pagina (A4 = 595 x 842 pt.)
            int _topBorder = 40;
            int _leftBorder = 10;
            int _rightBorder = 10;
            int _bottomBorder = 10;

            // Stili caratteri
            //int _normalTextSize = 12;
            int _paragraphTitleSize = 14;
            int _paragraphTextSize = 9;
            float _myLeading = 30f;
            float totlaWidth;

            Font _titlesFontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, _paragraphTitleSize, Font.BOLD);
            Font _textFontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, _paragraphTextSize, Font.NORMAL);
            Font _miniTitlesFontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, _paragraphTextSize, Font.BOLD, BaseColor.WHITE);
            Font _miniTitlesFontStyleIns = FontFactory.GetFont(FontFactory.TIMES_ROMAN, _paragraphTextSize, Font.NORMAL);
            Font _miniTextFontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL);
            #endregion

            string pathFile = @"/PdfDoc/" + Path.GetRandomFileName() + ".pdf";
            pathFile = Path.Combine(HttpContext.Current.Server.MapPath(pathFile));
            using (var doc = new Document(PageSize.A4, _leftBorder, _rightBorder, _topBorder, _bottomBorder))
            {
                PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(pathFile, FileMode.Create));
                doc.Open();

                totlaWidth = CreateHeader(_rightBorder, _leftBorder, _miniTextFontStyle, doc);

                Paragraph spacer = new Paragraph(_myLeading, " ");
                doc.Add(spacer);

                CreateUsrInfoTab(order, doc, _miniTitlesFontStyle, _miniTitlesFontStyleIns);

                doc.Add(spacer = new Paragraph(_myLeading, " "));

                CreateBillingTab(order, doc, totlaWidth);

                //the end
                var endTab = new PdfPTable(1) { TotalWidth = totlaWidth };
                var endCell = new PdfPCell
                {
                    Border = Rectangle.NO_BORDER,
                    HorizontalAlignment = 2,
                    VerticalAlignment = 2
                };
                var msgP = new Paragraph(ConfigurationManager.AppSettings["MsgServicePDF"], _miniTextFontStyle);
                endCell.AddElement(msgP);
                endTab.AddCell(endCell);

                endCell = new PdfPCell
                {
                    Border = Rectangle.NO_BORDER,
                    BackgroundColor = BaseColor.LIGHT_GRAY,
                    HorizontalAlignment = 2,
                    VerticalAlignment = 2
                };
                Font ff = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.RED);
                var msgP2 = new Phrase(20f, ConfigurationManager.AppSettings["EndMesPDF"], ff);
                endCell.AddElement(msgP2);
                endCell.Border = Rectangle.NO_BORDER;
                endCell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                endCell.VerticalAlignment = Element.ALIGN_JUSTIFIED;
                endTab.AddCell(endCell);
                doc.Add(endTab);

                doc.Add(spacer);
                doc.Add(spacer);

                var endTab2 = new PdfPTable(2) { TotalWidth = totlaWidth };
                var endCell2 = new PdfPCell
                {
                    Border = Rectangle.NO_BORDER,
                    HorizontalAlignment = 2,
                    VerticalAlignment = 2
                };
                var msgPost = new Paragraph("Data:", _textFontStyle);
                endCell2.AddElement(msgPost);
                endTab2.AddCell(endCell2);

                var endCell3 = new PdfPCell
                {
                    Border = Rectangle.NO_BORDER,
                    HorizontalAlignment = 2,
                    VerticalAlignment = 2
                };
                var msgPost2 = new Paragraph("Firma klientit: ", _textFontStyle);
                endCell3.AddElement(msgPost2);
                endTab2.AddCell(endCell3);

                doc.Add(endTab2);
                if (order.PAYMENT.Type == (int)PaymentType.CA)
                {
                    doc.Add(spacer);
                    doc.Add(spacer);

                    var cashTab = new PdfPTable(2) { TotalWidth = totlaWidth };
                    var cashCell = new PdfPCell
                    {
                        //Border = Rectangle.NO_BORDER,
                        HorizontalAlignment = 2,
                        VerticalAlignment = 2
                    };

                    cashCell.Border = Rectangle.TOP_BORDER;
                    var msgCash = new Paragraph(_myLeading, "Paguar: " + order.PAYMENT.CASH_PAYMENT.Receiver, _textFontStyle);
                    cashCell.AddElement(msgCash);
                    cashTab.AddCell(cashCell);

                    var cashCell2 = new PdfPCell
                    {
                        HorizontalAlignment = 2,
                        VerticalAlignment = 2
                    };
                    cashCell2.Border = Rectangle.TOP_BORDER;
                    var msgCash2 = new Paragraph(_myLeading, string.Format("Firma:( {0} ): ", order.PAYMENT.CASH_PAYMENT.Receiver), _textFontStyle);//\n\r
                    cashCell2.AddElement(msgCash2);
                    cashTab.AddCell(cashCell2);

                    doc.Add(cashTab);
                }
            }
            return RequestFileStream(pathFile);
        }
Пример #16
0
 public List<ORDER_BONUS> GetOrderBonuses(ORDERS Order)
 {
     return _orderDAO.GetOrderBonuses(Order);
 }
Пример #17
0
        public string Update(ORDERS Order, bool Attach = true)
        {
            string retString = String.Empty;
            CUSTOMER customer = _customerDAO.GetById(Order.CustomerID.Value);

            // first buy of this customer & invited by someone
            if ((!customer.FirstBuy.HasValue || !customer.FirstBuy.Value) && Order.PAYMENT.Type == (int)PaymentType.CA && Order.Completed)
            {
                if (customer.InvitedFrom.HasValue)
                {
                    insertCustomerBonus(customer);
                    retString = "Bonus added to inviter " + customer.CUSTOMER2.Email;
                    Util.Mailer.SendBonus(customer, customer.CUSTOMER2.Email, Configuration.BonusValue + " € bonus per ju ne FZone");
                }

                customer.FirstBuy = true;
                _customerDAO.Update(customer, true, false);
            }
            _orderDAO.Update(Order, Attach);

            // payment
            if (Order.PAYMENT != null)
            {
                if (Order.PAYMENT.Type == (int)PaymentType.CA)
                {
                    var entry = Context.ObjectStateManager.GetObjectStateEntry(Order.PAYMENT.CASH_PAYMENT);
                    entry.SetModifiedProperty("Receiver");
                    entry.SetModifiedProperty("Comments");
                    entry.SetModifiedProperty("PaidOn");
                }
                else if (Order.PAYMENT.Type == (int)PaymentType.PP)
                {
                    //TODO
                }
            }
            Context.SaveChanges();
            return retString;
        }
Пример #18
0
 public void Insert(ORDERS newOrder)
 {
     Context.ORDERS.AddObject(newOrder);
 }
Пример #19
0
        public string Insert(ORDERS Order, bool FrontEnd, bool SaveContext = true)
        {
            string retString = String.Empty;
            //if there is any used bonus, decrease the remainder
            if (Order.ORDER_BONUS.Count > 0)
            {
                BONUS bonus;
                foreach (ORDER_BONUS bon in Order.ORDER_BONUS)
                {
                    bonus = _bonusDAO.GetById(bon.BonusID);

                    // object must be detached from context, otherwise Version field for concurrency check will not be updated!!!
                    Context.BONUS.Detach(bonus);

                    // using the version that was initially retrieved from db
                    // if another user modified this record an OptimisticConcurrencyException will be raised
                    if (bon.Value > bonus.ValueRemainder)
                    {
                        //TODO think what to do with version
                        //bonus.Version = bon.BONUS.Version;
                        throw new System.Data.OptimisticConcurrencyException("Bonus not sufficient.");
                    }
                    bonus.ValueRemainder -= bon.Value;

                    _bonusDAO.Update(bonus);
                    bon.BONUS = null;
                }
            }

            CUSTOMER customer = _customerDAO.GetById(Order.CustomerID.Value);

            // for electronic payments insert directly
            if ((Order.PAYMENT.Type == (int)PaymentType.PP && Order.PAYMENT.PAYPAL_PAYMENT.TransactionStatus == "Completed")
                    || (Order.PAYMENT.Type == (int)PaymentType.EP && Order.PAYMENT.EASYPAY_PAYMENT.TransactionStatus == "Success")
                    || (Order.PAYMENT.Type == (int)PaymentType.CA && !FrontEnd && Order.Completed))
            {
                if (!customer.FirstBuy.HasValue || !customer.FirstBuy.Value)
                {
                    // set first buy of user
                    customer.FirstBuy = true;
                    _customerDAO.Update(customer, true, false);

                    // first buy of this customer & invited by someone
                    if (customer.InvitedFrom.HasValue)
                    {
                        insertCustomerBonus(customer);
                        retString = "Bonus added to inviter " + customer.CUSTOMER2.Email;
                        Util.Mailer.SendBonus(customer, customer.CUSTOMER2.Email, Configuration.BonusValue + " € bonus per ju ne FZone");
                    }
                }
            }
            Guid g = Guid.NewGuid();
            UniqueIdGenerator unique = UniqueIdGenerator.GetInstance();
            string vNum = unique.GetBase32UniqueId(g.ToByteArray(), 20).ToLower();
            Order.VerificationNumber = vNum;
            _orderDAO.Insert(Order);

            // payment
            if (Order.PAYMENT != null)
            {
                Context.ObjectStateManager.ChangeObjectState(Order.PAYMENT, EntityState.Added);
                if (Order.PAYMENT.Type == (int)PaymentType.CA)
                {
                    Context.ObjectStateManager.ChangeObjectState(Order.PAYMENT.CASH_PAYMENT, System.Data.EntityState.Added);
                }
                else if (Order.PAYMENT.Type == (int)PaymentType.PP)
                {
                    Context.ObjectStateManager.ChangeObjectState(Order.PAYMENT.PAYPAL_PAYMENT, System.Data.EntityState.Added);
                }
                else if (Order.PAYMENT.Type == (int)PaymentType.EP)
                {
                    Context.ObjectStateManager.ChangeObjectState(Order.PAYMENT.EASYPAY_PAYMENT, System.Data.EntityState.Added);
                }
            }

            if (SaveContext)
            {
                Context.SaveChanges();
            }
            return retString;
        }
Пример #20
0
 public void Delete(ORDERS delOrder)
 {
     Context.ORDERS.Attach(delOrder);
     Context.DeleteObject(delOrder);
 }
Пример #21
0
        protected void savePayPalOrder(PDTData data, List<SHOPPING_CART> carts, string originalResponse)
        {
            CultureInfo ci = new CultureInfo("en-US");
            string cartID = data.Invoice;
            if (carts != null && carts.Count > 0)
            {
                decimal total = ApplicationContext.Current.Carts.GetShoppingCartTotalAmount(cartID).Value;

                ORDERS order = new ORDERS();

                int addrID = 0;
                // Bonus has been used
                if (total != data.GrossTotal)
                {
                    string[] custom = data.Custom.Split('-');
                    if (custom.Length == 3)
                    {
                        decimal bonus = Convert.ToDecimal(custom[2], ci);
                        int bonusID = Convert.ToInt32(custom[1]);
                        addrID = Convert.ToInt32(custom[0]);
                        if (bonus == total - data.GrossTotal)
                        {
                            setBonus(order, bonusID, bonus);
                        }
                        else
                        {
                            BasePage.Log(null, "IPN order save - bonus MANIPULATION. Original:" + (total - data.GrossTotal) + " new: " + bonus +
                                " - txnID: " + data.TransactionId, "", "IPN Handler");
                            return;
                        }
                    }
                }
                else
                {
                    addrID = Convert.ToInt32(data.Custom);
                }

                order.TotalAmount = total;
                order.AmountPaid = data.GrossTotal;
                order.Verified = false;
                order.Canceled = false;
                if (data.PaymentStatus.ToUpper() == "COMPLETED")
                {
                    order.Completed = true;
                }
                else
                {
                    order.Completed = false;
                }
                order.Status = 1;

                try
                {
                    order.CustomerID = carts.First().CustomerID;

                    order.PAYMENT = new PAYMENT() { Type = 2 };
                    order.PAYMENT.PAYPAL_PAYMENT = new PAYPAL_PAYMENT()
                    {
                        Amount = data.GrossTotal,
                        CartID = cartID,
                        PaidOn = DateTime.Now,
                        Currency = data.Currency,
                        Fee = data.Fee,
                        PayerEmail = data.PayerEmail,
                        TransactionKey = data.TransactionId,
                        PayerName = data.PayerFirstName + " " + data.PayerLastName,
                        PaypalEmail = data.ReceiverEmail,
                        Response = originalResponse,
                        TransactionStatus = data.PaymentStatus,
                        PayerStatus = data.PayerStatus
                    };

                    // for now it is set to carrier without a fee
                    order.ShippingID = 3;

                    order.DateCreated = DateTime.Now;
                    ADDRESS addr = ApplicationContext.Current.Customers.GetAddressById(addrID);
                    // addresses
                    if (addr != null)
                    {
                        ADDRESSINFO shipping = new ADDRESSINFO(addr);
                        order.ADDRESSINFO = shipping;
                    }
                    //inserting and not saving as the saving will be done in the details insertion
                    ApplicationContext.Current.Orders.Insert(order, true, false);

                    // inserting the products of this order

                    ApplicationContext.Current.Orders.InsertDetailsFromCart(order, carts, false);

                    List<ORDER_DETAIL> details = ApplicationContext.Current.Orders.GetDetails(order.ID);

                    CUSTOMER customer = ApplicationContext.Current.Customers.GetById(carts[0].CustomerID);

                    Thread thread = new Thread(() => BasePage.sendOrderMailToAdmins(details, "PayPal", "PayPal Order", order.TotalAmount, customer.Name + " " + customer.Surname));
                    thread.Start();

                    Thread thread2 = new Thread(() => BasePage.sendOrderMailToCustomer(customer, details, "Porosia ne FZone.al"));
                    thread2.Start();
                }
                catch (System.Threading.ThreadAbortException ex)
                {
                }
                catch (Exception e)
                {
                    //TODO log exception
                    BasePage.Log(e, e.Message, e.StackTrace, "paypalSuccess.Save");
                }
            }
        }
Пример #22
0
 public void DeleteById(int id)
 {
     ORDERS obj = new ORDERS() { ID = id };
     Delete(obj);
 }
Пример #23
0
        private void saveOrder()
        {
            ORDERS order = new ORDERS();

            order.TotalAmount = TotalAmount.Value + ShipCost;

            order.BonusUsed = 0;
            order.AmountPaid = TotalOrder;
            order.Verified = false;

            order.Canceled = false;
            order.Completed = false;

            order.Status = 1;

            string paymentType = String.Empty;

            int i;
            try
            {
                order.CustomerID = CurrentCustomer.Id;
                if (Int32.TryParse(selectedPayment.Value, out i))
                {
                    if (i == 3 || i == 4)
                    {
                        order.PAYMENT = new PAYMENT() { Type = (int) PaymentType.CA };
                        order.PAYMENT.CASH_PAYMENT = new CASH_PAYMENT() { Amount = TotalOrder };
                        if (i == 3)
                        {
                            order.PAYMENT.CASH_PAYMENT.Comments = txtCashComments.Text;
                            order.PAYMENT.CASH_PAYMENT.Receiver = "Korrier";
                            //TODO paid date
                            order.ShippingID = 3;
                            paymentType = "Korrier";
                        }
                        else
                        {
                            order.PAYMENT.CASH_PAYMENT.Receiver = "Zyra";
                            order.ShippingID = 1;
                            paymentType = "Zyra";
                        }
                    }
                }
                if ((ddlShippingAddress.SelectedValue == "0" || ddlShippingAddress.Items.Count == 0) && i == 3)
                {
                    writeResult(Resources.Lang.SpecifyShippingAddress);
                    radioBtnCarrier.Checked = true;
                    divConfirmLink.Visible = true;
                    return;
                }
                // setting used bonuses in the order object
                setBonus(order);
                order.DateCreated = DateTime.Now;

                if (i == 3)
                {
                    // addresses
                    ADDRESSINFO shipping = new ADDRESSINFO(address1.GetAddress());
                    //ADDRESSINFO billing = new ADDRESSINFO(address2.GetAddress());
                    order.ADDRESSINFO = shipping;
                    //order.ADDRESSINFO1 = billing;
                }

                //inserting and not saving if there are any details, as the saving will be done in the details insertion
                ApplicationContext.Current.Orders.Insert(order, true, false);

                // inserting the products of this order
                List<SHOPPING_CART> carts = ApplicationContext.Current.Carts.GetShoppingCartItems(CartSession.First().Id);

                ApplicationContext.Current.Orders.InsertDetailsFromCart(order, carts, false);

                List<ORDER_DETAIL> details = ApplicationContext.Current.Orders.GetDetails(order.ID);

                Thread thread = new Thread(() => sendOrderMailToAdmins(details, paymentType, txtCashComments.Text, TotalOrder, CurrentCustomer.FullName));
                thread.Start();

                CUSTOMER customer = ApplicationContext.Current.Customers.GetByEmail(User.Identity.Name);

                Thread thread2 = new Thread(() => sendOrderMailToCustomer(customer, details, "Porosia ne FZone.al"));
                thread2.Start();

                CartSession = null;

                Response.Redirect("/personal/orderDet/" + FashionZone.BL.Util.Encryption.Encrypt(order.ID.ToString()));
            }
            catch (System.Threading.ThreadAbortException ex)
            {
            }
            catch (Exception e)
            {
                //TODO log exception
                Log(e, e.Message, e.StackTrace, "Checkout.Save");
                writeResult(Resources.Lang.ErrorVerifiedLabel);
            }
        }
Пример #24
0
        public void InsertDetailsFromCart(ORDERS Order, List<SHOPPING_CART> Cart, bool Attach = true)
        {
            if (Cart != null && Cart.Count > 0)
            {
                ORDER_DETAIL detail;
                foreach (SHOPPING_CART item in Cart)
                {
                    detail = new ORDER_DETAIL();
                    detail.OrderID = Order.ID;
                    detail.CampaignID = item.CampaignID;
                    detail.ProdAttrID = item.ProdAttrID;
                    detail.Quantity = item.Quantity;

                    // first insert order
                    _orderDAO.InsertDetail(detail);

                    item.CAMPAIGN = null;
                    item.CUSTOMER = null;
                    item.PRODUCT_ATTRIBUTE = null;

                    //second remove the related cart item
                    _cartDAO.Delete(item, Attach);
                }
                Context.SaveChanges();
            }
        }
 private void setBonus(ORDERS order, int bonusID, decimal BonusUsed)
 {
     BONUS bonus = new BONUS() { ID = bonusID };
     ORDER_BONUS ordBonus = new ORDER_BONUS() { OrderID = order.ID, BonusID = bonusID, Value = BonusUsed, ORDERS = order, BONUS = bonus };
     order.BonusUsed = BonusUsed;
     order.ORDER_BONUS.Add(ordBonus);
 }
Пример #26
0
 public List<ORDERS> Search(ORDERS Order, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
 {
     return _orderDAO.Search(Order, PageSize, PageIndex, out TotalRecords, OrderExp, SortDirection);
 }
Пример #27
0
 public void Update(ORDERS Order)
 {
     Update(Order, true);
 }
Пример #28
0
 public void Delete(ORDERS Order)
 {
     _orderDAO.Delete(Order);
     //TODO handle related objects in transaction (product quantity)
 }
Пример #29
0
     private void FixupORDERS(ORDERS previousValue)
     {
         if (previousValue != null && previousValue.ORDER_BONUS.Contains(this))
         {
             previousValue.ORDER_BONUS.Remove(this);
         }
 
         if (ORDERS != null)
         {
             if (!ORDERS.ORDER_BONUS.Contains(this))
             {
                 ORDERS.ORDER_BONUS.Add(this);
             }
             if (OrderID != ORDERS.ID)
             {
                 OrderID = ORDERS.ID;
             }
         }
     }
Пример #30
0
        private void FixupORDERS(ORDERS previousValue)
        {
            if (previousValue != null && previousValue.RETURN.Contains(this))
            {
                previousValue.RETURN.Remove(this);
            }

            if (ORDERS != null)
            {
                if (!ORDERS.RETURN.Contains(this))
                {
                    ORDERS.RETURN.Add(this);
                }
                if (OrderID != ORDERS.ID)
                {
                    OrderID = ORDERS.ID;
                }
            }
            else if (!_settingFK)
            {
                OrderID = null;
            }
        }