Exemplo n.º 1
0
        //InSertAllOrderDetail
        private int InSertAllOrder(DataTable tb_order)
        {
            int result = 0;

            foreach (DataRow datarow in tb_order.Rows)
            {
                if (datarow[0].ToString() != "")
                {
                    EC_tb_Order ec_tb_order = new EC_tb_Order();
                    ec_tb_order.OrderID         = Convert.ToInt32(datarow[0].ToString());
                    ec_tb_order.CustomerID      = Convert.ToInt32(datarow[1].ToString());
                    ec_tb_order.CustomerName    = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[2].ToString());
                    ec_tb_order.Quatity         = Convert.ToInt32(datarow[3].ToString());
                    ec_tb_order.OrderDate       = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[4].ToString());
                    ec_tb_order.SalesPersonID   = Convert.ToInt32(datarow[5].ToString());
                    ec_tb_order.SalesPersonName = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[6].ToString());
                    ec_tb_order.PaymentID       = Convert.ToInt32(datarow[7].ToString());
                    ec_tb_order.PaymentName     = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[8].ToString());
                    ec_tb_order.DiscountType    = Convert.ToInt32(datarow[9].ToString());
                    ec_tb_order.Discount        = Convert.ToDecimal(datarow[10].ToString());
                    ec_tb_order.TotalDiscount   = Convert.ToDecimal(datarow[11].ToString());
                    ec_tb_order.TotalTax        = Convert.ToDecimal(datarow[12].ToString());
                    ec_tb_order.TotalAmount     = Convert.ToDecimal(datarow[13].ToString());

                    if (bus_tb_order.InsertOrder(ec_tb_order, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        result++;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        //muiBtnOK_Click
        private void muiBtnOK_Click(object sender, RoutedEventArgs e)
        {
            if (StaticClass.GeneralClass.list_ec_tb_order_general.Count == 0)
            {
                tblNotification.Text = FindResource("select_least_order").ToString();
            }
            else
            {
                if (thread_delete != null && thread_delete.ThreadState == ThreadState.Running)
                {
                }
                else
                {
                    thread_delete = new Thread(() =>
                    {
                        try
                        {
                            int result_order       = 0;
                            int result_orderdetail = 0;

                            for (int i = 0; i < StaticClass.GeneralClass.list_ec_tb_order_general.Count; i++)
                            {
                                EC_tb_Order ec_tb_order = new EC_tb_Order();
                                ec_tb_order.OrderID     = StaticClass.GeneralClass.list_ec_tb_order_general[i].OrderID;
                                if (bus_tb_order.DeleteOrder(ec_tb_order) == 1)
                                {
                                    result_order++;
                                    if (bus_tb_orderdetail.DeleteAllOrderDetail("WHERE [OrderID]=" + StaticClass.GeneralClass.list_ec_tb_order_general[i].OrderID) > 0)
                                    {
                                        result_orderdetail++;
                                    }
                                }
                            }

                            if (result_order == result_orderdetail)
                            {
                                StaticClass.GeneralClass.flag_check_delete_order_orderdetail = true;
                                StaticClass.GeneralClass.list_ec_tb_order_general.Clear();
                                if (btndelete_delegate != null)
                                {
                                    btndelete_delegate(true);
                                    this.Dispatcher.Invoke((Action)(() => { this.Close(); }));
                                }
                            }
                            else
                            {
                                this.tblNotification.Dispatcher.Invoke((Action)(() => { this.tblNotification.Text = FindResource("error_delete").ToString(); }));
                            }
                        }
                        catch (Exception ex)
                        {
                            this.tblNotification.Dispatcher.Invoke((Action)(() => { this.tblNotification.Text = ex.Message; }));
                        }
                    });
                    thread_delete.Start();
                }
            }
        }
Exemplo n.º 3
0
        //updater Order
        public int UpdateOrder(EC_tb_Order ec_tb_ord, bool data_type)
        {
            string sql = "";

            if (!data_type)
            {
                sql = "UPDATE [tb_Order] SET [CustomerID] = " + ec_tb_ord.CustomerID + ", [CustomerName] = '" + ec_tb_ord.CustomerName + "',[Quantity] =" + ec_tb_ord.Quatity + ",[OrderDate] ='" + ec_tb_ord.OrderDate +
                      "', [SalespersonID] = " + ec_tb_ord.SalesPersonID + ", [SalespersonName] ='" + ec_tb_ord.SalesPersonName + "', [PaymentID] = " + ec_tb_ord.PaymentID + ", [PaymentName] = '" + ec_tb_ord.PaymentName +
                      "',[DiscountType]=" + ec_tb_ord.DiscountType + ",[Discount] = " + ec_tb_ord.Discount.ToString(new CultureInfo("en-US")) + ",[TotalDiscount]=" + ec_tb_ord.TotalDiscount.ToString(new CultureInfo("en-US")) + ",[TotalTax] = " + ec_tb_ord.TotalTax.ToString(new CultureInfo("en-US")) + ",[TotalAmount] = " + ec_tb_ord.TotalAmount.ToString(new CultureInfo("en-US")) + " WHERE [OrderID] = " + ec_tb_ord.OrderID;
            }
            else
            {
                sql = "UPDATE [tb_Order] SET [CustomerID] = " + ec_tb_ord.CustomerID + ", [CustomerName] = N'" + ec_tb_ord.CustomerName + "', [Quantity] = " + ec_tb_ord.Quatity + ", [OrderDate] = N'" + ec_tb_ord.OrderDate +
                      "', [SalespersonID] = " + ec_tb_ord.SalesPersonID + ", [SalespersonName] = N'" + ec_tb_ord.SalesPersonName + "', [PaymentID] = " + ec_tb_ord.PaymentID + ", [PaymentName] = N'" + ec_tb_ord.PaymentName +
                      "', [DiscountType] = " + ec_tb_ord.DiscountType + ", [Discount] = " + ec_tb_ord.Discount.ToString(new CultureInfo("en-US")) + ", [TotalDiscount] = " + ec_tb_ord.TotalDiscount.ToString(new CultureInfo("en-US")) + ", [TotalTax] = " + ec_tb_ord.TotalTax.ToString(new CultureInfo("en-US")) + ",[TotalAmount] = " + ec_tb_ord.TotalAmount.ToString(new CultureInfo("en-US")) + " WHERE [OrderID] = " + ec_tb_ord.OrderID;
            }
            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemplo n.º 4
0
        //insert Order
        public int InsertOrder(EC_tb_Order ec_tb_ord, bool data_type)
        {
            string sql = "";

            if (!data_type)
            {
                sql = "INSERT INTO [tb_Order]([CustomerID],[CustomerName],[Quantity],[OrderDate],[SalespersonID],[SalespersonName],[PaymentID],[PaymentName],[DiscountType],[Discount],[TotalDiscount],[TotalTax],[TotalAmount]) VALUES(" +
                      ec_tb_ord.CustomerID + ",'" + ec_tb_ord.CustomerName + "'," + ec_tb_ord.Quatity + ",'" + ec_tb_ord.OrderDate + "'," + ec_tb_ord.SalesPersonID + ",'" + ec_tb_ord.SalesPersonName + "'," +
                      ec_tb_ord.PaymentID + ",'" + ec_tb_ord.PaymentName + "'," + ec_tb_ord.DiscountType + "," + ec_tb_ord.Discount.ToString(new CultureInfo("en-US")) + "," + ec_tb_ord.TotalDiscount.ToString(new CultureInfo("en-US")) + "," + ec_tb_ord.TotalTax.ToString(new CultureInfo("en-US")) + "," + ec_tb_ord.TotalAmount.ToString(new CultureInfo("en-US")) + ")";
            }
            else
            {
                sql = "INSERT INTO [tb_Order]([CustomerID],[CustomerName],[Quantity],[OrderDate],[SalespersonID],[SalespersonName],[PaymentID],[PaymentName],[DiscountType],[Discount],[TotalDiscount],[TotalTax],[TotalAmount]) VALUES(" +
                      ec_tb_ord.CustomerID + ", N'" + ec_tb_ord.CustomerName + "', " + ec_tb_ord.Quatity + ", N'" + ec_tb_ord.OrderDate + "', " + ec_tb_ord.SalesPersonID + ", N'" + ec_tb_ord.SalesPersonName + "', " +
                      ec_tb_ord.PaymentID + ", N'" + ec_tb_ord.PaymentName + "', " + ec_tb_ord.DiscountType + ", " + ec_tb_ord.Discount.ToString(new CultureInfo("en-US")) + ", " + ec_tb_ord.TotalDiscount.ToString(new CultureInfo("en-US")) + ", " + ec_tb_ord.TotalTax.ToString(new CultureInfo("en-US")) + "," + ec_tb_ord.TotalAmount.ToString(new CultureInfo("en-US")) + ")";
            }
            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        private void GetOrders(int be_limit, int af_limit, string _con1, string _con2)
        {
            if (thread_order != null && thread_order.ThreadState == ThreadState.Running)
            {
            }
            else
            {
                thread_order = new Thread(() =>
                {
                    try
                    {
                        list_ec_tb_order.Clear();

                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            this.chkAll.IsChecked = false;
                            this.mpr.Visibility = System.Windows.Visibility.Visible;
                            this.mpr.IsActive = true;
                            this.dtgOrders.Visibility = System.Windows.Visibility.Hidden;
                            dtgOrders.Items.Refresh();
                        }));

                        dt_orders.Clear();
                        int no = paging_number_previous - 1;

                        using (dt_orders = bus_tb_order.GetOrderFollowPaging(be_limit, af_limit, _con1, _con2, StaticClass.GeneralClass.flag_database_type_general))
                        {
                            foreach (DataRow dr in dt_orders.Rows)
                            {
                                _orderDate = string.Format(@"{0:" + StaticClass.GeneralClass.dateFromatSettings[StaticClass.GeneralClass.app_settings["dateFormat"]].ToString() + _orderTime + "}", Convert.ToDateTime(dr["OrderDate"].ToString()));
                                no++;
                                EC_tb_Order ec_tb_order     = new EC_tb_Order();
                                ec_tb_order.No              = no;
                                ec_tb_order.OrderID         = Convert.ToInt32(dr["OrderID"].ToString());
                                ec_tb_order.CustomerID      = Convert.ToInt32(dr["CustomerID"].ToString());
                                ec_tb_order.CustomerName    = dr["CustomerName"].ToString();
                                ec_tb_order.Quatity         = Convert.ToInt32(dr["Quantity"].ToString());
                                ec_tb_order.OrderDate       = _orderDate; //dr["OrderDate"].ToString();
                                ec_tb_order.SalesPersonID   = Convert.ToInt32(dr["SalespersonID"].ToString());
                                ec_tb_order.SalesPersonName = dr["SalespersonName"].ToString();
                                ec_tb_order.PaymentID       = Convert.ToInt32(dr["PaymentID"].ToString());
                                ec_tb_order.PaymentName     = dr["PaymentName"].ToString();
                                ec_tb_order.DiscountType    = Convert.ToInt32(dr["DiscountType"].ToString());
                                if (ec_tb_order.DiscountType == 1)
                                {
                                    ec_tb_order.DisAmount  = "";
                                    ec_tb_order.DisPercent = "%";
                                }
                                else
                                {
                                    ec_tb_order.DisAmount  = StaticClass.GeneralClass.currency_setting_general;
                                    ec_tb_order.DisPercent = "";
                                }
                                ec_tb_order.Discount    = Convert.ToDecimal(dr["Discount"].ToString());
                                ec_tb_order.StrDiscount = StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.Discount);

                                ec_tb_order.TotalDiscount    = Convert.ToDecimal(string.IsNullOrEmpty(dr["TotalDiscount"].ToString()) ? "0" : dr["TotalDiscount"].ToString());
                                ec_tb_order.StrTotalDiscount = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.TotalDiscount);

                                ec_tb_order.TotalTax    = Convert.ToDecimal(dr["TotalTax"].ToString());
                                ec_tb_order.StrTotalTax = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.TotalTax);

                                ec_tb_order.TotalAmount    = Convert.ToDecimal(dr["TotalAmount"].ToString());
                                ec_tb_order.StrTotalAmount = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_order.TotalAmount);

                                ec_tb_order.ImageSource = @"pack://application:,,,/Resources/ViewDetails.png";
                                ec_tb_order.CheckDel    = false;
                                ec_tb_order.Currency    = StaticClass.GeneralClass.currency_setting_general;

                                list_ec_tb_order.Add(ec_tb_order);
                            }
                        }

                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            tblTotal.Text = FindResource("total").ToString() + "(" + list_ec_tb_order.Count.ToString() + ")";
                            dtgOrders.Items.Refresh();
                        }));

                        Thread.Sleep(500);

                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            this.mpr.Visibility = System.Windows.Visibility.Hidden;
                            this.mpr.IsActive = false;
                            this.dtgOrders.Visibility = System.Windows.Visibility.Visible;
                        }));

                        //data statistic
                        DataStatistic();

                        //set condition report order
                        if (StaticClass.GeneralClass.flag_database_type_general == false)
                        {
                            StaticClass.GeneralClass.condition_report_order = "select * from [tb_Order] " + _con1 + " limit " + be_limit + ", " + af_limit;
                        }
                        else
                        {
                            StaticClass.GeneralClass.condition_report_order = "select top(" + af_limit + ") * from [tb_Order] where [OrderID] not in (select top(" + be_limit + ") [OrderID] from [tb_Order] " + _con1 + ") " + _con2;
                        }
                    }
                    catch (Exception ex)
                    {
                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            ModernDialog md = new ModernDialog();
                            md.CloseButton.Content = FindResource("close").ToString();
                            md.Title = FindResource("notification").ToString();
                            md.Content = ex.Message;
                            md.ShowDialog();
                        }));
                    }
                });
                thread_order.Start();
            }
        }
