Esempio n. 1
0
        public ActionResult Admin()
        {
            string       QueryString = @"SELECT id, FirstName, LastName, EmailAddress, DOB, CarYear, CarMake, CarModel, DUI, tickets, Insurance, Quote from QuoteAttributes";
            List <quote> Quotes      = new List <quote>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(QueryString, connection);

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    var quote = new quote();
                    quote.id           = Convert.ToInt32(reader["id"]);
                    quote.FirstName    = reader["FirstName"].ToString();
                    quote.LasttName    = reader["LastName"].ToString();
                    quote.EmailAddress = reader["EmailAddress"].ToString();
                    quote.DOB          = Convert.ToDateTime(reader["DOB"]);
                    quote.CarMake      = reader["CarMake"].ToString();
                    quote.CarModel     = reader["CarModel"].ToString();
                    quote.CarYear      = Convert.ToInt32(reader["CarYear"]);
                    quote.DUI          = Convert.ToInt32(reader["DUI"]);
                    quote.Insurance    = Convert.ToInt32(reader["Insurance"]);
                    quote.tickets      = Convert.ToInt32(reader["tickets"]);
                    quote.Quote        = QuoteGenerator(quote.DOB, quote.CarYear, quote.CarMake, quote.CarModel, quote.DUI, quote.tickets, quote.Insurance);
                    Quotes.Add(quote);
                }
            }
            return(View(Quotes));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Putquote(int id, quote quote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != quote.Id)
            {
                return(BadRequest());
            }

            db.Entry(quote).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!quoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            quote quote = db.quotes.Find(id);

            db.quotes.Remove(quote);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public String LineCreate(string fkidx, quoteline line)
        {
            quote header = db.quotes.Find(Convert.ToInt32(fkidx));

            line.quote = header;
            db.quotelines.Add(line);
            db.SaveChanges();
            return("");
        }
Esempio n. 5
0
        private static void PopulateDatabase(quoteableDbContext context)
        {
            var author1 = new Author()
            {
                FirstName = "Dr",
                LastName  = "Seuss"
            };
            var author2 = new Author()
            {
                FirstName = "Mr",
                LastName  = "Spock"
            };
            var author3 = new Author()
            {
                FirstName = "Mr",
                LastName  = "Tuvok"
            };

            var document1 = new quote();

            document1.Quotes = "Green Eggs and Ham";

            var document2 = new quote();

            document2.Quotes = "Vulcan, A Primer";

            var document3 = new quote();

            document3.Quotes = "Green Eggs and Vulcans";

            var da1 = new quoteAuthor()
            {
                Quote = document1, Author = author1
            };
            var da2 = new quoteAuthor()
            {
                Quote = document2, Author = author2
            };
            var da3 = new quoteAuthor()
            {
                Quote = document3, Author = author1
            };
            var da4 = new quoteAuthor()
            {
                Quote = document3, Author = author2
            };
            var da5 = new quoteAuthor()
            {
                Quote = document3, Author = author3
            };

            context.AddRange(da1, da2, da3, da4, da5);

            context.SaveChanges();
        }
Esempio n. 6
0
                public void AddQuoteData(double thePrice, double theData, quote
theQuote, int theCurrentBar)
                {

                        if (BarDataCollection.Count == 0)
                                return;

                        SortedList<double, QuoteDataAtPrice> currentBarDataSL =
BarDataCollection[CurrentBar];

                        if ((currentBarDataSL != null) && currentBarDataSL.ContainsKey(thePrice))
                                {
                                        QuoteDataAtPrice theQuoteDataAtPrice = currentBarDataSL[thePrice];
                                        if (theQuote == quote.bid)
                                                theQuoteDataAtPrice.TotalBidSize += theData;
                                        else if (theQuote == quote.ask)
                                                theQuoteDataAtPrice.TotalAskSize += theData;
                                        else if (theQuote == quote.last)
                                                theQuoteDataAtPrice.TotalTradeSize += theData;
                                        else if (theQuote == quote.lastAtBid)
                                                theQuoteDataAtPrice.TotalTradeSizeAtBid += theData;
                                        else if (theQuote == quote.lastAtAsk)
                                                theQuoteDataAtPrice.TotalTradeSizeAtAsk += theData;
                                        else if (theQuote == quote.drift)
                                                theQuoteDataAtPrice.Drift += theData;


                                        theQuoteDataAtPrice.CurrentBarNumber = theCurrentBar;
                                        theQuoteDataAtPrice.Price = thePrice;
                                        theQuoteDataAtPrice.High = High[0];
                                        theQuoteDataAtPrice.Low = Low[0];
                                }
                                else
                                {
                                        QuoteDataAtPrice theQuoteDataAtPrice = new QuoteDataAtPrice();
                                        if (theQuote == quote.bid)
                                                theQuoteDataAtPrice.TotalBidSize += theData;
                                        else if (theQuote == quote.ask)
                                                theQuoteDataAtPrice.TotalAskSize += theData;
                                        else if (theQuote == quote.last)
                                                theQuoteDataAtPrice.TotalTradeSize += theData;
                                        else if (theQuote == quote.lastAtBid)
                                                theQuoteDataAtPrice.TotalTradeSizeAtBid += theData;
                                        else if (theQuote == quote.lastAtAsk)
                                                theQuoteDataAtPrice.TotalTradeSizeAtAsk += theData;
                                        else if (theQuote == quote.drift)
                                                theQuoteDataAtPrice.Drift += theData;

                                        theQuoteDataAtPrice.CurrentBarNumber = theCurrentBar;
                                        theQuoteDataAtPrice.Price = thePrice;
                                        theQuoteDataAtPrice.High = High[0];
                                        theQuoteDataAtPrice.Low = Low[0];
                                        currentBarDataSL.Add(thePrice, theQuoteDataAtPrice);
                                }
                }
