private static InventoryPeriod getEntityByModel(InventoryPeriodModel model) { if (model == null) { return(null); } InventoryPeriod entity = new InventoryPeriod(); if (model.Id == 0) { entity.CompanyId = AuthenticationHelper.CompanyId.Value; entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; } else { entity.CompanyId = model.CompanyId; entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; } entity.CalendarId = model.CalendarId; entity.Id = model.Id; entity.SOBId = model.SOBId; entity.Status = model.Status; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return(entity); }
private void lkStockCardWarehouse_EditValueChanged(object sender, EventArgs e) { if (lkStockCardWarehouse.EditValue != null) { int warehouse = Convert.ToInt32(lkStockCardWarehouse.EditValue); lkStockArchivePeriod.Properties.DataSource = InventoryPeriod.GetInventoryPeriodDatesByWareHouse(warehouse); } }
private void LoadManageInventory() { lkAccountType.SetupActivityEditor().SetDefaultActivity(); lkInventoryAccount.SetupActivityEditor().SetDefaultActivity(); lkInventoryStore.SetupAllowedPhysicalStores().SetDefaultPhysicalStore(); lkPhysicalStore.SetupAllowedPhysicalStores().SetDefaultPhysicalStore(); gridManageInventory.DataSource = InventoryPeriod.GetInvetoryPeriods(); }
public InventoryPeriod GetSingle(string id, long companyId) { long longId = Convert.ToInt64(id); InventoryPeriod inventoryPeriod = this.GetAll(companyId) .FirstOrDefault(x => x.Id == longId); return(inventoryPeriod); }
private void lkWarehouse_EditValueChanged(object sender, EventArgs e) { if (lkAccount.EditValue != null && lkCategories.EditValue != null) { gridMain.DataSource = BLL.Receipt.GetInventoryListByAccountandWarehouse(Convert.ToInt32(lkAccount.EditValue), Convert.ToInt32(lkWarehouse.EditValue), Convert.ToInt32(lkCategories.EditValue)); lkPeriod.Properties.DataSource = InventoryPeriod.GetInvetoryPeriodByWarehouse(Convert.ToInt32(lkWarehouse.EditValue)); } }
public string Update(InventoryPeriod entity) { var originalEntity = this.Context.InventoryPeriods.Find(entity.Id); this.Context.Entry(originalEntity).CurrentValues.SetValues(entity); this.Context.Entry(originalEntity).State = EntityState.Modified; this.Commit(); return(entity.Id.ToString()); }
public string Update(InventoryPeriod entity) { if (entity.IsValid()) { return(this.repository.Update(entity)); } else { return("Entity is not in valid state"); } }
private void lkInventoryStore_EditValueChanged(object sender, EventArgs e) { if (lkInventoryStore.EditValue != null && lkInventoryStore.EditValue != "" && lkAccount.EditValue != null) { lkPeriod.Properties.DataSource = InventoryPeriod.GetInvetoryPeriods(Convert.ToInt32(lkInventoryStore.EditValue)); } else { lkPeriod.Properties.DataSource = null; } }
public InventoryPeriodModel(InventoryPeriod entity) { this.Id = entity.Id; this.SOBId = entity.SOBId; this.Status = entity.Status; this.CalendarId = entity.CalendarId; this.CompanyId = entity.CompanyId; this.CreateBy = entity.CreateBy; this.CreateDate = entity.CreateDate; this.UpdateBy = entity.UpdateBy; this.UpdateDate = entity.UpdateDate; }
private void btnFinalPrintout_Click(object sender, EventArgs e) { int periodId = Convert.ToInt32(lkPeriod.EditValue); int activityID = Convert.ToInt32(lkInventoryAccount.EditValue); int physicalStoreID = Convert.ToInt32(lkInventoryStore.EditValue); PhysicalStore physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(physicalStoreID); try { if (InventoryPeriod.HasUnCommited(periodId, activityID)) { throw new Exception("This inventory has not been commited yet,you are not allow to print before"); } DevExpress.XtraReports.UI.XtraReport xreport; DateTimePickerEx dtDate = new DateTimePickerEx(); dtDate.Value = DateTimeHelper.ServerDateTime; if (Settings.LocalvsTender) { xreport = new HCMIS.Desktop.Reports.InventoryCountSheetLocalTender(CurrentContext.LoggedInUserName); (xreport as HCMIS.Desktop.Reports.InventoryCountSheetLocalTender).Date.Text = dtDate.Text; } else { xreport = new HCMIS.Desktop.Reports.InventoryCountSheet(CurrentContext.LoggedInUserName); (xreport as HCMIS.Desktop.Reports.InventoryCountSheet).Date.Text = dtDate.Text; } xreport.DataSource = BLL.Receipt.GetInventoryCountbyInventoryPeriodID(periodId, physicalStoreID, activityID); xreport.ShowPreview(); } catch (Exception exp) { XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 string Insert(InventoryPeriod entity) { this.Context.InventoryPeriods.Add(entity); this.Commit(); return(entity.Id.ToString()); }