コード例 #1
0
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            decimal salesPrice;
            int     carID        = (int)GridView1.SelectedDataKey.Value;
            string  previousPage = (string)Session["PreviousPage"];

            Session["Car_ID"] = carID;

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                salesPrice = (from n in db.Cars
                              where n.Car_ID == carID
                              select n.Price).Single();
            }

            Session["Sales_Price"] = salesPrice;

            if (previousPage != null)
            {
                Response.Redirect(previousPage);
            }
            else
            {
                Response.Redirect("Process_Order.aspx");
            }
        }
コード例 #2
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            int id = 0;

              if (tbExistingCustomer.Text == "")
              {
            Session["PreviousPage"] = "Maintenance.aspx";
            Response.Redirect("Browse_Customers.aspx");
              }

              if (!int.TryParse(tbExistingCustomer.Text, out id))
            return;

              using (VWCTSDataContext db = new VWCTSDataContext())
              {
            var customer = from n in db.Customers
                           where n.Customer_ID == id
                           select n;

            foreach (var n in customer)
            {
              tbFirstName.Text = n.First_Name;
              tbLastName.Text = n.Last_Name;
              tbAddress.Text = n.Street_Number;
              tbCity.Text = n.City;
              tbState.Text = n.State;
              tbZipCode.Text = n.Zip_Code.ToString();
              tbPhoneNumber.Text = n.Phone_Number.ToString();
              Session["Customer_ID"] = n.Customer_ID;
            }
              }
        }
コード例 #3
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            int id = 0;

            if (tbExistingCustomer.Text == "")
            {
                Session["PreviousPage"] = "Maintenance.aspx";
                Response.Redirect("Browse_Customers.aspx");
            }

            if (!int.TryParse(tbExistingCustomer.Text, out id))
            {
                return;
            }

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                var customer = from n in db.Customers
                               where n.Customer_ID == id
                               select n;

                foreach (var n in customer)
                {
                    tbFirstName.Text       = n.First_Name;
                    tbLastName.Text        = n.Last_Name;
                    tbAddress.Text         = n.Street_Number;
                    tbCity.Text            = n.City;
                    tbState.Text           = n.State;
                    tbZipCode.Text         = n.Zip_Code.ToString();
                    tbPhoneNumber.Text     = n.Phone_Number.ToString();
                    Session["Customer_ID"] = n.Customer_ID;
                }
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var    dataSource = (IQueryable)Session["DataSource"];
            string department = (string)Session["Department"];

            if (Session["Employee_ID"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!Page.IsPostBack)
            {
                Session["CarHistory"] = null;

                VWCTSDataContext db = new VWCTSDataContext();
                var source          = from n in db.Histories
                                      where n.Type == "Initial Delivery"
                                      select n;

                Session["DataSource"] = source;
                if (Session["Customer_ID"] != null)
                {
                    int id = (int)Session["Customer_ID"];
                    tbCustomerID.Text = id.ToString();
                    source            = from n in source
                                        where n.Customer_ID == id
                                        select n;
                }

                /* Dim q = From e1 In db.Employees, e2 In e1.Employees _
                 *  Where e1.City = e2.City _
                 *  Select FirstName1 = e1.FirstName, LastName1 = e1.LastName, _
                 *         FirstName2 = e2.FirstName, LastName2 = e2.LastName, e1.City*/

                var gridSource = from n in source
                                 join p in db.Customers on n.Customer_ID equals p.Customer_ID
                                 join q in db.Cars on n.Car_ID equals q.Car_ID
                                 orderby n.Date ascending
                                 select new
                {
                    Customer    = n.Customer_ID,
                    Name        = string.Concat(p.Last_Name, ", ", p.First_Name),
                    Car         = n.Car_ID,
                    Model       = q.Model,
                    Trim        = q.Trim,
                    Date        = n.Date,
                    Type        = n.Type,
                    Description = n.Description
                };

                GridView1.DataSource = gridSource;
                GridView1.DataBind();
            }

            lblCarID.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblVIN.ForeColor   = System.Drawing.ColorTranslator.FromHtml("#606760");
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var    dataSource = (IQueryable)Session["DataSource"];
            string department = (string)Session["Department"];

            if (Session["Employee_ID"] == null || department == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (department == "Admin")
            {
                GridView1.AutoGenerateDeleteButton = true;
            }
            else
            {
                GridView1.AutoGenerateDeleteButton = false;
            }

            if (!Page.IsPostBack)
            {
                int carID = 0;
                if (Session["Car_ID"] != null && Session["PreviousPage"] != null)
                {
                    carID        = (int)Session["Car_ID"];
                    tbCarID.Text = carID.ToString();
                }

                VWCTSDataContext db = new VWCTSDataContext();
                //using(VWCTSDataContext db = new VWCTSDataContext()){
                var source = from n in db.Cars
                             where n.Status == "On Lot"
                             select n;

                var gridSource = from n in source
                                 select new
                {
                    ID       = n.Car_ID, Model = n.Model, Trim = n.Trim,
                    Color    = n.Color, Transmission = n.Transmission,
                    Location = n.Location, Price = n.Price
                };

                GridView1.DataSource  = gridSource;
                Session["DataSource"] = source;
                GridView1.DataBind();
                //}
            }

            lblCarID.ForeColor        = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblModel.ForeColor        = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblTrim.ForeColor         = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblColor.ForeColor        = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblTransmission.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblListPrice.ForeColor    = System.Drawing.ColorTranslator.FromHtml("#606760");
        }
コード例 #6
0
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            string password = Hash(Login1.Password);

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                var department = from n in db.Employees
                                 where (n.User_Name == Login1.UserName && n.Password == password)
                                 select n;

                foreach (var n in department)
                {
                    Session["Employee_ID"] = n.Employee_ID;
                    Session["Department"]  = n.Department;
                    Response.Redirect("Browse_Cars.aspx");
                }
            }
        }
コード例 #7
0
        protected void ddlTrim_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                var options = from n in db.Optional_Packages
                              where ddlTrim.SelectedValue == n.Trim && ddlModel.SelectedValue == n.Model
                              select n;

                cblPackages.Items.Clear();
                foreach (var n in options)
                {
                    ListItem item = new ListItem();
                    item.Value = n.Package_ID.ToString();
                    item.Text  = n.Option_Name;
                    cblPackages.Items.Add(item);
                }
            }
        }
コード例 #8
0
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            string password = Hash(Login1.Password);

              using (VWCTSDataContext db = new VWCTSDataContext())
              {
            var department = from n in db.Employees
                         where (n.User_Name == Login1.UserName && n.Password == password)
                         select n;

            foreach (var n in department)
            {
              Session["Employee_ID"] = n.Employee_ID;
              Session["Department"] = n.Department;
              Response.Redirect("Browse_Cars.aspx");
            }
              }
        }
コード例 #9
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int row   = e.RowIndex;
            int carID = (int)GridView1.DataKeys[row].Value;

            IQueryable <Car> dataSource = (IQueryable <Car>)Session["DataSource"];
            var source = from n in dataSource
                         where n.Car_ID != carID
                         select n;

            Session["DataSource"] = source;

            VWCTSDataContext db = new VWCTSDataContext();
            var options         = from n in db.Car_Options
                                  where n.Car_ID == carID
                                  select n;

            foreach (var n in options)
            {
                db.Car_Options.DeleteOnSubmit(n);
            }

            Car deleteCar = (from n in db.Cars
                             where n.Car_ID == carID
                             select n).Single();

            db.Cars.DeleteOnSubmit(deleteCar);
            db.SubmitChanges();

            var gridSource = from n in source
                             select new
            {
                ID           = n.Car_ID,
                Model        = n.Model,
                Trim         = n.Trim,
                Color        = n.Color,
                Transmission = n.Transmission,
                Location     = n.Location,
                Price        = n.Price
            };

            GridView1.DataSource = gridSource;
            GridView1.DataBind();
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var    dataSource = (IQueryable)Session["DataSource"];
            string department = (string)Session["Department"];

            if (Session["Employee_ID"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!Page.IsPostBack)
            {
                VWCTSDataContext db = new VWCTSDataContext();
                var source          = from n in db.Customers
                                      select n;

                var gridSource = from n in source
                                 orderby n.Last_Name ascending
                                 select new
                {
                    ID      = n.Customer_ID,
                    Name    = string.Concat(n.Last_Name, ", ", n.First_Name),
                    Phone   = string.Concat(n.Area_Code, " ", n.Phone_Number),
                    Address = string.Concat(n.Street_Number, " ", n.City, " ",
                                            n.State, " ", n.Zip_Code)
                };

                GridView1.DataSource  = gridSource;
                Session["DataSource"] = source;
                GridView1.DataBind();
            }

            lblFirstName.ForeColor   = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblLastName.ForeColor    = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblAddress.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblCity.ForeColor        = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblState.ForeColor       = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblZipCode.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblPhoneNumber.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblID.ForeColor          = System.Drawing.ColorTranslator.FromHtml("#606760");
        }
コード例 #11
0
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            IQueryable <History> source = (IQueryable <History>)Session["DataSource"];
            VWCTSDataContext     db     = new VWCTSDataContext();
            var gridSource = from n in source
                             join p in db.Customers on n.Customer_ID equals p.Customer_ID
                             join q in db.Cars on n.Car_ID equals q.Car_ID
                             orderby n.Date ascending
                             select new
            {
                Customer    = n.Customer_ID,
                Name        = string.Concat(p.Last_Name, ", ", p.First_Name),
                Car         = n.Car_ID,
                Model       = q.Model,
                Trim        = q.Trim,
                Date        = n.Date,
                Type        = n.Type,
                Description = n.Description
            };

            GridView1.DataSource = gridSource;
            GridView1.PageIndex  = e.NewPageIndex;
            GridView1.DataBind();
        }
