Ejemplo n.º 1
0
        protected void grdSlip_SelectedIndexChanged(object sender, EventArgs e)
        {
            var db    = new MarinaEntities();
            var lease = new Lease();

            lease.CustomerID = Convert.ToInt32(Session["CustomerID"]);
            lease.SlipID     = Convert.ToInt32(grdSlip.SelectedRow.Cells[1].Text);
            db.Leases.Add(lease);
            db.SaveChanges();
            Response.Redirect("~/MyLease");
        }
        protected void uxPurchase_Click(object sender, EventArgs e)
        {
            int customerID = Convert.ToInt32(Session["CustomerID"]);
            int slipID     = Convert.ToInt32(DropDownSlips.SelectedValue);
            var db         = new MarinaEntities();
            var lease      = new Lease {
                SlipID = slipID, CustomerID = customerID
            };

            db.Leases.Add(lease);
            db.SaveChanges();
            uxLeaseHistory.DataSource = MarinaManager.GetLeasesByCustomerID(customerID);
            uxLeaseHistory.DataBind();
        }
Ejemplo n.º 3
0
        protected void btnLease_Click(object sender, EventArgs e)
        {
            int customerID = Convert.ToInt32(Session["CustomerID"]);
            int slipID     = Convert.ToInt32(dropDownSlips.SelectedValue);


            var db   = new MarinaEntities();
            var auth = new Lease {
                SlipID = slipID, CustomerID = customerID
            };

            db.Leases.Add(auth);
            db.SaveChanges();

            gridViewLease.DataSource = MainManager.GetLeaseByCustomerID(customerID);
            gridViewLease.DataBind();
        }
Ejemplo n.º 4
0
        //Adding customer
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var customer = new Customer
            {
                FirstName = txtFirstName.Text,
                LastName  = txtLastName.Text,
                City      = txtCity.Text,
                Phone     = txtPhone.Text
            };

            var db = new MarinaEntities();

            db.Customers.Add(customer);
            db.SaveChanges();

            Response.Redirect("~/Registration");
        }
Ejemplo n.º 5
0
        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {
            // grab slipID from the slip ID column
            var slipID = int.Parse(GridView2.SelectedRow.Cells[0].Text);
            // grab userID from session
            var userID = int.Parse(Session["CustomerID"].ToString());

            // using entity framework
            using (var context = new MarinaEntities())
            {
                // grab the selected slip from context, as well as user
                var lease = (from l in context.Leases where l.CustomerID == userID select l).First();
                var user  = (from c in context.Customers where c.ID == userID select c).First();

                context.Leases.Remove(lease);
                context.SaveChanges();
            }

            Response.Redirect("Panel.aspx");
        }
Ejemplo n.º 6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var db = new MarinaEntities();

            var user = MainManager.Authenticate(txtFirstName.Text, txtLastName.Text);

            if (user == null)
            {
                var auth = new Customer
                {
                    FirstName = txtFirstName.Text,
                    LastName  = txtLastName.Text,
                    City      = txtCity.Text,
                    Phone     = txtPhone.Text
                };
                db.Customers.Add(auth);
            }


            db.SaveChanges();
            FormsAuthentication.SignOut();
            Response.Redirect("~/Login");
        }