예제 #1
0
파일: DAO.cs 프로젝트: bstaykov/Telerik-DB
        public static void InsertCustomer(string customerID, string companyName, string contactName = null,
               string contactTitle = null, string address = null, string city = null, string region = null,
                string postalCode = null, string country = null, string phone = null, string fax = null)
        {
            var db = new NorthwindEntities();

            using (db)
            {
                Customer customer = new Customer()
                {
                    CustomerID = customerID,
                    CompanyName = companyName,
                    ContactName = contactName,
                    ContactTitle = contactTitle,
                    Address = address,
                    City = city,
                    Region = region,
                    PostalCode = postalCode,
                    Country = country,
                    Phone = phone,
                    Fax = fax
                };

                db.Customers.Add(customer);
                db.SaveChanges();
                Console.WriteLine("Customer inserted.");

            }
        }
예제 #2
0
파일: DAO.cs 프로젝트: bstaykov/Telerik-DB
 public static void DeleteCustomer(string customerID)
 {
     var db = new NorthwindEntities();
     using (db)
     {
         var customer = db.Customers.Find(customerID);
         db.Customers.Remove(customer);
         db.SaveChanges();
         Console.WriteLine("Customer deleted.");
     }
 }
예제 #3
0
        public static void DeleteCustomer(string customerID)
        {
            var db = new NorthwindEntities();

            using (db)
            {
                var customer = db.Customers.Find(customerID);
                db.Customers.Remove(customer);
                db.SaveChanges();
                Console.WriteLine("Customer deleted.");
            }
        }
예제 #4
0
        public static void UpdateCustomer(string customerID, string companyName, string contactName = null,
                                          string contactTitle = null, string address = null, string city  = null, string region = null,
                                          string postalCode   = null, string country = null, string phone = null, string fax    = null)
        {
            var db = new NorthwindEntities();

            using (db)
            {
                var customer = db.Customers.Find(customerID);
                customer.CompanyName  = companyName;
                customer.ContactName  = contactName;
                customer.ContactTitle = contactTitle;
                customer.Address      = address;
                customer.City         = city;
                customer.Region       = region;
                customer.PostalCode   = postalCode;
                customer.Country      = country;
                customer.Phone        = phone;
                customer.Fax          = fax;

                db.SaveChanges();
                Console.WriteLine("Customer updated.");
            }
        }
예제 #5
0
파일: DAO.cs 프로젝트: bstaykov/Telerik-DB
        public static void UpdateCustomer(string customerID, string companyName, string contactName = null,
               string contactTitle = null, string address = null, string city = null, string region = null,
                string postalCode = null, string country = null, string phone = null, string fax = null)
        {
            var db = new NorthwindEntities();

            using (db)
            {

                var customer = db.Customers.Find(customerID);
                customer.CompanyName = companyName;
                customer.ContactName = contactName;
                customer.ContactTitle = contactTitle;
                customer.Address = address;
                customer.City = city;
                customer.Region = region;
                customer.PostalCode = postalCode;
                customer.Country = country;
                customer.Phone = phone;
                customer.Fax = fax;

                db.SaveChanges();
                Console.WriteLine("Customer updated.");
            }
        }