コード例 #12
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool error = false;
            int  employeeID = 0, areaCode = 0, phoneNumber = 0, zipCode = 0;

            if (tbFirstName.Text == "")
            {
                error = true;
                lblFirstName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbLastName.Text == "")
            {
                error = true;
                lblLastName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbAddress.Text == "")
            {
                error = true;
                lblAddress.ForeColor = System.Drawing.Color.Red;
            }

            if (tbCity.Text == "")
            {
                error             = true;
                lblCity.ForeColor = System.Drawing.Color.Red;
            }

            if (tbState.Text == "")
            {
                error = true;
                lblState.ForeColor = System.Drawing.Color.Red;
            }

            if (tbZipCode.Text == "")
            {
                error = true;
                lblZipCode.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbZipCode.Text, out zipCode))
                {
                    error = true;
                    lblZipCode.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbPhoneNumber.Text == "" || tbAreaCode.Text == "" || tbPhoneNumber.Text.Length < 7 || tbAreaCode.Text.Length < 3)
            {
                error = true;
                lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbPhoneNumber.Text, out phoneNumber))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }

                if (!int.TryParse(tbAreaCode.Text, out areaCode))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbPassword.Text == "")
            {
                error = true;
                lblPassword.ForeColor = System.Drawing.Color.Red;
            }

            if (tbPassword2.Text == "")
            {
                error = true;
                lblPassword2.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (tbPassword.Text != tbPassword2.Text)
                {
                    error = true;
                    lblPassword.ForeColor  = System.Drawing.Color.Red;
                    lblPassword2.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (ddlDepartment.SelectedValue == "")
            {
                error = true;
                lblDepartment.ForeColor = System.Drawing.Color.Red;
            }

            if (tbUserName.Text == "")
            {
                error = true;
                lblUserName.ForeColor = System.Drawing.Color.Red;
            }

            if (error)
            {
                return;
            }


            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                Employee newEmployee = new Employee();
                newEmployee.Area_Code     = areaCode;
                newEmployee.City          = tbCity.Text;
                newEmployee.First_Name    = tbFirstName.Text;
                newEmployee.Last_Name     = tbLastName.Text;
                newEmployee.Phone_Number  = phoneNumber;
                newEmployee.State         = tbState.Text;
                newEmployee.Street_Number = tbAddress.Text;
                newEmployee.Zip_Code      = zipCode;
                newEmployee.Password      = tbPassword.Text;
                newEmployee.User_Name     = tbUserName.Text;
                newEmployee.Department    = ddlDepartment.SelectedValue;
                db.Employees.InsertOnSubmit(newEmployee);

                db.SubmitChanges();
                lblMessage.Text = "Employee Added";

                btnSubmit.Enabled      = false;
                btnCancel.Enabled      = false;
                btnNewEmployee.Visible = true;
            }
        }
コード例 #13
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool error = false;
            int  employeeID = 0, areaCode = 0, phoneNumber = 0, zipCode = 0;

            if (tbFirstName.Text == "")
            {
                error = true;
                lblFirstName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbLastName.Text == "")
            {
                error = true;
                lblLastName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbAddress.Text == "")
            {
                error = true;
                lblAddress.ForeColor = System.Drawing.Color.Red;
            }

            if (tbCity.Text == "")
            {
                error = true;
                lblCity.ForeColor = System.Drawing.Color.Red;
            }

            if (tbState.Text == "")
            {
                error = true;
                lblState.ForeColor = System.Drawing.Color.Red;
            }

            if (tbZipCode.Text == "")
            {
                error = true;
                lblZipCode.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbZipCode.Text, out zipCode))
                {
                    error = true;
                    lblZipCode.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbPhoneNumber.Text == "" || tbAreaCode.Text == "" || tbPhoneNumber.Text.Length < 7 || tbAreaCode.Text.Length < 3)
            {
                error = true;
                lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbPhoneNumber.Text, out phoneNumber))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }

                if (!int.TryParse(tbAreaCode.Text, out areaCode))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbPassword.Text == "")
            {
                error = true;
                lblPassword.ForeColor = System.Drawing.Color.Red;
            }

            if (tbPassword2.Text == "")
            {
                error = true;
                lblPassword2.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (tbPassword.Text != tbPassword2.Text)
                {
                    error = true;
                    lblPassword.ForeColor = System.Drawing.Color.Red;
                    lblPassword2.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (ddlDepartment.SelectedValue == "")
            {
              error = true;
              lblDepartment.ForeColor = System.Drawing.Color.Red;
            }

            if (tbUserName.Text == "")
            {
              error = true;
              lblUserName.ForeColor = System.Drawing.Color.Red;
            }

            if (error)
                return;

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
              Employee newEmployee = new Employee();
              newEmployee.Area_Code = areaCode;
              newEmployee.City = tbCity.Text;
              newEmployee.First_Name = tbFirstName.Text;
              newEmployee.Last_Name = tbLastName.Text;
              newEmployee.Phone_Number = phoneNumber;
              newEmployee.State = tbState.Text;
              newEmployee.Street_Number = tbAddress.Text;
              newEmployee.Zip_Code = zipCode;
              newEmployee.Password = tbPassword.Text;
              newEmployee.User_Name = tbUserName.Text;
              newEmployee.Department = ddlDepartment.SelectedValue;
              db.Employees.InsertOnSubmit(newEmployee);

              db.SubmitChanges();
              lblMessage.Text = "Employee Added";

              btnSubmit.Enabled = false;
              btnCancel.Enabled = false;
              btnNewEmployee.Visible = true;
            }
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataSource = (IQueryable) Session["DataSource"];
            string department = (string)Session["Department"];

            if (Session["Employee_ID"] == null || department == null)
              Response.Redirect("Login.aspx");

            if (department == "Admin")
              GridView1.AutoGenerateDeleteButton = true;
            else
              GridView1.AutoGenerateDeleteButton = false;

            if (!Page.IsPostBack)
            {
              int carID = 0;
              if(Session["Car_ID"] != null && Session["PreviousPage"] !=null){
            carID = (int)Session["Car_ID"];
            tbCarID.Text = carID.ToString();
              }

              VWCTSDataContext db = new VWCTSDataContext();
              //using(VWCTSDataContext db = new VWCTSDataContext()){
            var source = from n in db.Cars
                         where n.Status == "On Lot"
                         select n;

            var gridSource = from n in source
                          select new
                          {
                            ID = n.Car_ID, Model = n.Model, Trim = n.Trim,
                            Color = n.Color, Transmission = n.Transmission,
                            Location = n.Location, Price = n.Price
                          };

            GridView1.DataSource = gridSource;
            Session["DataSource"] = source;
            GridView1.DataBind();
              //}
            }

            lblCarID.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblModel.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblTrim.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblColor.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblTransmission.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblListPrice.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
        }
コード例 #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataSource = (IQueryable)Session["DataSource"];
              string department = (string)Session["Department"];

              if (Session["Employee_ID"] == null)
            Response.Redirect("Login.aspx");

              if (Session["CarHistory"] == null)
            Response.Redirect("Browse_History.aspx");

              int carID = (int)Session["CarHistory"];

              VWCTSDataContext db = new VWCTSDataContext();
              int customerID = (from n in db.Histories
                        where n.Car_ID == carID
                        select n.Customer_ID).First();

              var source = from n in db.Histories
                   where n.Car_ID == carID
                   select n;

              Session["DataSource"] = source;
              var gridSource = from n in source
               orderby n.Date ascending
               select new
               {
                 Date = n.Date,
                 Type = n.Type,
                 Description = n.Description
               };

              GridView1.DataSource = gridSource;
              GridView1.DataBind();

              var car = (from n in db.Cars
                where n.Car_ID == carID
                select n).Single();

              tbCarID.Text = carID.ToString();
              tbVIN.Text = car.VIN;
              tbModel.Text = car.Model;
              tbTrim.Text = car.Trim;
              tbTransmission.Text = car.Transmission;
              tbColor.Text = car.Color;
              tbMiles.Text = car.Miles.ToString();

              var customer = (from n in db.Customers
                      where n.Customer_ID == customerID
                      select n).Single();

              tbLastName.Text = customer.Last_Name;
              tbFirstName.Text = customer.First_Name;
              tbAreaCode.Text = customer.Area_Code.ToString();
              tbPhoneNumber.Text = customer.Phone_Number.ToString();
              tbCity.Text = customer.City;
              tbState.Text = customer.State;
              tbZipCode.Text = customer.Zip_Code.ToString();
              tbAddress.Text = customer.Street_Number;
              tbCustomerID.Text = customer.Customer_ID.ToString();
        }
コード例 #16
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VWCTSDataContext db = new VWCTSDataContext();
              var queryResults = from n in db.Customers
                         select n;

              if (tbID.Text != "")
              {
            int id = 0;
            if (!int.TryParse(tbID.Text, out id))
            {
              lblID.ForeColor = System.Drawing.Color.Red;
              return;
            }

            queryResults = from n in queryResults
                       where id == n.Customer_ID
                       select n;
              }

              if (tbFirstName.Text != "")
              {
            queryResults = from n in queryResults
                       where tbFirstName.Text == n.First_Name
                       select n;
              }

              if (tbLastName.Text != "")
              {
            queryResults = from n in queryResults
                       where tbLastName.Text == n.Last_Name
                       select n;
              }

              if (tbAddress.Text != "")
              {
            queryResults = from n in queryResults
                       where tbAddress.Text == n.Street_Number
                       select n;
              }

              if (tbCity.Text != "")
              {
            queryResults = from n in queryResults
                       where tbCity.Text == n.City
                       select n;
              }

              if (tbState.Text != "")
              {
            queryResults = from n in queryResults
                       where tbState.Text == n.State
                       select n;
              }

              if(tbZipCode.Text != "")
              {
            int zip = 0;
            if(!int.TryParse(tbZipCode.Text, out zip)){
              lblZipCode.ForeColor = System.Drawing.Color.Red;
              return;
            }

            queryResults = from n in queryResults
                       where zip == n.Zip_Code
                       select n;
              }

              if(tbAreaCode.Text != "" && tbPhoneNumber.Text != ""){
            int area = 0;
            int num = 0;

            if(!int.TryParse(tbAreaCode.Text, out area)){
              lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
              return;
            }

            if(!int.TryParse(tbPhoneNumber.Text, out num)){
              lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
              return;
            }

            queryResults = from n in queryResults
                       where area == n.Area_Code && num == n.Phone_Number
                       select n;
              }
              else if(tbAreaCode.Text != "" || tbPhoneNumber.Text != "")
              {
            lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            return;
              }

              var gridSource = from n in queryResults
                       orderby n.Last_Name ascending
                       select new
                       {
                         ID = n.Customer_ID,
                         Name = string.Concat(n.Last_Name, ", ", n.First_Name),
                         Phone = string.Concat(n.Area_Code, " ", n.Phone_Number),
                         Address = string.Concat(n.Street_Number, " ", n.City, " ",
                                                 n.State, " ", n.Zip_Code)
                       };

              GridView1.DataSource = gridSource;
              Session["DataSource"] = queryResults;
              GridView1.DataBind();
        }
