Mike Askew 131 Veteran Poster Featured Poster

Use .ShowDialog() instead of .Show(). This will make the form behave similar to a messagebox in terms of nothing else apart from the form can be clicked until the form is closed.

.ShowDialog() also allows you to assign dialog responses to buttons on your form and then do logic based off your form response (used when making custom message boxes etc).

To reload the XML data you will need to rerun the entire of the method that loads the XML I think unless you literally just want to reload the XML file into memory. Which would be for example:

private void label5_Click(object sender, EventArgs e)
        {
            About LF = new About();
            LF.ShowDialog();

            //Written in the browser it may be slightly off
            if (LD.DialogResult == DialogResult.OK)
            {
                smtpDetails = new XmlDocument();
                smtpDetails.Load(PATH);
            }
        }

When running modal forms however you will need to assign the button return for the dialog, this is done using the property DialogResult of the button. The example code is based off of the confirmation button being set to a result of "Ok".

Mike Askew 131 Veteran Poster Featured Poster

Ok.

Firstly, your admin form does not run modally (ie. the main form is still accessible while the admin form is open), is this the intention? Obviously not sure how the form works/is used for.

Secondly, irritatingly running the form non-modally means my idea for refreshing the XML wont work due to the continued execution of the thread, which is paused with a modal form.

Mike Askew 131 Veteran Poster Featured Poster

Wheres the code block on the main form calling the admin one? (assuming there is one)

Mike Askew 131 Veteran Poster Featured Poster

Form1.Refresh() Just redraws the form and its associated objects on screen.

You will need to rerun smtpDetails.Load(PATH); to reload the XML document.

This will be done in the code block that makes the admin form (dont have that in my inbox either so cant comment on the exact layout, it would go after the .Show() call or .ShowDialog()

Mike Askew 131 Veteran Poster Featured Poster

sorry for the delayed reply.

So from my understanding you need to refresh the main form on the close of the admin one?

Mike Askew 131 Veteran Poster Featured Poster
  public void AddContact()
  { 
    Console.WriteLine("Enter contact name");
    Name = Console.ReadLine();
    Console.WriteLine("Enter contact Address");
    Address = Console.ReadLine();
    Console.WriteLine("Enter contact Email");
    Email = Console.ReadLine();
    Console.WriteLine("Enter contact PhoneNo");
    PhoneNo = Console.ReadLine();

    StreamWriter sw = new StreamWriter("FilePathHere");
    sw.WriteLine(string.Format("{0},{1},{2},{3},"), Name, Address, Email, PhoneNo);
    sw.Close();
  }

Would create a CSV style storage of the details.

Mike Askew 131 Veteran Poster Featured Poster
Mike Askew 131 Veteran Poster Featured Poster

Again my console line version:

            string XMLFilePath = @"C:\Users\maskew\Documents\DaniWeb\TestXML.xml";

            XmlDocument XmlFile = new XmlDocument();
            XmlFile.Load(XMLFilePath);

            XmlNodeList Results = XmlFile.GetElementsByTagName("SMTP_Server");
            Console.WriteLine(Results[0].InnerText);

            if (Results[0].InnerText == string.Empty)
            {
                Console.WriteLine("Please Fill in SMTP Details");
            }

            SmtpClient client = new SmtpClient(Results[0].InnerText);
            Console.ReadLine();

My If statement triggers the writeline using your provided blank XML document.

Hmm I believe I have your XML generation code in my inbox? I will have a look at it when I get a minute.

Mike Askew 131 Veteran Poster Featured Poster

Change your if statement to check for string.Empty instead of null :) Should solve the issue as it currently reads the .InnerText as "" which is the equiv of string.Empty.

Changes to your XML to make it generate valid files:
- Get rid of the rogue -
- Change standalone="true"?> to standalone="yes"?> as it only accepts a yes/no response.

Mike Askew 131 Veteran Poster Featured Poster

Unrelated to the current question, why do your auto generated XML files always have a - before <table>? It technically invalidates the XML file structure :) will probably a rogue - in your XML construction code

Mike Askew 131 Veteran Poster Featured Poster

After starting a wonderful debate on StackOverflow I have picked on my implementation of IEnumerable and will bend that as polymorphism.

