Esempio n. 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var cities = GetSelectedCity();

            if (cities.Any())
            {
                DeleteCurrentCities();
                SaveSelectedCity(cities);

                var selectedCity = (PostClCity)cbCityList.SelectedItem;

                var context = new CLDMSEntities();

                var account =
                    context.Accounts.FirstOrDefault(o => o.AccountId == GlobalVar.CurrentAccount.AccountId);

                if (account != null)
                {
                    account.FirstCity   = selectedCity.CityId;
                    account.LastUpdated = DateTime.Now;
                    context.SaveChanges();

                    ReOrderCityList(selectedCity.CityId);

                    _frmMain.AfterLogging();
                }
                Close();
            }
            else
            {
                MessageBox.Show("Please choose at least one city in the list", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        private void IniteStatelist()
        {
            var context = new CLDMSEntities();

            var dtDealerCityAccount =
                context.SelectedCities.Where(x => x.AccountId == GlobalVar.CurrentAccount.AccountId).ToList();

            IQueryable <IGrouping <string, City> > statelist =
                context.Cities.OrderBy(j => j.State).GroupBy(i => i.State);

            foreach (var state in statelist)
            {
                var treeNode = new TreeNode(state.Key,
                                            state.OrderBy(i => i.CityName)
                                            .Select(
                                                city =>
                                                new TreeNode(city.CityName)
                {
                    Tag     = city.CityID,
                    Checked =
                        dtDealerCityAccount.FirstOrDefault(
                            i => i.CityId == city.CityID) != null
                })
                                            .ToArray());
                StateTreeview.Nodes.Add(treeNode);
                GridviewHelper.HideCheckBox(StateTreeview, treeNode);
            }
        }
Esempio n. 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (ValidateEmpty() && ValidateSamePassword())
            {
                var context = new CLDMSEntities();

                var account =
                    context.Accounts.FirstOrDefault(x => x.AccountId == GlobalVar.CurrentAccount.AccountId);

                account.AccountPassword = txtNewPass.Text;

                account.LastUpdated = DateTime.Now;

                account.IsFirstLogOn = false;

                account.Active = true;

                context.SaveChanges();

                frmMain.txtPassword.Text = txtNewPass.Text;

                Close();

                var cForm = CreditCardAuthorizeForm.Instance(frmMain);

                cForm.Show();

                cForm.Activate();
            }
        }
Esempio n. 4
0
        public static int GetDailyUse()
        {
            var context = new CLDMSEntities();

            return(context.Trackings.Count(x => x.AccountId == GlobalVar.CurrentAccount.AccountId &&
                                           x.AddedDate.Value.Year == DateTime.Now.Year &&
                                           x.AddedDate.Value.Month == DateTime.Now.Month &&
                                           x.AddedDate.Value.Day == DateTime.Now.Day));
        }
Esempio n. 5
0
        private void CombineWithCurrentData(AppraisalViewFormModel result, string VIN)
        {
            var context = new CLDMSEntities();
            var item    = context.Inventories.FirstOrDefault(i => i.VINNumber.ToLower().Equals(VIN.ToLower()));

            if (result != null)
            {
                CheckInDatabase(result, item);
            }
        }
Esempio n. 6
0
        private void CombineWithCurrentData(AppraisalViewFormModel result, int listingID)
        {
            var context = new CLDMSEntities();
            var item    = context.Inventories.FirstOrDefault(i => i.ListingID == listingID);

            if (result != null)
            {
                CheckInDatabase(result, item);
            }
        }
Esempio n. 7
0
        public static IEnumerable <UsState> GetAllStates()
        {
            var context = new CLDMSEntities();

            return(context.UsaZipCodes.Select(x => new UsState()
            {
                State = x.StateName,
                StateAbbr = x.StateAbbr,
            }
                                              ).Distinct().OrderBy(x => x.State).ToList());
        }
Esempio n. 8
0
        void editWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var context = new CLDMSEntities();
            var item    = context.Inventories.FirstOrDefault(i => i.ListingID == listingID);

            var result = _decodeType.Equals(DecodeType.VIN) ? VinDecodeHelper.DecodeProcessingByVin(item.VINNumber) : VinDecodeHelper.GetVehicleInformationFromYearMakeModel(int.Parse(item.ModelYear), item.Make, item.Model);

            CombineWithCurrentData(result, listingID);
            BindingFormControl(result);
            if (result != null)
            {
                txtVin.Text = result.VinNumber;
            }
            lblMessage.Text = "Edit inventory";
            Isbusy          = false;
        }
