コード例 #1
0
        private void ADD_DATA_TO_GRID()
        {
            PUYODataContext a = new PUYODataContext();

            var productPriceQuery = from Product_Price in a.Products
                                    where Product_Price.Barcode_Number.Equals(Barcode_Text.Text)
                                    select Product_Price.Product_Price;

            string productPrice = productPriceQuery.First().ToString();

            int productPriceINT = Convert.ToInt32(productPrice);

            int productQuantityINT;

            if (Barcode_Quantity_Text.Text.Equals(""))
            {
                productQuantityINT = 1;
            }
            else
            {
                productQuantityINT = Convert.ToInt32(Barcode_Quantity_Text.Text);
            }

            int totalINT = productPriceINT * productQuantityINT;

            var productNameQuery = from Product_2 in a.Products
                                   where Product_2.Barcode_Number.Equals(Barcode_Text.Text)
                                   select Product_2.Product_Name;

            string productName = productNameQuery.First().ToString();

            ADD_DATA(productName, productPriceINT, productQuantityINT, totalINT);
        }
コード例 #2
0
        private void Add_Data_Button_Click(object sender, EventArgs e)
        {
            PUYODataContext a = new PUYODataContext();

            string productName = Product_Name_Combo.Text;

            var productPriceQuery = from Product in a.Products
                                    where Product.Product_Name.Equals(productName)
                                    select Product.Product_Price;

            string productPrice = productPriceQuery.First().ToString();

            int productPriceINT = Convert.ToInt32(productPrice);

            int productQuantityINT;

            if (Quantity_Text.Text.Equals(""))
            {
                productQuantityINT = 1;
            }
            else
            {
                productQuantityINT = Convert.ToInt32(Quantity_Text.Text);
            }

            int totalINT = productPriceINT * productQuantityINT;

            ADD_DATA(productName, productPriceINT, productQuantityINT, totalINT);
        }
コード例 #3
0
        private void ADD_BARCODE_DATA()
        {
            PUYODataContext a = new PUYODataContext();

            string barcode = Barcode_Text.Text;

            var productNameQuery = from Product in a.Products
                                   where Product.Barcode_Number.Equals(Barcode_Text.Text)
                                   select Product.Product_Name;

            string productName = productNameQuery.First().ToString();

            var productPriceQuery = from Product in a.Products
                                    where Product.Barcode_Number.Equals(Barcode_Text.Text)
                                    select Product.Product_Price;

            string productPrice = productPriceQuery.First().ToString();

            int productPriceINT = Convert.ToInt32(productPrice);

            int productQuantityINT;

            if (Barcode_Quantity_Text.Text.Equals(""))
            {
                productQuantityINT = 1;
            }
            else
            {
                productQuantityINT = Convert.ToInt32(Barcode_Quantity_Text.Text);
            }

            ADD_DATA(productName, productQuantityINT);
        }
コード例 #4
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();
        }
コード例 #5
0
        public ADD_STOCK()
        {
            InitializeComponent();

            PUYODataContext a = new PUYODataContext();
            var             productTypeQuery = from Product_Type in a.Product_Types
                                               select Product_Type.Product_Type_Name;

            Product_Type_Combo.DataSource    = productTypeQuery;
            Product_Type_Combo.DisplayMember = "Product_Type_Name";

            var productName = from Product in a.Products
                              where Product.Product_Type_ID.Equals("PT00001")
                              select Product.Product_Name;

            Product_Name_Combo.DataSource    = productName;
            Product_Name_Combo.DisplayMember = "Product_Name";

            dataGridView1.ColumnCount     = 2;
            dataGridView1.Columns[0].Name = "Product_Name";
            dataGridView1.Columns[1].Name = "Product_Quantity";

            DataGridViewButtonColumn deleteButtonColumn = new DataGridViewButtonColumn();

            deleteButtonColumn.Name = "Delete_Product";

            deleteButtonColumn.UseColumnTextForButtonValue = true;
            deleteButtonColumn.Text = "Delete";

            dataGridView1.Columns.Add(deleteButtonColumn);

            REFRESH_STOCKDATA();
        }
