public static bool Delete(Copy c) { try { SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True"); SqlCommand cmd = new SqlCommand("Delete Copy where copyNumber = @copyNumber", cn); cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber); cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); return true; } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } }
public static bool Update(Copy b) { return CopyDA.Update(b); }
public static bool Insert(Copy b) { return CopyDA.Insert(b); }
public static bool Delete(Copy b) { return CopyDA.Delete(b); }
public static bool Update(Copy c) { try { SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True"); SqlCommand cmd = new SqlCommand("Update Copy set bookNumber = @bookNumber, " + "sequenceNumber = @sequenceNumber, type = @type, price=@price where copyNumber = @copyNumber", cn); cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber); cmd.Parameters.AddWithValue("@bookNumber", c.BookNumber); cmd.Parameters.AddWithValue("@sequenceNumber", c.SequenceNumber); cmd.Parameters.AddWithValue("@type", c.Type); cmd.Parameters.AddWithValue("@price", c.Price); cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); return true; } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } }
public static bool Insert(Copy c) { try { SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=Library;Integrated Security=True"); SqlCommand cmd = new SqlCommand("Insert into Copy(copyNumber, bookNumber, sequenceNumber, type, price)" + "values(@copyNumber, @bookNumber, @sequenceNumber, @type, @price)", cn); cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber); cmd.Parameters.AddWithValue("@bookNumber", c.BookNumber); cmd.Parameters.AddWithValue("@sequenceNumber", c.SequenceNumber); cmd.Parameters.AddWithValue("@type", c.Type); cmd.Parameters.AddWithValue("@price", c.Price); cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); return true; } catch (System.Exception ex) { MessageBox.Show(ex.Message); return false; } }