public bool SavePeriodMappingByID(lwg_PeriodMapping lwg) { if (lwg != null && !dbContext.lwg_PeriodMapping.Any(o => o.PeriodID == lwg.PeriodID && o.CatalogID == lwg.CatalogID)) { dbContext.lwg_PeriodMapping.Add(lwg); dbContext.SaveChanges(); return(true); } return(false); }
public bool DeletePeriodMappingBuyID(int periodID, int productID) { lwg_PeriodMapping lwg = dbContext.lwg_PeriodMapping.SingleOrDefault(o => o.PeriodID == periodID && o.CatalogID == productID); if (lwg != null) { dbContext.lwg_PeriodMapping.Add(lwg); dbContext.SaveChanges(); return(true); } return(false); }
protected void btnPeriodAdd_Click(object sender, EventArgs e) { PeriodBiz pBiz = new PeriodBiz(); lwg_PeriodMapping lwg = new lwg_PeriodMapping(); lwg.CatalogID = ProductId; lwg.PeriodID = int.Parse(drpPeriod.SelectedValue); if (pBiz.SavePeriodMappingByID(lwg)) { BindingPeriod(); } //TODO: save fail }
protected void grdPeriod_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.DataItem == null) { return; } lwg_PeriodMapping lg = (lwg_PeriodMapping)e.Row.DataItem; if (lg != null) { Literal ltrProductDisplay = (Literal)e.Row.FindControl("ltrProductDisplay"); ltrProductDisplay.Text = lg.lwg_Catalog.TitleDisplay; Literal ltrPeriodName = (Literal)e.Row.FindControl("ltrPeriodName"); ltrPeriodName.Text = lg.lwg_Period.Name; LinkButton lnkbtnRemove = (LinkButton)e.Row.FindControl("lnkbtnRemove"); lnkbtnRemove.CommandArgument = lg.PeriodID.ToString(); } }
public bool CheckAndInsertPeriod(string periodName, int catalogID) { lwg_Period lwg = dbContext.lwg_Period.SingleOrDefault(o => o.Name.ToLower().Equals(periodName.ToLower())); if (lwg == null) { lwg = new lwg_Period(); lwg.Name = periodName; SavePeriod(lwg); } if (!dbContext.lwg_PeriodMapping.Any(o => o.CatalogID == catalogID && o.PeriodID == lwg.PeriodId)) { lwg_PeriodMapping periodMapping = new lwg_PeriodMapping(); periodMapping.PeriodID = lwg.PeriodId; periodMapping.CatalogID = catalogID; dbContext.lwg_PeriodMapping.Add(periodMapping); dbContext.SaveChanges(); return(true); } return(false); }