public bool UpdateData(ChiTietPhieuMuon_Ob ctOj) { cmd.CommandText = "Update chitietphieumuon set SoPhieuMuon ='" + ctOj.SoPhieuMuon1 + "', MaSach = '" + ctOj.MaSach1 + "', HenTra = CONVERT(DATE, '" + ctOj.HenTra1 + "',103) where sophieu= '" + ctOj.SoPhieuMuon1 + "')"; cmd.CommandType = CommandType.Text; cmd.Connection = con.Connection; try { con.OpenCon(); cmd.ExecuteNonQuery(); con.CloseCon(); return(true); } catch (Exception ex) { string mex = ex.Message; cmd.Dispose();//xoa bo phien lam viec con.CloseCon(); } return(false); }
//them data public bool AddData(ChiTietPhieuMuon_Ob ctOj) { cmd.CommandText = "insert into chitietphieumuon values ('" + ctOj.SoPhieuMuon1 + "','" + ctOj.MaSach1 + "',CONVERT(DATE, '" + ctOj.HenTra1 + "',103) )"; cmd.CommandType = CommandType.Text; cmd.Connection = con.Connection; try { con.OpenCon(); cmd.ExecuteNonQuery(); con.CloseCon(); return(true); } catch (Exception ex) { string mex = ex.Message; cmd.Dispose();//xoa bo phien lam viec con.CloseCon(); } return(false); }
//ham lay du lieu vao control void ganDL(ChiTietPhieuMuon_Ob ctObj) { ctObj.SoPhieuMuon1 = txtSoPhieu.Text.Trim(); ctObj.MaSach1 = txtMaSach.Text.Trim(); ctObj.HenTra1 = dateTimePicker1.Text.Trim(); }