Esempio n. 9
0
        private static void SaveSelectedCity(IEnumerable <int> cities)
        {
            var context = new CLDMSEntities();

            foreach (int city in cities)
            {
                context.SelectedCities.Add(new SelectedCity()
                {
                    AccountId = GlobalVar.CurrentAccount.AccountId,
                    CityId    = city,
                    DateStamp = DateTime.Now,
                    DealerId  = GlobalVar.CurrentAccount.DealerId
                });
            }
            context.SaveChanges();
        }
Esempio n. 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            this._frmMain.txtEndingSentence.Text = this.htmlEditorControl.InnerHtml;

            var context = new CLDMSEntities();

            var dealer = context.Dealers.First(o => o.DealerId == GlobalVar.CurrentDealer.DealerId);

            dealer.EndingSentence = String.IsNullOrEmpty(this.htmlEditorControl.InnerHtml) ? "" : this.htmlEditorControl.InnerHtml.Trim();

            context.SaveChanges();

            GlobalVar.CurrentDealer.EndingSentence = dealer.EndingSentence;

            this.Close();
        }
Esempio n. 11
0
        private void SaveToDB()
        {
            var context = new CLDMSEntities();
            var item    = context.Inventories.FirstOrDefault(i => i.ListingID == listingID);

            if (item != null)
            {
                LoadData(item);
                context.SaveChanges();
            }
            else
            {
                var inventory = new Inventory();
                LoadData(inventory);
                context.Inventories.Add(inventory);
                context.SaveChanges();
            }
        }
Esempio n. 12
0
        public static PostClPackgae GetDataFeedPackage()
        {
            using (var context = new CLDMSEntities())
            {
                return(context.Packages.Where(x => x.MonthlyPrice == 0).Select(x => new PostClPackgae()
                {
                    PackageId = x.PackageId,
                    MonthlyPrice = x.MonthlyPrice.Value,
                    PackageName = x.PackageName,
                    Period = x.Period,
                    QuickBookPackageId = x.QuickBookPackageId.Value,
                    QuickBookPackageName = x.QuickBookPackageName,
                    TotalCharge = x.TotalCharge.Value,
                }

                                                                               ).First());
            }
        }
Esempio n. 13
0
        public static IEnumerable <PostClPackgae> GetAllPackages()
        {
            using (var context = new CLDMSEntities())
            {
                return(context.Packages.Where(x => x.MonthlyPrice > 0).Select(x => new PostClPackgae()
                {
                    PackageId = x.PackageId,
                    MonthlyPrice = x.MonthlyPrice.Value,
                    PackageName = x.PackageName,
                    Period = x.Period,
                    QuickBookPackageId = x.QuickBookPackageId.Value,
                    QuickBookPackageName = x.QuickBookPackageName,
                    TotalCharge = x.TotalCharge.Value,
                }

                                                                              ).ToList());
            }
        }
Esempio n. 14
0
        private void DeleteCurrentCities()
        {
            var context = new CLDMSEntities();
            var item    =
                context.SelectedCities.Where(
                    i =>
                    i.AccountId == GlobalVar.CurrentAccount.AccountId &&
                    i.DealerId == GlobalVar.CurrentAccount.DealerId);

            foreach (var city in item)
            {
                context.SelectedCities.Remove(city);
            }
            if (item.Any())
            {
                context.SaveChanges();
            }
        }
Esempio n. 15
0
        public static ZipCodeCity LookUpZipCode(int zipCode)
        {
            var context = new CLDMSEntities();

            if (context.UsaZipCodes.Any(x => x.UsaZipCodeId == zipCode))
            {
                var findResult = context.UsaZipCodes.FirstOrDefault(x => x.UsaZipCodeId == zipCode);
                return(new ZipCodeCity
                {
                    City = findResult.CityName,
                    State = findResult.StateName,
                    StateAbbr = findResult.StateAbbr
                });
            }
            else
            {
                return(new ZipCodeCity());
            }
        }
