Пример #1
0
 public void Save(DM_NhomHang data)
 {
     using (Karaoke2017Entities db = new Karaoke2017Entities())
     {
         if (data.id > 0)
         {
             var nhomHang = db.DM_NhomHang.Find(data.id);
             nhomHang.ma     = data.ma;
             nhomHang.ten    = data.ten;
             nhomHang.ghichu = data.ghichu;
             db.SaveChanges();
         }
         else
         {
             db.DM_NhomHang.Add(data);
             db.SaveChanges();
         }
     }
 }
Пример #2
0
        //Lưu
        private void bbtnLuu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!CheckData())
            {
                return;
            }
            else
            {
                DM_NhomHang data = new DM_NhomHang()
                {
                    ma     = txtMa.Text.Trim(),
                    ten    = txtTen.Text.Trim(),
                    ghichu = txtGhiChu.Text.Trim()
                };
                if (_id > -1)
                {
                    data.id = _id;
                }
                NhomHangController.Instance.Save(data);

                this.Close();
            }
        }