Ejemplo n.º 1
0
        private async void Send(ImageExtension imageExtension)
        {
            string extensionImage = ImageExtensionMethods.GetImageExtensionString(imageExtension);

            try
            {
                var upImageBytes = File.ReadAllBytes(imageCompressDirectory + extensionImage);
                var upJSONBytes  = File.ReadAllBytes(JSONFileDirectory);

                HttpClient client = new HttpClient();
                MultipartFormDataContent content = new MultipartFormDataContent();

                ByteArrayContent imageContent  = new ByteArrayContent(upImageBytes);
                string           imageSendName = "image" + extensionImage;
                content.Add(imageContent, "image", imageSendName);

                ByteArrayContent JSONContent = new ByteArrayContent(upJSONBytes);
                content.Add(JSONContent, "coordinate", "coordinate.txt");

                var response =
                    await client.PostAsync(URLSend, content);

                var responsestr = response.Content.ReadAsStringAsync().Result;
            }
            catch (Exception e)
            {
                await DisplayAlert("Errore invio file", "Errore connessione con il server " + e.Source, "OK");
            }
        }
        private void GenerateBarcodeTag(JewelMaster entity)
        {
            var jewelMasterDataSet = new JewelMasterDataSet();

            var barcode        = new BarcodeUtility();
            var jewelImage     = barcode.MakeBarcodeImage(entity.JewelNo);
            var jewelMasterRow = jewelMasterDataSet.Tables["JewelMaster"].NewRow();

            jewelMasterRow["JewelId"]          = entity.JewelId;
            jewelMasterRow["JewelNo"]          = entity.JewelNo;
            jewelMasterRow["StyleNo"]          = entity.StyleNo;
            jewelMasterRow["JewelDescription"] = entity.JewelDescription;
            jewelMasterRow["MetalColor"]       = entity.MetalColor;
            jewelMasterRow["ImagePath"]        = ImageExtension.GetImageName(entity.StyleNo);
            jewelMasterRow["DiamondPcs"]       = Convert.ToString(entity.DiamondPcs);
            jewelMasterRow["DiamondWt"]        = Convert.ToString(entity.DiamondWt);
            jewelMasterRow["GrsWt"]            = Convert.ToString(entity.GrsWt);
            jewelMasterRow["NetWt"]            = Convert.ToString(entity.NetWt);
            jewelMasterRow["JewelImage"]       = ImageConverterHelper.ImageToByteArray(jewelImage);

            jewelMasterDataSet.Tables["JewelMaster"].Rows.Add(jewelMasterRow);

            if (!File.Exists(Application.StartupPath + @"\" + ReportConstants.JEWELMASTERREPORTPATH))
            {
                return;
            }

            var reportDocument = new ReportDocument();

            reportDocument.Load(Application.StartupPath + @"\" + ReportConstants.JEWELMASTERREPORTPATH);
            reportDocument.SetDataSource(jewelMasterDataSet);
            crystalReportViewer1.ReportSource = reportDocument;
            crystalReportViewer1.Refresh();
        }
        public async Task <Product> UpdateProductAsync(Product product, string webRoot)
        {
            var dbProduct = await _context.Products.FirstOrDefaultAsync(x => x.Id == product.Id);

            if (dbProduct == null)
            {
                return(dbProduct);
            }

            string folderName = Path.Combine("images", "shop");

            if (product.Photo != null)
            {
                ImageExtension.DeleteImage(webRoot, folderName, dbProduct.PictureUrl);
                string fileName = await product.Photo.SaveImg(webRoot, folderName);

                dbProduct.PictureUrl = fileName;
            }
            dbProduct.Name           = product.Name;
            dbProduct.Price          = product.Price;
            dbProduct.Description    = product.Description;
            dbProduct.ProductBrandId = product.ProductBrandId;
            dbProduct.ProductTypeId  = product.ProductTypeId;
            await _context.SaveChangesAsync();

            return(dbProduct);
        }
        public override void BindValues(JewelMaster entity)
        {
            if (entity == null)
            {
                return;
            }
            btnPrintSticker.Enabled = true;

            txtJewelNo.Text    = entity.JewelNo;
            txtStyleNo.Text    = entity.StyleNo;
            cboJewelDesc.Text  = entity.JewelDescription;
            cboMetalColor.Text = entity.MetalColor;
            txtDiamondPcs.Text = Convert.ToString(entity.DiamondPcs);
            txtDiamondWt.Text  = Convert.ToString(entity.DiamondWt);
            txtNetWt.Text      = Convert.ToString(entity.NetWt);
            txtGrsWt.Text      = Convert.ToString(entity.GrsWt);

            var imagePath = Path.Combine(_winSettingProvider.ImageDirectory, ImageExtension.GetImageName(entity.StyleNo));

            {
                if (File.Exists(imagePath))
                {
                    HasImage = true;
                    using (var img = Image.FromFile(imagePath))
                        jewelPictureBox.Image = img.Clone <Image>();
                }
                else
                {
                    HasImage = false;
                    jewelPictureBox.Image = Image.FromFile(Application.StartupPath + @"\Resource\TirthJewels.JPG");
                }
            }
            GenerateBarcodeTag(entity);
        }
        public void BindForm(ItemDetail item)
        {
            CertificateCharges.Text = item.CertificateCharges.ToString("C");
            DesignCode.Text         = item.DesignCode;
            ItemCategory.Text       = item.ItemCategory;
            ItemDesc.Text           = item.ItemDescription;
            LabourCharges.Text      = item.LabourCharges.ToString("C");
            MetalNetAmount.Text     = item.MetalDetail.MetalNetAmount.ToString("C");
            MetalNetWt.Text         = item.MetalDetail.MetalNetWt.ToString();
            MetalType.Text          = item.MetalDetail.MetalType;
            StoneNetAmount.Text     = item.StoneDetail.StoneNetAmount.ToString("C");
            lblTotalAmount.Text     = item.Amount.ToString("C");
            StoneNetWt.Text         = item.StoneDetail.StoneNetWt.ToString();
            StoneType.Text          = item.StoneDetail.StoneType;
            TotalWeight.Text        = item.TotalWeight.ToString();
            lblStamping.Text        = item.StampingCharges.ToString("C");
            CStpe.Text  = item.ColorStoneDetail.ColorStoneType;
            CSwt.Text   = item.ColorStoneDetail.ColorStoneNetWt.ToString();
            CSnamt.Text = item.ColorStoneDetail.ColorStoneNetAmount.ToString("C");

            _chart = item.StoneDetail.StoneChart;

            TotalStonePcs.Text = item.StoneDetail.TotalStonePcs != 0 ? item.StoneDetail.TotalStonePcs.ToString()
                                                                        : item.ColorStoneDetail.ColorTotalStonePcs.ToString();

            JewelNumber.Text = item.DesignCode;
            pictureBox.Image = ImageExtension.ResolveImage(item.DesignCode);
        }
Ejemplo n.º 6
0
 public Image(string name, int size, IEnumerable <Atribute> atributes, Resolution resolution, int depth, int channels, ImageExtension extension) : base(name, size, atributes)
 {
     Resolution = resolution;
     Depth      = depth;
     Channels   = channels;
     Extension  = extension;
 }
        public async Task <ActionResult <About> > Update(int id, [FromForm] AboutUpdateDto aboutUpdateDto)
        {
            if (id != aboutUpdateDto.Id)
            {
                return(BadRequest());
            }
            About dbAbout = _context.Abouts.FirstOrDefault(p => p.Id == id);

            if (dbAbout == null)
            {
                return(NotFound());
            }
            dbAbout.Title       = aboutUpdateDto.Title;
            dbAbout.Description = aboutUpdateDto.Description;

            string folderName = Path.Combine("images", "about");

            if (aboutUpdateDto.Photo != null)
            {
                ImageExtension.DeleteImage(_env.WebRootPath, folderName, dbAbout.PhotoUrl);
                string fileName = await aboutUpdateDto.Photo.SaveImg(_env.WebRootPath, folderName);

                dbAbout.PhotoUrl = fileName;
            }
            await _context.SaveChangesAsync();

            return(Ok());
        }
Ejemplo n.º 8
0
        public async Task <Doctor> UpdateDoctorAsync(Doctor doctor, string webRoot)
        {
            var dbDoctor = await _context.Doctors.FirstOrDefaultAsync(x => x.Id == doctor.Id);

            if (dbDoctor == null)
            {
                return(dbDoctor);
            }

            string folderName = Path.Combine("images", "doctors");

            if (doctor.Photo != null)
            {
                ImageExtension.DeleteImage(webRoot, folderName, dbDoctor.PhotoUrl);
                string fileName = await doctor.Photo.SaveImg(webRoot, folderName);

                dbDoctor.PhotoUrl = fileName;
            }

            dbDoctor.Name         = doctor.Name;
            dbDoctor.Description  = doctor.Description;
            dbDoctor.Facebook     = doctor.Facebook;
            dbDoctor.Profession   = doctor.Profession;
            dbDoctor.DepartmentId = doctor.DepartmentId;
            await _context.SaveChangesAsync();

            return(dbDoctor);
        }
Ejemplo n.º 9
0
        private byte[] Run(int sizeInBytes, string extension, out ImageExtension parsedExtension)
        {
            if (sizeInBytes < 1000)
            {
                throw new ArgumentException("Size must be greater than 1000 bytes (1 KB).");
            }

            var isExtensionValid = Enum.TryParse <ImageExtension>(extension, out parsedExtension);

            if (!isExtensionValid)
            {
                throw new ArgumentException($"Extension {extension} is invalid. Value must be 'Jpg' or 'Png'.");
            }

            var bytes      = new byte[sizeInBytes];
            var imageBytes = parsedExtension switch
            {
                ImageExtension.Jpg => jpgImage,
                ImageExtension.Png => pngImage,
                _ => jpgImage,
            };

            imageBytes.CopyTo(bytes, 0);

            return(bytes);
        }
Ejemplo n.º 10
0
 public IActionResult Delete(int id, Product product)
 {
     try
     {
         var item         = procuctDb.Products.Find(id);
         var itemPictures = procuctDb.Pictures.Where(x => x.ProductID == id).ToList();
         var properies    = procuctDb.Properties.Where(x => x.ProductId == id).ToList();
         procuctDb.Properties.RemoveRange(properies);
         foreach (var itemPicture in itemPictures)
         {
             ImageExtension.DeleteImage(itemPicture.PhotoUrl, hostEnvironment);
         }
         procuctDb.Pictures.RemoveRange(itemPictures);
         procuctDb.Products.Remove(item);
         procuctDb.SaveChanges();
         DeletedProduct deleted = new DeletedProduct
         {
             DeletedDate = DateTime.Today,
             Name        = item.Name,
             DeletedId   = item.Id
         };
         procuctDb.DeletedProducts.Add(deleted);
         procuctDb.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(RedirectToAction(nameof(Delete), id));
     }
 }
Ejemplo n.º 11
0
        private void setupNavigationBar()
        {
            //Back button title
            var attributes = new UITextAttributes
            {
                Font      = UIFont.SystemFontOfSize(14, UIFontWeight.Medium),
                TextColor = Colors.NavigationBar.BackButton.ToNativeColor()
            };

            UIBarButtonItem.Appearance.SetTitleTextAttributes(attributes, UIControlState.Normal);
            UIBarButtonItem.Appearance.SetTitleTextAttributes(attributes, UIControlState.Highlighted);
            UIBarButtonItem.Appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(6, 0), UIBarMetrics.Default);

            //Back button icon
            var image = UIImage.FromBundle("icBackNoPadding");

            UINavigationBar.Appearance.BackIndicatorImage = image;
            UINavigationBar.Appearance.BackIndicatorTransitionMaskImage = image;

            //Title and background
            var barBackgroundColor = Colors.NavigationBar.BackgroundColor.ToNativeColor();

            UINavigationBar.Appearance.ShadowImage     = new UIImage();
            UINavigationBar.Appearance.BarTintColor    = barBackgroundColor;
            UINavigationBar.Appearance.BackgroundColor = barBackgroundColor;
            UINavigationBar.Appearance.TintColor       = Colors.NavigationBar.BackButton.ToNativeColor();
            UINavigationBar.Appearance.SetBackgroundImage(ImageExtension.ImageWithColor(barBackgroundColor), UIBarMetrics.Default);
            UINavigationBar.Appearance.TitleTextAttributes = new UIStringAttributes
            {
                Font            = UIFont.SystemFontOfSize(14, UIFontWeight.Medium),
                ForegroundColor = UIColor.Black
            };
        }
        public async Task <Blog> UpdateBlogAsync(Blog blog, string webRoot)
        {
            var dbBlog = await _context.Blogs.FirstOrDefaultAsync(b => b.Id == blog.Id);

            if (dbBlog == null)
            {
                return(dbBlog);
            }
            string folderName = Path.Combine("images", "blog");

            if (blog.Photo != null)
            {
                ImageExtension.DeleteImage(webRoot, folderName, dbBlog.PhotoUrl);
                string fileName = await blog.Photo.SaveImg(webRoot, folderName);

                dbBlog.PhotoUrl = fileName;
            }

            dbBlog.Title       = blog.Title;
            dbBlog.Description = blog.Description;
            dbBlog.Topic       = blog.Topic;
            await _context.SaveChangesAsync();

            return(dbBlog);
        }
        public async Task <ActionResult <Bio> > Update(int id, [FromForm] BioUpdateDto bioUpdateDto)
        {
            if (id != bioUpdateDto.Id)
            {
                return(BadRequest());
            }
            Bio dbBio = _context.Bios.FirstOrDefault(p => p.Id == id);

            if (dbBio == null)
            {
                return(NotFound());
            }
            dbBio.Phone    = bioUpdateDto.Phone;
            dbBio.Email    = bioUpdateDto.Email;
            dbBio.Facebook = bioUpdateDto.Facebook;
            dbBio.Address  = bioUpdateDto.Address;

            string folderName = Path.Combine("images", "logo");

            if (bioUpdateDto.Logo != null)
            {
                ImageExtension.DeleteImage(_env.WebRootPath, folderName, dbBio.LogoUrl);
                string fileName = await bioUpdateDto.Logo.SaveImg(_env.WebRootPath, folderName);

                dbBio.LogoUrl = fileName;
            }
            await _context.SaveChangesAsync();

            return(Ok(dbBio));
        }
Ejemplo n.º 14
0
        public IResult Insert()
        {
            var result = new Result
            {
                Operation = Operation.Create,
                Status    = Status.Success
            };

            try
            {
                if (!ModelState.IsValid)
                {
                    result.Status     = Status.Fail;
                    result.StatusCode = HttpStatusCode.BadRequest;
                    return(result);
                }
                var       product = JsonConvert.DeserializeObject <Products>(Request.Form["product"]);
                IFormFile img     = null;
                if (Request.Form.Files.Count != 0)
                {
                    var image = Request.Form.Files;
                    img = image[0];
                }
                var pdtNameCheck = _context.Products.Where(p => p.ProductName == product.ProductName && p.ProductId != product.ProductId && p.IsDeleted != true).FirstOrDefault();
                if (pdtNameCheck != null)
                {
                    result.Message    = "Product of this name exists already";
                    result.Status     = Status.Fail;
                    result.StatusCode = HttpStatusCode.BadRequest;
                    return(result);
                }
                var pdtModelCheck = _context.Products.Where(p => p.ModelNumber == product.ModelNumber && p.ProductId != product.ProductId && p.IsDeleted != true).FirstOrDefault();
                if (pdtModelCheck != null)
                {
                    result.Message    = "Product with this model number exists";
                    result.Status     = Status.Fail;
                    result.StatusCode = HttpStatusCode.BadRequest;
                    return(result);
                }
                product.CreatedDate = DateTime.Now;
                product.IsActive    = true;
                if (img != null)
                {
                    ImageExtension imageExtension = new ImageExtension();
                    product.ProductImage = imageExtension.Image(img);
                }
                _context.Products.Add(product);
                _context.SaveChanges();
                result.StatusCode = HttpStatusCode.OK;
                return(result);
            }
            catch (Exception e)
            {
                result.Message    = e.Message;
                result.Status     = Status.Error;
                result.StatusCode = HttpStatusCode.InternalServerError;
                return(result);
            }
        }
Ejemplo n.º 15
0
        public static Bitmap ApplyMaskForAllChanales(Bitmap img, double[][] mask, int treshe = 0)
        {
            Bitmap resBmp = new Bitmap(img);
            var    colors = ImageExtension.GetolorMatrix(img);
            int    r_tr   = 0;
            int    g_tr   = 0;
            int    b_tr   = 0;

            for (int i = 0; i < colors.Length; i++)
            {
                for (int j = 0; j < colors[0].Length; j++)
                {
                    if (colors[i][j].R > r_tr)
                    {
                        r_tr = colors[i][j].R;
                    }
                    if (colors[i][j].G > g_tr)
                    {
                        g_tr = colors[i][j].G;
                    }
                    if (colors[i][j].B > b_tr)
                    {
                        b_tr = colors[i][j].B;
                    }
                }
            }

            r_tr /= 2;
            g_tr /= 2;
            b_tr /= 2;

            if (treshe != 0)
            {
                r_tr = treshe;
                g_tr = treshe;
                b_tr = treshe;
            }

            for (int i = 0; i < colors.Length; i++)
            {
                for (int j = 0; j < colors[0].Length; j++)
                {
                    var itemMatrix = getItemMatrix(i, j, colors, mask.Length);
                    var newRValue  = ItemCalculation(itemMatrix, mask, r_tr, ColorChannel.Red);
                    var bval       = (byte)newRValue;
                    var newGValue  = (byte)ItemCalculation(itemMatrix, mask, g_tr, ColorChannel.Green);
                    var newBValue  = (byte)ItemCalculation(itemMatrix, mask, b_tr, ColorChannel.Blue);

                    var newVal = (newRValue > 0 || newGValue > 0 || newBValue > 0) ? 255 : 0;

                    Color newColor;
                    newColor = Color.FromArgb(colors[i][j].A, (byte)newVal, newVal, newVal);

                    resBmp.SetPixel(i, j, newColor);
                }
            }

            return(resBmp);
        }
Ejemplo n.º 16
0
        public void ApplyMask(double[][] maskH, double[][] maskV, int treshe = 0)
        {
            Color[][] colorsH = ImageExtension.GetolorMatrix(MaskApplier.ApplyMaskForAllChanales(BitmapImg, maskH, treshe));
            Color[][] colorsV = ImageExtension.GetolorMatrix(MaskApplier.ApplyMaskForAllChanales(BitmapImg, maskV, treshe));
            ResultImg = new Bitmap(BitmapImg);

            if (chanel == ColorChannel.All)
            {
                for (int i = 0; i < colorsH.Length; i++)
                {
                    for (int j = 0; j < colorsH[0].Length; j++)
                    {
                        var r = Math.Sqrt((colorsH[i][j].R * colorsH[i][j].R) + (colorsV[i][j].R * colorsV[i][j].R));
                        var g = Math.Sqrt((colorsH[i][j].G * colorsH[i][j].G) + (colorsV[i][j].G * colorsV[i][j].G));
                        var b = Math.Sqrt((colorsH[i][j].B * colorsH[i][j].B) + (colorsV[i][j].B * colorsV[i][j].B));

                        ResultImg.SetPixel(i, j, Color.FromArgb(255, (byte)r, (byte)g, (byte)b));
                    }
                }
            }
            else
            {
                var initialColors = ImageExtension.GetolorMatrix(BitmapImg);
                for (int i = 0; i < colorsH.Length; i++)
                {
                    for (int j = 0; j < colorsH[0].Length; j++)
                    {
                        var r = (chanel == ColorChannel.Red)
                            ? Math.Sqrt((colorsH[i][j].R * colorsH[i][j].R) + (colorsV[i][j].R * colorsV[i][j].R))
                            : initialColors[i][j].R;
                        var g = (chanel == ColorChannel.Green)
                            ? Math.Sqrt((colorsH[i][j].G * colorsH[i][j].G) + (colorsV[i][j].G * colorsV[i][j].G))
                            : initialColors[i][j].G;
                        var b = (chanel == ColorChannel.Blue)
                            ? Math.Sqrt((colorsH[i][j].B * colorsH[i][j].B) + (colorsV[i][j].B * colorsV[i][j].B))
                            : initialColors[i][j].B;

                        ResultImg.SetPixel(i, j, Color.FromArgb(255, (byte)r, (byte)g, (byte)b));
                    }
                }
            }

            var reHisto = HistogramCalc.GetHistogram(ResultImg, Chanel);

            var values = new ChartValues <ObservableValue>();

            foreach (var item in reHisto)
            {
                values.Add(new ObservableValue(item));
            }

            WorkCollection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Values = values
                }
            };
        }