Esempio n. 7
0
 public ActionResult Edit([Bind(Include = "quoteId,code,name,description,accountId,estimatedstartdate,estimatedenddate,DetailForm_pkidx_quotelineId,DetailForm_ddl_productId,DetailForm_qty,DetailForm_unitprice")] quote quote)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quote).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.accountIdList = new SelectList(db.accounts, "accountId", "code", quote.accountId);
     return(View(quote));
 }
Esempio n. 8
0
        public async Task <IHttpActionResult> Getquote(int id)
        {
            quote quote = await db.quotes.FindAsync(id);

            if (quote == null)
            {
                return(NotFound());
            }

            return(Ok(quote));
        }
Esempio n. 9
0
        public async Task <IHttpActionResult> Postquote(quote quote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.quotes.Add(quote);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = quote.Id }, quote));
        }
Esempio n. 10
0
        private void AddRecord_Click(object sender, RoutedEventArgs e)
        {
            Analytics.TrackEvent("Quotes - Save new Record");
            if (newquote.IsVisible)
            {
                // Create a new object because the old one
                // is being tracked by EF now.
                //   SalesRepIDMatch();
                quote newQuote = new quote()

                {
                    Date1          = add_quotedate.SelectedDate,
                    Representative = add_salesrep.Text,
                    Company        = add_custname.Text,
                    Address        = add_custaddress.Text,
                    ContactPerson  = add_custcontact.Text,
                    Phone          = add_custphone.Text,
                    Mobile         = add_custmobile.Text,
                    Email          = add_custemail.Text,
                    StrataNo       = add_custstrata.Text,
                    RefNo          = add_custref.Text,
                    JobLocation    = add_siteaddress.Text,
                    SiteContact    = add_sitecontact.Text,
                    SCPhone        = add_sitephone.Text,
                    SCMobile       = add_sitemobile.Text,
                    SCEmail        = add_siteemail.Text,
                    Inductiontime  = add_indtime.Text,
                    Notes          = add_notes.Text,
                    repID          = add_repID.Text,
                };
                SalesRepIDMatch();
                {
                    context.quotes.Local.Add(newQuote);
                    qtViewSource.View.Refresh();
                    qtViewSource.View.MoveCurrentTo(newQuote);
                }
                //Close the secondary ADD grid and move back to EXISTING grid
                newQuoteDataGrid.Visibility = Visibility.Collapsed;
                newquote.Visibility         = Visibility.Collapsed;
                btnAddCancel.Visibility     = Visibility.Collapsed;
                quoteBtn.Visibility         = Visibility.Visible;
                addQuoteBtn.Visibility      = Visibility.Collapsed;
                quoteinfo.Visibility        = Visibility.Visible;
                quoteitemdetails.Visibility = Visibility.Visible;
                lblLocation.Text            = "Quotes | All Loaded";
                quoteinfo.IsSelected        = true;
            }    //Save to the database now all has been checked
            context.SaveChanges();
            qtViewSource.View.MoveCurrentToPrevious();
            qtViewSource.View.MoveCurrentToNext();
            QID.Visibility = Visibility.Visible;
            TitleUpdate();
        }
Esempio n. 11
0
        public String LineEdit(string fkidx, quoteline line)
        {
            if (ModelState.IsValid)
            {
                quote header = db.quotes.Find(Convert.ToInt32(fkidx));
                line.quote           = header;
                db.Entry(line).State = EntityState.Modified;
                db.SaveChanges();
                return("");
            }

            return("");
        }
Esempio n. 12
0
        // GET: /CRM/quotes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            quote quote = db.quotes.Find(id);

            if (quote == null)
            {
                return(HttpNotFound());
            }
            return(View(quote));
        }
