public bool SaveCatalogInstrumentalSearch(lwg_CatalogInstrumentSearch lwg) { if (lwg != null && lwg.CatalogId > 0 && !string.IsNullOrEmpty(lwg.IntrText)) { if (dbContext.lwg_CatalogInstrumentSearch.Any(lc => lc.CatalogId == lwg.CatalogId)) { lwg_CatalogInstrumentSearch cis = dbContext.lwg_CatalogInstrumentSearch.Where(lc => lc.CatalogId == lwg.CatalogId).FirstOrDefault(); cis.IntrText = lwg.IntrText; } else { lwg_CatalogInstrumentSearch cis = new lwg_CatalogInstrumentSearch(); if (dbContext.lwg_CatalogInstrumentSearch.Count() > 0) { cis.Id = dbContext.lwg_CatalogInstrumentSearch.OrderByDescending(lc => lc.Id).First().Id + 1; } else { cis.Id = 1; } cis.CatalogId = lwg.CatalogId; cis.IntrText = lwg.IntrText; dbContext.lwg_CatalogInstrumentSearch.Add(cis); } dbContext.SaveChanges(); return(true); } return(false); }
public string GetInstrSearchByCatalogID(int catalogID) { lwg_CatalogInstrumentSearch lg = dbContext.lwg_CatalogInstrumentSearch.Where(lw => lw.CatalogId == catalogID).FirstOrDefault(); if (lg != null) { return(lg.IntrText); } return(string.Empty); }
public bool DeleteCatalogInstrumentalSearch(int id) { lwg_CatalogInstrumentSearch cis = dbContext.lwg_CatalogInstrumentSearch.SingleOrDefault(c => c.Id == id); if (cis != null) { dbContext.lwg_CatalogInstrumentSearch.Remove(cis); dbContext.SaveChanges(); return(true); } return(false); }
public void SaveCatalogLWG() { Page.Validate("AddEdit"); if (Page.IsValid) { CatalogBiz pBiz = new CatalogBiz(); Product product = ProductManager.GetProductById(ProductId); lwg_Catalog p = pBiz.GetByID(ProductId); if (p == null) { p = new lwg_Catalog(); p.CatalogId = ProductId; lblNote.Text = "Insert error, please try again"; } else { lblNote.Text = "Update error, please try again"; } if (p != null) { // insert data p.CatalogNumber = txtCatalogNumber.Text; p.Duration = txtDuration.Text.TrimStart().TrimEnd(); // "Duration1"; if (!string.IsNullOrEmpty(txtGrade.Text)) { p.Grade = txtGrade.Text; } if (drpInstrumental.Items.Count > 0 && !drpInstrumental.SelectedValue.Equals("-1")) { p.InstrumentalId = int.Parse(drpInstrumental.SelectedValue); } p.KaldbNumber = txtKaldbNumber.Text;// "Kalddbnumber1"; p.pages = txtPages.Text; string tempPDF = string.Empty; string strPDF = SavePDFFile(uploadPDF, ref tempPDF); if (string.IsNullOrEmpty(tempPDF)) { LWGUtils.ClearOldFile(string.Format("{0}{1}", LWGUtils.GetPDFPath(), p.PDF)); p.PDF = strPDF; //TODO: change to uploadfile control } p.PDF = p.PDF == null ? string.Empty : p.PDF; p.Subtitle = txtSubTitle.Text; p.TextLang = txtTextLang.Text; // replace YearTo, YearFrom by Year p.Year = txtYear.Text.Trim(); p.CopyrightYear = txtCopyrightYear.Text.Trim(); p.InstrDetail = txtInstrDetail.Text.TrimStart().TrimEnd(); p.VocAccomp = chkVocAccomp.Checked; p.TableofContents = txtTableofContents.Content; if (string.IsNullOrEmpty(p.SoundIcon)) { p.SoundIcon = string.Empty; } //Save Catalog if (pBiz.SaveCatalog(p)) { // save publisher, genre,... pBiz.SaveCatalogPublisher(p.CatalogId, int.Parse(drpCatalogPublisher.SelectedValue)); if (!string.IsNullOrEmpty(txtCatalogInstrSearch.Text)) { lwg_CatalogInstrumentSearch lwg = new lwg_CatalogInstrumentSearch(); lwg.CatalogId = p.CatalogId; lwg.IntrText = txtCatalogInstrSearch.Text; pBiz.SaveCatalogInstrumentalSearch(lwg); } if (!string.IsNullOrEmpty(txtCatalogNameSearch.Text)) { lwg_CatalogNameSearch lwg = new lwg_CatalogNameSearch(); lwg.CatalogId = p.CatalogId; lwg.Name = txtCatalogNameSearch.Text; pBiz.SaveCatalogNameSearch(lwg); } lblNote.Text = "Save success!"; //ClearData(); } } lblNote.Visible = true; } }