//Thêm 1 đầu bếp vào danh sách public Boolean InsertChef(ChefDTO lst) { try { CHEF_INFO newDishType = new CHEF_INFO() { Id = Guid.NewGuid(), NAME = lst.NAME, ADDRESS = lst.ADDRESS, BIRTHDAY = lst.BIRTHDAY, PHONE = lst.PHONE }; Context.CHEF_INFO.AddObject(newDishType); Context.SaveChanges(); return true; } catch (Exception ex) { throw ex; } }
/// <summary> /// Create a new CHEF_INFO object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="nAME">Initial value of the NAME property.</param> public static CHEF_INFO CreateCHEF_INFO(global::System.Guid id, global::System.String nAME) { CHEF_INFO cHEF_INFO = new CHEF_INFO(); cHEF_INFO.Id = id; cHEF_INFO.NAME = nAME; return cHEF_INFO; }
/// <summary> /// Deprecated Method for adding a new object to the CHEF_INFO EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCHEF_INFO(CHEF_INFO cHEF_INFO) { base.AddObject("CHEF_INFO", cHEF_INFO); }
//cập nhật thông tin nhân viên public Boolean UpdateChef(CHEF_INFO lst) { try { CHEF_INFO query = (from p in Context.CHEF_INFO where p.Id == lst.Id select p).SingleOrDefault(); query.NAME = lst.NAME; query.ADDRESS = lst.ADDRESS; query.BIRTHDAY = lst.BIRTHDAY; query.PHONE = lst.PHONE; Context.SaveChanges(); return true; } catch (Exception ex) { throw ex; } }
public Boolean InsertCheft(CHEF_INFO lst) { try { lst.Id = Guid.NewGuid(); Context.CHEF_INFO.AddObject(lst); Context.SaveChanges(); return true; } catch (Exception ex) { throw ex; } }
private void button15_Click(object sender, EventArgs e) { BindDataDauBep(); SMSRepostitory rep = new SMSRepostitory(); CHEF_INFO dt = new CHEF_INFO(); if (FormState == FormBase.FormStateType.New) { dt.NAME = textBox7.Text.Trim(); dt.BIRTHDAY = dateTimePicker1.Value; dt.ADDRESS = textBox4.Text.Trim(); dt.PHONE = textBox5.Text.Trim(); rep.InsertCheft(dt); } else if (FormState == FormBase.FormStateType.Edit) { dt.Id = PKEY; dt.NAME = textBox7.Text.Trim(); dt.BIRTHDAY = dateTimePicker1.Value; dt.ADDRESS = textBox4.Text.Trim(); dt.PHONE = textBox5.Text.Trim(); rep.UpdateChef(dt); } FormState = FormBase.FormStateType.Normal; LoadDataDauBep(); }