Esempio n. 13
0
        public async Task <IHttpActionResult> Deletequote(int id)
        {
            quote quote = await db.quotes.FindAsync(id);

            if (quote == null)
            {
                return(NotFound());
            }

            db.quotes.Remove(quote);
            await db.SaveChangesAsync();

            return(Ok(quote));
        }
        public ActionResult QuoteDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            quote obj = db.quotes.Find(id);

            if (obj == null)

            {
                return(HttpNotFound());
            }
            return(View(obj));
        }
 public ActionResult DeleteQuote(int id)
 {
     try
     {
         quote obj = db.quotes.Find(id);
         db.quotes.Remove(obj);
         db.SaveChanges();
         return(RedirectToAction("DisplayQuote"));
     }
     catch (DataException)
     {
         return(RedirectToAction("DeleteQuote", new { id = id, saveChangesError = true }));
     }
     //return RedirectToAction("DisplayQuote");
 }
Esempio n. 16
0
        public IHttpActionResult Create(QuotesDto quotesDto)
        {
            quote quote = new quote
            {
                description = quotesDto.description,
                price       = quotesDto.price,
                duration    = quotesDto.duration,
                lawyerid    = quotesDto.lawyerId,
                caseid      = quotesDto.caseId
            };

            ecaseEntity.quotes.Add(quote);
            ecaseEntity.SaveChanges();
            return(Ok(quote));
        }
Esempio n. 17
0
        // GET: /CRM/quotes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            quote quote = db.quotes.Find(id);

            if (quote == null)
            {
                return(HttpNotFound());
            }
            ViewBag.accountIdList = new SelectList(db.accounts, "accountId", "code", quote.accountId);
            return(View(quote));
        }
Esempio n. 18
0
        public ActionResult QuoteGenerator(string FirstName, string LastName, string EmailAddress, DateTime DOB,
                                           int CarYear, string CarMake, string CarModel, int DUI, int tickets, int Insurance)
        {
            int Quote = QuoteGenerator(DOB, CarYear, CarMake, CarModel, DUI, tickets, Insurance);

            string queryString = @"INSERT INTO QuoteAttributes(FirstName, LastName, EmailAddress, DOB, CarYear, CarMake, CarModel, DUI, tickets, Insurance, Quote)
                                   VALUES (@FirstName,@LastName,@EmailAddress,@DOB,@CarYear,@CarMake,@CarModel,@DUI,@tickets,@Insurance, @Quote)";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.Add("@FirstName", SqlDbType.VarChar);
                command.Parameters.Add("@LastName", SqlDbType.VarChar);
                command.Parameters.Add("@EmailAddress", SqlDbType.VarChar);
                command.Parameters.Add("@DOB", SqlDbType.DateTime);
                command.Parameters.Add("@CarYear", SqlDbType.Int);
                command.Parameters.Add("@CarMake", SqlDbType.VarChar);
                command.Parameters.Add("@CarModel", SqlDbType.VarChar);
                command.Parameters.Add("@DUI", SqlDbType.Int);
                command.Parameters.Add("@tickets", SqlDbType.Int);
                command.Parameters.Add("@Insurance", SqlDbType.Int);
                command.Parameters.Add("@Quote", SqlDbType.Int);

                command.Parameters["@FirstName"].Value    = FirstName;
                command.Parameters["@LastName"].Value     = LastName;
                command.Parameters["@EmailAddress"].Value = EmailAddress;
                command.Parameters["@DOB"].Value          = DOB;
                command.Parameters["@CarYear"].Value      = CarYear;
                command.Parameters["@CarMake"].Value      = CarMake;
                command.Parameters["@CarModel"].Value     = CarModel;
                command.Parameters["@DUI"].Value          = DUI;
                command.Parameters["@tickets"].Value      = tickets;
                command.Parameters["@Insurance"].Value    = Insurance;
                command.Parameters["@Quote"].Value        = Quote;

                connection.Open();
                command.ExecuteNonQuery();
                connection.Close();
            }
            quote quoteInformation = new quote()
            {
                Quote = Quote,
            };

            ViewBag.Message = quoteInformation;
            return(View());
        }
