Exemple #1
0
        //insert Product
        public int InsertProduct(EC_tb_Product ec_tb_pro, bool data_type)
        {
            string sql = "";

            if (!data_type)
            {
                sql = "INSERT INTO [tb_Product]([BarcodeID],[ShortName],[LongName],[Cost],[Price],[InventoryCount],[CategoryID],[Tax],[PathImage],[Capture],[Active],[Country],[Size_Weight]) VALUES('" +
                      ec_tb_pro.BarcodeID + "','" + ec_tb_pro.ShortName + "','" + ec_tb_pro.LongName + "'," + ec_tb_pro.Cost.ToString(new CultureInfo("en-US")) + "," + ec_tb_pro.Price.ToString(new CultureInfo("en-US")) + "," + ec_tb_pro.InventoryCount + "," + ec_tb_pro.CategoryID + "," +
                      ec_tb_pro.Tax + ",'" + ec_tb_pro.PathImage + "'," + ec_tb_pro.Capture + "," + ec_tb_pro.Active + ",'" + ec_tb_pro.Country + "','" + ec_tb_pro.SizeWeight + "')";
            }
            else
            {
                sql = "INSERT INTO [tb_Product]([BarcodeID],[ShortName],[LongName],[Cost],[Price],[InventoryCount],[CategoryID],[Tax],[PathImage],[Capture],[Active],[Country],[Size_Weight]) VALUES(N'" +
                      ec_tb_pro.BarcodeID + "', N'" + ec_tb_pro.ShortName + "', N'" + ec_tb_pro.LongName + "', " + ec_tb_pro.Cost.ToString(new CultureInfo("en-US")) + ", " + ec_tb_pro.Price.ToString(new CultureInfo("en-US")) + ", " + ec_tb_pro.InventoryCount + ", " + ec_tb_pro.CategoryID + "," +
                      ec_tb_pro.Tax + ", N'" + ec_tb_pro.PathImage + "', " + ec_tb_pro.Capture + "," + ec_tb_pro.Active + ", N'" + ec_tb_pro.Country + "', N'" + ec_tb_pro.SizeWeight + "')";
            }
            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemple #2
0
        //update Product
        public int UpdateProduct(EC_tb_Product ec_tb_pro, bool data_type)
        {
            string sql = "";

            if (!data_type)
            {
                sql = "UPDATE [tb_Product] SET [ShortName] = '" + ec_tb_pro.ShortName + "', [LongName] ='" + ec_tb_pro.LongName + "', [Cost] = " + ec_tb_pro.Cost.ToString(new CultureInfo("en-US")) + ", [Price] = " + ec_tb_pro.Price.ToString(new CultureInfo("en-US")) + ", [InventoryCount] = " + ec_tb_pro.InventoryCount +
                      ",[CategoryID] =" + ec_tb_pro.CategoryID + ",[Tax] =" + ec_tb_pro.Tax + ",[PathImage] ='" + ec_tb_pro.PathImage + "', [Capture]=" + ec_tb_pro.Capture +
                      ",[Active]=" + ec_tb_pro.Active + ",[BarcodeID]='" + ec_tb_pro.BarcodeID + "', [Country] = '" + ec_tb_pro.Country + "', [Size_Weight] = '" + ec_tb_pro.SizeWeight + "' WHERE ProductID = " + ec_tb_pro.ProductID;
            }
            else
            {
                sql = "UPDATE [tb_Product] SET [ShortName] = N'" + ec_tb_pro.ShortName + "', [LongName] = N'" + ec_tb_pro.LongName + "', [Cost] = " + ec_tb_pro.Cost.ToString(new CultureInfo("en-US")) + ", [Price] = " + ec_tb_pro.Price.ToString(new CultureInfo("en-US")) + ", [InventoryCount] = " + ec_tb_pro.InventoryCount +
                      ",[CategoryID] =" + ec_tb_pro.CategoryID + ", [Tax] = " + ec_tb_pro.Tax + ",[PathImage] = N'" + ec_tb_pro.PathImage + "', [Capture]= " + ec_tb_pro.Capture +
                      ", [Active]=" + ec_tb_pro.Active + ",[BarcodeID]= N'" + ec_tb_pro.BarcodeID + "', [Country] = N'" + ec_tb_pro.Country + "', [Size_Weight] = N'" + ec_tb_pro.SizeWeight + "' WHERE ProductID = " + ec_tb_pro.ProductID;
            }

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
        //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);
        }
        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);
        }
Exemple #5
0
        //delete product from CategoryID
        public int DeleteProductFromCategoryID(EC_tb_Product ec_tb_pro)
        {
            string sql = "DELETE FROM [tb_Product] WHERE [CategoryID]=" + ec_tb_pro.CategoryID;

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemple #6
0
        //delete product
        public int DeleteProduct(EC_tb_Product ec_tb_pro)
        {
            string sql = "DELETE FROM [tb_Product] WHERE ProductID=" + ec_tb_pro.ProductID;

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
Exemple #7
0
        //update InventoryCount
        public int UpdateInventoryCount(EC_tb_Product ec_tb_product)
        {
            string sql = "Update [tb_Product] set [InventoryCount] = [InventoryCount] - " + ec_tb_product.InventoryCount + " where [ProductID] = " + ec_tb_product.ProductID;

            return(ConnectionDB.ExecuteNonQuery(sql));
        }
 //delete product from CategoryID
 public int DeleteProductFromCategoryID(EC_tb_Product ec_tb_pro)
 {
     return(sql_tb_pro.DeleteProductFromCategoryID(ec_tb_pro));
 }
 //delete Product
 public int DeleteProduct(EC_tb_Product ec_tb_pro)
 {
     return(sql_tb_pro.DeleteProduct(ec_tb_pro));
 }
 //update InventoryCount
 public int UpdateInventoryCount(EC_tb_Product ec_tb_product)
 {
     return(sql_tb_pro.UpdateInventoryCount(ec_tb_product));
 }
 //update Product
 public int UpdateProduct(EC_tb_Product ec_tb_pro, bool data_type)
 {
     return(sql_tb_pro.UpdateProduct(ec_tb_pro, data_type));
 }
 //insert Product
 public int InsertProduct(EC_tb_Product ec_tb_pro, bool data_type)
 {
     return(sql_tb_pro.InsertProduct(ec_tb_pro, data_type));
 }