예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        void RunVendorTest()
        {
            var conn = new Connection(@"localhost\sqlexpress", "PRSdb");

            conn.Open();
            Vendors.Connection = conn;

            var vendidtest = Vendors.GetByPK(2);

            var success = Vendors.Delete(4);
            var vendors = Vendors.GetAll();

            foreach (var v in vendors)
            {
                Console.WriteLine(v.Name);
            }

            //var newvendora = new Vendors();
            //newvendora.Address = "bridge4";
            //newvendora.City = "City";
            //newvendora.Code = "BGHTS";
            //newvendora.Email = "emaiiil.email";
            //newvendora.Name = "Big Hats";
            //newvendora.Phone = "484-562-4636";
            //newvendora.State = "NM";
            //newvendora.Zip = "43532";
            //success = Vendors.Insert(newvendora);

            foreach (var v in vendors)
            {
                Console.WriteLine(v.Name);
            }


            conn.Close();
        }
예제 #4
0
 public static void DeleteVendor(int id)
 {
     Vendors.Delete(id);
 }