public bool sua(theTV t)
 {
     if (string.IsNullOrEmpty(t.maThe))
     {
         return(false);
     }
     the.update(t);
     return(true);
 }
        public bool insert(theTV t)
        {
            if (dataTable("select * from THETHUVIEN where MaThe ='" + t.maThe + "'").Rows.Count > 0)
            {
                return(false);
            }
            string sqlCommand = string.Format("insert into THETHUVIEN values ('{0}','{1}','{2}',N'{3}',N'{4}')", t.maThe, t.ngayBD, t.ngayHH, t.ghiChu, t.trangThai);

            Excute(sqlCommand);
            return(true);
        }
示例#3
0
 private void Insert(object sender, EventArgs e)
 {
     try
     {
         theTV t = new theTV();
         t.maThe  = CardID.Text;
         t.ngayBD = IDate.Value.ToString();
         t.ngayHH = EDate.Value.ToString();
         if (Note.Text != "")
         {
             t.ghiChu = Note.Text;
         }
         if (t.isNull())
         {
             toolTip1.ToolTipTitle = "Warning";
             toolTip1.Show("Please enter full information", windowsUIButtonPanel1, windowsUIButtonPanel1.Location, 5000);
             return;
         }
         else
         {
             if (the.them(t))
             {
                 Form1_Load(sender, e);
                 resetText();
             }
             else
             {
                 if (the.sua(t))
                 {
                     Form1_Load(sender, e);
                     resetText();
                 }
                 else
                 {
                     return;
                 }
             }
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#4
0
 public string addCard()
 {
     try
     {
         theTV t = new theTV();
         t.maThe  = "CARD" + (the.getList().Rows.Count + 1).ToString("0000");
         t.ngayBD = DateTime.Now.ToString();
         t.ngayHH = DateTime.Now.AddYears(1).ToString();
         if (the.them(t))
         {
             return(t.maThe);
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         MessageBox.Show("Auto add card unsuccessful", "Oops");
         return(null);
     }
 }
        public void update(theTV t)
        {
            string sqlCommand = string.Format("update THETHUVIEN set NgayBatDau = '{0}', NgayHetHan = '{1}', GhiChu = N'{2}', TrangThai = N'{3}' where MaThe = '{4}'", t.ngayBD, t.ngayHH, t.ghiChu, t.trangThai, t.maThe);

            Excute(sqlCommand);
        }
 public bool them(theTV t)
 {
     return(the.insert(t));
 }