Exemple #1
0
        private void LoadProduct()
        {
            var product = productQtyRepository.GetAll(Store.ActiveMonth, Store.ActiveYear);

            lvwProduct.Items.Clear();

            foreach (var s in product)
            {
                PopulateProduct(s);
            }
        }
Exemple #2
0
        private void ProductQtyNewPeriod()
        {
            //cek periode baru
            int newYear  = 0;
            int newMonth = 0;

            if (Store.ActiveMonth < 12)
            {
                newYear  = Store.ActiveYear;
                newMonth = Store.ActiveMonth + 1;
            }
            else
            {
                newYear  = Store.ActiveYear + 1;
                newMonth = 1;
            }

            ProductQty productQty = new ProductQty();

            var newQty = productQtyRepository.GetAll(newMonth, newYear);

            if (newQty.Count == 0)
            {
                //cari data lama
                var oldQty = productQtyRepository.GetAll(Store.ActiveMonth, Store.ActiveYear);

                foreach (var p in oldQty)
                {
                    productQty.ActiveYear           = newYear;
                    productQty.ActiveMonth          = newMonth;
                    productQty.ProductId            = p.ProductId;
                    productQty.QtyBegin             = p.QtyEnd;
                    productQty.ValueBegin           = p.ValueEnd;
                    productQty.QtyIn                = 0;
                    productQty.PurchasePrice        = 0;
                    productQty.QtyAvailable         = 0;
                    productQty.ValueAverage         = 0;
                    productQty.ValueAvailable       = 0;
                    productQty.QtyOut               = 0;
                    productQty.SalesPrice           = 0;
                    productQty.QtyEnd               = p.QtyEnd;
                    productQty.ValueEnd             = p.ValueEnd;
                    productQty.QtyPlusCorrection    = 0;
                    productQty.QtyMinusCorrection   = 0;
                    productQty.ValuePlusCorrection  = 0;
                    productQty.ValueMinusCorrection = 0;

                    productQtyRepository.Save(productQty);
                }
            }
            else
            {
                foreach (var newQ in newQty)
                {
                    //cari data lama
                    var oldQty1 = productQtyRepository.GetByMonthAndYear(Store.ActiveMonth, Store.ActiveYear, newQ.ProductId);

                    if (oldQty1 != null)
                    {
                        productQtyRepository.UpdateQtyBegin(newMonth, newYear, oldQty1.ProductId, oldQty1.QtyEnd, oldQty1.ValueEnd);
                    }
                }
                inventoryRepository.GenerateInventory(newMonth, newYear);
            }
        }