Adding an image Viewer to Job Tracker

Yesterday, I ahd a kind perosn give me his code that he uses to add an image to the part. I however, want it in Job tracker for the resource. Here’s a pic.

Here’s the code given.

private void SetPictureBox()
{
bool imageFound = false;
//Get reference to part image
if (((Part_DataView !=null) && (Part_DataView.Count > 0)))
{
//string fileName=@"\pathtoimagesfolder" + edvOrderDtl.dataView[edvOrderDtl.Row][“PartNum”].ToString() + “.jpg”;
string[] subFolders = new string[] {xxxx};//we use this loop through subfolders until it finds a hit.
foreach (string subFolder in subFolders)
{
string fileName=@“Your File Pathway” + subFolder + “\” + Part_DataView[0][“PartNum”].ToString() + “.jpg”;
//MessageBox.Show(fileName);
if (File.Exists(fileName))
{
thePartPicture.Image = System.Drawing.Image.FromFile(fileName);//binds the control for the current part to the picture path enumerated from the search above
imageFound = true;
break;
}
else
{
thePartPicture.Image=null;
}
}

                            }
                            //imageAvailable.Enabled=imageFound;

First, I am in Test and not Live. My coding skills are very limited. So, forgive me for what may be a simple question, but how do I change the DataView to the right view for me? Obviously the part_DataView is not right for me. I have it set up where the jpg are labeled to be identical to the resource ID.

1 Like

Well, I figured a lot of this out, I think. Here’s what I came up with. Am I missing anything?

private void SetPictureBox()
{
bool imageFound = false;
//Get reference to part image
if (((Resource_DataView !=null) && (Resource_DataView.Count > 0)))
{
//string fileName="\pathtoimagesfolder" + Resource_DataView[0][“ResourceID”].ToString() + “.pdf”;

                                                            {
                                                               string fileName=\\pathtoimagesfolder\" + Resource_DataView[0]["ResourceID"].ToString() + ".pdf";
                                                                            //MessageBox.Show(fileName);
                                                                            if (File.Exists(fileName))
                                                                            {
                                                                                            thePartPicture.Image = System.Drawing.Image.FromFile(fileName);
                                                                                            imageFound = true;
                                                                                            break;
                                                                            }
                                                            else
                                                            {
                                                                            thePartPicture.Image=null;
                                                            }
                                            }

                            }
                            //imageAvailable.Enabled=imageFound;

            }

We do something like this, however, you just want to use windows forms and use a picture box. That is a pretty simple process:

It looks like this:

using System.Windows.Forms;

System.Windows.Forms.PictureBox pleaseWait = new System.Windows.Forms.PictureBox();
//You can do this on load if you want
pleaseWait = new System.Windows.Forms.PictureBox();

pleaseWait.Image = System.Drawing.Image.FromFile(@"\LocationOfImage\pw.gif");
pleaseWait.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
pleaseWait.Anchor = System.Windows.Forms.AnchorStyles.None;
pleaseWait.Location = new System.Drawing.Point(250,178);
ARInvForm.Controls.Add(pleaseWait);

This will let you create a box based on image size and allow you to place it wherever you want. You can go into Customization and use the grid there to find your drawing points. Works for us pretty well and when done just you .Dipose to get rid of it.

2 Likes

Will:
Good afternoon - I hope all is well.

Did you manage to get this working - we are looking to do something similar to assist us in JobEntry.

Roberto.

No, I finally just created another tab and put it in there. It works but not what I was originally wanting.

Will:

Did you perform this through a bpm and if so would you be happy to share with me your solution? - I can perhaps use this as a steer for my development.

Roberto.

Roberto:

No, I opened tracker up in Developer mode, customized the screen with adding another tab and the pic came from a dashboard i created that was linking to the part number. So whatever part number it was, it would show the corresponding pic. In the end, it worked very slow and no one really uses it today. And I never got back to perfecting it. But that is basically all I did. Nothing fancy.

Aaron:
Good afternoon - I hope all is well.
Where in Epicor do you use this code?
I would like to use this in JobEntry / JobTracker.
Would I just add this to the Load event?
Roberto

	private static void LoadPartImage(){
		var file = @"\\your_image_path\image.jpg";
		if (System.IO.File.Exists(file)) {
			epiPictureBoxPartImage.Image = System.Drawing.Image.FromFile(file); 
		}
	}	

Mathis - this worked perfectly, it literally took me 2 minutes to inject inline with what I was doing. I’m a total Epicor noob but since this is referencing a file on the file system, would I need to include the referenced file in a client deployment or something? I know this is old, I don’t expect a response but if anyone else knows, I would welcome the guidance :smiley: