Пример #1
0
        private void BarButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //txtMaLop.Text=temp1;
            //txtTenLop.Text=temp2;
            //txtMaKhoa.Text=temp3;
            Lop l = st.Pop();

            if (lobll.InsertLop(l))
            {
                ShowAllLop();
                //MessageBox.Show("Phục hồi thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
 private void BarButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (CheckData())
     {
         Lop l = new Lop();
         l.MALOP  = txtMaLop.Text;
         l.TENLOP = txtTenLop.Text;
         l.MAKH   = txtMaKhoa.Text;
         if (lobll.UpdateLop(l))
         {
             ShowAllLop();
         }
         else
         {
             MessageBox.Show("Đã có lỗi", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Пример #3
0
        public bool Delete(Lop l)
        {
            string        sql = "DELETE FROM LOP WHERE MALOP=@MALOP";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value = l.MALOP;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Пример #4
0
        public bool UpdateLop(Lop l)
        {
            string        sql = "UPDATE LOP SET MALOP=@MALOP,TENLOP=@TENLOP,MAKH=@MAKH WHERE MALOP=@MALOP";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value  = l.MALOP;
                cmd.Parameters.Add("@TENLOP", SqlDbType.NVarChar).Value = l.TENLOP;
                cmd.Parameters.Add("@MAKH", SqlDbType.NVarChar).Value   = l.MAKH;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Пример #5
0
 private void BtnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (CheckData())
     {
         Lop l = new Lop();
         l.MALOP  = txtMaLop.Text;
         l.TENLOP = txtTenLop.Text;
         l.MAKH   = txtMaKhoa.Text;
         st.Push(l);
         if (MessageBox.Show("Ban muon xoa khong", "Thong bao", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             if (lobll.Delete(l))
             {
                 ShowAllLop();
             }
             else
             {
                 MessageBox.Show("Đã có lỗi", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
Пример #6
0
        public bool InsertLop(Lop l)
        {
            string        sql = "INSERT INTO LOP(MALOP,TENLOP,MAKH) VALUES(@MALOP,@TENLOP,@MAKH)";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MALOP", SqlDbType.NChar).Value     = l.MALOP;
                cmd.Parameters.Add("@TENLOP", SqlDbType.NVarChar).Value = l.TENLOP;
                cmd.Parameters.Add("@MAKH", SqlDbType.NChar).Value      = l.MAKH;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("Lỗi trùng khóa chính hoặc khóa duy nhất");
                return(false);
            }
            return(true);
        }
Пример #7
0
 public bool UpdateLop(Lop l)
 {
     return(dal.UpdateLop(l));
 }
Пример #8
0
 public bool Delete(Lop l)
 {
     return(dal.Delete(l));
 }
Пример #9
0
 public bool InsertLop(Lop l)
 {
     return(dal.InsertLop(l));
 }