Mike Askew 131 Veteran Poster Featured Poster

Lol indeed, or just lose the contents of your stomach. That is the more likely outcome of one of those sessions :p

Mike Askew 131 Veteran Poster Featured Poster

I shall do, my David Lloyd gym I go to has just started doing them so I shall debate if I wish to die a horrible death or not and maybe go to one!

Mike Askew 131 Veteran Poster Featured Poster

I've heard cross-fit is an absolute killer indeed.

Mike Askew 131 Veteran Poster Featured Poster

You could use a background worker thread to send the email. This would leave the main form functional.

MSDN Link

Mike Askew 131 Veteran Poster Featured Poster

My company uses TFS or ClearCase when doing development. Personally I like TFS as it integrates wonderfully with VS2010 however I've never used clearcase so cant talk about that.

Mike Askew 131 Veteran Poster Featured Poster

Hmm you could probably get some sort of acne face wash etc or the doctor can point you the right direction.

An alternative is to jump rope. You can actually do much more cardio whilst jumping rope than running. (well in the same time)

Sometimes do a bit of jump rope while waiting for my training partner to finish sets while doing arms DTP training. Just for fun though, never thought about it from a serious cardio perspective.

Mike Askew 131 Veteran Poster Featured Poster

Sure,

Might be worth commenting out the try briefly and running to check it is that line that it is failing on.

Mike Askew 131 Veteran Poster Featured Poster

This will sound like a homework assignment, it sort of is, but isn't. Anyway!

I have created a simple address book application with a CSV backend.

This utilises a Person class to store the contacts details and an AddressBook class storing the list of Person.

Within the code we have to demonstrate:
- Polymorphism
- Inheritance
- Encapsulation

I have covered inheritance through the implementation of IEnumerable to allow for-each'ing through a list of People. Encapsulation is covered by using properties to allow access to private fields.

However I somewhere need to fit in an example use of Polymorphism which I'm failing to see how I can do with the current setup, and was looking for opinions as to where I could probably use it.

Mike Askew 131 Veteran Poster Featured Poster

Again using console application, I fail to recreate the error your seeing :/

            string XMLFilePath = @"C:\Users\maskew\Documents\DaniWeb\TestXML.xml";

            XmlDocument XmlFile = new XmlDocument();
            XmlFile.Load(XMLFilePath);

            XmlNodeList Results = XmlFile.GetElementsByTagName("SMTP_Server");
            Console.WriteLine(Results[0].InnerText);

            SmtpClient client = new SmtpClient(Results[0].InnerText);
            Console.ReadLine();

The following code runs cleanly to the end, I would expect it to throw the same exception as you if that line was the cause.

I was using the following XML file when testing this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Table>
  -<SMTP_details>
    <SMTP_Server>smtp.********.com</SMTP_Server>
    <SMTP_Port>25</SMTP_Port>
    <SMTP_Username>******.****@******.com</SMTP_Username>
    <SMTP_Password>**********</SMTP_Password>
    <Company_Name>TEST COMPANY</Company_Name>
    <Company_Tel>000000000000</Company_Tel>
  </SMTP_details>
</Table>
Mike Askew 131 Veteran Poster Featured Poster

I do have to question however, as I'm playing around with code. What determines the next picture box.

In my example I have 8 picture boxes in the layout:
[ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ]

So say I click the image in:
[ ] [ ] [x] [ ]
[ ] [ ] [ ] [ ]

Which of the picture boxes would be the next one (assuming all are empty except [x])?
[a] [b] [x] [c]
[ ] [ ] [ ] [ ]

A, B or C?

Mike Askew 131 Veteran Poster Featured Poster

Change the code to select the element to the same as how I selected the Company_Name and see if the error still occurs.

Mike Askew 131 Veteran Poster Featured Poster

@AD, Just tried it on my IE8, the escape doesnt work while the code box has focus, however if you click in the grayed out area around it and then press escape it closes for me.

I do have to agree though a little [x] to close it would be much more obvious to those who haven't been told how to shut it.

Mike Askew 131 Veteran Poster Featured Poster

Put it in a new thread with all the information we'd normally need and maybe that issue can be solved :)

