internal void LoadForInventory(Inventory inventory) { DateTime?expiryDate = null; if (!inventory.IsColumnNull("ExpiryDate")) { expiryDate = inventory.ExpiryDate; } string batchNo = ""; if (!inventory.IsColumnNull("BatchNo")) { batchNo = inventory.BatchNo; } string query = HCMIS.Repository.Queries.ReceivePallet.SelectLoadForInventory(batchNo, expiryDate, inventory.ItemID, inventory.UnitID, inventory.ManufacturerID, inventory.ActivityID, inventory.PhysicalStoreID); this.LoadFromRawSql(query); }
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); } }
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); } }
public static void CommitSingle(int inventoryId,DateTime ethiopianDate,int userId) { Inventory inventory = new Inventory(); inventory.LoadByPrimaryKey(inventoryId); if(!inventory.IsColumnNull("isDraft") && !inventory.IsDraft) { throw new Exception("This inventory has been commited already,you are not allow to commit again."); } try { var physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(inventory.PhysicalStoreID); inventory.InitializeCommit(userId,physicalStore.PhysicalStoreTypeID); inventory.Commit(ethiopianDate); inventory.FinishCommit(); } catch (Exception exp) { inventory.CancelCommit(exp); } }
public static void CommitSingle(int inventoryId, DateTime ethiopianDate, int userId) { Inventory inventory = new Inventory(); inventory.LoadByPrimaryKey(inventoryId); if (!inventory.IsColumnNull("isDraft") && !inventory.IsDraft) { throw new Exception("This inventory has been commited already,you are not allow to commit again."); } try { var physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(inventory.PhysicalStoreID); inventory.InitializeCommit(userId, physicalStore.PhysicalStoreTypeID); inventory.Commit(ethiopianDate); inventory.FinishCommit(); } catch (Exception exp) { inventory.CancelCommit(exp); } }
internal void LoadForInventory(Inventory inventory) { DateTime? expiryDate = null; if(!inventory.IsColumnNull("ExpiryDate")) { expiryDate = inventory.ExpiryDate; } string batchNo = ""; if(!inventory.IsColumnNull("BatchNo")) { batchNo = inventory.BatchNo; } string query = HCMIS.Repository.Queries.ReceivePallet.SelectLoadForInventory(batchNo, expiryDate, inventory.ItemID, inventory.UnitID, inventory.ManufacturerID, inventory.ActivityID, inventory.PhysicalStoreID); this.LoadFromRawSql(query); }
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); } }