Esempio n. 19
0
        public Trap GetTrap(string ori, string des, string dat)
        {
            string url = "https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/browsedates/v1.0/MA/MAD/en-US/" + ori + "-sky/" + des + "-sky/" + dat;



            JObject      resultJSon = JObject.Parse(getFromURLAsync(url).Result);
            Trap         tr         = new Trap();
            List <quote> qt         = new List <quote> ();
            string       air        = "hi";

            if (resultJSon["Quotes"].Count() != 0)
            {
                for (var i = 0; i < resultJSon["Quotes"].Count(); i++)
                {
                    if (ori.Equals(resultJSon["Places"][i]["IataCode"].ToString()))
                    {
                        tr.origine = resultJSon["Places"][i]["Name"] + " - " + resultJSon["Places"][i]["CountryName"];
                    }
                    if (des.Equals(resultJSon["Places"][i]["IataCode"].ToString()))
                    {
                        tr.destination = resultJSon["Places"][i]["Name"] + " - " + resultJSon["Places"][i]["CountryName"];
                    }


                    int idairline = (int)resultJSon["Quotes"][i]["OutboundLeg"]["CarrierIds"][0];

                    for (var j = 0; j < resultJSon["Carriers"].Count(); j++)
                    {
                        if (idairline == (int)resultJSon["Carriers"][j]["CarrierId"])
                        {
                            air = resultJSon["Carriers"][j]["Name"].ToString();
                        }
                    }
                    quote q = new quote(resultJSon["Quotes"][i]["OutboundLeg"]["DepartureDate"].ToString(), (float)resultJSon["Quotes"][i]["MinPrice"], air);
                    qt.Add(q);
                }


                tr.Q = qt;
                return(tr);
            }
            tr.origine = null;
            return(tr);
        }
        public ActionResult DeleteQuote(int?id, bool?saveChangesError = false)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Delete failed.Try again.";
            }

            quote obj = db.quotes.Find(id);

            if (obj == null)
            {
                return(HttpNotFound());
            }
            return(View(obj));
        }
Esempio n. 21
0
        private static void AddQuoteToDb(Quote quote)
        {
            using (InsuranceQuotesEntities db = new InsuranceQuotesEntities())
            {
                var addquote = new quote();
                addquote.fname     = quote.fname;
                addquote.lname     = quote.lname;
                addquote.email     = quote.email;
                addquote.dob       = new DateTime(quote.doby, quote.dobm, quote.dobd);
                addquote.car_year  = (short)quote.caryear;
                addquote.car_make  = quote.carmake;
                addquote.car_model = quote.carmodel;
                addquote.had_dui   = (quote.dui == 1) ? true : false;
                addquote.sp_ticket = (short)quote.tickets;
                addquote.coverage  = quote.coverage;
                addquote.premium   = quote.premium;

                db.quotes.Add(addquote);
                db.SaveChanges();
            }
        }
Esempio n. 22
0
        public ActionResult GetQuote()
        {
            quote obj = new quote();

            List <SelectListItem> equipmentList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "Dryvan", Value = "Dryvan"
                },
                new SelectListItem()
                {
                    Text = "Reefer", Value = "Reefer"
                },
                new SelectListItem()
                {
                    Text = "Flatbed", Value = "Flatbed"
                },
                new SelectListItem()
                {
                    Text = "Stepdeck", Value = "Stepdeck"
                }
            };

            obj.equipmentList = equipmentList;
            List <SelectListItem> provinceList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "Alberta - AB", Value = "AB"
                },
                new SelectListItem()
                {
                    Text = "British Columbia - BC", Value = "BC"
                },
                new SelectListItem()
                {
                    Text = "Manitoba - MB", Value = "MB"
                },
                new SelectListItem()
                {
                    Text = "New Brunswick - NB", Value = "NB"
                },
                new SelectListItem()
                {
                    Text = "Newfoundland and Labrador - NL", Value = "NL"
                },
                new SelectListItem()
                {
                    Text = "Northwest Territories - NT", Value = "NT"
                },
                new SelectListItem()
                {
                    Text = "Nova Scotia - NS", Value = "NS"
                },
                new SelectListItem()
                {
                    Text = "Nunavut - NU", Value = "NU"
                },
                new SelectListItem()
                {
                    Text = "Ontario - ON", Value = "ON"
                },
                new SelectListItem()
                {
                    Text = "Prince Edward Island - PE", Value = "PE"
                },
                new SelectListItem()
                {
                    Text = "Quebec - QC", Value = "QC"
                },
                new SelectListItem()
                {
                    Text = "Saskatchewan - SK", Value = "SK"
                },
                new SelectListItem()
                {
                    Text = "Yukon - YT", Value = "YT"
                }
            };

            obj.provinceList = provinceList;
            return(View(obj));
        }
