Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Box 1

Status
Not open for further replies.

postmanplod

Programmer
Aug 18, 2008
47
GB
I'm a total newby to C # and am trying to customise our ERP system (Epicor Vantage). I want to add a message box that will prompt the user, using the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Diagnostics;
using Bpm.Action;



namespace Bpm.Custom
{



public class Part
{

public virtual void OnBeforeCheckAltMethodForDelete(ref string ipPartNum, ref string ipRevisionNum, ref string ipAltMethod, ref string opMessage)
{
//
// TODO: Replace the throw statement with any code for an action before Part.CheckAltMethodForDelete() method invocation
//
//throw new System.NotImplementedException(CallContext.CurrentContext.ToString());

private void button1_Click(object sender, EventArgs e)
{
DialogResult result;
result = MessageBox.Show("Are you sure you want to delete this rev?", "Application 1", MessageBoxButtons.YesNo);

if (result == DialogResult.No) {
MessageBox.Show("App won´t close");
}

if (result == DialogResult.Yes) {
this.Dispose();
}
}
}
}
}

However, I keep receiving errors when trying to debug saying a } is expected on line 20 and and end of file is expeced on 41. What am I doing wrong?

Thanks for any help

Michael
 
You have a button click event within another event. This is not valid.
 
I replaced it with:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Diagnostics;
using Bpm.Action;



namespace Bpm.Custom
{



public class Part
{

public virtual void OnBeforeCheckAltMethodForDelete(ref string ipPartNum, ref string ipRevisionNum, ref string ipAltMethod, ref string opMessage)
{
//
// TODO: Replace the throw statement with any code for an action before Part.CheckAltMethodForDelete() method invocation
//
//throw new System.NotImplementedException(CallContext.CurrentContext.ToString());


DialogResult result;
result = MessageBox.Show("Are you sure you want to delete this rev?", "Application 1", MessageBoxButtons.YesNo);

if (result == DialogResult.No) {
MessageBox.Show("App won´t close");
}

if (result == DialogResult.Yes) {
this.Dispose();
}
}
}
}
}

But continue to receive the message: Error 1 Type or namespace definition, or end-of-file expected C:\Documents and Settings\Hutcheson\Desktop\C# Stuff\ClassLibrary1\ClassLibrary1\Class1.cs 40 1 ClassLibrary1

Deleting the } on the last line doesn't help. This is becoming a pain.
 
Hi,

You have one extra closed bracket. I suggest your code be something like...

Code:
public virtual void OnBeforeCheckAltMethodForDelete...
{
   if (MessageBox.Show("Are you sure you want to delete this rev?", "Application 1", MessageBoxButtons.YesNo) == DialogResult.No)
   {
      MessageBox.Show("App won´t close");
   }
   else
   {
      this.Dispose();
   }               
}

Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top