Mike Askew 131 Veteran Poster Featured Poster

You will probably want to make use of the tag property to allow you to order the pictures boxes in some way. Then you need a search algorithm to find which is the nearest tag number to the selected one thats empty.

Mike Askew 131 Veteran Poster Featured Poster

You use the IP address of the server in the data source of the connection string.

See:
- http://msdn.microsoft.com/en-us/library/ms175483(v=sql.105).aspx
- http://stackoverflow.com/questions/4743799/connect-sql-deployed-database-over-the-internet

Next time please google your question first, I hate just reciting two links within the top four entries on a google search.

Mike Askew 131 Veteran Poster Featured Poster

For clarification...

You have say 5 picture boxes

[] [] [] [] []

You load an image into one

[x] [] [] [] []

and so you want the code to then automatically put the image into the next empty one?

[x] [x] [] [] []?

Mike Askew 131 Veteran Poster Featured Poster

Good to hear, sorry left the office as you sent the code.

I know that feeling oh too well though!

Mike Askew 131 Veteran Poster Featured Poster

Thanks :)

Mike Askew 131 Veteran Poster Featured Poster

Hahah, Sorry Mikey/Dave/Fred.. :)

xD

Mike Askew 131 Veteran Poster Featured Poster

Hi Dave,

Im now multiple people muahahaha!

Hmm thats an odd issue. Especially when its working for me.

Might be worth debugging the method and seeing what the XmlNodeList contains at execution time. Should say count = 1 as one of its properties as it does when I run the program.

Mike Askew 131 Veteran Poster Featured Poster

Just wondering as I've been caught by it twice now.

It is intentional that after pressing the code button you can't close the code entry window without first entering some text? So if you accidently press it, it forces me to put a random one letter code block to then be removed in order for me to continue posting.

Just a small annoyance when I manage to do it :)

Mike Askew 131 Veteran Poster Featured Poster

I worry that people will never understand why it's important for things to be symmetrical. Three items on a shelf need to be arranged so that they are equal distances from the edges, and each other, or bad things will surely happen. The trouble is, when you try and share this information you get treated like you are a loon rather than heroically attempting to save the world from disaster.

I know that worry!

Or when the pens of the desk are wonky and they must line up else it just looks awful.

One day the world will end due to those wonky pens...

Mike Askew 131 Veteran Poster Featured Poster

Umm I don't see why it wouldnt work :/

What does the variable PATH contain i.e. the actual value? As that could be the only reason it isnt working.

Mike Askew 131 Veteran Poster Featured Poster

Sorry for the hi-jack, seems related, I decided to un-disable adverts earlier as felt bad for reducing advertising revenue.

