Exemplo n.º 1
0
        //public static void SUBMIT_EXPIRY(string MASTER_EXPIRY_TRANSACTION_ID)
        //{
        //    //string Master_Transaction_ID = MASTER_TRANSACTION_ID;

        //    string Master_Expiry_Transaction_ID = MASTER_EXPIRY_TRANSACTION_ID;

        //    PUYODataContext a = new PUYODataContext();

        //    foreach (EXPIRATION_TRANSACTION EXPIRED_ITEM in EXPIRATION_TRANSACTIONS)
        //    {
        //        string Product_Name_Single = EXPIRED_ITEM.PRODUCT_NAME;

        //        var Get_Product_ID = from Product_Get in a.Products
        //                             where Product_Get.Product_Name.Equals(Product_Name_Single)
        //                             select Product_Get.Product_ID;

        //        string Product_ID_Single = Get_Product_ID.First().ToString();

        //        string Price_Single = EXPIRED_ITEM.PRODUCT_PRICE.ToString();

        //        string Product_Quantity_Single = EXPIRED_ITEM.PRODUCT_QUANTITY.ToString();

        //        string Total_Price_Single = EXPIRED_ITEM.TOTAL_COST.ToString();

        //        string Expiry_ID;

        //        var Get_Last_Expiry = from Expiry_Transaction in a.Expiries
        //                              orderby Expiry_Transaction.Expiry_ID descending
        //                              select Expiry_Transaction.Expiry_ID;

        //        int Count_Expiries = Get_Last_Expiry.Count();

        //        if (Count_Expiries == 0)
        //        {
        //            Expiry_ID = "EI00001";
        //        }
        //        else
        //        {
        //            var Get_Last_Expiry_ID = Get_Last_Expiry.First().ToString();
        //            string New_Expiry_ID = ID_PADDING(Get_Last_Expiry_ID);
        //            Expiry_ID = New_Expiry_ID;
        //        }

        //        var Get_Product_Stock = from Product_Get in a.Products
        //                                where Product_Get.Product_Name.Equals(Product_Name_Single)
        //                                select Product_Get.Product_Stock;

        //        int Get_Product_Stock_INT = int.Parse(Get_Product_Stock.First().ToString());

        //        Product Update_Product_Stock = a.Products.FirstOrDefault(Productstock => Productstock.Product_ID.Equals(Product_ID_Single));
        //        Update_Product_Stock.Product_Stock = Get_Product_Stock_INT - EXPIRED_ITEM.PRODUCT_QUANTITY;

        //        //Submit to the cashier first

        //        Expiry New_Expiry = new Expiry();
        //        New_Expiry.Master_Expiry_ID = MASTER_EXPIRY_TRANSACTION_ID;
        //        New_Expiry.Product_ID = Product_ID_Single;
        //        New_Expiry.Quantity = Convert.ToInt32(Product_Quantity_Single);
        //        New_Expiry.Expiry_ID = Expiry_ID;
        //        New_Expiry.Total_Cost = Convert.ToInt32(Total_Price_Single);

        //        a.Expiries.InsertOnSubmit(New_Expiry);
        //        a.SubmitChanges();

        //        //Then submit to the warehouse

        //        PUYOWAREHOUSEDataContext b = new PUYOWAREHOUSEDataContext();

        //        Warehouse_Expiry New_Warehouse_Expiry = new Warehouse_Expiry();
        //        New_Warehouse_Expiry.Master_Expiry_ID = MASTER_EXPIRY_TRANSACTION_ID;
        //        New_Warehouse_Expiry.Product_ID = Product_ID_Single;
        //        New_Warehouse_Expiry.Quantity = Convert.ToInt32(Product_Quantity_Single);
        //        New_Warehouse_Expiry.Expiry_ID = Expiry_ID;
        //        New_Warehouse_Expiry.Total_Cost = Convert.ToInt32(Total_Price_Single);

        //        b.Warehouse_Expiries.InsertOnSubmit(New_Warehouse_Expiry);
        //        b.SubmitChanges();
        //    }

        //}

        public static void SUBMIT_RESTOCKING()
        {
            PUYODataContext a = new PUYODataContext();

            // Loop through all the rows in the data grid view and prepare to submit the data
            foreach (RESTOCKING_TRANSACTION RESTOCKING_ITEM in RESTROCKING_TRANSACTIONS)
            {
                string Product_Name_Single = RESTOCKING_ITEM.PRODUCT_NAME;

                var Get_Product_Id = from Product_Get in a.Products
                                     where Product_Get.Product_Name.Equals(Product_Name_Single)
                                     select Product_Get.Product_ID;

                string Product_ID_Single = Get_Product_Id.First().ToString();

                int Added_Stock = RESTOCKING_ITEM.PRODUCT_QUANTITY_ADDED;

                var Get_Product_Stock = from Product_Get in a.Products
                                        where Product_Get.Product_Name.Equals(Product_Name_Single)
                                        select Product_Get.Product_Stock;

                int Get_Product_Stock_INT = int.Parse(Get_Product_Stock.First().ToString());

                Product Update_Product_Stock = a.Products.FirstOrDefault(ProductStock => ProductStock.Product_ID.Equals(Product_ID_Single));

                Update_Product_Stock.Product_Stock = Get_Product_Stock_INT + RESTOCKING_ITEM.PRODUCT_QUANTITY_ADDED;

                a.SubmitChanges();
            }
            RESTROCKING_TRANSACTIONS.Clear();
        }