Esempio n. 16
0
        private void btnSubmitRequest_Click(object sender, EventArgs e)
        {
            var context = new CLDMSEntities();

            var account = context.Accounts.First(o => o.AccountId == GlobalVar.CurrentAccount.AccountId);

            account.APIUsername = String.IsNullOrEmpty(txtUserName.Text) ? "" : txtUserName.Text.Trim();

            account.APIPassword = String.IsNullOrEmpty(txtPassword.Text) ? "" : txtPassword.Text.Trim();

            account.APIAccountId = String.IsNullOrEmpty(txtAccountId.Text) ? "" : txtAccountId.Text.Trim();

            account.LastUpdated = DateTime.Now;

            context.SaveChanges();

            GlobalVar.CurrentAccount.APIUsername = account.APIUsername;

            GlobalVar.CurrentAccount.APIPassword = account.APIPassword;

            GlobalVar.CurrentAccount.APIAccountId = account.APIAccountId;

            this.Close();
        }
Esempio n. 17
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (dateTimePickerFrom.Value > dateTimePickerEnd.Value)
            {
                MessageBox.Show(
                    "Date Range is not valid",
                    "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    var context = new CLDMSEntities();

                    var dateTo = new DateTime(dateTimePickerFrom.Value.Year, dateTimePickerFrom.Value.Month, dateTimePickerFrom.Value.Day);

                    var dateEnd =
                        new DateTime(dateTimePickerEnd.Value.Year, dateTimePickerEnd.Value.Month,
                                     dateTimePickerEnd.Value.Day).AddDays(1);

                    var fullCityList = context.Cities.ToList();

                    var fullAdsList = new List <TrackingAds>();

                    var selectedCity = (ShortCity)cbCity.SelectedItem;

                    if (selectedCity.CityId == 0)
                    {
                        foreach (
                            var tmp in
                            context.Trackings.Where(
                                a => a.AccountId == GlobalVar.CurrentAccount.AccountId && a.AddedDate >= dateTo && a.AddedDate <= dateEnd))
                        {
                            var index  = 1;
                            var record = new TrackingAds()
                            {
                                Index          = index++,
                                CityName       = fullCityList.FirstOrDefault(x => x.CityID == tmp.CityId).CityName,
                                CraigslistUrl  = tmp.AdsUrl,
                                PostingId      = tmp.CLPostingId.GetValueOrDefault(),
                                CreatedDate    = tmp.AddedDate.GetValueOrDefault(),
                                ExpirationDate = tmp.AddedDate.GetValueOrDefault().AddDays(30)
                            };
                            fullAdsList.Add(record);
                        }
                    }
                    else
                    {
                        foreach (
                            var tmp in
                            context.Trackings.Where(
                                a => a.AccountId == GlobalVar.CurrentAccount.AccountId && a.CityId == selectedCity.CityId && a.AddedDate >= dateTo && a.AddedDate <= dateEnd))
                        {
                            var index  = 1;
                            var record = new TrackingAds()
                            {
                                Index          = index++,
                                CityName       = fullCityList.FirstOrDefault(x => x.CityID == tmp.CityId).CityName,
                                CraigslistUrl  = tmp.AdsUrl,
                                PostingId      = tmp.CLPostingId.GetValueOrDefault(),
                                CreatedDate    = tmp.AddedDate.GetValueOrDefault(),
                                ExpirationDate = tmp.AddedDate.GetValueOrDefault().AddDays(30)
                            };
                            fullAdsList.Add(record);
                        }
                    }



                    var csvWriterDealer = new CsvExport <TrackingAds>(fullAdsList.OrderBy(x => x.CreatedDate).ToList());


                    string pathDownload = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

                    string fileName = "trackingads" + "_" + DateTime.Now.ToString("MMddyy") +
                                      DateTime.Now.Millisecond +
                                      ".csv";

                    string fullFilePathForDealer = pathDownload + fileName;

                    csvWriterDealer.ExportToFileWithHeader(fullFilePathForDealer);

                    EmailHelper.SendExcelMail(fileName, csvWriterDealer.ExportToBytes());
                    MessageBox.Show("Hi " + GlobalVar.CurrentAccount.FirstName + " " + GlobalVar.CurrentAccount.LastName +
                                    ". You will receive the report in your inbox shortly.", "Info", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        "There is an error when opening a report. Please send the report to your email instead.");
                }
            }
        }