However I've since had my firefox crash 4 times on loading pages, the page loads visually and then I lose complete responsiveness of the tab, and so I've been forced to redisable them :(

Mike Askew 131 Veteran Poster Featured Poster

In that case you should be able to adapt the above code I gave into your program.

Try:

private void Send_Click(object sender, EventArgs e)
        {
            if (File.Exists(@"C:\Timewade\Quickticket\Person.xml"))
            {
                smtpDetails = new XmlDocument();
                smtpDetails.Load(PATH);

                XmlNodeList results = smtpDetails.GetElementsByTagName("Company_Name");
                compName.Text = results[0].InnerText;

Explanation:

The XmlNodeList will contain all nodes returned from the .GetElementsByTagName() call and from there, as we know there is only one element, we can reference the position 0 in the XmlNodeList and then find its .InnerText which contains what is inside the element in the XML.

Mike Askew 131 Veteran Poster Featured Poster
        static void Main(string[] args)
        {
            string XMLFilePath = @"C:\Users\maskew\Documents\DaniWeb\TestXML.xml";

            XmlDocument XmlFile = new XmlDocument();
            XmlFile.Load(XMLFilePath);

            XmlNodeList Results = XmlFile.GetElementsByTagName("Company_Name");
            Console.WriteLine(Results[0].InnerText);
            Console.ReadLine();
        }

Little console app I ran and retrieved the value, console displayed: "TEST COMPANY". This method assumes that there is only one entry of the <Company_Name></Company_Name> per XML file.

Is that the case?

Mike Askew 131 Veteran Poster Featured Poster

Cheers, its worth noting standalone="" expects a yes or no as its value.

Can you also disclose the variable type of root as it cannot be determined from code.

Mike Askew 131 Veteran Poster Featured Poster

Hi Mark,

Any chance of getting this XML sheet? Or a stripped down version of it showing the part causing the issue?

Edit: could you also disclose the variable type of root as it cannot be determined from code.

Mike Askew 131 Veteran Poster Featured Poster

You have two syntax errors.

----------------------
Change

<VALUE><xsl:value-of select="$RecordName" /><xsl:text>.</xsl:text><xsl:value-of select="$currentID" />

to:

<VALUE><xsl:value-of select="result:num2dot($currentID)" /></VALUE>

This is because we do not need the <xsl:value-of() /> to retrieve the variable value, simply referencing it is enough.

----------------------

Change

<xsl:if test="$currentID <= $endID">

to:

<xsl:if test="$currentID &lt;= $endID">

This is because < is a reserved character in XSLT.

----------------------

I couldn't fully test it running due to namespace errors on the line xmlns:result="http://www.example.com/results" extension-element-prefixes="result"> however I presume this is a replacement to a real namespace.

Mike Askew 131 Veteran Poster Featured Poster

Use the StreamWriter class.

using System.IO;

StreamWriter sw = new StreamWriter(FullFilePathHere);
sw.WriteLine("I have written a line to the above specified file.");
sw.Close();
Mike Askew 131 Veteran Poster Featured Poster

Whats the problem with this?

Mike Askew 131 Veteran Poster Featured Poster

Great minds think alike, so they say @nmaillet

nmaillet commented: Sure do. +5
Mike Askew 131 Veteran Poster Featured Poster

Here you go

The above magical link will take you to a long list of pages. Through which you can look for examples of open source BMP software.

Mike Askew 131 Veteran Poster Featured Poster
public class Profile
    {
        public Profile()
        {
        }
        // method
        public string getMSG()
        {
            return "What do you look like";
        }

        private string _eyecolor;
        public string eyeColor
        { // Missing this opening bracket for a property
            get { return _eyecolor; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                {
                    _eyecolor = value.Substring(0, 1).ToUpper() + value.Substring(1); // Substring had a small s not S
                }
                else
                {
                    _eyecolor = value; // Typo, _eycolor not _eyecolor
                }
            }
        }

        public string getEyeColor()
        {
            return "Eye color: " + _eyecolor + "Complexion color:"; // Typo, _eycolor not _eyecolor
        }

        public string _ccomplexion;
        public string cComplexion // Again property not setup correctly
        {
            get { return _ccomplexion; } // Added get { }
        }

        private string _haircolor; // Missing semi colon
        public string hairColor
        {
            get
            {
                return "Hair Color: " + _haircolor + "Age: ";
            }
            set { _haircolor = value; }
        }

        private int _age;
        public int age
        {
            get { return _age; }
            set { _age = value; }
        }

        public string getFullProfile()
        {
        return "For a " + _eyecolor + " , "+ _ccomplexion+" and "+ _haircolor+"We suggest the following outfit"+"<br /><br /> " + "click Here"; // Missing " marks and +
        }
    }

All the errors we're completely careless ones that you could of fixed yourself. Most of them were property construction (which you managed to do perfectly once so god knows why the others were wrong) and typos.

Didn't need me to go through that and correct them all..

Mike Askew 131 Veteran Poster Featured Poster

Might have to try that actually and see!

Mike Askew 131 Veteran Poster Featured Poster

I usually do 8 miles on treadmill 4 times a week at home, when I have enough time I do cross-country on a 12-14 miles distance. Run Forrest, run!

Wish I had the cardio fitness to be able to do that :p

Mike Askew 131 Veteran Poster Featured Poster

Once you select an attachment there is a background process as the document uploads to the server to be checked. You may notice an uploading message in your browser status bar.

As that is what I get, once the document is uploaded options appear to place the document within the post.

Mike Askew 131 Veteran Poster Featured Poster

Keyboard commandos will see it more often. ;)

Hmmm nah, more along the lines of look at my avatar and apply as required :D

Mike Askew 131 Veteran Poster Featured Poster