/// <summary> /// Generates the matrix for A new user. /// </summary> /// <param name="userID">The user ID.</param> public void GenerateMatrixForANewUser(int userID) { BLL.Activity store = new Activity(); store.LoadAll(); while (!store.EOF) { BLL.UserActivity usrStore = new UserActivity(); usrStore.AddNew(); usrStore.UserID = userID; usrStore.ActivityID = store.ID; usrStore.CanAccess = false; usrStore.IsDefault = false; usrStore.Save(); store.MoveNext(); } }
/// <summary> /// Renews the matrix for A user. /// </summary> /// <param name="userID">The user ID.</param> public void RenewMatrixForAUser(int userID) { BLL.Activity store = new Activity(); store.LoadAll(); while (!store.EOF) { BLL.UserActivity usrStore = new UserActivity(); this.LoadByUserAndStoreID(userID,store.ID); if (this.RowCount == 0) { usrStore.AddNew(); usrStore.UserID = userID; usrStore.ActivityID = store.ID; usrStore.CanAccess = false; usrStore.IsDefault = false; usrStore.Save(); } store.MoveNext(); } }
/// <summary> /// The code supports manufacturer preference here too but we choose not to prefer manufacturers when looking into the stores. /// </summary> /// <param name="userID"></param> /// <param name="orderDetailID"></param> /// <param name="pricedUnpricedBoth"></param> /// <param name="bal"> </param> /// <param name="markStockoutBit"> </param> /// <param name="usableStock"> </param> /// <param name="approved"> </param> public decimal LoadOptionsForOrderDetail(int userID, int orderDetailID, PriceSettings pricedUnpricedBoth, Balance bal, bool markStockoutBit, out decimal usableStock, out decimal approved) { decimal avQuantity = 0; BLL.OrderDetail orderDetail = new OrderDetail(); orderDetail.LoadByPrimaryKey(orderDetailID); BLL.Order order = new Order(); order.LoadByPrimaryKey(orderDetail.OrderID); Institution ru = new Institution(); ru.LoadByPrimaryKey(order.RequestedBy); int month = EthiopianDate.EthiopianDate.Now.Month; int year = EthiopianDate.EthiopianDate.Now.Year; decimal availableQty = 0; usableStock = 0; approved = 0; int? manufacturerPrefrence = null, unitID = null; if (!orderDetail.IsColumnNull("PreferredManufacturerID")) { manufacturerPrefrence = orderDetail.PreferredManufacturerID; } DateTime? expPreferrence = null; if(!orderDetail.IsColumnNull("PreferredExpiryDate")) { expPreferrence = orderDetail.PreferredExpiryDate; } int? preferredPhysicalStoreID = null; if (!orderDetail.IsColumnNull("PreferredPhysicalStoreID")) { preferredPhysicalStoreID = orderDetail.PreferredPhysicalStoreID; } //-------------------------------------------------------------------------- //manufacturerPrefrence = null; //We are overriding the manufacturer preference. //expPreferrence = null; //-------------------------------------------------------------------------- if (!orderDetail.IsColumnNull("UnitID")) { unitID = orderDetail.UnitID; } BLL.UserActivity userStore = new UserActivity(); // Definitely a danger zone userStore.LoadByUserIDAndStoreType(userID, order.FromStore, orderDetail.ItemID, unitID.Value); while (!userStore.EOF) { var activity = new Activity(); activity.LoadByPrimaryKey(userStore.ActivityID); if(order.FromStore == Mode.Constants.RDF && !BLL.Settings.IsCenter && !BLL.Settings.PrivateCanGetFromMDGAndPBS && ru.Ownership == OwnershipType.Constants.Private && activity.IsSubsidized ){ userStore.MoveNext(); continue; } // Load the Activity Selection that has PRiced Commodities. Balance balance = new Balance(); if (pricedUnpricedBoth == PriceSettings.PRICED_ONLY || pricedUnpricedBoth == PriceSettings.BOTH) { BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.PRICED_ONLY, orderDetail, userStore.ActivityID, orderDetail.ItemID, order, balance, unitID, manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved, out availableQty, markStockoutBit); avQuantity += availableQty; if (availableQty > 0) { this.AddNew(); this.ID = userStore.ActivityID; this.Name = string.Format("{0} ({1})", activity.FullActivityName, availableQty.ToString("#,##0")); PrepareColumnsForApproval(); this.SetColumn("AvailableSKU", availableQty); this.SetColumn("IsDeliveryNote", false); this.SetColumn("TextID",string.Format("N{0}",this.ID)); } } // Load Activity Selections for Delivery Note Items. if (pricedUnpricedBoth == PriceSettings.DELIVERY_NOTE_ONLY || pricedUnpricedBoth == PriceSettings.BOTH) { BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.DELIVERY_NOTE_ONLY, orderDetail, userStore.ActivityID, orderDetail.ItemID, order, balance, unitID, manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved, out availableQty, markStockoutBit); avQuantity += availableQty; if (availableQty > 0) { this.AddNew(); this.ID = userStore.ActivityID; //Just to give it a different ID so we know there is a change only. this.Name = string.Format("+-- {0} - Delivery Notes - ({1})", userStore.GetColumn("ActivityName"), availableQty.ToString("#,##0")); PrepareColumnsForApproval(); this.SetColumn("AvailableSKU", availableQty); this.SetColumn("IsDeliveryNote", true); this.SetColumn("TextID", string.Format("D{0}", this.ID)); } } userStore.MoveNext(); } return avQuantity; }
private void repositoryItemCheckEditIsDefault_CheckedChanged(object sender, EventArgs e) { DataRow dr = gridViewUserStoreMatrix.GetFocusedDataRow(); int ID = int.Parse(dr["ID"].ToString()); BLL.UserActivity userStore = new UserActivity(); userStore.LoadByPrimaryKey(ID); userStore.MakeDefault(); RefreshUserStoreGrid(userStore.UserID); }
private void RefreshUserStoreGrid(int userID) { BLL.Activity stores=new Activity(); stores.LoadAll(); BLL.UserActivity userStore = new UserActivity(); userStore.LoadByUserID(userID); if (userStore.RowCount == 0) { BLL.UserActivity usrStore = new UserActivity(); usrStore.GenerateMatrixForANewUser(userID); RefreshUserStoreGrid(userID); } else if (userStore.RowCount == stores.RowCount) { grdUserStoreMatrix.DataSource = userStore.DefaultView; lcUserStoreMatrix.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; } else { BLL.UserActivity usrStore = new UserActivity(); usrStore.RenewMatrixForAUser(userID); RefreshUserStoreGrid(userID); } }
/// <summary> /// The code supports manufacturer preference here too but we choose not to prefer manufacturers when looking into the stores. /// </summary> /// <param name="userID"></param> /// <param name="orderDetailID"></param> /// <param name="pricedUnpricedBoth"></param> /// <param name="bal"> </param> /// <param name="markStockoutBit"> </param> /// <param name="usableStock"> </param> /// <param name="approved"> </param> public decimal LoadOptionsForOrderDetail(int userID, int orderDetailID, PriceSettings pricedUnpricedBoth, Balance bal, bool markStockoutBit, out decimal usableStock, out decimal approved) { decimal avQuantity = 0; BLL.OrderDetail orderDetail = new OrderDetail(); orderDetail.LoadByPrimaryKey(orderDetailID); BLL.Order order = new Order(); order.LoadByPrimaryKey(orderDetail.OrderID); Institution ru = new Institution(); ru.LoadByPrimaryKey(order.RequestedBy); int month = EthiopianDate.EthiopianDate.Now.Month; int year = EthiopianDate.EthiopianDate.Now.Year; decimal availableQty = 0; usableStock = 0; approved = 0; int?manufacturerPrefrence = null, unitID = null; if (!orderDetail.IsColumnNull("PreferredManufacturerID")) { manufacturerPrefrence = orderDetail.PreferredManufacturerID; } DateTime?expPreferrence = null; if (!orderDetail.IsColumnNull("PreferredExpiryDate")) { expPreferrence = orderDetail.PreferredExpiryDate; } int?preferredPhysicalStoreID = null; if (!orderDetail.IsColumnNull("PreferredPhysicalStoreID")) { preferredPhysicalStoreID = orderDetail.PreferredPhysicalStoreID; } //-------------------------------------------------------------------------- //manufacturerPrefrence = null; //We are overriding the manufacturer preference. //expPreferrence = null; //-------------------------------------------------------------------------- if (!orderDetail.IsColumnNull("UnitID")) { unitID = orderDetail.UnitID; } BLL.UserActivity userStore = new UserActivity(); // Definitely a danger zone userStore.LoadByUserIDAndStoreType(userID, order.FromStore, orderDetail.ItemID, unitID.Value); while (!userStore.EOF) { var activity = new Activity(); activity.LoadByPrimaryKey(userStore.ActivityID); if (order.FromStore == Mode.Constants.RDF && !BLL.Settings.IsCenter && !BLL.Settings.PrivateCanGetFromMDGAndPBS && ru.Ownership == OwnershipType.Constants.Private && activity.IsSubsidized) { userStore.MoveNext(); continue; } // Load the Activity Selection that has PRiced Commodities. Balance balance = new Balance(); if (pricedUnpricedBoth == PriceSettings.PRICED_ONLY || pricedUnpricedBoth == PriceSettings.BOTH) { BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.PRICED_ONLY, orderDetail, userStore.ActivityID, orderDetail.ItemID, order, balance, unitID, manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved, out availableQty, markStockoutBit); avQuantity += availableQty; if (availableQty > 0) { this.AddNew(); this.ID = userStore.ActivityID; this.Name = string.Format("{0} ({1})", activity.FullActivityName, availableQty.ToString("#,##0")); PrepareColumnsForApproval(); this.SetColumn("AvailableSKU", availableQty); this.SetColumn("IsDeliveryNote", false); this.SetColumn("TextID", string.Format("N{0}", this.ID)); } } // Load Activity Selections for Delivery Note Items. if (pricedUnpricedBoth == PriceSettings.DELIVERY_NOTE_ONLY || pricedUnpricedBoth == PriceSettings.BOTH) { BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.DELIVERY_NOTE_ONLY, orderDetail, userStore.ActivityID, orderDetail.ItemID, order, balance, unitID, manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved, out availableQty, markStockoutBit); avQuantity += availableQty; if (availableQty > 0) { this.AddNew(); this.ID = userStore.ActivityID; //Just to give it a different ID so we know there is a change only. this.Name = string.Format("+-- {0} - Delivery Notes - ({1})", userStore.GetColumn("ActivityName"), availableQty.ToString("#,##0")); PrepareColumnsForApproval(); this.SetColumn("AvailableSKU", availableQty); this.SetColumn("IsDeliveryNote", true); this.SetColumn("TextID", string.Format("D{0}", this.ID)); } } userStore.MoveNext(); } return(avQuantity); }