Example #1
0
        private void AddImageButton_OnClick(object sender, RoutedEventArgs e)
        {
            string   title       = AddImageTitleTextBox.Text;
            string   description = AddImageDescriptionTextBox.Text;
            DateTime date        = Convert.ToDateTime(AddImageDatePicker.Text);

            byte[] photo = GetJPGFromImageControl(ImagePhoto.Source as BitmapImage);

            if (!FieldsCompleted(title, description))
            {
                AddImageDisplayInfoTextBlock.Text = @"Must complete mandatory fields.";
            }
            else
            {
                AddImageButton.IsEnabled = true;
                Imagine image = new Imagine()
                {
                    Data      = date,
                    Descriere = description,
                    Titlu     = title,
                    Foto      = photo
                };

                _client.AddImage(image);

                AddImageDisplayInfoTextBlock.Text       = @"Image added.";
                AddImageDisplayInfoTextBlock.Visibility = Visibility.Visible;
            }

            ImagesTabItem_OnLoaded(sender, e);
        }
Example #2
0
 public static void MergeImageEntities(Imagine dbImage, Imagine foundImage)
 {
     dbImage.Descriere   = foundImage.Descriere;
     dbImage.Titlu       = foundImage.Titlu;
     dbImage.DataImagine = foundImage.DataImagine;
     dbImage.Foto        = foundImage.Foto;
 }
