示例#1
0
        public void DeleteOrderTest()
        {
            int           id     = 0;
            List <string> errors = new List <string>();

            //id = 0
            int x = BLOrders.DeleteOrder(id, ref errors);

            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);
        }
示例#2
0
        public void ReadOrderTest()
        {
            int           id     = 0;
            List <string> errors = new List <string>();

            //id = 0
            Orders x = BLOrders.ReadOrder(id, ref errors);

            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual(null, x);

            //no errors
            errors = new List <string>();

            Orders y = BLOrders.ReadOrder(1, ref errors);

            Assert.AreEqual(0, errors.Count);
            Assert.AreNotEqual(null, y);
        }
示例#3
0
    private void ClearFields()
    {
        this.created = DateTime.MinValue;
            this.uid = string.Empty;
            this.saveInfo = false;

            this.creditCard = null;
            this.billingAddress = null;
            this.shippingAddress = null;
            this.shoppingCart = null;
            this.category = null;

            this.billingAddress = new BLAddress();
            this.shippingAddress = new BLAddress();
            this.shoppingCart = new BLShoppingCart();
            this.creditCard = new BLCreditCard();
            this.items = new BLItems();
            this.orders = new BLOrders();
            this.category = new BLCategory();
            this.item = new BLItem();
    }
示例#4
0
        public void CreateOrderTest()
        {
            int   order_id    = -1;
            int   customer_id = -1;
            float subtotal    = -1F;
            float tax_total   = -1F;
            float grand_total = -1F;
            char  condition   = 'z';



            Orders order = null;

            List <string> errors = new List <string>();

            BLOrders.CreateOrder(null, ref errors);
            Assert.AreEqual(1, errors.Count);

            AsynchLog.LogNow(errors);

            //order_id = -1
            errors = new List <string>();

            order             = new Orders();
            order.order_id    = order_id;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //customer_id = -1
            order.order_id    = 1;
            order.customer_id = customer_id;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();

            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //subtotal = -1
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = subtotal;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);

            //grand_total = -1
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = grand_total;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);

            //tax_total = -1
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = tax_total;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);

            //grand_total calculation
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 1F;
            order.grand_total = 0;
            order.tax_total   = 1F;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //condition = k
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = condition;

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //all 8 errors
            order.order_id    = order_id;
            order.customer_id = customer_id;
            order.subtotal    = subtotal;
            order.grand_total = grand_total;
            order.tax_total   = tax_total;
            order.condition   = condition;

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(7, errors.Count);
            AsynchLog.LogNow(errors);

            //no errors
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(0, errors.Count);
            AsynchLog.LogNow(errors);
        }
示例#5
0
    private void goToNext01_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        if (Page.IsValid && cust.ShoppingCart.ItemsCount>0)
            {

                SaveFields();
                decimal shipmentCharges = 0;
                try
                {
                    shipmentCharges = decimal.Parse((string)ViewState["upsShipmentCharges"]);
                }
                catch{}
                decimal totalCCSurcharge = cust.ShoppingCart.GetTotalCCSurcharge(getCCSurcharge()) + shipmentCharges * getCCSurcharge();
                if(int.Parse(this.PayementMethod.Value) == 2)
                    totalCCSurcharge = 0;
                this.orderId = BLOrders.Create(cust.ID, totalCCSurcharge, shipmentCharges);
                if (this.orderId>0)
                {
                    if (emailNotification)
                    {
                        StringWriter writer = new StringWriter();
                        Server.Execute("email/emailNewOrder.aspx?oid="+this.orderId.ToString(), writer);
                        string strhtmlbody = writer.ToString();
                        //                        Response.Write(strhtmlbody);
                        //                        Response.End();
                        MailMessage objMailMessage = new MailMessage();
                        objMailMessage.Subject = this.lastName.Text+", " + this.firstName.Text + " " + this.state.Text + ", Order #" + this.orderId;
                        objMailMessage.From = this.emailNotificationCustomerFrom;
                        objMailMessage.To = email.Text;
                        objMailMessage.Cc = this.emailNotificationCustomerCc;
                        objMailMessage.Bcc = this.emailNotificationCustomerBcc;
                        objMailMessage.Body = strhtmlbody;
                        objMailMessage.BodyFormat = MailFormat.Html;
                        SmtpMail.SmtpServer = this.smtpServer;
                        SmtpMail.Send( objMailMessage );

                        cust.ShoppingCart.Retrieve();
                        DataView dvProductList = cust.ShoppingCart.Products.Tables[0].DefaultView;
                        dvProductList.RowFilter = "ProductInventory <= ProductReorder";

                        if (dvProductList.Count>0)
                        {
                            StringWriter writer1 = new StringWriter();
                            Server.Execute("email/emailReorder.aspx?cid="+cust.ID.ToString(), writer1);
                            strhtmlbody = writer1.ToString();
                            //                            Response.Write(strhtmlbody);
                            //                            Response.End();
                            objMailMessage = new MailMessage();
                            objMailMessage.Subject = siteName+": Reorder products";
                            objMailMessage.From = this.emailNotificationVendorFrom;
                            objMailMessage.To = this.emailNotificationVendorTo;
                            objMailMessage.Cc = this.emailNotificationVendorCc;
                            objMailMessage.Bcc = this.emailNotificationVendorBcc;
                            objMailMessage.Body = strhtmlbody;
                            objMailMessage.BodyFormat = MailFormat.Html;
                            SmtpMail.SmtpServer = this.smtpServer;
                            SmtpMail.Send( objMailMessage );
                        }
                    }
                    spanThankNameSite.InnerText = (string)ConfigurationSettings.AppSettings.Get("siteName");
                    BLOrders order = new BLOrders();
                    order.ID = this.orderId;
                    order.Retrieve();
                    if (Session["personalizeOrder"] != null && (bool)Session["personalizeOrder"] == true)
                    {
                        aPersonalizeOrder.HRef = new Uri(Page.Request.Url,"index.aspx?page=orderpersonalize&uid="+order.UID).ToString();
                        pnPersonalizeOrder.Visible = true;
                    }
                     cust.ShoppingCart.Clear();

                    confirmation.Visible=false;
                    this.aPrintOrder.Attributes["onclick"] = "window.open('orderprint.aspx?uid="+order.UID+"', 'anew', config='toolbar=no, menubar=no, resizable=yes, scrollbars=yes');";
                    thankyou.Visible=true;
                }
            }
    }
示例#6
0
 public Orders ReadOrder(int id, ref List <string> errors)
 {
     return(BLOrders.ReadOrder(id, ref errors));
 }
示例#7
0
 public int DeleteOrder(int id, ref List <string> errors)
 {
     return(BLOrders.DeleteOrder(id, ref errors));
 }
示例#8
0
 public int UpdateOrder(Orders order, ref List <string> errors)
 {
     return(BLOrders.UpdateOrder(order, ref errors));
 }