Esempio n. 23
0
        public ActionResult GetQuote(quote obj)
        {
            List <SelectListItem> equipmentList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "Dryvan", Value = "Dryvan"
                },
                new SelectListItem()
                {
                    Text = "Reefer", Value = "Reefer"
                },
                new SelectListItem()
                {
                    Text = "Flatbed", Value = "Flatbed"
                },
                new SelectListItem()
                {
                    Text = "Stepdeck", Value = "Stepdeck"
                }
            };
            List <SelectListItem> provinceList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "Alberta - AB", Value = "AB"
                },
                new SelectListItem()
                {
                    Text = "British Columbia - BC", Value = "BC"
                },
                new SelectListItem()
                {
                    Text = "Manitoba - MB", Value = "MB"
                },
                new SelectListItem()
                {
                    Text = "New Brunswick - NB", Value = "NB"
                },
                new SelectListItem()
                {
                    Text = "Newfoundland and Labrador - NL", Value = "NL"
                },
                new SelectListItem()
                {
                    Text = "Northwest Territories - NT", Value = "NT"
                },
                new SelectListItem()
                {
                    Text = "Nova Scotia - NS", Value = "NS"
                },
                new SelectListItem()
                {
                    Text = "Nunavut - NU", Value = "NU"
                },
                new SelectListItem()
                {
                    Text = "Ontario - ON", Value = "ON"
                },
                new SelectListItem()
                {
                    Text = "Prince Edward Island - PE", Value = "PE"
                },
                new SelectListItem()
                {
                    Text = "Quebec - QC", Value = "QC"
                },
                new SelectListItem()
                {
                    Text = "Saskatchewan - SK", Value = "SK"
                },
                new SelectListItem()
                {
                    Text = "Yukon - YT", Value = "YT"
                }
            };

            obj.provinceList = provinceList;

            obj.equipmentList = equipmentList;
            if (obj.pickup_date != null && obj.drop_date != null)
            {
                if (!(obj.pickup_date >= DateTime.Now))
                {
                    ModelState.AddModelError("PickUp Date", "PickUp Date cannot be before current date");
                }
                if (!(obj.drop_date >= DateTime.Now))
                {
                    ModelState.AddModelError("Drop Date", "Drop Date cannot be before current date");
                }
                if (!(obj.drop_date >= obj.drop_date))
                {
                    ModelState.AddModelError("Drop Date", "Drop Date cannot be before PickUp Date");
                }
            }
            if (ModelState.IsValid)
            {
                db.quotes.Add(obj);
                db.SaveChanges();
                return(RedirectToAction("GetQuote"));
            }

            return(View(obj));
        }
 set => Set(ref quote, nameof(Quote), value);
        private void DuplicateCommit_Click(object sender, RoutedEventArgs e)
        {
            Analytics.TrackEvent("DEBUG - #5 Commit duplicate Quote As Is");

            if (duplicateCreate.IsVisible)
            {
                // Create a new object because the old one
                // is being tracked by EF now.
                Analytics.TrackEvent("DEBUG - #6 DEFINE newQuote THEN ASSIGN TEXT FROM INSERTED INTO FIELDS");

                dup_salesrep.Text          = Properties.Settings.Default.Name;
                dup_repID.Text             = Properties.Settings.Default.Qid;
                dup_quotedate.SelectedDate = DateTime.Now;


                quote dupQuote = new quote()
                {
                    Date1          = DateTime.Now,
                    Representative = dup_salesrep.Text,
                    Company        = dup_custname.Text,
                    Address        = dup_custaddress.Text,
                    ContactPerson  = dup_custcontact.Text,
                    Phone          = dup_custphone.Text,
                    Mobile         = dup_custmobile.Text,
                    Email          = dup_custemail.Text,
                    StrataNo       = dup_custstrata.Text,
                    RefNo          = dup_custref.Text,
                    JobLocation    = dup_siteaddress.Text,
                    SiteContact    = dup_sitecontact.Text,
                    SCPhone        = dup_sitephone.Text,
                    SCMobile       = dup_sitemobile.Text,
                    SCEmail        = dup_siteemail.Text,
                    Inductiontime  = dup_indtime.Text,
                    Notes          = dup_notes.Text,
                    repID          = dup_repID.Text,
                    //  repID = Properties.Settings.Default.Qid,
                    //  Induction = Convert.ToInt32(dup_induction),
                    //  COD = Convert.ToInt32(dup_cod),
                    //  SvnDays = Convert.ToInt32(dup_svndays),
                    //  PROGRESSPAYMENT = Convert.ToInt32(dup_pp),
                    //  SWMS = Convert.ToInt32(dup_swms),
                    //    Induction = add_induction.
                };
                //   dup_repID.Text = Properties.Settings.Default.Qid,
                DupRepIDMatch();
                {
                    Analytics.TrackEvent("DEBUG - #7 BRING VIEW INTO CONTEXT");
                    context.quotes.Local.Add(dupQuote);
                    qtViewSource.View.Refresh();
                    qtViewSource.View.MoveCurrentTo(dupQuote);
                }
                Analytics.TrackEvent("DEBUG - #8 SHOW/HIDE GRIDS");
                //Close the secondary ADD grid and move back to EXISTING grid
                duplicateQuoteDataGrid.Visibility = Visibility.Collapsed;
                duplicateCreate.Visibility        = Visibility.Collapsed;
                //    btnAddCancel.Visibility = Visibility.Collapsed;
                quoteSearchBtn.Visibility    = Visibility.Collapsed;
                quoteBtn.Visibility          = Visibility.Visible;
                addQuoteBtn.Visibility       = Visibility.Collapsed;
                quoteinfo.Visibility         = Visibility.Visible;
                quoteitemdetails.Visibility  = Visibility.Visible;
                duplicateQuoteBtn.Visibility = Visibility.Collapsed;
                lblLocation.Text             = "Quotes | All Loaded";
                quoteinfo.IsSelected         = true;
            }    //Save to the database now all has been checked
            Analytics.TrackEvent("DEBUG - #9 SAVE CONTEXT TO DB");
            context.SaveChanges();
            qtViewSource.View.MoveCurrentToPrevious();
            qtViewSource.View.MoveCurrentToNext();
            QID.Visibility = Visibility.Visible;
            TitleUpdate();
            Analytics.TrackEvent("DEBUG #10 END - COMPLETED DUPLICATION OF QUOTE");
        }
        private void quoteDuplicate_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("This will duplicate the details on Quote" + QID.Text + ". Click YES to DUPLICATE or NO to CANCEL", "Duplicate Quote" + QID.Text + " - ARE YOU SURE?", MessageBoxButton.YesNo, MessageBoxImage.Question);

            switch (result)
            {
            case MessageBoxResult.Yes:
                Analytics.TrackEvent("Quote Duplicate -  Start DUPLICATE Quote");
                //First Setup the form to create a duplicate quote
                quoteinfo.Visibility              = Visibility.Collapsed;
                quoteitemdetails.Visibility       = Visibility.Collapsed;
                quoteBtn.Visibility               = Visibility.Collapsed;
                quoteSearchBtn.Visibility         = Visibility.Collapsed;
                quoteSearch.Visibility            = Visibility.Collapsed;
                addQuoteBtn.Visibility            = Visibility.Collapsed;
                duplicateQuoteBtn.Visibility      = Visibility.Visible;
                duplicateCreate.Visibility        = Visibility.Visible;
                duplicateQuoteDataGrid.Visibility = Visibility.Visible;
                QID.Visibility                     = Visibility.Collapsed;
                lblLocation.Text                   = "Quotes | Duplicate Existing Quote";
                duplicateCreate.IsSelected         = true;
                Properties.Settings.Default.Status = "*** DUPLICATE QUOTE ENTRY ***";
                Properties.Settings.Default.Save();
                // Normally we would now clear all the data from the view to prep for new - Here we will only clear certain fields
                Analytics.TrackEvent("Quote Duplicate -  Copied info to new view");

                if (duplicateCreate.IsVisible)
                {
                    // Create a new object because the old one
                    // is being tracked by EF now.
                    Analytics.TrackEvent("Quote Duplicate -  RepID and Rep name updated to current user");

                    dup_salesrep.Text = Properties.Settings.Default.Name;
                    dup_repID.Text    = Properties.Settings.Default.Qid;
                    Analytics.TrackEvent("Quote Duplicate -  Today's date set");
                    dup_quotedate.SelectedDate = DateTime.Now;
                    dup_notes.Text             = "" + DateTime.Now.ToString("dd/MM/yy") + " - Duplicate of# " + QID.Text + "";
                    quote dupQuote = new quote()
                    {
                        Date1          = DateTime.Now,
                        Representative = dup_salesrep.Text,
                        Company        = dup_custname.Text,
                        Address        = dup_custaddress.Text,
                        ContactPerson  = dup_custcontact.Text,
                        Phone          = dup_custphone.Text,
                        Mobile         = dup_custmobile.Text,
                        Email          = dup_custemail.Text,
                        StrataNo       = dup_custstrata.Text,
                        RefNo          = dup_custref.Text,
                        JobLocation    = dup_siteaddress.Text,
                        SiteContact    = dup_sitecontact.Text,
                        SCPhone        = dup_sitephone.Text,
                        SCMobile       = dup_sitemobile.Text,
                        SCEmail        = dup_siteemail.Text,
                        Inductiontime  = dup_indtime.Text,
                        Notes          = dup_notes.Text,
                        repID          = dup_repID.Text,

                        /*  repID = Properties.Settings.Default.Qid,
                         * Induction = Convert.ToInt32(dup_induction),
                         * COD = Convert.ToInt32(dup_cod),
                         * SvnDays = Convert.ToInt32(dup_svndays),
                         * PROGRESSPAYMENT = Convert.ToInt32(dup_pp),
                         * SWMS = Convert.ToInt32(dup_swms),
                         * Induction = add_induction.
                         */
                    };
                    //   dup_repID.Text = Properties.Settings.Default.Qid,
                    DupRepIDMatch();
                    {
                        Analytics.TrackEvent("Quote Duplicate -  BRING VIEW INTO CONTEXT");
                        context.quotes.Local.Add(dupQuote);
                        qtViewSource.View.Refresh();
                        qtViewSource.View.MoveCurrentTo(dupQuote);
                    }
                    Analytics.TrackEvent("Quote Duplicate -  SHOW/HIDE GRIDS");
                    //Close the secondary ADD grid and move back to EXISTING grid
                    duplicateQuoteDataGrid.Visibility = Visibility.Collapsed;
                    duplicateCreate.Visibility        = Visibility.Collapsed;
                    quoteinfoLoaded.Visibility        = Visibility.Collapsed;
                    //    btnAddCancel.Visibility = Visibility.Collapsed;
                    quoteSearchBtn.Visibility    = Visibility.Collapsed;
                    quoteBtn.Visibility          = Visibility.Visible;
                    addQuoteBtn.Visibility       = Visibility.Collapsed;
                    quoteinfo.Visibility         = Visibility.Visible;
                    quoteitemdetails.Visibility  = Visibility.Visible;
                    duplicateQuoteBtn.Visibility = Visibility.Collapsed;
                    lblLocation.Text             = "Quotes | All Loaded";
                    quoteinfo.IsSelected         = true;
                }        //Save to the database now all has been checked
                Analytics.TrackEvent("Quote Duplicate -  SAVE CONTEXT TO DB");
                context.SaveChanges();
                qtViewSource.View.MoveCurrentToPrevious();
                qtViewSource.View.MoveCurrentToNext();
                QID.Visibility = Visibility.Visible;
                TitleUpdate();
                Analytics.TrackEvent("Quote Duplicate -  COMPLETED DUPLICATION OF QUOTE");
                MessageBox.Show("Quote has been duplicated, you can now add quote items to the quote", "Quote Duplicated", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                break;

            case MessageBoxResult.No:
                Analytics.TrackEvent("Quote Duplicate -  Cancelled DUPLICATE Quote");
                break;
            }
        }