Example #3
0
        private void BuildComanda()
        {
            try
            {
                var imageCounter = 0;
                var kmBoard      = 0;
                var imagesList   = new List <Imagine>();

                if (_serviceAutoCheckBox.IsChecked ?? false)
                {
                    kmBoard = int.Parse(_kmBoardTextBox.Text);
                }

                var comanda = new Comanda()
                {
                    Id             = Guid.NewGuid(),
                    Auto           = _auto,
                    Client         = _auto.Client,
                    DataProgramare = _programDatePicker.DisplayDate.Date,
                    DataSystem     = DateTime.Now,
                    Descriere      = _commandDescBox.Text,
                    StareComanda   = StareComanda.InAsteptare,
                    KmBoard        = kmBoard
                };


                foreach (var image in _imaginesList)
                {
                    var img       = new BitmapImage(new Uri(image.Path));
                    var memStream = new MemoryStream();
                    var encoder   = new JpegBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(img));
                    encoder.Save(memStream);

                    var item = new Imagine()
                    {
                        Id        = Guid.NewGuid(),
                        Data      = DateTime.Now,
                        Descriere = image.Descriere,
                        Foto      = memStream.ToArray(),
                        Titlu     = image.Titlu,
                    };

                    imagesList.Add(item);

                    imageCounter++;
                }

                _detaliuComanda = new DetaliuComanda()
                {
                    Id       = Guid.NewGuid(),
                    Comanda  = comanda,
                    Imagines = imagesList
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #4
0
        private void buttonAddNewImage_Click(object sender, EventArgs e)
        {
            string   title       = textBoxAddImageTitle.Text;
            string   description = textBoxAddImageDescription.Text;
            DateTime date        = Convert.ToDateTime(dateTimePickerAddImageDate.Text);

            Image currentImage = Image.FromFile(_imageLocation);

            byte[] photo = ImageToByteArray(currentImage);

            if (!FieldsCompleted(title, description))
            {
                labelAddImage.Text = @"You must complete all fields.";
            }
            else
            {
                buttonAddNewImage.Enabled = true;
                Imagine image = new Imagine()
                {
                    Data      = date,
                    Descriere = description,
                    Titlu     = title,
                    Foto      = photo
                };

                _myPhotos.AddImage(image);

                labelAddImage.Text    = @"Image added.";
                labelAddImage.Visible = true;
            }
        }
Example #5
0
 public void Add(Imagine imagine)
 {
     if (imagine == null)
     {
         return;
     }
     Context.Imagines.Add(imagine);
     Context.SaveChanges();
 }
Example #6
0
 public void Delete(Imagine imagine)
 {
     if (imagine == null)
     {
         return;
     }
     Context.Imagines.Remove(imagine);
     Context.SaveChanges();
 }
Example #7
0
        public void Create(Imagine imagine)
        {
            if (imagine != null)
            {
                throw new System.ArgumentNullException();
            }

            imagineRepository.Add(imagine);
            imagineRepository.Save();
        }
        public void AddImage(Imagine image)
        {
            if (image == null)
            {
                throw new ArgumentException("Image must not be null.");
            }

            _context.Imagini.Add(image);
            _context.SaveChanges();
        }
        public Imagine Add(Imagine imagine)
        {
            if (GetById(imagine.ImagineId) != null)
            {
                return(null);
            }

            db.Imagines.Add(imagine);
            db.SaveChanges();

            return(imagine);
        }
Example #10
0
        public void Add(int roomId, string image)
        {
            var newImage = new Imagine();

            newImage.Id_Camera = roomId;
            newImage.Image     = image;

            var context = new HotelEntities();

            context.Imagine.Add(newImage);
            context.SaveChanges();
        }
        public Boolean Delete(int id)
        {
            Imagine imagine = GetById(id);

            if (imagine == null)
            {
                return(false);
            }

            db.Imagines.Remove(imagine);
            db.SaveChanges();
            return(true);
        }
 public void AddImage(Imagine image)
 {
     if (image == null)
     {
         return;
     }
     if (_applicationContext.Imagines.FirstOrDefault(i => i.ImagineId == image.ImagineId) != null)
     {
         return;
     }
     _applicationContext.Imagines.Add(image);
     _applicationContext.SaveChanges();
 }
Example #13
0
        public void Update(Imagine imagine)
        {
            if (imagine != null)
            {
                throw new System.ArgumentNullException();
            }
            var imagineU = imagineRepository.Where(i => i.Id == imagine.Id).FirstOrDefault();

            imagineU.Data           = imagine.Data == default(DateTime) ? imagineU.Data : imagine.Data;
            imagineU.Descriere      = imagine.Descriere == null ? imagineU.Descriere : imagine.Descriere;
            imagineU.DetaliuComanda = imagine.DetaliuComanda == null ? imagineU.DetaliuComanda : imagine.DetaliuComanda;
            imagineU.Foto           = imagine.Foto == null ? imagineU.Foto : imagine.Foto;

            imagineRepository.Save();
        }
Example #14
0
        public void imagineTest()
        {
            var i = new Imagine();

            Assert.IsTrue(new[] { 0, 2 }.SequenceEqual(i.imagine(1, 1, 1, 1)));
            Assert.IsTrue(new[] { 1, 0 }.SequenceEqual(i.imagine(1, 0, 1, 0)));
            Assert.IsTrue(new[] { -1, 1 }.SequenceEqual(i.imagine(0, 1, 1, 1)));
            Assert.IsTrue(new[] { -87, 3782 }.SequenceEqual(i.imagine(42, 43, 44, 45)));
            Assert.IsTrue(new[] { -5, 10 }.SequenceEqual(i.imagine(1, 2, 3, 4)));
            Assert.IsTrue(new[] { 5, -10 }.SequenceEqual(i.imagine(-1, -2, 3, 4)));
            Assert.IsTrue(new[] { -999, 1001 }.SequenceEqual(i.imagine(-1, -1, -1, -1000)));
            Assert.IsTrue(new[] { -1000, 100 }.SequenceEqual(i.imagine(10, 100, 0, 10)));
            Assert.IsTrue(new[] { 15, 0 }.SequenceEqual(i.imagine(5, 0, 3, 0)));
            Assert.IsTrue(new[] { -15, 0 }.SequenceEqual(i.imagine(0, 5, 0, 3)));
        }
        public void UpdateImage(Imagine image)
        {
            if (image == null)
            {
                return;
            }
            if (_applicationContext.Imagines.FirstOrDefault(i => i.ImagineId == image.ImagineId) == null)
            {
                return;
            }
            var clonedImage = image;

            ImageTransformer.MergeImageEntities(clonedImage, image);
            _applicationContext.SaveChanges();
        }
Example #16
0
        /// <inheritdoc />
        /// <summary>
        /// Creates the imagine.
        /// </summary>
        /// <param name="imagine">The imagine.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool CreateImagine(Imagine imagine)
        {
            try
            {
                _imagineWrite = new WriteImagineRepository(_context);

                _imagineWrite.Create(imagine);
                _context.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                var message = DbEntityCustomException.BuildMessageExceptions(e);
                throw new DbEntityCustomException(message);
            }
        }
        public void UpdateImage(Imagine image)
        {
            if (image == null)
            {
                throw new ArgumentException("Image must not be null.");
            }

            var toUpdate = _context.Imagini.Find(image.Id);

            if (toUpdate == null)
            {
                return;
            }

            _context.Entry(toUpdate).CurrentValues.SetValues(image);
            _context.SaveChanges();
        }
Example #18
0
 private void button2_Click(object sender, EventArgs e)
 {
     IE = new Imagine(IW, IH);
     foreach (var ik in IPath.Keys)
     {
         var i = IPath[ik];
         IE.InImgs.Add(i);
     }
     foreach (var ik in OPath.Keys)
     {
         var i = OPath[ik];
         IE.OutImgs.Add(i);
     }
     Console.WriteLine("Training:" + IE.InImgs.Count + " Images.");
     IE.Train(4, 7, Environment.TickCount);
     Console.WriteLine("Trained.");
 }
Example #19
0
        private void buttonUpdateImage_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridViewDisplayImage.SelectedRows)
            {
                int     id    = Convert.ToInt32(row.Cells[0].Value);
                Imagine image = _carService.FindImageById(id);

                image.Titlu     = row.Cells[1].Value.ToString();
                image.Data      = Convert.ToDateTime(row.Cells[2].Value);
                image.Descriere = row.Cells[4].Value.ToString();

                _carService.UpdateImage(image);
            }

            // reload to view changes
            FormDisplayDetails_Load(sender, e);
        }
        public List <Comanda> GetImagesForOrder(Imagine image, Comanda order)
        {
            if (order == null)
            {
                return(null);
            }
            if (_applicationContext.Comandas.FirstOrDefault(i => i.ComandaId == order.ComandaId) == null)
            {
                return(null);
            }

            var query = from o in _applicationContext.Comandas
                        where o.ComandaId == order.ComandaId
                        select o;

            return(query.Any() ? query.ToList() : null);
        }
        public Imagine Update(Imagine imagine)
        {
            if (GetById(imagine.ImagineId) == null)
            {
                return(null);
            }

            Imagine imagine1 = GetById(imagine.ImagineId);

            imagine1.Titlu     = imagine.Titlu;
            imagine1.Descriere = imagine.Descriere;
            imagine1.Data      = imagine.Data;
            imagine1.Foto      = imagine.Foto;

            db.SaveChanges();

            return(imagine);
        }