Esempio n. 18
0
        private void btnView_Click_1(object sender, EventArgs e)
        {
            if (dateTimePickerFrom.Value > dateTimePickerEnd.Value)
            {
                MessageBox.Show(
                    "Date Range is not valid",
                    "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    var context = new CLDMSEntities();

                    var dateTo = new DateTime(dateTimePickerFrom.Value.Year, dateTimePickerFrom.Value.Month, dateTimePickerFrom.Value.Day);

                    var dateEnd =
                        new DateTime(dateTimePickerEnd.Value.Year, dateTimePickerEnd.Value.Month,
                                     dateTimePickerEnd.Value.Day).AddDays(1);


                    var fullCityList = context.Cities.ToList();

                    var fullAdsList = new List <TrackingAds>();

                    var selectedCity = (ShortCity)cbCity.SelectedItem;

                    if (selectedCity.CityId == 0)
                    {
                        foreach (
                            var tmp in
                            context.Trackings.Where(
                                a => a.AccountId == GlobalVar.CurrentAccount.AccountId && a.AddedDate >= dateTo && a.AddedDate <= dateEnd))
                        {
                            var index  = 1;
                            var record = new TrackingAds()
                            {
                                Index          = index++,
                                CityName       = fullCityList.FirstOrDefault(x => x.CityID == tmp.CityId).CityName,
                                CraigslistUrl  = tmp.AdsUrl,
                                PostingId      = tmp.CLPostingId.GetValueOrDefault(),
                                CreatedDate    = tmp.AddedDate.GetValueOrDefault(),
                                ExpirationDate = tmp.AddedDate.GetValueOrDefault().AddDays(30)
                            };
                            fullAdsList.Add(record);
                        }
                    }
                    else
                    {
                        foreach (
                            var tmp in
                            context.Trackings.Where(
                                a => a.AccountId == GlobalVar.CurrentAccount.AccountId && a.CityId == selectedCity.CityId && a.AddedDate >= dateTo && a.AddedDate <= dateEnd))
                        {
                            var index  = 1;
                            var record = new TrackingAds()
                            {
                                Index          = index++,
                                CityName       = fullCityList.FirstOrDefault(x => x.CityID == tmp.CityId).CityName,
                                CraigslistUrl  = tmp.AdsUrl,
                                PostingId      = tmp.CLPostingId.GetValueOrDefault(),
                                CreatedDate    = tmp.AddedDate.GetValueOrDefault(),
                                ExpirationDate = tmp.AddedDate.GetValueOrDefault().AddDays(30)
                            };
                            fullAdsList.Add(record);
                        }
                    }


                    var csvWriterDealer = new CsvExport <TrackingAds>(fullAdsList.OrderBy(x => x.CreatedDate).ToList());


                    string pathDownload = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

                    string fullFilePathForDealer = pathDownload + "/trackingads" + "_" + DateTime.Now.ToString("MMddyy") +
                                                   DateTime.Now.Millisecond +
                                                   ".csv";

                    csvWriterDealer.ExportToFileWithHeader(fullFilePathForDealer);


                    //var xlApp = new Excel.ApplicationClass();

                    //object missing = System.Reflection.Missing.Value;

                    //xlApp.Workbooks.OpenText
                    //    (
                    //        fullFilePathForDealer,
                    //        Excel.XlPlatform.xlWindows, //Origin
                    //        1, // Start Row
                    //        Excel.XlTextParsingType.xlDelimited, //Datatype
                    //        Excel.XlTextQualifier.xlTextQualifierNone, //TextQualifier
                    //        false, // Consecutive Deliminators
                    //        false, // tab
                    //        false, // semicolon
                    //        true, //COMMA
                    //        false, // space
                    //        false, // other
                    //        missing, // Other Char
                    //        missing, // FieldInfo
                    //        missing, //TextVisualLayout
                    //        missing, // DecimalSeparator
                    //        missing, // ThousandsSeparator
                    //        missing, // TrialingMionusNumbers
                    //        missing //Local
                    //    );


                    //xlApp.Visible = true;
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        "There is an error when opening a report. Please send the report to your email instead.");
                }
            }
        }