コード例 #17
0
        protected void ddlTrim_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (VWCTSDataContext db = new VWCTSDataContext())
              {
            var options = from n in db.Optional_Packages
                          where ddlTrim.SelectedValue == n.Trim && ddlModel.SelectedValue == n.Model
                          select n;

            cblPackages.Items.Clear();
            foreach (var n in options)
            {
              ListItem item = new ListItem();
              item.Value = n.Package_ID.ToString();
              item.Text = n.Option_Name;
              cblPackages.Items.Add(item);
            }
              }
        }
コード例 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string department = (string)Session["Department"];
              if (department == null)
            Response.Redirect("Login.aspx");

              if (Session["Selected Car"] == null)
              {
            if (Request.UrlReferrer == null)
              Response.Redirect("Browse_Cars.aspx");
            else
              Response.Redirect(Request.UrlReferrer.ToString());
              }
              else
              {
            int id = (int)Session["Selected Car"];

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
              var car = (from n in db.Cars
                     where n.Car_ID == id
                     select n).Single();

              tbCarID.Text = car.Car_ID.ToString();
              tbVin.Text = car.VIN.ToString();
              tbModel.Text = car.Model;
              tbTrim.Text = car.Trim;
              tbMiles.Text = car.Miles.ToString();
              tbColor.Text = car.Color;
              tbTransmission.Text = car.Transmission;
              tbListPrice.Text = car.Price.ToString();
              tbLocation.Text = car.Location;
              tbStatus.Text = car.Status;
              imgCar.ImageUrl = car.Picture;

              if (department == "Admin")
              {
            LblInvoice.Visible = true;
            tbInvoice.Visible = true;
            tbInvoice.Text = car.Invoice.ToString();
              }

              var options = from n in db.Car_Options
                        where n.Car_ID == car.Car_ID
                        select n;

              foreach (var n in options)
              {
            ListItem newItem = new ListItem();
            newItem.Enabled = true;
            newItem.Value = n.Package_ID.ToString();

            var package = (from p in db.Optional_Packages
                           where p.Package_ID == n.Package_ID
                           select p).Single();
            newItem.Text = package.Option_Name;
            cblPackages.Items.Add(newItem);
              }
            }
              }

              if (imgCar.ImageUrl == "" || imgCar.ImageUrl == null)
            imgCar.Visible = false;
        }
コード例 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string department = (string)Session["Department"];

            if (department == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (Session["Selected Car"] == null)
            {
                if (Request.UrlReferrer == null)
                {
                    Response.Redirect("Browse_Cars.aspx");
                }
                else
                {
                    Response.Redirect(Request.UrlReferrer.ToString());
                }
            }
            else
            {
                int id = (int)Session["Selected Car"];

                using (VWCTSDataContext db = new VWCTSDataContext())
                {
                    var car = (from n in db.Cars
                               where n.Car_ID == id
                               select n).Single();

                    tbCarID.Text        = car.Car_ID.ToString();
                    tbVin.Text          = car.VIN.ToString();
                    tbModel.Text        = car.Model;
                    tbTrim.Text         = car.Trim;
                    tbMiles.Text        = car.Miles.ToString();
                    tbColor.Text        = car.Color;
                    tbTransmission.Text = car.Transmission;
                    tbListPrice.Text    = car.Price.ToString();
                    tbLocation.Text     = car.Location;
                    tbStatus.Text       = car.Status;
                    imgCar.ImageUrl     = car.Picture;

                    if (department == "Admin")
                    {
                        LblInvoice.Visible = true;
                        tbInvoice.Visible  = true;
                        tbInvoice.Text     = car.Invoice.ToString();
                    }

                    var options = from n in db.Car_Options
                                  where n.Car_ID == car.Car_ID
                                  select n;

                    foreach (var n in options)
                    {
                        ListItem newItem = new ListItem();
                        newItem.Enabled = true;
                        newItem.Value   = n.Package_ID.ToString();

                        var package = (from p in db.Optional_Packages
                                       where p.Package_ID == n.Package_ID
                                       select p).Single();
                        newItem.Text = package.Option_Name;
                        cblPackages.Items.Add(newItem);
                    }
                }
            }

            if (imgCar.ImageUrl == "" || imgCar.ImageUrl == null)
            {
                imgCar.Visible = false;
            }
        }
コード例 #20
0
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            IQueryable<History> source = (IQueryable<History>)Session["DataSource"];
              VWCTSDataContext db = new VWCTSDataContext();
              var gridSource = from n in source
                       join p in db.Customers on n.Customer_ID equals p.Customer_ID
                       join q in db.Cars on n.Car_ID equals q.Car_ID
                       orderby n.Date ascending
                       select new
                       {
                         Customer = n.Customer_ID,
                         Name = string.Concat(p.Last_Name, ", ", p.First_Name),
                         Car = n.Car_ID,
                         Model = q.Model,
                         Trim = q.Trim,
                         Date = n.Date,
                         Type = n.Type,
                         Description = n.Description
                       };

              GridView1.DataSource = gridSource;
              GridView1.PageIndex = e.NewPageIndex;
              GridView1.DataBind();
        }
コード例 #21
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VWCTSDataContext db = new VWCTSDataContext();
              var queryResults = from n in db.Histories
                         where n.Type == "Initial Delivery"
                         select n;

              if (tbCarID.Text != "")
              {
            int id = 0;
            if (!int.TryParse(tbCarID.Text, out id))
            {
              lblCarID.ForeColor = System.Drawing.Color.Red;
              return;
            }

            queryResults = from n in queryResults
                       where id == n.Car_ID
                       select n;
              }

              if (tbCustomerID.Text != "")
              {
            int id = 0;
            if (!int.TryParse(tbCustomerID.Text, out id))
            {
              lblCustomerID.ForeColor = System.Drawing.Color.Red;
              return;
            }

            queryResults = from n in queryResults
                       where id == n.Customer_ID
                       select n;
              }

              if (tbVIN.Text != "")
              {
            var carID = (from n in db.Cars
                    where n.VIN == tbVIN.Text
                    select n.Car_ID).Single();

            queryResults = from n in queryResults
                       where carID == n.Car_ID
                       select n;
              }

              if (tbLastName.Text != "")
              {
            var customerID = (from n in db.Customers
                          where tbLastName.Text == n.Last_Name
                          select n.Customer_ID).Single();

            queryResults = from n in queryResults
                       where customerID == n.Customer_ID
                       select n;
              }

              var gridSource = from n in queryResults
                       join p in db.Customers on n.Customer_ID equals p.Customer_ID
                       join q in db.Cars on n.Car_ID equals q.Car_ID
                       orderby n.Date ascending
                       select new
                       {
                         Customer = n.Customer_ID,
                         Name = string.Concat(p.Last_Name, ", ", p.First_Name),
                         Car = n.Car_ID,
                         Model = q.Model,
                         Trim = q.Trim,
                         Date = n.Date,
                         Type = n.Type,
                         Description = n.Description
                       };

              GridView1.DataSource = gridSource;
              Session["DataSource"] = queryResults;
              GridView1.DataBind();
        }
コード例 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataSource = (IQueryable)Session["DataSource"];
              string department = (string)Session["Department"];

              if (Session["Employee_ID"] == null)
            Response.Redirect("Login.aspx");

              if (!Page.IsPostBack)
              {
            Session["CarHistory"] = null;

            VWCTSDataContext db = new VWCTSDataContext();
            var source = from n in db.Histories
                     where n.Type == "Initial Delivery"
                     select n;

            Session["DataSource"] = source;
            if(Session["Customer_ID"] != null){
              int id = (int)Session["Customer_ID"];
              tbCustomerID.Text = id.ToString();
              source = from n in source
                   where n.Customer_ID == id
                   select n;
            }

            /* Dim q = From e1 In db.Employees, e2 In e1.Employees _
            Where e1.City = e2.City _
            Select FirstName1 = e1.FirstName, LastName1 = e1.LastName, _
                   FirstName2 = e2.FirstName, LastName2 = e2.LastName, e1.City*/

            var gridSource = from n in source
                         join p in db.Customers on n.Customer_ID equals p.Customer_ID
                         join q in db.Cars on n.Car_ID equals q.Car_ID
                         orderby n.Date ascending
                         select new
                         {
                           Customer = n.Customer_ID,
                           Name = string.Concat(p.Last_Name, ", ", p.First_Name),
                           Car = n.Car_ID,
                           Model = q.Model,
                           Trim = q.Trim,
                           Date = n.Date,
                           Type = n.Type,
                           Description = n.Description
                         };

            GridView1.DataSource = gridSource;
            GridView1.DataBind();
              }

              lblCarID.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblVIN.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
        }
