public static DataTable GetInvetoryPeriodByWarehouse(int warehouseId)
 {
     string query = HCMIS.Repository.Queries.InventoryPeriod.SelectGetInvetoryPeriodByWarehouse(warehouseId);
         InventoryPeriod period = new InventoryPeriod();
         period.LoadFromRawSql(query);
         return period.DataTable;
 }
Example #2
0
        public static bool HasUnCommited(int periodID, int activityID)
        {
            InventoryPeriod period = new InventoryPeriod();
            string          query  = HCMIS.Repository.Queries.InventoryPeriod.SelectHasUnCommited(periodID, activityID);

            period.LoadFromRawSql(query);
            return(period.Getint("Count") > 0);
        }
Example #3
0
        public static DataTable GetInventoryPeriodDatesByWareHouse(int WarehouseID)
        {
            string          query  = HCMIS.Repository.Queries.InventoryPeriod.SelectGetInventoryPeriodDatesByWareHouse(WarehouseID);
            InventoryPeriod period = new InventoryPeriod();

            period.LoadFromRawSql(query);
            return(period.DataTable);
        }
Example #4
0
        internal static bool HasInCompleteReceives(int activityID, int physicalStoreID)
        {
            InventoryPeriod period = new InventoryPeriod();
            string          query  = HCMIS.Repository.Queries.InventoryPeriod.SelectHasInCompleteReceives(activityID, physicalStoreID, ReceiptConfirmationStatus.Constants.GRV_PRINTED);

            period.LoadFromRawSql(query);
            return(period.Getint("Count") > 0);
        }
Example #5
0
        public static DataTable GetInvetoryPeriods()
        {
            string query =
                HCMIS.Repository.Queries.InventoryPeriod.SelectGetInvetoryPeriods();
            InventoryPeriod period = new InventoryPeriod();

            period.LoadFromRawSql(query);
            return(period.DataTable);
        }
        public InventoryPeriod AddInventoryPeriod()
        {
            var inventoryPeriod = new InventoryPeriod();

            inventoryPeriod.AddNew();
            inventoryPeriod.PhysicalStoreID = this.ID;
            //ToDo: Remove hardCore
            inventoryPeriod.InventoryStatusID = BLL.InventoryStatus.Constants.DraftInventorySaved;
            inventoryPeriod.StartDate         = FiscalYear.Current.StartDate;
            inventoryPeriod.EndDate           = FiscalYear.Current.EndDate;
            inventoryPeriod.Remark            = "First Inventory";
            inventoryPeriod.FiscalYearID      = FiscalYear.Current.ID;
            inventoryPeriod.Save();
            return(inventoryPeriod);
        }
        public static void CommitInventory(int periodId, int activityId, int physicalStoreId, DateTime ethiopianDate, int userId, BackgroundWorker backgroundWorker)
        {
            Inventory inventory = new Inventory();

            if (!InventoryPeriod.HasUnCommited(periodId, activityId))
            {
                throw new Exception("This inventory has been commited already,you are not allow to commit again.");
            }
            if (InventoryPeriod.HasInCompleteReceives(activityId, physicalStoreId))
            {
                throw new Exception("There are incompleted receives,you can only processed after canceling the receives.");
            }
            inventory.LoadByStoreAndActivity(activityId, physicalStoreId, periodId);

            try
            {
                var physicalStore = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreId);
                inventory.InitializeCommit(userId, physicalStore.PhysicalStoreTypeID);

                inventory.Rewind();
                int count = 0;
                while (!inventory.EOF)
                {
                    string itemDetail = inventory.GetColumn("FullItemName") + " - " + inventory.GetColumn("ManufacturerName")
                                        + " - " + inventory.GetColumn("Unit") + " - " + inventory.GetColumn("ExpiryDate")
                                        + " - " + inventory.GetColumn("BatchNo");



                    if (inventory.IsColumnNull("IsDraft") || inventory.IsDraft)
                    {
                        inventory.Commit(ethiopianDate, backgroundWorker);
                    }

                    inventory.MoveNext();
                    count++;
                    backgroundWorker.ReportProgress(count, itemDetail);
                }

                inventory.FinishCommit();
            }
            catch (Exception exception)
            {
                inventory.CancelCommit(exception);
            }
        }
