Пример #1
0
        public void addCompanyImage(byte[] Image)
        {
            ICompanyDetails CompanyDetails = new CompanyDetails();

            CompanyDetails.AddCompanyLogo(Image);
            var _selectedCompany = SelectedCompany as CompanyDetailsEntities;
            var results          = CompanyDetails.GetCompanyDetails();
            {
                compId = results.ID;
                _selectedCompany.Comp_logo = results.Comp_logo;
                if (results.Comp_logo != null && results.Comp_logo.Length > 0)
                {
                    Bitmap imageBitMap = BytesToBitmap(results.Comp_logo);
                    //Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\Ashutosh Dwivedi\Desktop\Motivationla.jpg", true);
                    results.ButtonSource          = BitmapConversion.BitmapToBitmapSource(imageBitMap);
                    _selectedCompany.ButtonSource = BitmapConversion.BitmapToBitmapSource(imageBitMap);
                }
            }
        }
Пример #2
0
        //public void LoadCountry()
        //{
        //    _countrycombo = new ObservableCollection<Country>(_objDataSource.CountryList());

        //}
        //ObservableCollection<StateDropDown> StateListing = new ObservableCollection<StateDropDown>();
        //public void LoadState(string countrycode)
        //{
        //    ICompanyDetails CompanyDetails = new CompanyDetails();
        //    StateListing = new ObservableCollection<StateDropDown>
        //            (from state in CompanyDetails.GetStates()
        //             where state.CountryCode.Equals(countrycode)
        //             select state);

        //    Mouse.OverrideCursor = Cursors.Wait;
        //    //this.SingleStateList.Add(StateDropDown)e.User;
        //    BackgroundWorker worker = new BackgroundWorker();

        //    //Set the WorkerReportsProgress property to true if you want the BackgroundWorker to support progress updates.
        //    //When this property is true, user code can call the ReportProgress method to raise the ProgressChanged event.
        //    worker.WorkerReportsProgress = true;

        //    //This event is raised when you call the RunWorkerAsync method. This is where you start the time-consuming operation.
        //    worker.DoWork += new DoWorkEventHandler(this.LoadProductsBackgroundState);

        //    // This event is raised when you call the ReportProgress method.
        //    worker.ProgressChanged += new ProgressChangedEventHandler(this.LoadProductsBackgroundProgressState);
        //    //The RunWorkerCompleted event is raised when the background worker has completed.
        //    //Depending on whether the background operation completed successfully, encountered an error,
        //    //or was canceled, update the user interface accordingly
        //    worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.LoadProductsBackgroundCompleteState);

        //    //Starts running a background operation
        //    worker.RunWorkerAsync();

        //    //this.LoadProductsBackgroundProgressState(object, ProgressChangedEventArgs e);
        //    this.OnPropertyChanged("SingleStateList");
        //}


        #region Background Worker

        /// <summary>
        /// Loads the product models background.
        /// </summary>
        public void LoadCompanyBackground()
        {
            //int compId = 0;
            Mouse.OverrideCursor = Cursors.Wait;
            SelectedCompany      = null; // Unselects last selection. Essential, as assignment below won't clear other control's SelectedItems
            var             Company        = new CompanyDetailsEntities();
            ICompanyDetails CompanyDetails = new CompanyDetails();
            var             results        = CompanyDetails.GetCompanyDetails();

            if (results != null)
            {
                compId            = results.ID;
                companyname       = results.CompanyName;
                compDetailsbackup = results;
            }
            else
            {
                CompanyName = "Please setup your company details";
            }
            //var shippingdetails = CompanyDetails.GetShippingDetails(compId, "Company");
            //results.ShippingAddress = shippingdetails;
            if (results.Comp_logo != null && results.Comp_logo.Length > 0)
            {
                Bitmap imageBitMap = BytesToBitmap(results.Comp_logo);
                //Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\Ashutosh Dwivedi\Desktop\Motivationla.jpg", true);
                results.ButtonSource = BitmapConversion.BitmapToBitmapSource(imageBitMap);
            }
            else
            {
                Bitmap imageBitMap = BytesToBitmap(Default_photo_aray);
                //Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\Ashutosh Dwivedi\Desktop\Motivationla.jpg", true);
                results.ButtonSource = BitmapConversion.BitmapToBitmapSource(imageBitMap);
            }

            int minHeight = 300;

            var  height      = System.Windows.SystemParameters.PrimaryScreenHeight - 155;
            bool validHeight = int.TryParse(height.ToString(), out minHeight);

            results.CompGridHeight = minHeight;

            SelectedCompany      = results;
            Mouse.OverrideCursor = null;


            Mouse.OverrideCursor = Cursors.Wait;

            ////run time-consuming operations on a background thread
            BackgroundWorker worker = new BackgroundWorker();

            ////Set the WorkerReportsProgress property to true if you want the BackgroundWorker to support progress updates.
            ////When this property is true, user code can call the ReportProgress method to raise the ProgressChanged event.
            worker.WorkerReportsProgress = true;

            ////This event is raised when you call the RunWorkerAsync method. This is where you start the time-consuming operation.
            worker.DoWork += new DoWorkEventHandler(this.LoadProductsBackground);

            //// This event is raised when you call the ReportProgress method.
            worker.ProgressChanged += new ProgressChangedEventHandler(this.LoadProductsBackgroundProgress);

            ////The RunWorkerCompleted event is raised when the background worker has completed.
            ////Depending on whether the background operation completed successfully, encountered an error,
            ////or was canceled, update the user interface accordingly
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.LoadProductsBackgroundComplete);

            ////Starts running a background operation
            worker.RunWorkerAsync();
        }