Windows Develop Bookmark and Share   
 index > Windows Forms General > Help Needed
 

Help Needed

Hi,

I am new to .net and i m just trying to learn it.meanwhile i got a job and they gave me an application to work on.

The developed architecture is very complex and i m finding it diff. to understand the process.Any sugestions here.

Its a window appllication with c# code behind.I m suppose to work on a save button for a form.So when all the text box

fields are entered the data of the text box should be sent to the database through a stored procedure.But the code already

built is not straight forward, they are a no. of in built functionalities and properties.It references a business entity and business

service........anybody there who can help me.Plz reply .

Thank you,

kori,

mannsko  Sunday, April 06, 2008 2:08 AM
mannsko wrote:

code for :when save button is clicked all the text box fields are entered the data of the text box should be sent to the database through a stored procedure

OK, open up the project in VS2008, highlight your textBox, find Properties on the right, On the top of that long box there is a button with a striking lightning. Click it. You will see events for the textBox. Find the event TextChanged. Name it in the textBox in the event dialog box. It could be tetxBox1_TextChanged. Close the event dialog box.

VS2008 will generate for you an event delegate textBox1_TextChanged in the code.

In that method you will have to detect the fact that the user entered the carriage return. You do the fllowing:

private void textbox1_TextChanged ( object sender, EventArgs ee)

{

string text = this.textBox1.Text;

if ( text.IndexOf (Environment.NewLine) != -1 )

{

// at this point your text is ready to be send down the pipe to Sql Server.

// the reason for this if statement is that the event will fire every time a letter was

// added or even removed. However when user hits CR, that's it.

// At this point you will also clear the textbox (after the text was send to Sql Server):

this.textBox1.Text = String.Empty;

}

{

AlexBB - Vista Ult64 SqlSer64 WinSer64  Sunday, April 06, 2008 2:49 AM
mannsko wrote:

Hi,

service........anybody there who can help me.Plz reply .

Thank you,

kori,

But what do you want?

AlexBB - Vista Ult64 SqlSer64 WinSer64  Sunday, April 06, 2008 2:11 AM

code for :when save button is clicked all the text box fields are entered the data of the text box should be sent to the database through a stored procedure

mannsko  Sunday, April 06, 2008 2:16 AM

try this

string SQLCommand = "select getdate()";

private SqlConnection Conn = new SqlConnection();

Conn.ConnectionString = "Data Source=" + this.TxtServerName.Text + ";UID=" + this.TxtUserName.Text + ";PWD=" + this.TxtPassword.Text;

Conn.ConnectionString += ";Initial Catalog=" + DDListDatabase.SelectedItem;

SqlCommand TestCon = new SqlCommand(SQLCommand, Conn);

try

{

Conn.Open();

SqlDataReader SqlReader = TestCon.ExecuteReader();

try

{

Reader.Close();

Reader.Dispose();

}

catch { }

}

catch

{

return (false);

}

try

{

Conn.Close();

Conn.Dispose();

}

catch { }

return (true);

}

Romeomussluv  Sunday, April 06, 2008 2:34 AM
mannsko wrote:

code for :when save button is clicked all the text box fields are entered the data of the text box should be sent to the database through a stored procedure

We can only help you on high level information until you post here the methods that transact to your database when the button is clicked. I believe that the application is written in different layer as what you mentioned.

But anyway, if you'll be able to look at the method that tries to transact to the database then you can call that when the click event of the button is invoked. That is the only piece I can share as of the moment.

Bermil M. Espina  Sunday, April 06, 2008 2:37 AM
mannsko wrote:

code for :when save button is clicked all the text box fields are entered the data of the text box should be sent to the database through a stored procedure

OK, open up the project in VS2008, highlight your textBox, find Properties on the right, On the top of that long box there is a button with a striking lightning. Click it. You will see events for the textBox. Find the event TextChanged. Name it in the textBox in the event dialog box. It could be tetxBox1_TextChanged. Close the event dialog box.

VS2008 will generate for you an event delegate textBox1_TextChanged in the code.

In that method you will have to detect the fact that the user entered the carriage return. You do the fllowing:

private void textbox1_TextChanged ( object sender, EventArgs ee)

{

string text = this.textBox1.Text;

if ( text.IndexOf (Environment.NewLine) != -1 )

{

// at this point your text is ready to be send down the pipe to Sql Server.

// the reason for this if statement is that the event will fire every time a letter was

// added or even removed. However when user hits CR, that's it.

// At this point you will also clear the textbox (after the text was send to Sql Server):

this.textBox1.Text = String.Empty;

}

{

AlexBB - Vista Ult64 SqlSer64 WinSer64  Sunday, April 06, 2008 2:49 AM

You can use google to search for other answers

Custom Search

More Threads

• Adding Find to a program
• How to prevent Combo Box automatic selection of text?
• How Do You Search the Text Of Another Window?
• Visual C# 2005 Express TextBox ApplicationSettings PropertyBinding changes not saved to *.config file
• Removing node from Tree using ContextMenuStrip
• Introduce delay between controls display : textbox and the group radiobutton for the playsound.
• Printing - Using printDocument
• Treeview nodes Compare
• How to read text from image
• searching an oledb...