Ejemplo n.º 17
0
        public async Task <ActionResult> RenderImage(int id)
        {
            Opdracht opdracht = await db.Opdrachten.FindAsync(id);

            byte[] imageBytes = opdracht.Image;

            return(File(imageBytes, $"{ImageExtension.GetMimeTypeFromImageByteArray(imageBytes)}"));
        }
        public IActionResult OnPostForm([FromForm] IFormFile frm)
        {
            string cdn       = "C:\\";
            string path      = "TestImage";
            var    imagePath = ImageExtension.SaveToCdn(frm, cdn, path);

            return(Ok());
        }
Ejemplo n.º 19
0
 public void ProcessRequest(HttpContext context)
 {
     if (this.ImageGuid == new Guid() || ImageExtension == null)
     {
         return;
     }
     context.Response.ContentType = string.Format("image/{0}", ImageExtension.ToUpperInvariant());
     WriteImage(context);
 }
 internal static string GetDisplayName(this ImageExtension enumValue)
 {
     return(enumValue
            .GetType()
            .GetMember(enumValue.ToString())
            .First()
            .GetCustomAttribute <DisplayAttribute>()
            .GetName());
 }
Ejemplo n.º 21
0
        private void dgvJewel_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dataGridView = ((frmCatalogue)Owner).dgvJewel;

            try
            {
                if (((DataGridView)sender).Columns[e.ColumnIndex].Name == "Select" & e.RowIndex >= 0)
                {
                    if (dgvJewel.Columns[e.ColumnIndex].CellType == typeof(DataGridViewCheckBoxCell))
                    {
                        int dl;
                        for (dl = 0; dl <= dataGridView.Rows.Count - 1; dl++)
                        {
                            if (dataGridView.Rows[dl].Cells[2].Value.ToString().Trim() == dgvJewel.Rows[e.RowIndex].Cells[2].Value.ToString().Trim())
                            {
                                MessageBox.Show(Resources.frmProduct_dgvJewel_CellContentClick_Record_already_exists_, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                dgvJewel.Rows[e.RowIndex].Cells[0].Value = false;
                                return;
                            }
                        }

                        dataGridView.Rows.Add(1);
                        dataGridView.Rows[AddProductToGrid].Cells[0].Value  = true;
                        dataGridView.Rows[AddProductToGrid].Height          = 100;
                        dataGridView.Rows[AddProductToGrid].Cells[2].Value  = dgvJewel.Rows[e.RowIndex].Cells[2].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[3].Value  = dgvJewel.Rows[e.RowIndex].Cells[3].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[4].Value  = dgvJewel.Rows[e.RowIndex].Cells[4].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[5].Value  = dgvJewel.Rows[e.RowIndex].Cells[5].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[6].Value  = dgvJewel.Rows[e.RowIndex].Cells[6].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[7].Value  = dgvJewel.Rows[e.RowIndex].Cells[7].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[8].Value  = dgvJewel.Rows[e.RowIndex].Cells[8].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[9].Value  = dgvJewel.Rows[e.RowIndex].Cells[9].Value;
                        dataGridView.Rows[AddProductToGrid].Cells[10].Value = dgvJewel.Rows[e.RowIndex].Cells[10].Value;

                        var styleno = dataGridView.Rows[AddProductToGrid].Cells[6].Value;
                        dataGridView[1, AddProductToGrid].Value = ImageExtension.ResolveImage(styleno.ToString());
                        dgvJewel[1, GridRow].Value = ImageExtension.ResolveImage(styleno.ToString());

                        dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1;
                        AddProductToGrid = ((frmCatalogue)Owner).AddRowToGrid = ((frmCatalogue)Owner).AddRowToGrid + 1;

                        ((frmCatalogue)Owner).CatalogueRequest.Add(new QueryRequest()
                        {
                            JewelNo = dgvJewel.Rows[e.RowIndex].Cells[2].Value.ToString(),
                            StyleNo = dgvJewel.Rows[e.RowIndex].Cells[3].Value.ToString(),
                        });
                    }
                    ((frmCatalogue)Owner).GetTotal();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 22
0
        private void FindJewelByJewelNo(FindJewelBy findParam)
        {
            foreach (DataGridViewRow dgvr in dgvJewel.Rows)
            {
                var findCode = String.Empty;
                var code     = String.Empty;
                if (findParam == FindJewelBy.JewelNo)
                {
                    findCode = dgvr.Cells[_columnjewelnumber.ToLowerCaseColumnName()].Value.ToString();
                    code     = txtBarCode.Text;
                }

                if (String.Compare(findCode, code, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    MessageBox.Show(findParam + Resources.frmMemoOrder_FindJewelByJewelNo__already_exists__Please_search_for_new_record_, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtBarCode.Text = String.Empty;
                    return;
                }
            }

            JewelStockLedger JewelData = null;

            if (findParam == FindJewelBy.JewelNo)
            {
                JewelData = _transactionServices.GetJewelStockByJewelNo(txtBarCode.Text);
            }

            if (!(JewelData != null && JewelData.StockStatus == StockStatus.ItemIsInStock))
            {
                MessageBox.Show(Resources.frmMemoOrder_FindJewelByJewelNo_Records_Not_found__);
                txtBarCode.Text = String.Empty;
                return;
            }

            int _newRowNumber = dgvJewel.RowCount;

            dgvJewel.Rows.Add(1);
            dgvJewel.Rows[_newRowNumber].Height = 50;

            dgvJewel.Rows[_newRowNumber].Cells[_columnjewelnumber.ToLowerCaseColumnName()].Value   = JewelData.JewelNumber;
            dgvJewel.Rows[_newRowNumber].Cells[_columndesigncode.ToLowerCaseColumnName()].Value    = JewelData.DesignCode;
            dgvJewel.Rows[_newRowNumber].Cells[_columntype.ToLowerCaseColumnName()].Value          = JewelData.JewelItemCategory;
            dgvJewel.Rows[_newRowNumber].Cells[_columngoldkt.ToLowerCaseColumnName()].Value        = JewelData.KT;
            dgvJewel.Rows[_newRowNumber].Cells[_columntotalwt.ToLowerCaseColumnName()].Value       = JewelData.TotalWeight;
            dgvJewel.Rows[_newRowNumber].Cells[_columnmetalweight.ToLowerCaseColumnName()].Value   = JewelData.MetalWeight;
            dgvJewel.Rows[_newRowNumber].Cells[_columndiamondweight.ToLowerCaseColumnName()].Value = JewelData.StoneWeight;
            dgvJewel.Rows[_newRowNumber].Cells[_columndiapcs.ToLowerCaseColumnName()].Value        = JewelData.StonePcs;
            dgvJewel.Rows[_newRowNumber].Cells[_columncolwt.ToLowerCaseColumnName()].Value         = JewelData.CStoneWeight;
            dgvJewel.Rows[_newRowNumber].Cells[_columncolpcs.ToLowerCaseColumnName()].Value        = JewelData.CStonePcs;

            dgvJewel[_columnimage.ToLowerCaseColumnName(), _newRowNumber].Value = ImageExtension.ResolveImage(JewelData.DesignCode);
            dgvJewel.Rows[_newRowNumber].Cells[_columndgRemoveItem.ToLowerCaseColumnName()].Value = "Remove";

            dgvJewel.FirstDisplayedScrollingRowIndex = dgvJewel.RowCount - 1;
            CalculateTotal();
        }
Ejemplo n.º 23
0
 private async Task RunPinkieScript(PinkieEvent script, Image pinkieImage)
 {
     foreach (PinkieLine?line in script)
     {
         if (line.ImagePath != null)
         {
             pinkieImage.Source = ImageExtension.GetPlatformIndependentPath(line.ImagePath);
         }
         _ = _mainPageReference.ShowFloatingText(line.Text, Color.HotPink);
         await Task.Delay(line.MillisecondsTime);
     }
 }
Ejemplo n.º 24
0
 public void BindForm(JewelStockLedger jewelStockLedger)
 {
     lblJewelNoValue.Text = jewelStockLedger.JewelNumber;
     lblStyleNoValue.Text = jewelStockLedger.DesignCode;
     //lblJewelDescValue.Text = jewelStockLedger.JewelDescription;
     //lblMetalColorValue.Text = Convert.ToString(jewelStockLedger.MetalColor);
     lblDiamondPcsValue.Text = Convert.ToString(jewelStockLedger.StonePcs);
     lblDiamondWtValue.Text  = Convert.ToString(jewelStockLedger.StoneWeight);
     lblGoldPcsValue.Text    = Convert.ToString(0.00);
     lblGoldWtValue.Text     = Convert.ToString(jewelStockLedger.StoneWeight);
     pictureBox.Image        = ImageExtension.ResolveImage(jewelStockLedger.DesignCode);
 }
Ejemplo n.º 25
0
        /*
         * Data estensione restituisce estensione in formato string
         */

        public static string GetImageExtensionString(this ImageExtension imageExtension)
        {
            switch (imageExtension)
            {
            case ImageExtension.WEBP:
                return(".webp");

            case ImageExtension.JPEG:
                return(".jpg");
            }
            return("error");
        }
Ejemplo n.º 26
0
        public bool RemoveImage(int id)
        {
            var picture = procuctDb.Pictures.Find(id);

            if (picture != null)
            {
                procuctDb.Pictures.Remove(picture);
                ImageExtension.DeleteImage(picture.PhotoUrl, hostEnvironment);
                procuctDb.SaveChanges();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 27
0
        public IResult Insert()
        {
            var result = new Result
            {
                Operation = Operation.Create,
                Status    = Status.Success
            };

            try
            {
                if (!ModelState.IsValid)
                {
                    result.Status     = Status.Fail;
                    result.StatusCode = HttpStatusCode.BadRequest;
                    return(result);
                }
                var       category = JsonConvert.DeserializeObject <Categories>(Request.Form["category"]);
                IFormFile img      = null;
                if (Request.Form.Files.Count != 0)
                {
                    var image = Request.Form.Files;
                    img = image[0];
                }
                var categoryCheck = _context.Categories.Where(c => c.CategoryName == category.CategoryName && c.CategoryId != category.CategoryId && c.IsDeleted != true).FirstOrDefault();
                if (categoryCheck != null)
                {
                    result.Message    = "Category of this name exists";
                    result.Status     = Status.Fail;
                    result.StatusCode = HttpStatusCode.BadRequest;
                    return(result);
                }
                category.CreatedDate = DateTime.Now;
                if (img != null)
                {
                    ImageExtension imageExtension = new ImageExtension();
                    category.CategoryImage = imageExtension.Image(img);
                }
                _context.Categories.Add(category);
                _context.SaveChanges();
                result.StatusCode = HttpStatusCode.OK;
                return(result);
            }
            catch (Exception e)
            {
                result.Message    = e.Message;
                result.Status     = Status.Error;
                result.StatusCode = HttpStatusCode.InternalServerError;
                return(result);
            }
        }
        //uploading image
        private Boolean UploadImage()
        {
            Boolean imageSaved = false;

            if (FileUploadImage.HasFile == true)
            {
                HttpPostedFile postedFile = FileUploadImage.PostedFile;
                ImageName      = Path.GetFileName(postedFile.FileName);
                ImageExtension = Path.GetExtension(ImageName);
                ImageSize      = postedFile.ContentLength;
                ImagePath      = "~/Uploaded/" + ImageName;

                if (ImageExtension.ToLower() == ".jpg" || ImageExtension.ToLower() == ".bmp" ||
                    ImageExtension.ToLower() == ".png" || ImageExtension.ToLower() == ".jpeg")
                {
                    if (ImageSize < 102400)
                    {
                        System.Drawing.Image image = System.Drawing.Image.FromStream(postedFile.InputStream);
                        int height = image.Height;
                        int width  = image.Width;

                        if (height <= 600 && width <= 600)
                        {
                            FileUploadImage.SaveAs(Server.MapPath("~/Uploaded/") + ImageName + ".jpg");
                            ImageRegistration.ImageUrl = "~/Uploaded/" + ImageName + ".jpg";
                            //string ImageData = "Uploaded/" + ImageName + ".jpg";
                            imageSaved = true;
                        }
                        else
                        {
                            ImageMsgID.Text = "Kindly Upload Image in Proper Dimensions 200 x 200";
                        }
                    }
                    else
                    {
                        ImageMsgID.Text = "File Size exceeds 100 KB - Please Upload File Size Maximum 100 KB";
                    }
                }
                else
                {
                    ImageMsgID.Text = "Only JPEG/JPG/PNG/BMP Image File Acceptable - Please Upload Image File Again";
                }
            }
            else
            {
                ImageMsgID.Text = "You have not selected any file - Browse and Select File First";
            }

            return(imageSaved);
        }
Ejemplo n.º 29
0
        private void Initialize()
        {
            for (int i = 0; i < textBoxes.Count(); ++i)
            {
                textBoxes[i].Text = card.Properties[properties[i]].Value;
            }

            if (!textBoxBackground.Text.Equals(""))
            {
                pictureImage.Image = Image.FromFile(
                    ImageExtension.GetPathWithoutExtension(Utils.RESOURCES_PATH + card.Properties["Background"].Value)
                    );
            }
        }
Ejemplo n.º 30
0
        /*
         * Invio file al server in base ad algoritmo scelto
         */

        private void SendFileToServer(CompressionAlgorithmSelected compressionAlgorithmSelected)
        {
            ImageExtension imageExtension = ImageExtensionMethods.GetImageExtension(compressionAlgorithmSelected);

            try
            {
                CreateJSONFiles();
                Send(imageExtension);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }