예제 #1
0
        //PayOrder
        private bool PayOrder()
        {
            int  quantity = StaticClass.GeneralClass.list_ec_tb_orderdetail_general.Count;
            bool result   = false;

            if (quantity > 0)
            {
                //create Order
                EC_tb_Order ec_tb_order = new EC_tb_Order();
                ec_tb_order.CustomerID      = StaticClass.GeneralClass.customerid_general;
                ec_tb_order.CustomerName    = StaticClass.GeneralClass.customername_general;
                ec_tb_order.Quatity         = quantity;
                ec_tb_order.OrderDate       = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                ec_tb_order.SalesPersonID   = StaticClass.GeneralClass.salespersonid_login_general;
                ec_tb_order.SalesPersonName = StaticClass.GeneralClass.salespersonname_login_general;

                this.Dispatcher.Invoke((Action)(() =>
                {
                    ec_tb_order.PaymentID = list_ec_payment.Find(x => x.RdoCard.IsChecked.Value == true).PaymentID;
                    ec_tb_order.PaymentName = list_ec_payment.Find(x => x.RdoCard.IsChecked.Value == true).Card;
                }));
                ec_tb_order.DiscountType  = StaticClass.GeneralClass.discounttype_general;
                ec_tb_order.Discount      = StaticClass.GeneralClass.discount_general;
                ec_tb_order.TotalDiscount = StaticClass.GeneralClass.totaldiscount_general;
                ec_tb_order.TotalTax      = StaticClass.GeneralClass.totaltaxrate_general;
                ec_tb_order.TotalAmount   = total;

                if (bus_tb_order.InsertOrder(ec_tb_order, StaticClass.GeneralClass.flag_database_type_general) == 1)
                {
                    int num_orderdetail_inserted = 0;

                    foreach (EC_tb_OrderDetail ec_tb_orderdetail in StaticClass.GeneralClass.list_ec_tb_orderdetail_general)
                    {
                        ec_tb_order.OrderID       = bus_tb_order.GetMaxOrderID("");
                        ec_tb_orderdetail.OrderID = ec_tb_order.OrderID;

                        if (bus_tb_orderdetail.InsertOrderDetail(ec_tb_orderdetail, StaticClass.GeneralClass.flag_database_type_general) == 1)
                        {
                            num_orderdetail_inserted++;

                            //update InventoryCount for Product
                            EC_tb_Product ec_tb_product = new EC_tb_Product();
                            ec_tb_product.ProductID      = ec_tb_orderdetail.ProductID;
                            ec_tb_product.InventoryCount = ec_tb_orderdetail.Qty;
                            bus_tb_product.UpdateInventoryCount(ec_tb_product);
                        }
                    }
                    //if insert orderdetai success
                    if (num_orderdetail_inserted > 0)
                    {
                        result = true;
                    }

                    //if insert orderdetail failed
                    else
                    {
                        if (bus_tb_order.DeleteOrder(ec_tb_order) == 1)
                        {
                            result = false;
                        }
                    }
                }
            }
            return(result);
        }
예제 #2
0
        private bool PayOrder()
        {
            int  quantity = StaticClass.GeneralClass.list_ec_tb_orderdetail_general.Count;
            bool result   = false;

            if (quantity > 0)
            {
                //create Order
                EC_tb_Order ec_tb_order = new EC_tb_Order();
                ec_tb_order.CustomerID      = StaticClass.GeneralClass.customerid_general;
                ec_tb_order.CustomerName    = StaticClass.GeneralClass.customername_general;
                ec_tb_order.Quatity         = quantity;
                ec_tb_order.OrderDate       = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt");
                ec_tb_order.SalesPersonID   = StaticClass.GeneralClass.salespersonid_login_general;
                ec_tb_order.SalesPersonName = StaticClass.GeneralClass.salespersonname_login_general;
                this.Dispatcher.Invoke((Action)(() =>
                {
                    ShellOutModel shellPayMent = (ShellOutModel)lstShellOut.Items[0];
                    ec_tb_order.PaymentID = Convert.ToInt16(shellPayMent.PaymentId); //paymentid;
                    ec_tb_order.PaymentName = shellPayMent.PaymentName;              //paymentname;
                }));
                ec_tb_order.DiscountType  = StaticClass.GeneralClass.discounttype_general;
                ec_tb_order.Discount      = StaticClass.GeneralClass.discount_general;
                ec_tb_order.TotalDiscount = StaticClass.GeneralClass.totaldiscount_general;
                ec_tb_order.TotalTax      = StaticClass.GeneralClass.totaltaxrate_general;
                ec_tb_order.TotalAmount   = total;

                if (bus_tb_order.InsertOrder(ec_tb_order, StaticClass.GeneralClass.flag_database_type_general) == 1)
                {
                    int num_orderdetail_inserted = 0;

                    foreach (EC_tb_OrderDetail ec_tb_orderdetail in StaticClass.GeneralClass.list_ec_tb_orderdetail_general)
                    {
                        //ec_tb_orderdetail.ID = bus_tb_orderdetail.GetMaxID("") + 1;
                        ec_tb_order.OrderID       = bus_tb_order.GetMaxOrderID("");
                        ec_tb_orderdetail.OrderID = ec_tb_order.OrderID;

                        if (bus_tb_orderdetail.InsertOrderDetail(ec_tb_orderdetail, StaticClass.GeneralClass.flag_database_type_general) == 1)
                        {
                            num_orderdetail_inserted++;

                            //update InventoryCount for Product
                            EC_tb_Product ec_tb_product = new EC_tb_Product();
                            ec_tb_product.ProductID      = ec_tb_orderdetail.ProductID;
                            ec_tb_product.InventoryCount = ec_tb_orderdetail.Qty;
                            bus_tb_product.UpdateInventoryCount(ec_tb_product);
                            ShellOutViewModel.eventSavePaymentOther(ec_tb_order.OrderID, null);
                        }
                    }
                    //if insert orderdetai success
                    if (num_orderdetail_inserted > 0)
                    {
                        result = true;
                    }

                    //if insert orderdetail failed
                    else
                    {
                        if (bus_tb_order.DeleteOrder(ec_tb_order) == 1)
                        {
                            result = false;
                        }
                    }
                }
            }
            return(result);
        }