コード例 #1
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void grdIncidents_UpdateItem(int IncidentID)
        {
            Incident item = null;
            // Load the item here, e.g. item = MyDataLayer.Find(id);
            TechSupportEntities db = new TechSupportEntities();

            item = db.Incidents.Find(IncidentID);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", IncidentID));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here, e.g. MyDataLayer.SaveChanges();
                try {
                    db.SaveChanges();
                    grdIncidents.DataBind();
                }
                catch (DbUpdateConcurrencyException ex) { HandleConcurrencyError(ex); }
                catch (DbEntityValidationException ex) { HandleValidationError(ex); }
                catch (Exception ex) { HandleOtherErrors(ex); }
            }
        }
コード例 #2
0
        public IQueryable <Customer> ddlCustomers_GetData()
        {
            TechSupportEntities db = new TechSupportEntities();

            return(from c in db.Customers
                   orderby c.Name
                   select c);
        }
コード例 #3
0
        protected void cstmCustomerID_ServerValidate(object source, ServerValidateEventArgs args)
        {
            TechSupportEntities db = new TechSupportEntities();
            Customer            c  = db.Customers.Find(int.Parse(args.Value));

            args.IsValid = (c == null) ? false : true;
            if (!args.IsValid)
            {
                ResetProductControls();
            }
        }
コード例 #4
0
        // The return type can be changed to IEnumerable, however to support
        // paging and sorting, the following parameters must be added:
        //     int maximumRows
        //     int startRowIndex
        //     out int totalRowCount
        //     string sortByExpression
        public IQueryable <Incident> grdIncidents_GetData([Control] string ddlCustomers)
        {
            TechSupportEntities db = new TechSupportEntities();

            if (ddlCustomers == null)
            {
                ddlCustomers = db.Customers.FirstOrDefault().CustomerID.ToString();
            }
            return(from i in db.Incidents
                   where i.CustomerID.ToString() == ddlCustomers
                   select i);
        }
コード例 #5
0
        private void SetupPageForCustomer(int customerID)
        {
            TechSupportEntities db = new TechSupportEntities();

            selected = db.Customers.Find(customerID);
            if (selected == null)
            {
                return;
            }
            Session["customer"]        = selected;
            lblName.Text               = selected.Name;
            btnRegisterProduct.Enabled = true;
            ddlProducts.Enabled        = true;
        }