コード例 #23
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VWCTSDataContext db = new VWCTSDataContext();
            var queryResults    = from n in db.Cars
                                  where n.Status == "On Lot"
                                  select n;

            if (tbCarID.Text != "")
            {
                int id = 0;
                if (!int.TryParse(tbCarID.Text, out id))
                {
                    lblCarID.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where id == n.Car_ID
                               select n;
            }

            if (ddlModel.SelectedValue != "")
            {
                queryResults = from n in queryResults
                               where ddlModel.SelectedValue == n.Model
                               select n;
            }


            if (ddlTrim.Text != "")
            {
                queryResults = from n in queryResults
                               where ddlTrim.SelectedValue == n.Trim
                               select n;
            }

            if (ddlColor.Text != "")
            {
                queryResults = from n in queryResults
                               where ddlColor.SelectedValue == n.Color
                               select n;
            }

            if (ddlTransmission.Text != "")
            {
                queryResults = from n in queryResults
                               where ddlTransmission.SelectedValue == n.Transmission
                               select n;
            }

            if (tbListPriceLow.Text != "")
            {
                int low = 0;
                if (!int.TryParse(tbListPriceLow.Text, out low))
                {
                    lblListPrice.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where low <= n.Price
                               select n;
            }

            if (tbListPriceHigh.Text != "")
            {
                int high = 0;
                if (!int.TryParse(tbListPriceHigh.Text, out high))
                {
                    lblListPrice.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where high >= n.Price
                               select n;
            }

            var gridSource = from n in queryResults
                             select new
            {
                ID           = n.Car_ID,
                Model        = n.Model,
                Trim         = n.Trim,
                Color        = n.Color,
                Transmission = n.Transmission,
                Location     = n.Location,
                Price        = n.Price
            };

            GridView1.DataSource  = gridSource;
            Session["DataSource"] = queryResults;
            GridView1.DataBind();
        }
コード例 #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Employee_ID"] == null)
              Response.Redirect("Login.aspx");

            lblFirstName.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblLastName.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblAddress.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblCity.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblState.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblZipCode.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblPhoneNumber.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblAdditionalInfo.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");

            if (!IsPostBack)
            {
               if (Session["Last"] != null)
            tbLastName.Text = (string)Session["Last"];

              if (Session["First"] != null)
            tbFirstName.Text = (string)Session["First"];

              if (Session["Address"] != null)
            tbAddress.Text = (string)Session["Address"];

              if (Session["City"] != null)
            tbCity.Text = (string)Session["City"];

              if (Session["State"] != null)
            tbState.Text = (string)Session["State"];

              if (Session["City"] != null)
            tbZipCode.Text = (string)Session["City"];

              if (Session["Area"] != null)
            tbAreaCode.Text = (string)Session["Area"];

              if (Session["Phone"] != null)
            tbPhoneNumber.Text = (string)Session["Phone"];

              if (Session["Car_ID"] != null)
              {
            int carID = (int)Session["Car_ID"];

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
              var car = (from n in db.Cars
                         where carID == n.Car_ID
                         select n).Single();

              tbCarID.Text = car.Car_ID.ToString(); ;
              tbVin.Text = car.VIN;
              tbModel.Text = car.Model;
              tbTrim.Text = car.Trim;
              tbMiles.Text = car.Miles.ToString();
            }
              }

              if (Session["Customer_ID"] != null)
              {
            int customerID = (int)Session["Customer_ID"];

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
              var customer = (from n in db.Customers
                              where customerID == n.Customer_ID
                              select n).Single();

              tbExistingCustomer.Text = customer.Customer_ID.ToString();
              tbFirstName.Text = customer.First_Name;
              tbLastName.Text = customer.Last_Name;
              tbAddress.Text = customer.Street_Number;
              tbCity.Text = customer.City;
              tbState.Text = customer.State;
              tbZipCode.Text = customer.Zip_Code.ToString();
              tbAreaCode.Text = customer.Area_Code.ToString();
              tbPhoneNumber.Text = customer.Phone_Number.ToString();

              var carID = from n in db.Histories
                          where n.Customer_ID == customer.Customer_ID
                                && n.Type == "Initial Delivery"
                          select n.Car_ID;

              if (carID.Count() == 1)
              {
                foreach (var id in carID)
                {
                  var car = (from n in db.Cars
                             where id == n.Car_ID
                             select n).Single();

                  tbCarID.Text = car.Car_ID.ToString(); ;
                  tbVin.Text = car.VIN;
                  tbModel.Text = car.Model;
                  tbTrim.Text = car.Trim;
                  tbMiles.Text = car.Miles.ToString();
                }
              }
            }
              }
            }
        }
コード例 #25
0
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            decimal salesPrice;
            int carID = (int)GridView1.SelectedDataKey.Value;
            string previousPage = (string)Session["PreviousPage"];
            Session["Car_ID"] = carID;

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
              salesPrice = (from n in db.Cars
                        where n.Car_ID == carID
                        select n.Price).Single();
            }

            Session["Sales_Price"] = salesPrice;

            if (previousPage != null)
              Response.Redirect(previousPage);
            else
              Response.Redirect("Process_Order.aspx");
        }
