public void update(NhapSach tts) { string cn = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|QLBansach_Data.mdf;Integrated Security=True;User Instance=True"; con = new SqlConnection(cn); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "st_capnhatsach"; cmd.Parameters.Add("@masach", System.Data.SqlDbType.Int).Value = tts.masach; cmd.Parameters.Add("@tensach", System.Data.SqlDbType.NVarChar, 100).Value = tts.tensach; cmd.Parameters.Add("@dongia", System.Data.SqlDbType.Int).Value = tts.dongia; cmd.Parameters.Add("@donvitinh", System.Data.SqlDbType.NVarChar, 10).Value = tts.donvitinh; cmd.Parameters.Add("@mota", System.Data.SqlDbType.NText).Value = tts.mota; cmd.Parameters.Add("@hinhminhhoa", System.Data.SqlDbType.NVarChar, 50).Value = tts.hinhminhhoa; cmd.Parameters.Add("@macd", System.Data.SqlDbType.Int).Value = tts.macd; cmd.Parameters.Add("@manxb", System.Data.SqlDbType.Int).Value = tts.manxb; cmd.Parameters.Add("@ngaycapnhat", System.Data.SqlDbType.SmallDateTime).Value = tts.ngaycapnhat; cmd.Parameters.Add("@tentacgia", System.Data.SqlDbType.NVarChar, 80).Value = tts.tentacgia; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public NhapSach_DTO TimNhapSachTheoMaNhap(string MaNhap) { NhapSach_DTO nhapSach_DTO = new NhapSach_DTO(); //tim 1 nhan vien theo ma nhan vien NhapSach nhapSach = data.NhapSaches.SingleOrDefault( u => u.MaNhap == MaNhap && u.TrangThai.Value == true); // đỗ dữ liệu từ nhân viên trong database sang nhân viên dto de chuyen di nhapSach_DTO.MaNhap = nhapSach.MaNhap; nhapSach_DTO.MaNV = nhapSach.MaNV; nhapSach_DTO.NgayNhap = (DateTime)nhapSach.NgayNhap; nhapSach_DTO.ThanhTien = double.Parse(nhapSach.ThanhTien.ToString()); return(nhapSach_DTO); }
public bool XoaNhapSach(string strMaNhapSach) { try { NhapSach nhapSach = data.NhapSaches.SingleOrDefault( u => u.MaNhap == strMaNhapSach && u.TrangThai == true); nhapSach.TrangThai = false; data.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public void delete(NhapSach tts) { string cn = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|QLBansach_Data.mdf;Integrated Security=True;User Instance=True"; con = new SqlConnection(cn); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "st_xoasach"; cmd.Parameters.Add("@masach", System.Data.SqlDbType.Int).Value = tts.masach; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public bool SuaNhapSach(NhapSach_DTO nhapSach_DTO) { try { NhapSach nhapSach = data.NhapSaches.SingleOrDefault(u => u.MaNhap == nhapSach_DTO.MaNhap); nhapSach.MaNhap = nhapSach_DTO.MaNhap; nhapSach.MaNV = nhapSach_DTO.MaNV; nhapSach.NgayNhap = nhapSach_DTO.NgayNhap; nhapSach.ThanhTien = decimal.Parse(nhapSach_DTO.ThanhTien.ToString()); data.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool ThemNhapSach(NhapSach_DTO nhapSach_DTO) { try { NhapSach nhapSach = new NhapSach(); nhapSach.MaNhap = nhapSach_DTO.MaNhap; nhapSach.MaNV = nhapSach_DTO.MaNV; nhapSach.NgayNhap = nhapSach_DTO.NgayNhap; nhapSach.ThanhTien = (decimal)nhapSach_DTO.ThanhTien; nhapSach.TrangThai = true; data.NhapSaches.Add(nhapSach); data.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public void insert(NhapSach tts) { string cn = "Server=ltp1305.mssql.somee.com;Database=ltp1305;User Id=TheMadKitten_SQLLogin_1;Password=66rbhow211;"; con = new SqlConnection(cn); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "st_themsach"; cmd.Parameters.Add("@tensach", System.Data.SqlDbType.NVarChar, 100).Value = tts.tensach; cmd.Parameters.Add("@dongia", System.Data.SqlDbType.Int).Value = tts.dongia; cmd.Parameters.Add("@donvitinh", System.Data.SqlDbType.NVarChar, 10).Value = tts.donvitinh; cmd.Parameters.Add("@mota", System.Data.SqlDbType.NText).Value = tts.mota; cmd.Parameters.Add("@hinhminhhoa", System.Data.SqlDbType.NVarChar, 50).Value = tts.hinhminhhoa; cmd.Parameters.Add("@macd", System.Data.SqlDbType.Int).Value = tts.macd; cmd.Parameters.Add("@manxb", System.Data.SqlDbType.Int).Value = tts.manxb; cmd.Parameters.Add("@ngaycapnhat", System.Data.SqlDbType.SmallDateTime).Value = tts.ngaycapnhat; cmd.Parameters.Add("@tentacgia", System.Data.SqlDbType.NVarChar, 80).Value = tts.tentacgia; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public void SetUp() { this.nhapSach = new NhapSach(1, "2017-01-05", "6", 0, "CN0001", 50000, 50); }
//xu ly nhap sach private void NhậpSáchToolStripMenuItem1_Click(object sender, EventArgs e) { NhapSach nhapSach = new NhapSach(); nhapSach.ShowDialog(); }