//Thêm loại món ăn vào danh sách public Boolean InsertTable(TableDTO lst) { try { TABLES_INFO newDishType = new TABLES_INFO() { Id = Guid.NewGuid(), NAME = lst.NAME, CODE = lst.code, WAITER_ID = (from a in Context.WAITER_INFO where a.NAME == lst.WaiterName select a.Id).SingleOrDefault() }; Context.TABLES_INFO.AddObject(newDishType); Context.SaveChanges(); return true; } catch (Exception ex) { throw ex; } }
/// <summary> /// Deprecated Method for adding a new object to the TABLES_INFO EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTABLES_INFO(TABLES_INFO tABLES_INFO) { base.AddObject("TABLES_INFO", tABLES_INFO); }
/// <summary> /// Create a new TABLES_INFO object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="cODE">Initial value of the CODE property.</param> /// <param name="nAME">Initial value of the NAME property.</param> public static TABLES_INFO CreateTABLES_INFO(global::System.Guid id, global::System.Int32 cODE, global::System.String nAME) { TABLES_INFO tABLES_INFO = new TABLES_INFO(); tABLES_INFO.Id = id; tABLES_INFO.CODE = cODE; tABLES_INFO.NAME = nAME; return tABLES_INFO; }
//cap nhat 1 ban public Boolean UpdateTable(TABLES_INFO lst) { try { TABLES_INFO query = (from p in Context.TABLES_INFO where p.Id == lst.Id select p).SingleOrDefault(); query.NAME = lst.NAME; query.CODE = lst.CODE; query.WAITER_ID = lst.WAITER_ID; Context.SaveChanges(); return true; } catch (Exception ex) { throw ex; } }
//them moi 1 ban public Boolean InsertTable(TABLES_INFO lst) { try { lst.Id = Guid.NewGuid(); lst.NAME = lst.NAME; lst.CODE = lst.CODE; lst.WAITER_ID = lst.WAITER_ID; Context.TABLES_INFO.AddObject(lst); Context.SaveChanges(); Context.SaveChanges(); return true; } catch (Exception ex) { throw ex; } }
private void bananSAVEbt_Click(object sender, EventArgs e) { TABLES_INFO dt = new TABLES_INFO(); if (FormState == FormStateType.New) { dt.NAME = textBox2.Text.Trim(); dt.CODE = Convert.ToInt32(textBox3.Text); dt.WAITER_ID = rep.GetWaiterNameID(comboBox1.SelectedValue.ToString()); rep.InsertTable(dt); } else if (FormState == FormStateType.Edit) { dt.Id = PKEY; dt.NAME = textBox1.Text.Trim(); dt.CODE = Convert.ToInt32(textBox3.Text); dt.WAITER_ID = rep.GetWaiterNameID(comboBox1.SelectedText); rep.UpdateTable(dt); } FormState = FormStateType.Normal; LoadDataTable(); }