Exemplo n.º 7
0
        //delete Order
        public int DeleteOrder(EC_tb_Order ec_tb_ord)
        {
            string sql = "DELETE FROM [tb_Order] WHERE [OrderID]=" + ec_tb_ord.OrderID;

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemplo n.º 8
0
        //muiBtnOK_Click
        private void muiBtnOK_Click(object sender, RoutedEventArgs e)
        {
            if (StaticClass.GeneralClass.list_ec_tb_orderdetail_general.Count == 0)
            {
                tblNotification.Text = FindResource("select_least_order_detail").ToString();
                return;
            }
            else
            {
                try
                {
                    int orderdetail_qty_root = bus_tb_orderdetail.GetOrderDetail("WHERE [OrderID] = " + StaticClass.GeneralClass.orderdetailid_general).Rows.Count;
                    int result = 0;

                    for (int i = 0; i < StaticClass.GeneralClass.list_ec_tb_orderdetail_general.Count; i++)
                    {
                        EC_tb_OrderDetail ec_tb_orderdetail = new EC_tb_OrderDetail();
                        ec_tb_orderdetail.OrderID   = StaticClass.GeneralClass.list_ec_tb_orderdetail_general[i].OrderID;
                        ec_tb_orderdetail.ProductID = StaticClass.GeneralClass.list_ec_tb_orderdetail_general[i].ProductID;
                        //ec_tb_orderdetail.InputID = StaticClass.GeneralClass.list_ec_tb_orderdetail_general[i].InputID;

                        if (bus_tb_orderdetail.DeleteOrderDetail(ec_tb_orderdetail) == 1)
                        {
                            result++;
                        }
                    }

                    if (result == orderdetail_qty_root)
                    {
                        EC_tb_Order ec_tb_order = new EC_tb_Order();
                        ec_tb_order.OrderID = StaticClass.GeneralClass.orderdetailid_general;
                        if (bus_tb_order.DeleteOrder(ec_tb_order) == 1)
                        {
                        }
                        else
                        {
                            tblNotification.Text = FindResource("cannot_delete_order").ToString();
                            return;
                        }
                    }


                    //update table order
                    if ((result > 0) && (result < orderdetail_qty_root))
                    {
                        DataTable dt_tb_order       = bus_tb_order.GetOrder("WHERE [OrderID] = " + StaticClass.GeneralClass.orderdetailid_general);
                        DataTable dt_tb_orderdetail = bus_tb_orderdetail.GetOrderDetail("WHERE [OrderID] = " + StaticClass.GeneralClass.orderdetailid_general);
                        int       quantity          = 0;
                        decimal   total_tax         = 0;
                        decimal   total             = 0;
                        decimal   total_discount    = 0;
                        decimal   total_amount      = 0;

                        foreach (DataRow datarow in dt_tb_orderdetail.Rows)
                        {
                            quantity  += Convert.ToInt32(datarow["Qty"].ToString());
                            total_tax += Convert.ToDecimal(datarow["Tax"].ToString());
                            total     += Convert.ToDecimal(datarow["Total"].ToString());
                        }

                        if (Convert.ToInt32(dt_tb_order.Rows[0]["DiscountType"].ToString()) == 1)
                        {
                            total_discount = Convert.ToDecimal(dt_tb_order.Rows[0]["Discount"].ToString()) * total / 100;
                        }
                        else
                        {
                            total_discount = Convert.ToDecimal(dt_tb_order.Rows[0]["Discount"].ToString());
                        }

                        total_amount = total - total_discount + total_tax;

                        EC_tb_Order ec_tb_order = new EC_tb_Order();
                        ec_tb_order.OrderID         = Convert.ToInt32(dt_tb_order.Rows[0]["OrderID"].ToString());
                        ec_tb_order.CustomerID      = Convert.ToInt32(dt_tb_order.Rows[0]["CustomerID"].ToString());
                        ec_tb_order.CustomerName    = dt_tb_order.Rows[0]["CustomerName"].ToString();
                        ec_tb_order.Quatity         = quantity;
                        ec_tb_order.OrderDate       = dt_tb_order.Rows[0]["OrderDate"].ToString();
                        ec_tb_order.SalesPersonID   = Convert.ToInt32(dt_tb_order.Rows[0]["SalespersonID"].ToString());
                        ec_tb_order.SalesPersonName = dt_tb_order.Rows[0]["SalespersonName"].ToString();
                        ec_tb_order.PaymentID       = Convert.ToInt32(dt_tb_order.Rows[0]["PaymentID"].ToString());
                        ec_tb_order.PaymentName     = dt_tb_order.Rows[0]["PaymentName"].ToString();
                        ec_tb_order.DiscountType    = Convert.ToInt32(dt_tb_order.Rows[0]["DiscountType"].ToString());
                        ec_tb_order.Discount        = Convert.ToDecimal(dt_tb_order.Rows[0]["Discount"].ToString());
                        ec_tb_order.TotalDiscount   = total_discount;
                        ec_tb_order.TotalTax        = total_tax;
                        ec_tb_order.TotalAmount     = total_amount;

                        bus_tb_order.UpdateOrder(ec_tb_order, StaticClass.GeneralClass.flag_database_type_general);
                    }

                    if (btndelete_delegate != null)
                    {
                        StaticClass.GeneralClass.flag_check_delete_order_orderdetail = true;

                        StaticClass.GeneralClass.list_ec_tb_orderdetail_general.Clear();
                        btndelete_delegate(true);
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    tblNotification.Text = ex.Message;
                }
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
 //delete Order
 public int DeleteOrder(EC_tb_Order ec_tb_ord)
 {
     return(sql_tb_ord.DeleteOrder(ec_tb_ord));
 }
Exemplo n.º 11
0
 //update Order
 public int UpdateOrder(EC_tb_Order ec_tb_ord, bool data_type)
 {
     return(sql_tb_ord.UpdateOrder(ec_tb_ord, data_type));
 }
Exemplo n.º 12
0
 //insert Order
 public int InsertOrder(EC_tb_Order ec_tb_ord, bool data_type)
 {
     return(sql_tb_ord.InsertOrder(ec_tb_ord, data_type));
 }