コード例 #26
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool error = false;
              int carID = 0, customerID = 0, areaCode = 0, phoneNumber = 0, zipCode = 0;
              decimal downPayment = 0, amountFinanced = 0, tradeValue = 0, salesPrice = 0;

              if (tbFirstName.Text == "")
              {
            error = true;
            lblFirstName.ForeColor = System.Drawing.Color.Red;
              }

              if (tbLastName.Text == "")
              {
            error = true;
            lblLastName.ForeColor = System.Drawing.Color.Red;
              }

              if (tbAddress.Text == "")
              {
            error = true;
            lblAddress.ForeColor = System.Drawing.Color.Red;
              }

              if (tbCity.Text == "")
              {
            error = true;
            lblCity.ForeColor = System.Drawing.Color.Red;
              }

              if (tbState.Text == "")
              {
            error = true;
            lblState.ForeColor = System.Drawing.Color.Red;
              }

              if (tbZipCode.Text == "")
              {
            error = true;
            lblZipCode.ForeColor = System.Drawing.Color.Red;
              }
              else{
            if(!int.TryParse(tbZipCode.Text, out zipCode)){
              error = true;
              lblZipCode.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (tbPhoneNumber.Text == "" || tbAreaCode.Text == "" || tbPhoneNumber.Text.Length < 7 || tbAreaCode.Text.Length < 3)
              {
            error = true;
            lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
              }
              else{
            if (!int.TryParse(tbPhoneNumber.Text, out phoneNumber))
            {
              error = true;
              lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }

            if(!int.TryParse(tbAreaCode.Text, out areaCode)){
              error = true;
              lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (tbCarID.Text == "")
              {
            error = true;
            lblCarID.ForeColor = System.Drawing.Color.Red;
              }
              else
              {
            if(!int.TryParse(tbCarID.Text, out carID)){
              error = true;
              lblCarID.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (tbAmountFinanced.Text == "")
            amountFinanced = 0;
              else
              {
            if(!decimal.TryParse(tbAmountFinanced.Text, out amountFinanced)){
              error = true;
              lblAmountFinanced.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (tbDownPayment.Text == "")
            downPayment = 0;
              else{
            if(!decimal.TryParse(tbDownPayment.Text, out downPayment)){
              error = true;
              lblDownPayment.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (tbTradeValue.Text == "")
            tradeValue = 0;
              else{
            if(!decimal.TryParse(tbTradeValue.Text, out tradeValue)){
              error = true;
              lblTradeValue.ForeColor = System.Drawing.Color.Red;
            }
              }

              if(tbSalesPrice.Text == ""){
            error = true;
            lblSalesPrice.ForeColor = System.Drawing.Color.Red;
              }
              else{
            if(!decimal.TryParse(tbSalesPrice.Text, out salesPrice)){
              error = true;
              lblSalesPrice.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (salesPrice != (tradeValue + downPayment + amountFinanced))
              {
            error = true;
            lblTradeValue.ForeColor = System.Drawing.Color.Red;
            lblDownPayment.ForeColor = System.Drawing.Color.Red;
            lblAmountFinanced.ForeColor = System.Drawing.Color.Red;
              }

              if (error)
            return;

              //LINQ TO SQL CODE TO SUBMIT TRANSACTION AND CUSTOMER IF NEW
              using (VWCTSDataContext db = new VWCTSDataContext())
              {
            if (Session["Customer_ID"] == null)
            {
              Customer newCustomer = new Customer();
              newCustomer.First_Name = tbFirstName.Text;
              newCustomer.Last_Name = tbLastName.Text;
              newCustomer.Street_Number = tbAddress.Text;
              newCustomer.City = tbCity.Text;
              newCustomer.State = tbState.Text;
              newCustomer.Zip_Code = zipCode;
              newCustomer.Area_Code = areaCode;
              newCustomer.Phone_Number = phoneNumber;

              db.Customers.InsertOnSubmit(newCustomer);
              db.SubmitChanges();

              customerID = (from n in db.Customers
                            select n.Customer_ID).Max();
            }
            else
            {
              customerID = (int)Session["Customer_ID"];
              db.Update_Customer(customerID, tbFirstName.Text, tbLastName.Text, areaCode,
                                  phoneNumber, tbAddress.Text, tbCity.Text, tbState.Text, zipCode);
            }

            int employeeID = 0;
            if (Session["Employee_ID"] == null)
              employeeID = 1;
            else
              employeeID = (int)Session["Employee_ID"];

            Transaction newTransaction = new Transaction();
            newTransaction.Car_ID = carID;
            newTransaction.Customer_ID = customerID;
            newTransaction.Amount_Financed = amountFinanced;
            newTransaction.Date = System.DateTime.Today;
            newTransaction.Down_Payment = downPayment;
            newTransaction.Employee_ID = employeeID;
            newTransaction.Sales_Price = salesPrice;
            newTransaction.Trade_Value = tradeValue;
            db.Transactions.InsertOnSubmit(newTransaction);

            History newHistory = new History();
            newHistory.Car_ID = carID;
            newHistory.Customer_ID = customerID;
            newHistory.Type = "Initial Delivery";
            newHistory.Date = DateTime.Today;
            db.Histories.InsertOnSubmit(newHistory);

            var update = (from n in db.Cars
                         where n.Car_ID == carID
                         select n).Single();
            update.Price = decimal.Parse(tbSalesPrice.Text);
            update.Status = "Sold";
            db.SubmitChanges();
              }

              Session["Car_ID"] = null;
              Session["Sales_Price"] = null;
              Session["Customer_ID"] = null;
              Session["PreviousPage"] = null;

              Session["Last"] = null;
              Session["First"] = null;
              Session["Address"] = null;
              Session["City"] = null;
              Session["State"] = null;
              Session["City"] = null;
              Session["Area"] = null;
              Session["Phone"] = null;

              btnSubmit.Enabled = false;
              btnCancel.Enabled = false;
              btnFind.Enabled = false;
              btnFindCar.Enabled = false;
              Label2.Text = "Order Processed";
              Label2.ForeColor = System.Drawing.Color.Red;
        }
コード例 #27
0
        protected void btnAdd_Car_Click(object sender, EventArgs e)
        {
            bool error = false;
              bool image = false;
              decimal invoice;
              decimal listPrice;
              string path = " ";
              Car_Option newOption;

              if (tbVin.Text.Length != 17)
              {
            error = true;
            lblVin.ForeColor = System.Drawing.Color.Red;
              }

              if (ddlModel.SelectedValue == "")
              {
            error = true;
            lblModel.ForeColor = System.Drawing.Color.Red;
              }

              if (ddlTrim.SelectedValue == "")
              {
            error = true;
            lblTrim.ForeColor = System.Drawing.Color.Red;
              }

              if(ddlColor.SelectedValue == "")
              {
            error = true;
            lblColor.ForeColor = System.Drawing.Color.Red;
              }

              if(ddlTransmission.SelectedValue == "")
              {
            error = true;
            lblTransmission.ForeColor = System.Drawing.Color.Red;
              }

              if (tbLocation.Text == "")
              {
            error = true;
            lblLocation.ForeColor = System.Drawing.Color.Red;
              }

              if (!decimal.TryParse(tbInvoice.Text, out invoice))
              {
            error = true;
            lblInvoice.ForeColor = System.Drawing.Color.Red;
              }

              if (!decimal.TryParse(tbListPrice.Text, out listPrice))
              {
            error = true;
            lblListPrice.ForeColor = System.Drawing.Color.Red;
              }

              if (error) return;

              if(uploadPhoto.PostedFile.ContentLength > 0 && uploadPhoto.FileName != ""){
            path = "~\\images\\" + uploadPhoto.FileName;
            imageUpload.ImageUrl = path;
            image = true;
              }

              using (VWCTSDataContext db = new VWCTSDataContext())
              {
            Car newCar = new Car();
            newCar.Model = ddlModel.SelectedValue;
            newCar.Trim = ddlTrim.SelectedValue;
            newCar.VIN = tbVin.Text;
            newCar.Color = ddlColor.SelectedValue;
            newCar.Transmission = ddlTransmission.SelectedValue;
            newCar.Invoice = decimal.Parse(tbInvoice.Text);
            newCar.Price = decimal.Parse(tbListPrice.Text);
            newCar.Location = tbLocation.Text;
            newCar.Status = "On Lot";
            newCar.Miles = 0;
            if(image)
              newCar.Picture = path;

            db.Cars.InsertOnSubmit(newCar);
            db.SubmitChanges();

            int id = (from n in db.Cars
                      select n.Car_ID).Max();

            foreach (ListItem n in cblPackages.Items)
            {
              if(n is ListItem){
                newOption = new Car_Option();
                newOption.Car_ID = id;
                newOption.Package_ID = int.Parse(n.Value);
                db.Car_Options.InsertOnSubmit(newOption);
              }
            }
            db.SubmitChanges();

            lblCarSubmitted.Text = "Car " + id + " Added Successfully";
            btnAddCar.Enabled = false;
            btnAddAnother.Visible = true;
              }
        }
コード例 #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Employee_ID"] == null)
              Response.Redirect("Login.aspx");

            if (!IsPostBack)
            {
              if (Session["Car_ID"] != null)
              {
            int carID = (int)Session["Car_ID"];
            tbCarID.Text = carID.ToString();
              }

              if (Session["Sales_Price"] != null)
              {
            decimal price = (decimal)Session["Sales_Price"];
            tbSalesPrice.Text = price.ToString();
              }

              if (Session["Last"] != null)
            tbLastName.Text = (string)Session["Last"];

              if (Session["First"] != null)
            tbFirstName.Text = (string)Session["First"];

              if (Session["Address"] != null)
            tbAddress.Text = (string)Session["Address"];

              if (Session["City"] != null)
            tbCity.Text = (string)Session["City"];

              if (Session["State"] != null)
            tbState.Text = (string)Session["State"];

              if (Session["City"] != null)
            tbZipCode.Text = (string)Session["City"];

              if (Session["Area"] != null)
            tbAreaCode.Text = (string)Session["Area"];

              if (Session["Phone"] != null)
            tbPhoneNumber.Text = (string)Session["Phone"];

              if (Session["PreviousPage"] == "Process_Order.aspx" && Session["Customer_ID"] != null)
              {
            int customerID = (int)Session["Customer_ID"];

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
              var customer = (from n in db.Customers
                              where n.Customer_ID == customerID
                              select n).Single();

              tbExistingCustomer.Text = customer.Customer_ID.ToString();
              tbFirstName.Text = customer.First_Name;
              tbLastName.Text = customer.Last_Name;
              tbAddress.Text = customer.Street_Number;
              tbCity.Text = customer.City;
              tbState.Text = customer.State;
              tbZipCode.Text = customer.Zip_Code.ToString();
              tbAreaCode.Text = customer.Area_Code.ToString();
              tbPhoneNumber.Text = customer.Phone_Number.ToString();
            }
              }

              lblFirstName.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblLastName.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblAddress.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblCity.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblState.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblZipCode.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblPhoneNumber.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");

              lblCarID.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblAmountFinanced.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblDownPayment.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblTradeValue.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblSalesPrice.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");

              lblExistingCustomer.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            }
        }
コード例 #29
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VWCTSDataContext db = new VWCTSDataContext();
            var queryResults    = from n in db.Customers
                                  select n;

            if (tbID.Text != "")
            {
                int id = 0;
                if (!int.TryParse(tbID.Text, out id))
                {
                    lblID.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where id == n.Customer_ID
                               select n;
            }

            if (tbFirstName.Text != "")
            {
                queryResults = from n in queryResults
                               where tbFirstName.Text == n.First_Name
                               select n;
            }

            if (tbLastName.Text != "")
            {
                queryResults = from n in queryResults
                               where tbLastName.Text == n.Last_Name
                               select n;
            }

            if (tbAddress.Text != "")
            {
                queryResults = from n in queryResults
                               where tbAddress.Text == n.Street_Number
                               select n;
            }

            if (tbCity.Text != "")
            {
                queryResults = from n in queryResults
                               where tbCity.Text == n.City
                               select n;
            }

            if (tbState.Text != "")
            {
                queryResults = from n in queryResults
                               where tbState.Text == n.State
                               select n;
            }

            if (tbZipCode.Text != "")
            {
                int zip = 0;
                if (!int.TryParse(tbZipCode.Text, out zip))
                {
                    lblZipCode.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where zip == n.Zip_Code
                               select n;
            }

            if (tbAreaCode.Text != "" && tbPhoneNumber.Text != "")
            {
                int area = 0;
                int num  = 0;

                if (!int.TryParse(tbAreaCode.Text, out area))
                {
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                if (!int.TryParse(tbPhoneNumber.Text, out num))
                {
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where area == n.Area_Code && num == n.Phone_Number
                               select n;
            }
            else if (tbAreaCode.Text != "" || tbPhoneNumber.Text != "")
            {
                lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                return;
            }

            var gridSource = from n in queryResults
                             orderby n.Last_Name ascending
                             select new
            {
                ID      = n.Customer_ID,
                Name    = string.Concat(n.Last_Name, ", ", n.First_Name),
                Phone   = string.Concat(n.Area_Code, " ", n.Phone_Number),
                Address = string.Concat(n.Street_Number, " ", n.City, " ",
                                        n.State, " ", n.Zip_Code)
            };

            GridView1.DataSource  = gridSource;
            Session["DataSource"] = queryResults;
            GridView1.DataBind();
        }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var    dataSource = (IQueryable)Session["DataSource"];
            string department = (string)Session["Department"];

            if (Session["Employee_ID"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (Session["CarHistory"] == null)
            {
                Response.Redirect("Browse_History.aspx");
            }

            int carID = (int)Session["CarHistory"];

            VWCTSDataContext db = new VWCTSDataContext();
            int customerID      = (from n in db.Histories
                                   where n.Car_ID == carID
                                   select n.Customer_ID).First();

            var source = from n in db.Histories
                         where n.Car_ID == carID
                         select n;

            Session["DataSource"] = source;
            var gridSource = from n in source
                             orderby n.Date ascending
                             select new
            {
                Date        = n.Date,
                Type        = n.Type,
                Description = n.Description
            };

            GridView1.DataSource = gridSource;
            GridView1.DataBind();

            var car = (from n in db.Cars
                       where n.Car_ID == carID
                       select n).Single();

            tbCarID.Text        = carID.ToString();
            tbVIN.Text          = car.VIN;
            tbModel.Text        = car.Model;
            tbTrim.Text         = car.Trim;
            tbTransmission.Text = car.Transmission;
            tbColor.Text        = car.Color;
            tbMiles.Text        = car.Miles.ToString();

            var customer = (from n in db.Customers
                            where n.Customer_ID == customerID
                            select n).Single();

            tbLastName.Text    = customer.Last_Name;
            tbFirstName.Text   = customer.First_Name;
            tbAreaCode.Text    = customer.Area_Code.ToString();
            tbPhoneNumber.Text = customer.Phone_Number.ToString();
            tbCity.Text        = customer.City;
            tbState.Text       = customer.State;
            tbZipCode.Text     = customer.Zip_Code.ToString();
            tbAddress.Text     = customer.Street_Number;
            tbCustomerID.Text  = customer.Customer_ID.ToString();
        }
コード例 #31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataSource = (IQueryable)Session["DataSource"];
              string department = (string)Session["Department"];

              if (Session["Employee_ID"] == null)
            Response.Redirect("Login.aspx");

              if (!Page.IsPostBack)
              {
            VWCTSDataContext db = new VWCTSDataContext();
            var source = from n in db.Customers
                     select n;

            var gridSource = from n in source
                         orderby n.Last_Name ascending
                         select new
                         {
                           ID = n.Customer_ID,
                           Name = string.Concat(n.Last_Name, ", ", n.First_Name),
                           Phone = string.Concat(n.Area_Code, " ", n.Phone_Number),
                           Address = string.Concat(n.Street_Number, " ", n.City, " ",
                                                   n.State, " ", n.Zip_Code)
                         };

            GridView1.DataSource = gridSource;
            Session["DataSource"] = source;
            GridView1.DataBind();
              }

              lblFirstName.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblLastName.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblAddress.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblCity.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblState.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblZipCode.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblPhoneNumber.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
              lblID.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
        }
コード例 #32
0
        protected void btnAdd_Car_Click(object sender, EventArgs e)
        {
            bool       error = false;
            bool       image = false;
            decimal    invoice;
            decimal    listPrice;
            string     path = " ";
            Car_Option newOption;

            if (tbVin.Text.Length != 17)
            {
                error            = true;
                lblVin.ForeColor = System.Drawing.Color.Red;
            }

            if (ddlModel.SelectedValue == "")
            {
                error = true;
                lblModel.ForeColor = System.Drawing.Color.Red;
            }

            if (ddlTrim.SelectedValue == "")
            {
                error             = true;
                lblTrim.ForeColor = System.Drawing.Color.Red;
            }

            if (ddlColor.SelectedValue == "")
            {
                error = true;
                lblColor.ForeColor = System.Drawing.Color.Red;
            }

            if (ddlTransmission.SelectedValue == "")
            {
                error = true;
                lblTransmission.ForeColor = System.Drawing.Color.Red;
            }

            if (tbLocation.Text == "")
            {
                error = true;
                lblLocation.ForeColor = System.Drawing.Color.Red;
            }

            if (!decimal.TryParse(tbInvoice.Text, out invoice))
            {
                error = true;
                lblInvoice.ForeColor = System.Drawing.Color.Red;
            }

            if (!decimal.TryParse(tbListPrice.Text, out listPrice))
            {
                error = true;
                lblListPrice.ForeColor = System.Drawing.Color.Red;
            }

            if (error)
            {
                return;
            }

            if (uploadPhoto.PostedFile.ContentLength > 0 && uploadPhoto.FileName != "")
            {
                path = "~\\images\\" + uploadPhoto.FileName;
                imageUpload.ImageUrl = path;
                image = true;
            }


            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                Car newCar = new Car();
                newCar.Model        = ddlModel.SelectedValue;
                newCar.Trim         = ddlTrim.SelectedValue;
                newCar.VIN          = tbVin.Text;
                newCar.Color        = ddlColor.SelectedValue;
                newCar.Transmission = ddlTransmission.SelectedValue;
                newCar.Invoice      = decimal.Parse(tbInvoice.Text);
                newCar.Price        = decimal.Parse(tbListPrice.Text);
                newCar.Location     = tbLocation.Text;
                newCar.Status       = "On Lot";
                newCar.Miles        = 0;
                if (image)
                {
                    newCar.Picture = path;
                }

                db.Cars.InsertOnSubmit(newCar);
                db.SubmitChanges();

                int id = (from n in db.Cars
                          select n.Car_ID).Max();

                foreach (ListItem n in cblPackages.Items)
                {
                    if (n is ListItem)
                    {
                        newOption            = new Car_Option();
                        newOption.Car_ID     = id;
                        newOption.Package_ID = int.Parse(n.Value);
                        db.Car_Options.InsertOnSubmit(newOption);
                    }
                }
                db.SubmitChanges();

                lblCarSubmitted.Text  = "Car " + id + " Added Successfully";
                btnAddCar.Enabled     = false;
                btnAddAnother.Visible = true;
            }
        }
コード例 #33
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VWCTSDataContext db = new VWCTSDataContext();
            var queryResults = from n in db.Cars
                           where n.Status == "On Lot"
                           select n;

            if (tbCarID.Text != "")
            {
              int id = 0;
              if(!int.TryParse(tbCarID.Text, out id)){
            lblCarID.ForeColor = System.Drawing.Color.Red;
            return;
              }

              queryResults = from n in queryResults
                         where id == n.Car_ID
                         select n;
            }

            if (ddlModel.SelectedValue != "")
            {
              queryResults = from n in queryResults
                         where ddlModel.SelectedValue == n.Model
                         select n;
            }

            if (ddlTrim.Text != "")
            {
              queryResults = from n in queryResults
                         where ddlTrim.SelectedValue == n.Trim
                         select n;
            }

            if (ddlColor.Text != "")
            {
              queryResults = from n in queryResults
                         where ddlColor.SelectedValue == n.Color
                         select n;
            }

            if (ddlTransmission.Text != "")
            {
              queryResults = from n in queryResults
                         where ddlTransmission.SelectedValue == n.Transmission
                         select n;
            }

            if (tbListPriceLow.Text != "" )
            {
              int low = 0;
              if(!int.TryParse(tbListPriceLow.Text, out low)){
            lblListPrice.ForeColor = System.Drawing.Color.Red;
            return;
              }

              queryResults = from n in queryResults
                         where low <= n.Price
                         select n;
            }

            if (tbListPriceHigh.Text != "")
            {
              int high = 0;
              if (!int.TryParse(tbListPriceHigh.Text, out high))
              {
            lblListPrice.ForeColor = System.Drawing.Color.Red;
            return;
              }

              queryResults = from n in queryResults
                         where high >= n.Price
                         select n;
            }

            var gridSource = from n in queryResults
                         select new
                         {
                           ID = n.Car_ID,
                           Model = n.Model,
                           Trim = n.Trim,
                           Color = n.Color,
                           Transmission = n.Transmission,
                           Location = n.Location,
                           Price = n.Price
                         };

            GridView1.DataSource = gridSource;
            Session["DataSource"] = queryResults;
            GridView1.DataBind();
        }
コード例 #34
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool    error = false;
            int     carID = 0, customerID = 0, areaCode = 0, phoneNumber = 0, zipCode = 0;
            decimal downPayment = 0, amountFinanced = 0, tradeValue = 0, salesPrice = 0;

            if (tbFirstName.Text == "")
            {
                error = true;
                lblFirstName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbLastName.Text == "")
            {
                error = true;
                lblLastName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbAddress.Text == "")
            {
                error = true;
                lblAddress.ForeColor = System.Drawing.Color.Red;
            }

            if (tbCity.Text == "")
            {
                error             = true;
                lblCity.ForeColor = System.Drawing.Color.Red;
            }

            if (tbState.Text == "")
            {
                error = true;
                lblState.ForeColor = System.Drawing.Color.Red;
            }

            if (tbZipCode.Text == "")
            {
                error = true;
                lblZipCode.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbZipCode.Text, out zipCode))
                {
                    error = true;
                    lblZipCode.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbPhoneNumber.Text == "" || tbAreaCode.Text == "" || tbPhoneNumber.Text.Length < 7 || tbAreaCode.Text.Length < 3)
            {
                error = true;
                lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbPhoneNumber.Text, out phoneNumber))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }

                if (!int.TryParse(tbAreaCode.Text, out areaCode))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbCarID.Text == "")
            {
                error = true;
                lblCarID.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbCarID.Text, out carID))
                {
                    error = true;
                    lblCarID.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbAmountFinanced.Text == "")
            {
                amountFinanced = 0;
            }
            else
            {
                if (!decimal.TryParse(tbAmountFinanced.Text, out amountFinanced))
                {
                    error = true;
                    lblAmountFinanced.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbDownPayment.Text == "")
            {
                downPayment = 0;
            }
            else
            {
                if (!decimal.TryParse(tbDownPayment.Text, out downPayment))
                {
                    error = true;
                    lblDownPayment.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbTradeValue.Text == "")
            {
                tradeValue = 0;
            }
            else
            {
                if (!decimal.TryParse(tbTradeValue.Text, out tradeValue))
                {
                    error = true;
                    lblTradeValue.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbSalesPrice.Text == "")
            {
                error = true;
                lblSalesPrice.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!decimal.TryParse(tbSalesPrice.Text, out salesPrice))
                {
                    error = true;
                    lblSalesPrice.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (salesPrice != (tradeValue + downPayment + amountFinanced))
            {
                error = true;
                lblTradeValue.ForeColor     = System.Drawing.Color.Red;
                lblDownPayment.ForeColor    = System.Drawing.Color.Red;
                lblAmountFinanced.ForeColor = System.Drawing.Color.Red;
            }

            if (error)
            {
                return;
            }

            //LINQ TO SQL CODE TO SUBMIT TRANSACTION AND CUSTOMER IF NEW
            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                if (Session["Customer_ID"] == null)
                {
                    Customer newCustomer = new Customer();
                    newCustomer.First_Name    = tbFirstName.Text;
                    newCustomer.Last_Name     = tbLastName.Text;
                    newCustomer.Street_Number = tbAddress.Text;
                    newCustomer.City          = tbCity.Text;
                    newCustomer.State         = tbState.Text;
                    newCustomer.Zip_Code      = zipCode;
                    newCustomer.Area_Code     = areaCode;
                    newCustomer.Phone_Number  = phoneNumber;

                    db.Customers.InsertOnSubmit(newCustomer);
                    db.SubmitChanges();

                    customerID = (from n in db.Customers
                                  select n.Customer_ID).Max();
                }
                else
                {
                    customerID = (int)Session["Customer_ID"];
                    db.Update_Customer(customerID, tbFirstName.Text, tbLastName.Text, areaCode,
                                       phoneNumber, tbAddress.Text, tbCity.Text, tbState.Text, zipCode);
                }

                int employeeID = 0;
                if (Session["Employee_ID"] == null)
                {
                    employeeID = 1;
                }
                else
                {
                    employeeID = (int)Session["Employee_ID"];
                }

                Transaction newTransaction = new Transaction();
                newTransaction.Car_ID          = carID;
                newTransaction.Customer_ID     = customerID;
                newTransaction.Amount_Financed = amountFinanced;
                newTransaction.Date            = System.DateTime.Today;
                newTransaction.Down_Payment    = downPayment;
                newTransaction.Employee_ID     = employeeID;
                newTransaction.Sales_Price     = salesPrice;
                newTransaction.Trade_Value     = tradeValue;
                db.Transactions.InsertOnSubmit(newTransaction);

                History newHistory = new History();
                newHistory.Car_ID      = carID;
                newHistory.Customer_ID = customerID;
                newHistory.Type        = "Initial Delivery";
                newHistory.Date        = DateTime.Today;
                db.Histories.InsertOnSubmit(newHistory);

                var update = (from n in db.Cars
                              where n.Car_ID == carID
                              select n).Single();
                update.Price  = decimal.Parse(tbSalesPrice.Text);
                update.Status = "Sold";
                db.SubmitChanges();
            }

            Session["Car_ID"]       = null;
            Session["Sales_Price"]  = null;
            Session["Customer_ID"]  = null;
            Session["PreviousPage"] = null;

            Session["Last"]    = null;
            Session["First"]   = null;
            Session["Address"] = null;
            Session["City"]    = null;
            Session["State"]   = null;
            Session["City"]    = null;
            Session["Area"]    = null;
            Session["Phone"]   = null;

            btnSubmit.Enabled  = false;
            btnCancel.Enabled  = false;
            btnFind.Enabled    = false;
            btnFindCar.Enabled = false;
            Label2.Text        = "Order Processed";
            Label2.ForeColor   = System.Drawing.Color.Red;
        }
コード例 #35
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Employee_ID"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            lblFirstName.ForeColor      = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblLastName.ForeColor       = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblAddress.ForeColor        = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblCity.ForeColor           = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblState.ForeColor          = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblZipCode.ForeColor        = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblPhoneNumber.ForeColor    = System.Drawing.ColorTranslator.FromHtml("#606760");
            lblAdditionalInfo.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");

            if (!IsPostBack)
            {
                if (Session["Last"] != null)
                {
                    tbLastName.Text = (string)Session["Last"];
                }

                if (Session["First"] != null)
                {
                    tbFirstName.Text = (string)Session["First"];
                }

                if (Session["Address"] != null)
                {
                    tbAddress.Text = (string)Session["Address"];
                }

                if (Session["City"] != null)
                {
                    tbCity.Text = (string)Session["City"];
                }

                if (Session["State"] != null)
                {
                    tbState.Text = (string)Session["State"];
                }

                if (Session["City"] != null)
                {
                    tbZipCode.Text = (string)Session["City"];
                }

                if (Session["Area"] != null)
                {
                    tbAreaCode.Text = (string)Session["Area"];
                }

                if (Session["Phone"] != null)
                {
                    tbPhoneNumber.Text = (string)Session["Phone"];
                }

                if (Session["Car_ID"] != null)
                {
                    int carID = (int)Session["Car_ID"];

                    using (VWCTSDataContext db = new VWCTSDataContext())
                    {
                        var car = (from n in db.Cars
                                   where carID == n.Car_ID
                                   select n).Single();

                        tbCarID.Text = car.Car_ID.ToString();;
                        tbVin.Text   = car.VIN;
                        tbModel.Text = car.Model;
                        tbTrim.Text  = car.Trim;
                        tbMiles.Text = car.Miles.ToString();
                    }
                }

                if (Session["Customer_ID"] != null)
                {
                    int customerID = (int)Session["Customer_ID"];

                    using (VWCTSDataContext db = new VWCTSDataContext())
                    {
                        var customer = (from n in db.Customers
                                        where customerID == n.Customer_ID
                                        select n).Single();

                        tbExistingCustomer.Text = customer.Customer_ID.ToString();
                        tbFirstName.Text        = customer.First_Name;
                        tbLastName.Text         = customer.Last_Name;
                        tbAddress.Text          = customer.Street_Number;
                        tbCity.Text             = customer.City;
                        tbState.Text            = customer.State;
                        tbZipCode.Text          = customer.Zip_Code.ToString();
                        tbAreaCode.Text         = customer.Area_Code.ToString();
                        tbPhoneNumber.Text      = customer.Phone_Number.ToString();

                        var carID = from n in db.Histories
                                    where n.Customer_ID == customer.Customer_ID &&
                                    n.Type == "Initial Delivery"
                                    select n.Car_ID;

                        if (carID.Count() == 1)
                        {
                            foreach (var id in carID)
                            {
                                var car = (from n in db.Cars
                                           where id == n.Car_ID
                                           select n).Single();

                                tbCarID.Text = car.Car_ID.ToString();;
                                tbVin.Text   = car.VIN;
                                tbModel.Text = car.Model;
                                tbTrim.Text  = car.Trim;
                                tbMiles.Text = car.Miles.ToString();
                            }
                        }
                    }
                }
            }
        }
コード例 #36
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool   error       = false;
            int    carID       = 0;
            int    customerID  = 0;
            int    areaCode    = 0;
            int    phoneNumber = 0;
            int    zipCode     = 0;
            int    miles       = 11111;
            string serviceType = " ";

            if (tbFirstName.Text == "")
            {
                error = true;
                lblFirstName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbLastName.Text == "")
            {
                error = true;
                lblLastName.ForeColor = System.Drawing.Color.Red;
            }

            if (tbAddress.Text == "")
            {
                error = true;
                lblAddress.ForeColor = System.Drawing.Color.Red;
            }

            if (tbCity.Text == "")
            {
                error             = true;
                lblCity.ForeColor = System.Drawing.Color.Red;
            }

            if (tbState.Text == "")
            {
                error = true;
                lblState.ForeColor = System.Drawing.Color.Red;
            }

            if (tbZipCode.Text == "")
            {
                error = true;
                lblZipCode.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbZipCode.Text, out zipCode))
                {
                    error = true;
                    lblZipCode.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbPhoneNumber.Text == "" || tbAreaCode.Text == "" || tbPhoneNumber.Text.Length < 7 || tbAreaCode.Text.Length < 3)
            {
                error = true;
                lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbPhoneNumber.Text, out phoneNumber))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }

                if (!int.TryParse(tbAreaCode.Text, out areaCode))
                {
                    error = true;
                    lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbCarID.Text == "")
            {
                error = true;
                lblCarID.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbCarID.Text, out carID))
                {
                    error = true;
                    lblCarID.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (tbVin.Text == "")
            {
                error            = true;
                lblVin.ForeColor = System.Drawing.Color.Red;
            }

            if (tbModel.Text == "")
            {
                error = true;
                lblModel.ForeColor = System.Drawing.Color.Red;
            }

            if (tbTrim.Text == "")
            {
                error             = true;
                lblTrim.ForeColor = System.Drawing.Color.Red;
            }

            if (tbMiles.Text == "")
            {
                error = true;
                lblMiles.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!int.TryParse(tbMiles.Text, out miles))
                {
                    error = true;
                    lblMiles.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (cbOilChange.Checked)
            {
                serviceType = "Oil Change";
            }
            else if (cbBrakeInspection.Checked)
            {
                serviceType = "Brake Inspection";
            }
            else if (cbCoolingSystem.Checked)
            {
                serviceType = "Cooling System";
            }
            else if (cbSuspension.Checked)
            {
                serviceType = "Suspension";
            }
            else if (cbTransmission.Checked)
            {
                serviceType = "Transmission";
            }
            else if (cbTireRotation.Checked)
            {
                serviceType = "Tire Rotation";
            }
            else if (cbAirConditioner.Checked)
            {
                serviceType = "Air Conditioner";
            }
            else if (cbScheduledMaintenance.Checked)
            {
                serviceType = "Scheduled Maintenance";
            }
            else if (cbOther.Checked)
            {
                serviceType = "Other";
            }
            else
            {
                error = true;
            }

            if (serviceType == "Other")
            {
                if (tbAdditionalInfo.Text == "")
                {
                    error = true;
                    lblAdditionalInfo.ForeColor = System.Drawing.Color.Red;
                }
            }

            if (error)
            {
                return;
            }

            using (VWCTSDataContext db = new VWCTSDataContext())
            {
                if (Session["Customer_ID"] == null)
                {
                    Customer newCustomer = new Customer();
                    newCustomer.Area_Code     = areaCode;
                    newCustomer.City          = tbCity.Text;
                    newCustomer.First_Name    = tbFirstName.Text;
                    newCustomer.Last_Name     = tbLastName.Text;
                    newCustomer.Phone_Number  = phoneNumber;
                    newCustomer.State         = tbState.Text;
                    newCustomer.Street_Number = tbAddress.Text;
                    newCustomer.Zip_Code      = zipCode;
                    db.Customers.InsertOnSubmit(newCustomer);
                }
                else
                {
                    customerID = (int)Session["Customer_ID"];

                    db.Update_Customer(customerID, tbFirstName.Text, tbLastName.Text, areaCode,
                                       phoneNumber, tbAddress.Text, tbCity.Text, tbState.Text, zipCode);
                }

                string time = ddlHour.SelectedValue + ":" + ddlMinute.SelectedValue
                              + ddl12Hour.SelectedValue;
                History newHistory = new History();
                newHistory.Car_ID      = carID;
                newHistory.Customer_ID = customerID;
                newHistory.Date        = DateTime.Today;
                newHistory.Type        = serviceType;
                newHistory.Description = time + " - " + tbAdditionalInfo.Text;
                db.Histories.InsertOnSubmit(newHistory);


                db.Update_Miles(carID, miles);
                db.SubmitChanges();
            }

            Session["Car_ID"]       = null;
            Session["PreviousPage"] = null;
            Session["Customer_ID"]  = null;

            Session["Last"]    = null;
            Session["First"]   = null;
            Session["Address"] = null;
            Session["City"]    = null;
            Session["State"]   = null;
            Session["City"]    = null;
            Session["Area"]    = null;
            Session["Phone"]   = null;

            btnFind.Enabled    = false;
            btnFindCar.Enabled = false;
            btnSubmit.Enabled  = false;
            btnCancel.Enabled  = false;

            Label1.Text      = "Service Processed";
            Label1.ForeColor = System.Drawing.Color.Red;
        }
コード例 #37
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Employee_ID"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!IsPostBack)
            {
                if (Session["Car_ID"] != null)
                {
                    int carID = (int)Session["Car_ID"];
                    tbCarID.Text = carID.ToString();
                }

                if (Session["Sales_Price"] != null)
                {
                    decimal price = (decimal)Session["Sales_Price"];
                    tbSalesPrice.Text = price.ToString();
                }

                if (Session["Last"] != null)
                {
                    tbLastName.Text = (string)Session["Last"];
                }

                if (Session["First"] != null)
                {
                    tbFirstName.Text = (string)Session["First"];
                }

                if (Session["Address"] != null)
                {
                    tbAddress.Text = (string)Session["Address"];
                }

                if (Session["City"] != null)
                {
                    tbCity.Text = (string)Session["City"];
                }

                if (Session["State"] != null)
                {
                    tbState.Text = (string)Session["State"];
                }

                if (Session["City"] != null)
                {
                    tbZipCode.Text = (string)Session["City"];
                }

                if (Session["Area"] != null)
                {
                    tbAreaCode.Text = (string)Session["Area"];
                }

                if (Session["Phone"] != null)
                {
                    tbPhoneNumber.Text = (string)Session["Phone"];
                }

                if (Session["PreviousPage"] == "Process_Order.aspx" && Session["Customer_ID"] != null)
                {
                    int customerID = (int)Session["Customer_ID"];

                    using (VWCTSDataContext db = new VWCTSDataContext())
                    {
                        var customer = (from n in db.Customers
                                        where n.Customer_ID == customerID
                                        select n).Single();

                        tbExistingCustomer.Text = customer.Customer_ID.ToString();
                        tbFirstName.Text        = customer.First_Name;
                        tbLastName.Text         = customer.Last_Name;
                        tbAddress.Text          = customer.Street_Number;
                        tbCity.Text             = customer.City;
                        tbState.Text            = customer.State;
                        tbZipCode.Text          = customer.Zip_Code.ToString();
                        tbAreaCode.Text         = customer.Area_Code.ToString();
                        tbPhoneNumber.Text      = customer.Phone_Number.ToString();
                    }
                }

                lblFirstName.ForeColor   = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblLastName.ForeColor    = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblAddress.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblCity.ForeColor        = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblState.ForeColor       = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblZipCode.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblPhoneNumber.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");

                lblCarID.ForeColor          = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblAmountFinanced.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblDownPayment.ForeColor    = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblTradeValue.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#606760");
                lblSalesPrice.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#606760");

                lblExistingCustomer.ForeColor = System.Drawing.ColorTranslator.FromHtml("#606760");
            }
        }
コード例 #38
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool error = false;
              int carID = 0;
              int customerID = 0;
              int areaCode = 0;
              int phoneNumber = 0;
              int zipCode = 0;
              int miles = 11111;
              string serviceType = " ";

              if (tbFirstName.Text == "")
              {
            error = true;
            lblFirstName.ForeColor = System.Drawing.Color.Red;
              }

              if (tbLastName.Text == "")
              {
            error = true;
            lblLastName.ForeColor = System.Drawing.Color.Red;
              }

              if (tbAddress.Text == "")
              {
            error = true;
            lblAddress.ForeColor = System.Drawing.Color.Red;
              }

              if (tbCity.Text == "")
              {
            error = true;
            lblCity.ForeColor = System.Drawing.Color.Red;
              }

              if (tbState.Text == "")
              {
            error = true;
            lblState.ForeColor = System.Drawing.Color.Red;
              }

              if (tbZipCode.Text == "")
              {
            error = true;
            lblZipCode.ForeColor = System.Drawing.Color.Red;
              }
              else
              {
            if (!int.TryParse(tbZipCode.Text, out zipCode))
            {
              error = true;
              lblZipCode.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (tbPhoneNumber.Text == "" || tbAreaCode.Text == "" || tbPhoneNumber.Text.Length < 7 || tbAreaCode.Text.Length < 3)
              {
            error = true;
            lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
              }
              else
              {
            if (!int.TryParse(tbPhoneNumber.Text, out phoneNumber))
            {
              error = true;
              lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }

            if (!int.TryParse(tbAreaCode.Text, out areaCode))
            {
              error = true;
              lblPhoneNumber.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (tbCarID.Text == "")
              {
            error = true;
            lblCarID.ForeColor = System.Drawing.Color.Red;
              }
              else
              {
            if (!int.TryParse(tbCarID.Text, out carID))
            {
              error = true;
              lblCarID.ForeColor = System.Drawing.Color.Red;
            }
              }

              if(tbVin.Text == ""){
            error = true;
            lblVin.ForeColor = System.Drawing.Color.Red;
              }

              if(tbModel.Text == ""){
            error = true;
            lblModel.ForeColor = System.Drawing.Color.Red;
              }

              if(tbTrim.Text == ""){
            error = true;
            lblTrim.ForeColor = System.Drawing.Color.Red;
              }

              if(tbMiles.Text == ""){
            error = true;
            lblMiles.ForeColor = System.Drawing.Color.Red;
              }
              else{
            if(!int.TryParse(tbMiles.Text, out miles)){
              error = true;
              lblMiles.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (cbOilChange.Checked)
            serviceType = "Oil Change";
              else if (cbBrakeInspection.Checked)
            serviceType = "Brake Inspection";
              else if (cbCoolingSystem.Checked)
            serviceType = "Cooling System";
              else if (cbSuspension.Checked)
            serviceType = "Suspension";
              else if (cbTransmission.Checked)
            serviceType = "Transmission";
              else if (cbTireRotation.Checked)
            serviceType = "Tire Rotation";
              else if (cbAirConditioner.Checked)
            serviceType = "Air Conditioner";
              else if (cbScheduledMaintenance.Checked)
            serviceType = "Scheduled Maintenance";
              else if (cbOther.Checked)
            serviceType = "Other";
              else
            error = true;

              if (serviceType == "Other")
              {
            if (tbAdditionalInfo.Text == "")
            {
              error = true;
              lblAdditionalInfo.ForeColor = System.Drawing.Color.Red;
            }
              }

              if (error)
            return;

              using (VWCTSDataContext db = new VWCTSDataContext())
              {
            if (Session["Customer_ID"] == null)
            {
              Customer newCustomer = new Customer();
              newCustomer.Area_Code = areaCode;
              newCustomer.City = tbCity.Text;
              newCustomer.First_Name = tbFirstName.Text;
              newCustomer.Last_Name = tbLastName.Text;
              newCustomer.Phone_Number = phoneNumber;
              newCustomer.State = tbState.Text;
              newCustomer.Street_Number = tbAddress.Text;
              newCustomer.Zip_Code = zipCode;
              db.Customers.InsertOnSubmit(newCustomer);
            }
            else{
              customerID = (int)Session["Customer_ID"];

              db.Update_Customer(customerID, tbFirstName.Text, tbLastName.Text, areaCode,
                                  phoneNumber, tbAddress.Text, tbCity.Text, tbState.Text, zipCode);
            }

            string time = ddlHour.SelectedValue + ":" + ddlMinute.SelectedValue
                          + ddl12Hour.SelectedValue;
            History newHistory = new History();
            newHistory.Car_ID = carID;
            newHistory.Customer_ID = customerID;
            newHistory.Date = DateTime.Today;
            newHistory.Type = serviceType;
            newHistory.Description = time + " - " + tbAdditionalInfo.Text;
            db.Histories.InsertOnSubmit(newHistory);

            db.Update_Miles(carID, miles);
            db.SubmitChanges();

              }

              Session["Car_ID"] = null;
              Session["PreviousPage"] = null;
              Session["Customer_ID"] = null;

              Session["Last"] = null;
              Session["First"] = null;
              Session["Address"] = null;
              Session["City"] = null;
              Session["State"] = null;
              Session["City"] = null;
              Session["Area"] = null;
              Session["Phone"] = null;

              btnFind.Enabled = false;
              btnFindCar.Enabled = false;
              btnSubmit.Enabled = false;
              btnCancel.Enabled = false;

              Label1.Text = "Service Processed";
              Label1.ForeColor = System.Drawing.Color.Red;
        }
コード例 #39
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int row = e.RowIndex;
            int carID = (int)GridView1.DataKeys[row].Value;

            IQueryable<Car> dataSource = (IQueryable<Car>)Session["DataSource"];
            var source = from n in dataSource
                     where n.Car_ID != carID
                     select n;
            Session["DataSource"] = source;

            VWCTSDataContext db = new VWCTSDataContext();
            var options = from n in db.Car_Options
                      where n.Car_ID == carID
                      select n;

            foreach (var n in options)
            {
              db.Car_Options.DeleteOnSubmit(n);
            }

            Car deleteCar = (from n in db.Cars
                         where n.Car_ID == carID
                         select n).Single();

            db.Cars.DeleteOnSubmit(deleteCar);
            db.SubmitChanges();

            var gridSource = from n in source
                         select new
                         {
                           ID = n.Car_ID,
                           Model = n.Model,
                           Trim = n.Trim,
                           Color = n.Color,
                           Transmission = n.Transmission,
                           Location = n.Location,
                           Price = n.Price
                         };

            GridView1.DataSource = gridSource;
            GridView1.DataBind();
        }
コード例 #40
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VWCTSDataContext db = new VWCTSDataContext();
            var queryResults    = from n in db.Histories
                                  where n.Type == "Initial Delivery"
                                  select n;

            if (tbCarID.Text != "")
            {
                int id = 0;
                if (!int.TryParse(tbCarID.Text, out id))
                {
                    lblCarID.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where id == n.Car_ID
                               select n;
            }

            if (tbCustomerID.Text != "")
            {
                int id = 0;
                if (!int.TryParse(tbCustomerID.Text, out id))
                {
                    lblCustomerID.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                queryResults = from n in queryResults
                               where id == n.Customer_ID
                               select n;
            }

            if (tbVIN.Text != "")
            {
                var carID = (from n in db.Cars
                             where n.VIN == tbVIN.Text
                             select n.Car_ID).Single();

                queryResults = from n in queryResults
                               where carID == n.Car_ID
                               select n;
            }

            if (tbLastName.Text != "")
            {
                var customerID = (from n in db.Customers
                                  where tbLastName.Text == n.Last_Name
                                  select n.Customer_ID).Single();

                queryResults = from n in queryResults
                               where customerID == n.Customer_ID
                               select n;
            }

            var gridSource = from n in queryResults
                             join p in db.Customers on n.Customer_ID equals p.Customer_ID
                             join q in db.Cars on n.Car_ID equals q.Car_ID
                             orderby n.Date ascending
                             select new
            {
                Customer    = n.Customer_ID,
                Name        = string.Concat(p.Last_Name, ", ", p.First_Name),
                Car         = n.Car_ID,
                Model       = q.Model,
                Trim        = q.Trim,
                Date        = n.Date,
                Type        = n.Type,
                Description = n.Description
            };

            GridView1.DataSource  = gridSource;
            Session["DataSource"] = queryResults;
            GridView1.DataBind();
        }