Exemple #1
0
        public void HienThiKeSach(TextBox txtMaKeSach, TextBox txtTenTheLoai, DataGridViewRow dgvrKeSach)
        {
            KeSach keSach = keSachDAL.LayKeSachTheoMa(dgvrKeSach.Cells[1].Value.ToString());

            txtMaKeSach.Text   = keSach.MaKeSach;
            txtTenTheLoai.Text = keSach.TenTheLoai;
        }
Exemple #2
0
 public static int Delete_KeSach(KeSach a)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@maKe", a.MaKe),
     };
     return(DataProvider.ExecuteNonQuery("Delete_KeSach", para));
 }
 public KeSach LayKeSachTheoMa(string maKeSach)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         KeSach keSach = ThuVienDS.KeSaches.Find(maKeSach);
         return(keSach);
     }
 }
 public bool ThemKeSach(KeSach keSach)
 {
     using (var ThuVienDS = new QLThuVienEntities())
     {
         ThuVienDS.KeSaches.Add(keSach);
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
Exemple #5
0
        public bool SuaThongTinSach(TextBox txtMaKeSach, TextBox txtTenTheLoai)
        {
            KeSach keSach = new KeSach();

            keSach.MaKeSach   = txtMaKeSach.Text;
            keSach.TenTheLoai = txtTenTheLoai.Text;
            keSachDAL.CapNhatKeSach(keSach);
            return(true);
        }
Exemple #6
0
        public bool ThemKeMoi(TextBox txtMaKeSach, TextBox txtTenTheLoai)
        {
            KeSach keSach = new KeSach();

            keSach.MaKeSach   = txtMaKeSach.Text;
            keSach.TenTheLoai = txtTenTheLoai.Text;
            keSachDAL.ThemKeSach(keSach);
            return(true);
        }
Exemple #7
0
 public static int Update_KeSach(KeSach a)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@maKe", a.MaKe),
         new SqlParameter("@chatLieu", a.ChatLieu),
         new SqlParameter("@sucChua", a.SucChua),
     };
     return(DataProvider.ExecuteNonQuery("Update_KeSach", para));
 }
 public bool CapNhatKeSach(KeSach keSach)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var ke = ThuVienDS.KeSaches.Find(keSach.MaKeSach);
         ke = keSach;
         ThuVienDS.SaveChanges();
     }
     return(true);
 }
 public List <KeSach> TimKiemKeSach(KeSach keSach)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var listKeSach = from ke in ThuVienDS.KeSaches select ke;
         if (keSach.MaKeSach != "none")
         {
             listKeSach = listKeSach.Where <KeSach>(c => c.MaKeSach.Contains(keSach.MaKeSach));
         }
         return(listKeSach.ToList());
     }
 }
        public bool ThemKe(string tenke, string theloai, ref string err)
        {
            QuanLyNhaSachDataContext qlNS = new QuanLyNhaSachDataContext();
            KeSach s = new KeSach();

            s.TenKeSach = tenke;
            s.TheLoai   = theloai;

            qlNS.KeSaches.InsertOnSubmit(s);

            qlNS.KeSaches.Context.SubmitChanges();

            return(true);
        }
Exemple #11
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            KeSach ks2 = new KeSach();

            ks2.MaKe    = txt_MaKe.Text; ks2.ChatLieu = txt_CL.Text;
            ks2.SucChua = txt_SC.Text;


            if (insert)
            {
                if (MessageBox.Show("Bạn muốn lưu dữ liệu được thêm mơi không???", "SAVE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    DataTable test = new DataTable(); //  kiểm tra mã đã  có trong bảng chưa???

                    string sql = "select *from KeSach where MaKe= '" + txt_MaKe.Text + "'";
                    test = DataProvider.GetData(sql);
                    int i = test.Rows.Count;
                    if (i > 0)
                    {
                        MessageBox.Show("Đã tồn tại " + txt_MaKe.Text, "Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        gridControl2.DataSource = BUS.Insert_KeSach(ks2);
                        MessageBox.Show("Đã lưu thành công");
                        gridControl2.DataSource = BUS.Select_KeSach();
                    }
                }
            }
            if (update)
            {
                if (MessageBox.Show("Bạn muốn lưu thay đổi không???", "SAVE", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    gridControl2.DataSource = BUS.Update_KeSach(ks2);
                    MessageBox.Show("Đã lưu thành công");
                    gridControl2.DataSource = BUS.Select_KeSach();
                }
            }
            txt_MaKe.Enabled   = false;
            btn_cancel.Enabled = false;
            btn_save.Enabled   = false;
            btn_delete.Enabled = true;
            btn_update.Enabled = true;
            btn_insert.Enabled = true;
        }
Exemple #12
0
 public frm_KS()
 {
     InitializeComponent();
     ks = new KeSach();
 }
Exemple #13
0
 public static int Delete_KeSach(KeSach a)
 {
     return(DAO.Delete_KeSach(a));
 }
Exemple #14
0
 public static int Update_KeSach(KeSach a)
 {
     return(DAO.Update_KeSach(a));
 }
Exemple #15
0
 public static int Insert_KeSach(KeSach a)
 {
     return(DAO.Insert_KeSach(a));
 }