protected void Button1_Click(object sender, EventArgs e) { if (txtHeader.InnerText != string.Empty && txtDescription.InnerText != string.Empty) { KitchenOnMyPlate.Menu newObject = new KitchenOnMyPlate.Menu(); newObject.Header = txtHeader.InnerText.Replace("$BR$", "<br/>");; newObject.Detail = txtDescription.InnerText.Replace("$BR$", "<br/>"); newObject.HeaderCus = txtHeaderDesc.InnerText.Replace("$BR$", "<br/>");; newObject.DetailCus = txtDescriptionCus.InnerText.Replace("$BR$", "<br/>");; newObject.ShowInBoth = (chkTiff.Checked && chkCust.Checked) ? "B" : chkTiff.Checked ? "N" : "C"; newObject.Picture = hdnImageNws.Value; //newObject.Date = DateTime.Now; newObject.IsActive = Convert.ToInt32(drpActive.SelectedValue); if (hdnID.Value != "" && hdnID.Value != "0") { newObject.Id = Convert.ToInt32(hdnID.Value); } CMSActivieies.SaveProduct(newObject); BindGrid(); txtHeader.InnerText = ""; txtDescription.InnerText = ""; lblMsg.Text = ""; Reset(); CacheHelper.Clear("Menu"); } else { lblMsg.Text = "Fill all fields"; } }
public static void SaveProduct(Menu obj) { using (DBKOMPDataContext db = new DBKOMPDataContext()) { if (obj.Id == 0) { db.Menus.InsertOnSubmit(obj); } else { KitchenOnMyPlate.Menu objUpdated = db.Menus.Where(p => (p.Id == obj.Id)).First(); objUpdated.Header = obj.Header; objUpdated.Detail = obj.Detail; objUpdated.IsActive = obj.IsActive; } db.SubmitChanges(); db.Dispose(); CacheHelper.Clear("Menu"); } }