Example #22
0
        public void CreateNew(ImagineDto imagineDto)
        {
            if (imagineDto == null)
            {
                throw new ArgumentNullException(nameof(imagineDto));
            }

            var imagine = new Imagine
            {
                Data      = imagineDto.Data,
                Descriere = imagineDto.Descriere,
                //DetaliuComanda = imagineDto.DetaliuComanda,
                Foto  = imagineDto.Foto,
                Titlu = imagineDto.Titlu
            };

            imagineRepository.Add(imagine);
            unitOfWork.Commit();
        }
Example #23
0
        public void Update(Imagine imagine1, Imagine imagine2)
        {
            if (imagine1 == null || imagine2 == null)
            {
                return;
            }

            var foundImage = Context.Imagines.FirstOrDefault(m => m.ImagineId == imagine1.ImagineId);

            if (foundImage != null)
            {
                foundImage.DetaliiComandas = imagine2.DetaliiComandas;
                foundImage.Titlu           = imagine2.Titlu;
                foundImage.DataImagine     = imagine2.DataImagine;
                foundImage.Descriere       = imagine2.Descriere;
                foundImage.Foto            = imagine2.Foto;
            }
            Context.Imagines.AddOrUpdate(foundImage);
            Context.SaveChanges();
        }
Example #24
0
        private void UpdateImageButton_OnClick(object sender, RoutedEventArgs e)
        {
            IList selectedImages = ImagesDataGrid.SelectedItems;
            int   imagesSize     = selectedImages.Count;

            for (var i = 0; i < imagesSize; i++)
            {
                DataRowView row    = (DataRowView)ImagesDataGrid.SelectedItems[i];
                string      textId = row["Id"].ToString();
                int         id     = Convert.ToInt32(textId);

                Imagine image = _client.FindImageById(id);
                image.Descriere = row["Descriere"].ToString();
                image.Data      = Convert.ToDateTime(row["Data"].ToString());
                image.Titlu     = row["Titlu"].ToString();

                _client.UpdateImageAsync(image);
            }

            ImagesTabItem_OnLoaded(sender, e);
        }
