public NhaXuatBanCollection TimDSNhaXuatBan(string tennxb) { NhaXuatBanCollection nxbColl = new NhaXuatBanCollection(); SqlConnection cnn = new SqlConnection(cnnstr); string query = "select * from nhaxuatban where tennxb <> '' "; query += "order by tennxb"; SqlCommand cmd = new SqlCommand(query, cnn); if (tennxb != "") { query = "select * from nhaxuatban where tennxb like @tennxb and tennxb <>''"; query += "order by tennxb"; cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@tennxb", "%" + tennxb + "%"); } cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { NhaXuatBanBO nxbBO = new NhaXuatBanBO(); nxbBO.MaNXB = dr["manxb"].ToString(); nxbBO.TenNXB = dr["tennxb"].ToString(); nxbColl.Add(nxbBO); } cnn.Close(); return nxbColl; }
public void NapDSNXB() { NhaXuatBanCollection nxb1= new NhaXuatBanCollection(); NhaXuatBanCollection nxb2 = new NhaXuatBanCollection(); NhaXuatBanCollection temp = new NhaXuatBanCollection(); temp = nhaxuatbanBUS.TimDSNhaXuatBan(""); NhaXuatBanBO nhaxuatbanBO = new NhaXuatBanBO(); nhaxuatbanBO.TenNXB = "..."; nhaxuatbanBO.MaNXB = ""; nxb1.Add(nhaxuatbanBO); nxb2.Add(nhaxuatbanBO); for (int i = 0; i < temp.Count; i++) { nxb1.Add(temp.Index(i)); nxb2.Add(temp.Index(i)); } NhaxuatbanMoiDropdown.DataSource = nxb1; NhaxuatbanMoiDropdown.DataTextField = "tennxb"; NhaxuatbanMoiDropdown.DataValueField = "manxb"; NhaxuatbanMoiDropdown.DataBind(); NhaXuatBanSuaDropDown.DataSource = nxb2; NhaXuatBanSuaDropDown.DataTextField = "tennxb"; NhaXuatBanSuaDropDown.DataValueField = "manxb"; NhaXuatBanSuaDropDown.DataBind(); }
public void SuaNXB(NhaXuatBanBO nhaxuatbanBO) { SqlConnection cnn = new SqlConnection(cnnstr); string query = "update nhaxuatban set tennxb=@tennxb where manxb=@manxb "; SqlCommand cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@tennxb", nhaxuatbanBO.TenNXB); cmd.Parameters.AddWithValue("@manxb", nhaxuatbanBO.MaNXB); cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); }
public bool SuaNhaXuatBan(string manxb, string tennxb) { try { NhaXuatBanBO nxbBO = new NhaXuatBanBO(); nxbBO.MaNXB = manxb; nxbBO.TenNXB = tennxb; nxbDAO.SuaNXB(nxbBO); return true; } catch { return false; } }
public NhaXuatBanBO Tim1NXB(string manxb) { NhaXuatBanBO nxbBO = new NhaXuatBanBO(); SqlConnection cnn = new SqlConnection(cnnstr); string query = "select * from nhaxuatban where tennxb <> '' "; query += " AND manxb=@manxb order by tennxb"; SqlCommand cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@manxb", manxb); cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { nxbBO.MaNXB = dr["manxb"].ToString(); nxbBO.TenNXB = dr["tennxb"].ToString(); break; } cnn.Close(); return nxbBO; }
public void Add(NhaXuatBanBO nhaxuatbanBO) { List.Add(nhaxuatbanBO); }