Example #1
0
 public bool sua(tacGia t)
 {
     if (string.IsNullOrEmpty(t.maTG))
     {
         return(false);
     }
     tg.update(t);
     return(true);
 }
Example #2
0
        public bool insert(tacGia t)
        {
            if (dataTable("select * from TACGIA where MaTG ='" + t.maTG + "'").Rows.Count > 0)
            {
                return(false);
            }
            string sqlCommand = string.Format("insert into TACGIA values ('{0}',N'{1}','{2}',N'{3}')", t.maTG, t.tenTG, t.website, t.ghiChu);

            Excute(sqlCommand);
            return(true);
        }
Example #3
0
        private void SuatacGia()
        {
            if (tblTacGia.Text == "")
            {
                MessageBox.Show("Phải chọn một dòng cần sửa");
                return;
            }
            tacGia tg = db.tacGias.Single(item => item.ID == int.Parse(tblId.Text));

            tg.TenTacGia = tblTacGia.Text;
            db.SubmitChanges();
            MessageBox.Show("Đã sửa thành công ");
        }
Example #4
0
        private void ThemtacGia()
        {
            if (tblTacGia.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin");
                return;
            }
            tacGia tg = new tacGia();

            tg.TenTacGia = tblTacGia.Text;
            db.tacGias.InsertOnSubmit(tg);
            db.SubmitChanges();
            MessageBox.Show("Đã thêm thành công ");
        }
Example #5
0
        private void datagrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int rowindex = datagrid.SelectedIndex;

            if (rowindex == -1)
            {
                return;
            }
            else
            {
                tacGia tg = (tacGia)datagrid.SelectedItem;
                tblId.Text     = tg.ID.ToString();
                tblTacGia.Text = tg.TenTacGia;
            }
        }
Example #6
0
 private void XoaTacGia()
 {
     try
     {
         if (tblTacGia.Text == "")
         {
             MessageBox.Show("Phải chọn  một dòng cần xóa");
             return;
         }
         tacGia tg = db.tacGias.Single(item => item.ID == int.Parse(tblId.Text));
         db.tacGias.DeleteOnSubmit(tg);
         db.SubmitChanges();
         MessageBox.Show("Đã xóa thành công ");
     }
     catch (Exception)
     {
         MessageBox.Show("Không được xóa");
     }
 }
Example #7
0
 private void Insert(object sender, EventArgs e)
 {
     try
     {
         tacGia tg = new tacGia();
         tg.maTG    = AuthorID.Text;
         tg.tenTG   = AuthorName.Text;
         tg.website = Website.Text;
         tg.ghiChu  = Note.Text;
         if (tg.isNull())
         {
             toolTip1.ToolTipTitle = "Warning";
             toolTip1.Show("Please enter full information", windowsUIButtonPanel1, windowsUIButtonPanel1.Location, 5000);
             return;
         }
         else
         {
             if (tacGia.them(tg))
             {
                 Authors_Load(sender, e);
                 resetText();
             }
             else
             {
                 if (tacGia.sua(tg))
                 {
                     Authors_Load(sender, e);
                     resetText();
                 }
                 else
                 {
                     return;
                 }
             }
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #8
0
        public void update(tacGia t)
        {
            string sqlCommand = string.Format("update TACGIA set TenTG = N'{0}', Website = '{1}', GhiChu = N'{2} where MaTG = '{3}'", t.tenTG, t.website, t.ghiChu, t.maTG);

            Excute(sqlCommand);
        }
Example #9
0
 public bool them(tacGia t)
 {
     return(tg.insert(t));
 }