Esempio n. 27
0
        private void DuplicateQuote_Click(object sender, RoutedEventArgs e)
        {
            Analytics.TrackEvent("Quotes - Create DUPLICATE Quote");
            Analytics.TrackEvent("DEBUG - #1 SHOW/HIDE GRIDS");
            //First Setup the form to create a new quote
            quoteinfo.Visibility        = Visibility.Collapsed;
            quoteitemdetails.Visibility = Visibility.Collapsed;
            quoteBtn.Visibility         = Visibility.Collapsed;
            quoteSearchBtn.Visibility   = Visibility.Collapsed;
            addQuoteBtn.Visibility      = Visibility.Visible;
            newquote.Visibility         = Visibility.Visible;
            newQuoteDataGrid.Visibility = Visibility.Visible;
            QID.Visibility      = Visibility.Collapsed;
            lblLocation.Text    = "Quotes | Duplicate Existing Quote";
            newquote.IsSelected = true;
            Properties.Settings.Default.Status = "*** DUPLICATE QUOTE ENTRY ***";
            Properties.Settings.Default.Save();
            // Normally we would now clear all the data from the view to prep for new - Here we will only clear certain fields
            Analytics.TrackEvent("DEBUG - #2 CLEAR OUT FIELDS");
            foreach (var child in newQuoteDataGrid.Children)
            {
                //   var tb = child as TextBox;
                //   if (tb != null)
                //   {
                //       tb.Text = "";
                //   }
            }
            //We will still clear the checkboxes so the rep can ensure they are correct
            Analytics.TrackEvent("DEBUG - #3 CLEAR OUT CHECK BOXES");
            foreach (var child in newQuoteDataGrid.Children)
            {
                var cb = child as CheckBox;
                if (cb != null)
                {
                    cb.IsChecked = false;
                }
            }
            //Add some pre-defined text before starting the quote
            Analytics.TrackEvent("DEBUG - #4 ADD PRE-DEFINED TEXT");
            add_quotedate.SelectedDate = DateTime.Now;
            add_siteaddress.Text       = "Same As Address";
            add_salesrep.Text          = Properties.Settings.Default.Name;
            add_repID.Text             = Properties.Settings.Default.Qid;
            TitleUpdate();

            Analytics.TrackEvent("DEBUG - #5 CHECK IF NEWQUOTE IS VISIBLE");

            //   if (newquote.IsVisible)
            if (newquote.IsVisible)
            {
                // Create a new object because the old one
                // is being tracked by EF now.
                Analytics.TrackEvent("DEBUG - #6 DEFINE newQuote THEN ASSIGN TEXT FROM INSERTED INTO FIELDS");
                quote newQuote = new quote()
                {
                    Date1          = DateTime.Now,
                    Representative = Properties.Settings.Default.Name,
                    Company        = add_custname.Text,
                    Address        = add_custaddress.Text,
                    ContactPerson  = add_custcontact.Text,
                    Phone          = add_custphone.Text,
                    Mobile         = add_custmobile.Text,
                    Email          = add_custemail.Text,
                    StrataNo       = add_custstrata.Text,
                    RefNo          = add_custref.Text,
                    JobLocation    = add_siteaddress.Text,
                    SiteContact    = add_sitecontact.Text,
                    SCPhone        = add_sitephone.Text,
                    SCMobile       = add_sitemobile.Text,
                    SCEmail        = add_siteemail.Text,
                    Inductiontime  = add_indtime.Text,
                    Notes          = add_notes.Text,
                    repID          = Properties.Settings.Default.Qid,
                    //    Induction = add_induction.
                };
                {
                    Analytics.TrackEvent("DEBUG - #7 BRING VIEW INTO CONTEXT");
                    context.quotes.Local.Add(newQuote);
                    qtViewSource.View.Refresh();
                    qtViewSource.View.MoveCurrentTo(newQuote);
                }
                Analytics.TrackEvent("DEBUG - #8 SHOW/HIDE GRIDS");
                //Close the secondary ADD grid and move back to EXISTING grid
                newQuoteDataGrid.Visibility = Visibility.Collapsed;
                newquote.Visibility         = Visibility.Collapsed;
                btnAddCancel.Visibility     = Visibility.Collapsed;
                quoteSearchBtn.Visibility   = Visibility.Collapsed;
                quoteBtn.Visibility         = Visibility.Visible;
                addQuoteBtn.Visibility      = Visibility.Collapsed;
                quoteinfo.Visibility        = Visibility.Visible;
                quoteitemdetails.Visibility = Visibility.Visible;
                lblLocation.Text            = "Quotes | All Loaded";
                quoteinfo.IsSelected        = true;
            }    //Save to the database now all has been checked
            Analytics.TrackEvent("DEBUG - #9 SAVE CONTEXT TO DB");
            context.SaveChanges();
            qtViewSource.View.MoveCurrentToPrevious();
            qtViewSource.View.MoveCurrentToNext();
            TitleUpdate();
            Analytics.TrackEvent("DEBUG #10 END - COMPLETED DUPLICATION OF QUOTE");
        }
