void RunVendorsTest() { Connection conn = new Connection(@"localhost\sqlexpress", "PrsDb"); conn.Open(); Vendors.Connection = conn; //GETALL var vendors = Vendors.GetAll(); foreach (var ven in vendors) { Console.WriteLine(ven); } //GetByPk Vendors vendor = Vendors.GetByPk(2); //assignment AND method call Console.WriteLine($"Vendor line deleted? {Vendors.Delete(3)}"); //UPDATE Vendors vendorV = Vendors.GetByPk(4); vendorV.Name = "Doggie Bone"; vendorV.State = "SD"; bool success = Vendors.Update(vendorV); Console.WriteLine($" {(success ? "Update successful" : "Update failed")}"); //INSERT Vendors vendorA = new Vendors(); // accesses default constructor in Vendors vendorA.Code = "MAGC"; vendorA.Name = "Magic R Us"; vendorA.Address = "111 Elm"; vendorA.City = "Columbus"; vendorA.State = "OH"; vendorA.Zip = "33321"; vendorA.Phone = "555-444-3333"; vendorA.Email = "*****@*****.**"; Console.WriteLine($"Vendor insertion successful? {Vendors.Insert(vendorA)}"); //GETBYCODE Vendors vendster = Vendors.GetByCode("WOOF"); Console.WriteLine(vendster); conn.Close(); }
void RunVendorsTest() { var conn = new Connection(@"localhost\sqlexpress", "PRS"); conn.Open(); Vendors.Connection = conn; var vendors = Vendors.GetAll(); foreach (var v in vendors) { Console.WriteLine(v.Name); } var vendor = Vendors.GetByPk(3); Debug.WriteLine(vendor); var rip = Vendors.Delete(3); var vendorabc = Vendors.GetByPk(1); vendorabc.Code = "ABC00"; var success = Vendors.Update(vendorabc); var newvendor = new Vendors(); newvendor.Code = "AHGFT"; newvendor.Name = "Macys"; newvendor.Address = "3475 dfdsf st"; newvendor.City = "Chicago"; newvendor.State = "Il"; newvendor.Zip = "55555"; newvendor.Phone = "234-456-1234"; newvendor.Email = "*****@*****.**"; success = Vendors.Insert(newvendor); conn.Close(); }
void RunVendorsTest() { var conn = new Connection(@"localhost\sqlexpress", "PrsDb7"); conn.Open(); Vendors.Connection = conn; // Insert var vendor = new Vendors { Code = "TARG", Name = "Target", Address = "123 Any St.", City = "Minneapolis", State = "MN", Zip = "12345", Phone = null, Email = null }; var success = Vendors.Insert(vendor); Console.WriteLine($"Insert worked: {success}"); Console.WriteLine("======================================"); var amazon = Vendors.GetByPk(3); Console.WriteLine($"Vendor 3 found: {amazon}"); var notfound = Vendors.GetByPk(333); Console.WriteLine(notfound?.ToString() ?? "Vendor 333 not found"); Console.WriteLine("======================================"); var vendors = Vendors.GetAll(); foreach (var v in vendors) { Console.WriteLine(v.Name); } conn.Close(); }