Example #25
0
 public void SetSprite(ref Imagine sprite)
 {
     this.sprite = sprite;
 }
Example #26
0
        private void AddOrderDetailsButton_OnClick(object sender, RoutedEventArgs e)
        {
            List <Material> materials  = new List <Material>();
            List <Operatie> operations = new List <Operatie>();
            List <Mecanic>  mechanics  = new List <Mecanic>();
            List <Imagine>  images     = new List <Imagine>();

            DataRowView selectedRow = (DataRowView)DisplayOrderOrdersDataGrid.SelectedItem;
            string      autoIdText  = selectedRow["Id"].ToString();
            int         orderId     = Convert.ToInt32(autoIdText);

            IList selectedMaterials = DisplayOrderMaterialsDataGrid.SelectedItems;
            int   materialsSize     = selectedMaterials.Count;

            for (var i = 0; i < materialsSize; i++)
            {
                DataRowView row    = (DataRowView)DisplayOrderMaterialsDataGrid.SelectedItems[i];
                string      textId = row["Id"].ToString();

                Console.WriteLine(textId); // a luat bine

                int id = Convert.ToInt32(textId);

                Material material = _client.FindMaterialById(id);
                _totalCost += material.Pret;

                material.Cantitate -= 1;
                _client.UpdateMaterial(material);

                materials.Add(material);

                // merge bine
                foreach (var item in materials)
                {
                    Console.WriteLine(item.Denumire, material.Id);
                }
            }

            IList selectedOperations = DisplayOrderOperationsDataGrid.SelectedItems;
            int   operationsSize     = selectedOperations.Count;

            for (var i = 0; i < operationsSize; i++)
            {
                DataRowView row    = (DataRowView)DisplayOrderOperationsDataGrid.SelectedItems[i];
                string      textId = row["Id"].ToString();
                int         id     = Convert.ToInt32(textId);

                Operatie operation = _client.FindOperationById(id);
                operations.Add(operation);
            }

            IList selectedMechanics = DisplayOrderMechanicsDataGrid.SelectedItems;
            int   mechanicsSize     = selectedMechanics.Count;

            for (var i = 0; i < mechanicsSize; i++)
            {
                DataRowView row    = (DataRowView)DisplayOrderMechanicsDataGrid.SelectedItems[i];
                string      textId = row["Id"].ToString();
                int         id     = Convert.ToInt32(textId);

                Mecanic mecanic = _client.FindMecanicById(id);
                mechanics.Add(mecanic);
            }

            IList selectedImages = DisplayOrderImagesDataGrid.SelectedItems;
            int   imagesSize     = selectedImages.Count;

            for (var i = 0; i < imagesSize; i++)
            {
                DataRowView row    = (DataRowView)DisplayOrderImagesDataGrid.SelectedItems[i];
                string      textId = row["Id"].ToString();
                int         id     = Convert.ToInt32(textId);

                Imagine image = _client.FindImageById(id);
                images.Add(image);
            }

            DetaliuComanda orderDetails = new DetaliuComanda()
            {
                ComandaId = orderId,
                Imagini   = images.ToArray(),
                Mecanici  = mechanics.ToArray(),
                Materiale = materials.ToArray(),
                Operatii  = operations.ToArray()
            };

            _client.AddOrderDetails(orderDetails);

            Comanda order = _client.FindOrderById(orderId);

            order.ValoarePiese = _totalCost + _serviceFee;
            _client.UpdateOrder(order);
        }
Example #27
0
 public void UpdateImage(Imagine image)
 {
     _api.UpdateImage(image);
 }