コード例 #6
0
        public DATA_SUBMISSION()
        {
            InitializeComponent();

            string Now_Date = DateTime.Now.ToShortDateString();

            label3.Text = Now_Date;

            PUYODataContext a = new PUYODataContext();

            var dataquery = from Transactions in a.Transactions
                            join Master_Transactions in a.Master_Transactions on Transactions.Master_Transaction_ID equals Master_Transactions.Master_Transaction_ID
                            where Master_Transactions.Master_Transaction_Date.Equals(Now_Date)
                            select new { Master_Transactions.Master_Transaction_Date, Transactions.Master_Transaction_ID, Transactions.Transaction_ID, Transactions.Product_ID, Transactions.Quantity, Transactions.Total_Price, Transactions.Status };

            dataGridView1.DataSource = dataquery;

            PUYOWAREHOUSEDataContext b = new PUYOWAREHOUSEDataContext();

            var stores = from Stores in b.Warehouse_Stores
                         select Stores.Store_ID;

            Store_Combo.DataSource    = stores;
            Store_Combo.DisplayMember = "Store_ID";
        }
コード例 #7
0
        private void REFRESH_STOCKDATA()
        {
            PUYODataContext a = new PUYODataContext();
            var             productStockGet = from products in a.Products
                                              select new { products.Product_ID, products.Product_Name, products.Product_Stock };

            StockData.DataSource = productStockGet;
        }
コード例 #8
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            PUYODataContext a = new PUYODataContext();
            string          ProductTypeName = Product_Type_Combo.Text;
            var             typeProduct     = from Product_Type in a.Product_Types
                                              where Product_Type.Product_Type_Name.Equals(ProductTypeName)
                                              select Product_Type.Product_Type_ID;
            string typeID = typeProduct.First().ToString();

            var productName = from Product in a.Products
                              where Product.Product_Type_ID.Equals(typeID)
                              select Product.Product_Name;

            Product_Name_Combo.DataSource    = productName;
            Product_Name_Combo.DisplayMember = "Product_Name";
        }
コード例 #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (Date_Text.Text.Equals(""))
            {
                Date_Text.Text = DateTime.Now.ToShortDateString();
            }

            string Now_Date = DateTime.Now.ToShortDateString();

            label3.Text = Now_Date;

            PUYODataContext a         = new PUYODataContext();
            var             dataquery = from Transactions in a.Transactions
                                        join Master_Transactions in a.Master_Transactions on Transactions.Master_Transaction_ID equals Master_Transactions.Master_Transaction_ID
                                        where Master_Transactions.Master_Transaction_Date.Equals(Date_Text.Text)
                                        select new { Master_Transactions.Master_Transaction_Date, Transactions.Master_Transaction_ID, Transactions.Transaction_ID, Transactions.Product_ID, Transactions.Quantity, Transactions.Total_Price, Transactions.Status };

            dataGridView1.DataSource = dataquery;
        }
コード例 #10
0
        public EXPIRY_FORM()
        {
            InitializeComponent();

            this.KeyPreview = true;

            this.KeyPreview = true;

            PUYODataContext a = new PUYODataContext();
            var             productTypeQuery = from Product_Type in a.Product_Types
                                               select Product_Type.Product_Type_Name;

            Product_Type_Combo.DataSource    = productTypeQuery;
            Product_Type_Combo.DisplayMember = "Product_Type_Name";

            var productName = from Product in a.Products
                              where Product.Product_Type_ID.Equals("PT00001")
                              select Product.Product_Name;

            Product_Name_Combo.DataSource    = productName;
            Product_Name_Combo.DisplayMember = "Product_Name";

            TransactionData.ColumnCount     = 4;
            TransactionData.Columns[0].Name = "Product_Name";
            TransactionData.Columns[1].Name = "Price";
            TransactionData.Columns[2].Name = "Product_Qty";
            TransactionData.Columns[3].Name = "Total";

            DataGridViewButtonColumn deleteButtonColumn = new DataGridViewButtonColumn();

            deleteButtonColumn.Name = "Delete_Product";

            deleteButtonColumn.UseColumnTextForButtonValue = true;
            deleteButtonColumn.Text = "Delete";

            TransactionData.Columns.Add(deleteButtonColumn);

            REFRESH_STOCKDATA();
        }
コード例 #11
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);
        }
コード例 #12
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();
        }