Exemple #1
0
        private void butxoa_Click(object sender, EventArgs e)
        {
            if (txtma.Text == "" || txtten.Text == "")
            {
                MessageBox.Show("Chưa chọn thông tin");
                return;
            }
            Tacgia tg = new Tacgia();

            tg.matg   = txtma.Text;
            tg.tentg  = txtten.Text;
            tg.diachi = txtdc.Text;

            if (MessageBox.Show(string.Format("Xóa tác giả"), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (Bus.DeleteProfile(tg) > 0)
                {
                    MessageBox.Show("Đã xóa");
                    tacgia_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("lỗi");
                }
            }
        }
Exemple #2
0
        private void butluu_Click(object sender, EventArgs e)
        {
            if (txtma.Text == "" || txtten.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin");
                return;
            }
            Tacgia tg = new Tacgia();

            tg.matg   = txtma.Text;
            tg.tentg  = txtten.Text;
            tg.diachi = txtdc.Text;
            if (MessageBox.Show(string.Format("thêm tác giả"), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (Bus.InsertProfile(tg) > 0)
                {
                    MessageBox.Show("Đã lưu");
                    tacgia_Load(sender, e);
                }
                else
                {
                    MessageBox.Show(" chưa lưu");
                }
            }
        }
        public bool Delete(Tacgia entity)
        {
            var model = _context.Tacgias.Find(entity.Id);

            _context.Tacgias.Remove(model);
            _context.SaveChanges();
            return(true);
        }
Exemple #4
0
        public ActionResult DeleteConfirmed(string id)
        {
            Tacgia tacgia = db.Tacgias.Find(id);

            db.Tacgias.Remove(tacgia);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #5
0
 public static int DeleteProfile(Tacgia tg)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@ma", tg.matg),
         new SqlParameter("@ten", tg.tentg),
     };
     return(DataProvider.ExecuteNonQuery("xoatacgia", para));
 }
Exemple #6
0
 public static int InsertProfile(Tacgia tg)
 {
     SqlParameter[] para = new SqlParameter[] {
         new SqlParameter("@ma", tg.matg),
         new SqlParameter("@ten", tg.tentg),
         new SqlParameter("@diachi", tg.diachi),
     };
     return(DataProvider.ExecuteNonQuery("themtacgia", para));
 }
        public ActionResult ThemTacGia(string tenTG)
        {
            Tacgia tg = new Tacgia();

            tg.Tentacgia = tenTG;
            db.Tacgias.Add(tg);
            db.SaveChanges();
            return(RedirectToAction("ThemSach"));
        }
Exemple #8
0
 public ActionResult Edit([Bind(Include = "matacgia,tentacgia,diachi,dienthoai")] Tacgia tacgia)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tacgia).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tacgia));
 }
Exemple #9
0
        public ActionResult Create([Bind(Include = "matacgia,tentacgia,diachi,dienthoai")] Tacgia tacgia)
        {
            if (ModelState.IsValid)
            {
                db.Tacgias.Add(tacgia);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tacgia));
        }
Exemple #10
0
        // GET: Tacgias/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tacgia tacgia = db.Tacgias.Find(id);

            if (tacgia == null)
            {
                return(HttpNotFound());
            }
            return(View(tacgia));
        }
 public int Add(Tacgia item)
 {
     _context.Tacgias.Add(item);
     _context.SaveChanges();
     return(item.Id);
 }
Exemple #12
0
 public static int DeleteProfile(Tacgia tg)
 {
     return(Dao.DeleteProfile(tg));
 }
Exemple #13
0
 public static int UpdateProfile(Tacgia tg)
 {
     return(Dao.UpdateProfile(tg));
 }
Exemple #14
0
 public static int InsertProfile(Tacgia tg)
 {
     return(Dao.InsertProfile(tg));
 }
 public bool Update(Tacgia item)
 {
     _context.Entry(item).State = EntityState.Modified;
     return(_context.SaveChanges() > 0);
 }
Exemple #16
0
 public int Add(Tacgia item)
 {
     return(_repository.Add(item));
 }
Exemple #17
0
 public bool Delete(Tacgia entity)
 {
     return(_repository.Delete(entity));
 }
Exemple #18
0
 public bool Update(Tacgia item)
 {
     return(_repository.Update(item));
 }