Esempio n. 28
0
        public static void PullQuotes(DateTime start, DateTime stop, string stockName)
        {
            ModelMadness madness = new ModelMadness();
            StockName    stock   = (from q in madness.StockNames where q.Stock == stockName select q).First();

            Console.WriteLine("Working on " + stock.Stock);

            //http://ichart.finance.yahoo.com/table.csv?s=TKR&a=00&b=1&c=2000&d=01&e=18&f=2010&g=d&ignore=.csv

            string url = @"http://ichart.finance.yahoo.com/table.csv?s=" +
                         stock.Stock + "&a=" + TwoDig(start.Month - 1) + "&b=" + start.Day + "&c=" + start.Year +
                         "&d=" + TwoDig(stop.Month - 1) + "&e=" + stop.Day + "&f=" + stop.Year +
                         "&g=d&ignore=.csv";

            AgentSession session = new AgentSession();
            AgentAction  action  = new AgentAction(url, false);

            bool          found    = false;
            AgentDocument document = null;

            try
            {
                document = AgentHandler.Instance.PerformAction(session, action);
                found    = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + url + " - " + ex.Message);
            }

            if (!found)
            {
                return;
            }

            //Date,Open,High,Low,Close,Volume,Adj Close

            string[] rows = document.ResponseString.Split('\n');

            if (rows.Length < 2)
            {
                return;
            }

            for (int i = 1; i < rows.Length; i++)
            {
                string   row    = rows[i];
                string[] fields = row.Split(',');
                if (fields.Length < 7)
                {
                    Console.WriteLine((i - 2) + " records stored");
                    continue;
                }

                quote q = new quote
                {
                    day            = (DateTime) new DateTimeConverter().ConvertFrom(fields[0]),
                    open           = decimal.Parse(fields[1]),
                    high           = decimal.Parse(fields[2]),
                    low            = decimal.Parse(fields[3]),
                    close          = decimal.Parse(fields[4]),
                    volume         = long.Parse(fields[5]),
                    adjusted_close = decimal.Parse(fields[6]),
                    StockName      = stock
                };

                madness.AddToquotes(q);
            }

            madness.SaveChanges();
        }