Exemplo n.º 2
0
        public static string GET_MASTER_TRANSACTION_ID()
        {
            //The Transaction_Type can be 'expired' and 'sold'

            PUYODataContext a = new PUYODataContext();

            string Master_Transaction_ID;

            var Get_Last_Master_Transaction = from Master_Transaction in a.Master_Transactions
                                              orderby Master_Transaction.Master_Transaction_ID descending
                                              select Master_Transaction.Master_Transaction_ID;

            int Count_Master_Transaction = Get_Last_Master_Transaction.Count();

            if (Count_Master_Transaction == 0)
            {
                Master_Transaction_ID = "MT00001";
            }
            else
            {
                var    Get_Last_Master_Transaction_ID = Get_Last_Master_Transaction.First().ToString();
                string New_Master_Transaction_ID      = ID_PADDING(Get_Last_Master_Transaction_ID);
                Master_Transaction_ID = New_Master_Transaction_ID;
            }

            DateTime Now_Date = DateTime.Now;

            Master_Transaction New_Master_Transaction = new Master_Transaction();

            New_Master_Transaction.Master_Transaction_ID   = Master_Transaction_ID;
            New_Master_Transaction.Master_Transaction_Date = Now_Date;

            a.Master_Transactions.InsertOnSubmit(New_Master_Transaction);
            a.SubmitChanges();

            return(Master_Transaction_ID);
        }
Exemplo n.º 3
0
        //public static int GET_EXPIRY_SUM()
        //{
        //    int sum = 0;

        //    foreach (EXPIRATION_TRANSACTION EXPIRED_ITEM in EXPIRATION_TRANSACTIONS)
        //    {
        //        sum += EXPIRED_ITEM.TOTAL_COST;
        //    }

        //    return sum;
        //}

        public static void SUBMIT_TRANSACTION(string MASTER_TRANSACTION_ID, string DATA_TYPE)
        {
            string Master_Transaction_ID = MASTER_TRANSACTION_ID;

            PUYODataContext a = new PUYODataContext();

            // Loop through all the rows in the data grid view and prepare to submit the data
            foreach (POS_TRANSACTION TRANSACTION_ITEM in POS_TRANSACTIONS)
            {
                //This is the data of the name of the product
                string Product_Name_Single = TRANSACTION_ITEM.PRODUCT_NAME;

                var Get_Product_ID = from Product_Get in a.Products
                                     where Product_Get.Product_Name.Equals(Product_Name_Single)
                                     select Product_Get.Product_ID;

                string Product_ID_Single = Get_Product_ID.First().ToString();

                //This is the data of the price of the product
                string Price_Single = TRANSACTION_ITEM.PRODUCT_PRICE.ToString();

                //This is the data of the quantity of the product
                string Product_Quantity_Single = TRANSACTION_ITEM.PRODUCT_QUANTITY.ToString();

                //This is the data of the total price of the product
                string Total_Price_Single = TRANSACTION_ITEM.TOTAL_PRICE.ToString();

                string Transaction_ID;

                var Get_Last_Transaction = from Transaction in a.Transactions
                                           orderby Transaction.Transaction_ID descending
                                           select Transaction.Transaction_ID;

                int Count_Transaction = Get_Last_Transaction.Count();

                if (Count_Transaction == 0)
                {
                    Transaction_ID = "TI00001";
                }
                else
                {
                    var    Get_Last_Transaction_ID = Get_Last_Transaction.First().ToString();
                    string New_Transaction_ID      = ID_PADDING(Get_Last_Transaction_ID);
                    Transaction_ID = New_Transaction_ID;
                }

                //Reduce the stock from the master_product database
                var Get_Product_Stock = from Product_Get in a.Products
                                        where Product_Get.Product_Name.Equals(Product_Name_Single)
                                        select Product_Get.Product_Stock;

                int Get_Product_Stock_INT = int.Parse(Get_Product_Stock.First().ToString());

                Product Update_Product_Stock = a.Products.FirstOrDefault(ProductStock => ProductStock.Product_ID.Equals(Product_ID_Single));
                Update_Product_Stock.Product_Stock = Get_Product_Stock_INT - TRANSACTION_ITEM.PRODUCT_QUANTITY;

                //Submitting to the database
                Transaction New_Transaction = new Transaction();
                New_Transaction.Master_Transaction_ID = Master_Transaction_ID;
                New_Transaction.Product_ID            = Product_ID_Single;
                New_Transaction.Quantity       = Convert.ToInt32(Product_Quantity_Single);
                New_Transaction.Transaction_ID = Transaction_ID;
                New_Transaction.Total_Price    = Convert.ToInt32(Total_Price_Single);
                New_Transaction.Status         = DATA_TYPE;

                a.Transactions.InsertOnSubmit(New_Transaction);
                a.SubmitChanges();
            }
            POS_TRANSACTIONS.Clear();
        }