Exemplo n.º 1
0
        public static int DeleteCustomer(string CusID)
        {
            var deleted = db.Customers.Where(x => x.CustomerID == CusID).FirstOrDefault();

            db.Customers.Remove(deleted);
            return(db.SaveChanges());
        }
        protected void lvwDt_ItemUpdating(object sender, ListViewUpdateEventArgs e)
        {
            ListViewItem item        = lvwDt.Items[e.ItemIndex];
            string       id          = lvwDt.DataKeys[e.ItemIndex].Value.ToString();
            string       compantName = (item.FindControl("txtval") as TextBox).Text;
            Customer     customer    = context.Customers.Find(id);

            customer.CompanyName = compantName;
            context.SaveChanges();
            lvwDt.EditIndex  = -1;
            lvwDt.DataSource = context.Customers.ToList();
            lvwDt.DataBind();
        }
Exemplo n.º 3
0
        public static int AddCustomer(Customer customer)
        {
            Customer c = new Customer();

            c.Address      = customer.Address;
            c.City         = customer.City;
            c.CompanyName  = customer.CompanyName;
            c.ContactName  = customer.ContactName;
            c.Country      = customer.Country;
            c.Phone        = customer.Phone;
            c.PostalCode   = customer.PostalCode;
            c.Region       = customer.Region;
            c.Fax          = customer.Fax;
            c.ContactTitle = customer.ContactTitle;
            c.CustomerID   = customer.CustomerID;

            db.Customers.Add(c);
            return(db.SaveChanges());
        }
Exemplo n.º 4
0
 public bool Save()
 {
     return(_ctx.SaveChanges() >= 0);
 }
Exemplo n.º 5
0
 public Category Add(Category category)
 {
     _context.Categories.Add(category);
     _context.SaveChanges();
     return(category);
 }
 public void SaveChanges()
 {
     _context.SaveChanges();
 }