Example #8
0
 public static DataTable GetInvetoryPeriods(int physicalStoreId, int?Status = null)
 {
     if (Status == null)
     {
         string          query  = HCMIS.Repository.Queries.InventoryPeriod.GetInvetoryPeriods(physicalStoreId);
         InventoryPeriod period = new InventoryPeriod();
         period.LoadFromRawSql(query);
         return(period.DataTable);
     }
     else
     {
         string          query  = HCMIS.Repository.Queries.InventoryPeriod.SelectGetInvetoryPeriods(physicalStoreId, Status);
         InventoryPeriod period = new InventoryPeriod();
         period.LoadFromRawSql(query);
         return(period.DataTable);
     }
 }
        public static DataTable GetInvetoryPeriods(int physicalStoreId,int? Status=null)
        {
            if (Status == null)
            {

                string query = HCMIS.Repository.Queries.InventoryPeriod.GetInvetoryPeriods(physicalStoreId);
                InventoryPeriod period = new InventoryPeriod();
                period.LoadFromRawSql(query);
                return period.DataTable;
            }
            else
            {
                string query = HCMIS.Repository.Queries.InventoryPeriod.SelectGetInvetoryPeriods(physicalStoreId, Status);
                InventoryPeriod period = new InventoryPeriod();
                period.LoadFromRawSql(query);
                return period.DataTable;

            }
        }
        private void startbgWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                // Add the inventory details.
                // For each Activity, populate the inventory.
                //ToDO: this grid reading in a non ui thread is dangerous
                //please don't do it this way.
                transactionMgr.BeginTransaction();
                int physicalStoreID = Convert.ToInt32(gridManageInvetoryView.GetFocusedDataRow()["ID"]);
                PhysicalStore physicalStore = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreID);

                DateTime startDate = dtStartInventory.Value;
                if (!physicalStore.IsColumnNull("CurrentInventoryPeriodID"))
                {
                // create the inventory period
                InventoryPeriod oldPeriod = new InventoryPeriod();
                oldPeriod.LoadByPrimaryKey(physicalStore.CurrentInventoryPeriodID);
                oldPeriod.EndDate = dtStartInventory.Value;
                oldPeriod.Save();
                }
                InventoryPeriod period = new InventoryPeriod();
                period.AddNew();
                period.InventoryStatusID = InventoryPeriod.Constants.BEGIN_INVENTORY;
                period.PhysicalStoreID = physicalStoreID;
                period.StartDate = dtStartInventory.Value;
                period.EndDate = FiscalYear.Current.EndDate;
                period.StartedBy = CurrentContext.UserId;
                period.FiscalYearID = FiscalYear.Current.ID;
                if (memoEdit1.EditValue != null)
                {
                    period.Remark = memoEdit1.EditValue.ToString();
                }

                period.Save();
                //ChangePhysicalStoreToCurrentPeriod

                physicalStore = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreID);
                physicalStore.CurrentInventoryPeriodID = period.ID;
                physicalStore.CurrentPeriodStartDate = period.StartDate;
                physicalStore.Save();

                Activity activity = new Activity();
                activity.LoadAll();
                int activityIndex = 1;
                while (!activity.EOF)
                {
                    // report that this activity is being processed.
                    startbgWorker.ReportProgress(activityIndex++, "Activity: " + activity.FullActivityName);

                    DataTable dtbl = Balance.GetBalanceByPhysicalStore(physicalStoreID, activity.ID, false);
                    decimal total = dtbl.Rows.Count;
                    decimal i = 0;
                    foreach (DataRow dr in dtbl.Rows)
                    {

                        Inventory inv = new Inventory();
                        inv.AddNew();

                        inv.IsDraft = true;
                        inv.PhysicalStoreID = physicalStoreID;
                        inv.RecordedBy = CurrentContext.UserId;
                        inv.RecordedDate = BLL.DateTimeHelper.ServerDateTime;

                        inv.InventoryPeriodID = period.ID;
                        inv.ItemID = Convert.ToInt32(dr["ID"]);
                        inv.UnitID = Convert.ToInt32(dr["UnitID"]);
                        inv.ActivityID = activity.ID;
                        inv.ManufacturerID = Convert.ToInt32(dr["ManufacturerID"]);
                        inv.SetColumn("BatchNo", dr["BatchNo"]);
                        inv.SetColumn("ExpiryDate", dr["ExpDate"]);
                        if (!inv.IsColumnNull("ExpiryDate") && inv.ExpiryDate < BLL.DateTimeHelper.ServerDateTime)
                        {
                            inv.SystemExpiredQuantity = Convert.ToDecimal(dr["SoundSOH"]);
                        }
                        else
                        {
                            inv.SystemSoundQuantity = Convert.ToDecimal(dr["SoundSOH"]);
                        }

                        inv.SystemDamagedQuantity = Convert.ToDecimal(dr["DamagedSOH"]);
                        inv.SetColumn("Cost", dr["Cost"]);
                        inv.Margin = dr["Margin"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["Margin"]);
                        inv.SetColumn("PalletLocationID", dr["PalletLocationID"]);
                        inv.Save();

                        startbgWorker.ReportProgress(Convert.ToInt32((i / total) * 100), "Detail");
                        //inventory
                        i++;
                    }

                    activity.MoveNext();
                }
                transactionMgr.CommitTransaction();
                XtraMessageBox.Show("The new Inventory Period has been defined.");
            }
            catch (Exception exception)
            {
                transactionMgr.RollbackTransaction();
                XtraMessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public static bool HasUnCommited(int periodID, int activityID)
 {
     InventoryPeriod period = new InventoryPeriod();
     string query = HCMIS.Repository.Queries.InventoryPeriod.SelectHasUnCommited(periodID, activityID);
     period.LoadFromRawSql(query);
     return period.Getint("Count") > 0;
 }
 internal static bool HasInCompleteReceives(int activityID,int physicalStoreID)
 {
     InventoryPeriod period = new InventoryPeriod();
     string query = HCMIS.Repository.Queries.InventoryPeriod.SelectHasInCompleteReceives(activityID, physicalStoreID, ReceiptConfirmationStatus.Constants.GRV_PRINTED);
     period.LoadFromRawSql(query);
     return period.Getint("Count") > 0;
 }
 public InventoryPeriod AddInventoryPeriod()
 {
     var inventoryPeriod = new InventoryPeriod();
     inventoryPeriod.AddNew();
     inventoryPeriod.PhysicalStoreID = this.ID;
     //ToDo: Remove hardCore
     inventoryPeriod.InventoryStatusID = BLL.InventoryStatus.Constants.DraftInventorySaved;
     inventoryPeriod.StartDate = FiscalYear.Current.StartDate;
     inventoryPeriod.EndDate = FiscalYear.Current.EndDate;
     inventoryPeriod.Remark = "First Inventory";
     inventoryPeriod.FiscalYearID = FiscalYear.Current.ID;
     inventoryPeriod.Save();
     return inventoryPeriod;
 }