private void btnNew_Click(object sender, EventArgs e) { int targetStore = (int)lueTargetStore.EditValue; int sourceStore = (int)lueSourceStore.EditValue; stockDetailDropdown.DataSource = StockHelper.GetStoreStocks(targetStore).Where(x => x.STOCKDETAIL_QUANTITY > 0); StockMaster stockMaster2 = new StockMaster() { STOCKMASTER_TARGETSTORE_ID = targetStore, STOCKMASTER_SOURCESTORE_ID = sourceStore, STOCKMASTER_TYPE_ID = StaticTypes.Entry, }; dbContext.StockMaster.Add(stockMaster2); dbContext.SaveChanges(); StockMaster stockMaster = new StockMaster() { STOCKMASTER_TARGETSTORE_ID = targetStore, STOCKMASTER_SOURCESTORE_ID = sourceStore, STOCKMASTER_TYPE_ID = StaticTypes.Output, STOCKMASTER_REF_ID = stockMaster2.ID, STOCKMASTER_REF_LINK = "StockMaster" }; dbContext.StockMaster.Add(stockMaster); dbContext.SaveChanges(); _stockMasterId = stockMaster.ID; _stockMasterIdEntry = stockMaster2.ID; lueTargetStore.Enabled = false; lueSourceStore.Enabled = false; gControlDetail.Enabled = true; }
private void LoadData() { foreach (var entity in dbContext.ChangeTracker.Entries()) { entity.Reload(); } var project = dbContext.Project.Find(_projectId); activeStockDetailBindingSource.DataSource = StockHelper.GetStoreStocks(project.Company.COMPANY_STORE_ID.Value); stockDetailBindingSource.DataSource = dbContext.StockDetail.Where(x => x.STOCKDETAIL_MASTER_ID == _stockMasterId).ToList(); }
public stck0004(int stockMasterId = 0) { InitializeComponent(); _stockMasterId = stockMasterId; if (_stockMasterId > 0) { LoadData(); var stockMaster = dbContext.StockMaster.Find(_stockMasterId); lueSourceStore.EditValue = stockMaster.STOCKMASTER_SOURCESTORE_ID; lueTargetStore.EditValue = stockMaster.STOCKMASTER_TARGETSTORE_ID; stockDetailDropdown.DataSource = StockHelper.GetStoreStocks(stockMaster.STOCKMASTER_TARGETSTORE_ID).Where(x => x.STOCKDETAIL_QUANTITY > 0); gControlMaster.Enabled = false; } else { gControlDetail.Enabled = false; } targetStoreBindingSource.DataSource = dbContext.ParameterDetail.Where(x => x.PARAMETERDETAIL_MASTER_ID == StaticTypes.Store).ToList(); sourceStoreBindingSource.DataSource = dbContext.ParameterDetail.Where(x => x.PARAMETERDETAIL_MASTER_ID == StaticTypes.Store).ToList(); }