Example #28
0
        static void Main(string[] args)
        {
            SasiuRepository  sasiuRepository  = new SasiuRepository();
            AutoRepository   autoRepository   = new AutoRepository();
            ClientRepository clientRepository = new ClientRepository();

            Sasiu sasiu = new Sasiu();

            sasiu.SasiuId  = 1;
            sasiu.CodSasiu = "12";
            sasiu.Denumire = "dsfsdfsdf";
            //sasiuRepository.Add(sasiu);

            //sasiuRepository.Update(sasiu);

            Client client = new Client();

            client.Nume       = "TestName";
            client.Prenume    = "TestPrenume";
            client.Adresa     = "TestAdresa";
            client.Localitate = "TestLocali";
            client.Judet      = "TestJudet";
            client.Telefon    = "0746653884";
            client.Email      = "TestEmail";



            ////List<Sasiu> sasiuri = sasiuApi.GetSasiuri();
            ////foreach (Sasiu sas in sasiuri)
            ////{
            ////    Console.WriteLine(sas.Denumire);

            ////Console.Read();

            ////sasiuRepository.UpdateSasiu(2, sasiu);
            ////sasiuRepository.Delete(2);

            Auto auto = new Auto();

            auto.NumarAuto = "TestNrAuto";

            auto.SerieSasiu = "TestSerie";

            auto.Sasiu = sasiu;

            Comanda comanda = new Comanda();

            comanda.StareComanda   = "TestStareComanda";
            comanda.DataSystem     = DateTime.Now;
            comanda.DataProgramare = DateTime.Now;
            comanda.DataFinalizare = DateTime.Now;
            comanda.KmBord         = 100;
            comanda.Descriere      = "Test Descriere";
            comanda.ValoarePiese   = 100;


            Imagine imagine = new Imagine();

            imagine.Titlu     = "TitluTest";
            imagine.Descriere = "TestDescriere";
            imagine.Data      = DateTime.Now;


            DetaliuComanda detaliuComanda = new DetaliuComanda();

            detaliuComanda.Imagines.Add(imagine);
            comanda.DetaliuComanda = detaliuComanda;



            auto.Comandas.Add(comanda);



            //client.Autoes.Add(auto);
            client.Autoes.Add(auto);


            clientRepository.Add(client);

            //// clientRepository.Delete(1);
        }
Example #29
0
 public void AddImage(Imagine image)
 {
     _api.AddImage(image);
 }
        private void buttonAddDetails_Click(object sender, EventArgs e)
        {
            List <Material> materials  = new List <Material>();
            List <Operatie> operations = new List <Operatie>();
            List <Mecanic>  mechanics  = new List <Mecanic>();
            List <Imagine>  images     = new List <Imagine>();

            int             index       = dataGridViewAddDetailByOrder.CurrentCell.RowIndex;
            DataGridViewRow selectedRow = dataGridViewAddDetailByOrder.Rows[index];
            int             orderId     = Convert.ToInt32(selectedRow.Cells[0].Value);

            foreach (DataGridViewRow row in dataGridViewAddDetailsMaterials.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Material material = _carService.FindMaterialById(id);
                TotalCost += material.Pret;

                material.Cantitate -= 1;
                _carService.UpdateMaterial(material);

                materials.Add(material);
            }

            foreach (DataGridViewRow row in dataGridViewAddDetailsOperations.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Operatie operation = _carService.FindOperationById(id);
                operations.Add(operation);
            }

            foreach (DataGridViewRow row in dataGridViewAddDetailsMechanics.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Mecanic mecanic = _carService.FindMecanicById(id);
                mechanics.Add(mecanic);
            }

            foreach (DataGridViewRow row in dataGridViewAddDetailsImages.SelectedRows)
            {
                int id = Convert.ToInt32(row.Cells[0].Value);

                Imagine image = _carService.FindImageById(id);
                images.Add(image);
            }

            DetaliuComanda orderDetails = new DetaliuComanda()
            {
                ComandaId = orderId,
                Imagini   = images,
                Mecanici  = mechanics,
                Materiale = materials,
                Operatii  = operations
            };

            _carService.AddOrderDetails(orderDetails);
            labelAddDetails.Text    = @"Order details added.";
            labelAddDetails.Visible = true;

            Comanda order = _carService.FindOrderById(orderId);

            order.ValoarePiese = TotalCost + ServiceFee;
            _carService.UpdateOrder(order);
        }