Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
Questionabout outerxml Pin
Hamsika rani6-May-07 6:51
Hamsika rani6-May-07 6:51 
AnswerRe: about outerxml Pin
Guffa6-May-07 8:03
Guffa6-May-07 8:03 
GeneralRe: about outerxml Pin
Hamsika rani6-May-07 13:32
Hamsika rani6-May-07 13:32 
QuestionDeployment concerns on c# 3.0 Pin
erdsah886-May-07 6:37
erdsah886-May-07 6:37 
QuestionVideo to Database ??? Pin
Aldorado6-May-07 6:18
Aldorado6-May-07 6:18 
AnswerRe: Video to Database ??? Pin
Rick van Woudenberg6-May-07 9:49
Rick van Woudenberg6-May-07 9:49 
GeneralRe: Video to Database ??? Pin
Aldorado7-May-07 2:04
Aldorado7-May-07 2:04 
QuestionTextfield doesn't get focused. HELP! Pin
Farica6-May-07 4:20
Farica6-May-07 4:20 
Hi I'm 'trying to get a textfield focused after a message has been given to the user.
This was pretty easy to do in other forms, but in this specific it doensn't focus. After the system has finished validating it should save the entered data to a database and clear the textfields for new entry ( which it does). But when validating it gets an exception, after clicking on ok in the messagebox it doesn't focus, but it clear all the textboxes. And thus, it's skipping to the clearing code.
Hereby I send my code so you guys could take a look. Please HELP!!!

By the way, the reason why I chose to use separate if statements for each "row of fields" is because the user is not obligated to fill in ALL row of fields. It may occur that he enters only row 1, 2 and 3. HEELLLLPPPP!!!

if (txtBrnchNr_1.Text.Trim().Length > 0 && txtBrnchDescr_1.Text.Trim().Length > 0 && txtBkBrnch_1.Text.Trim().Length > 0)
{
if (rdbBckOff_1.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}
if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_1.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_1.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_1.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_1.Text.Trim(), txtBrnchDescr_1.Text.Trim(), bckOff, txtBkBrnch_1.Text.Trim()));
this.isOkToSave = true;
}
}

//Same procedure for 2nd row of fields
if (txtBrnchNr_2.Text.Trim().Length > 0 && txtBrnchDescr_2.Text.Trim().Length > 0 && txtBkBrnch_2.Text.Trim().Length > 0)
{
if (rdbBckOff_2.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}

if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_2.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_2.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_2.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_2.Text.Trim(), txtBrnchDescr_2.Text.Trim(), bckOff, txtBkBrnch_2.Text.Trim()));
this.isOkToSave = true;
}

}
//Same procedure for 3rd row of fields
if (txtBrnchNr_3.Text.Trim().Length > 0 && txtBrnchDescr_3.Text.Trim().Length > 0 && txtBkBrnch_3.Text.Trim().Length > 0)
{
if (rdbBckOff_3.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}

if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_3.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_3.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_3.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_3.Text.Trim(), txtBrnchDescr_3.Text.Trim(), bckOff, txtBkBrnch_3.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 4th row of fields
if (txtBrnchNr_4.Text.Trim().Length > 0 && txtBrnchDescr_4.Text.Trim().Length > 0 && txtBkBrnch_4.Text.Trim().Length > 0)
{
if (rdbBckOff_4.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}

if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_4.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_4.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_4.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_4.Text.Trim(), txtBrnchDescr_4.Text.Trim(), bckOff, txtBkBrnch_4.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 5th row of fields
if (txtBrnchNr_5.Text.Trim().Length > 0 && txtBrnchDescr_5.Text.Trim().Length > 0 && txtBkBrnch_5.Text.Trim().Length > 0)
{
if (rdbBckOff_5.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}

if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_5.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_5.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_5.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_5.Text.Trim(), txtBrnchDescr_5.Text.Trim(), bckOff, txtBkBrnch_5.Text.Trim()));
this.isOkToSave = true;
}
}
//Same procedure for 6th row of fields
if (txtBrnchNr_6.Text.Trim().Length > 0 && txtBrnchDescr_6.Text.Trim().Length > 0 && txtBkBrnch_6.Text.Trim().Length > 0)
{
if (rdbBckOff_6.Checked == true)
{
bckOff = "Y";
}
else
{
bckOff = "N";
}

if (clsAlchCustomMeth.QueryData("SELECT * FROM SPRBRH00P WHERE BRHBRANCH = '" + txtBrnchNr_6.Text.Trim() + "';") == true)
{
MessageBox.Show("Branch " + txtBrnchNr_6.Text.Trim() + " could not be saved. Branch already exists.\nPlease remove from list.", "Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtBrnchNr_6.Focus();
}
else
{
myBranches.Add(new clsBranchGeneric(txtBrnchNr_6.Text.Trim(), txtBrnchDescr_6.Text.Trim(), bckOff, txtBkBrnch_6.Text.Trim()));
this.isOkToSave = true;
}
}
// Everything OK to save to database
}

DataSet dsBranch = new DataSet();
clsAlchCustomMeth.CreateSelCmd("SELECT * FROM SPRBRH00P;");
clsAlchCustomMeth.myAdapter.Fill(dsBranch, "Branches");

foreach (clsBranchGeneric b in myBranches)
{
DataRow newRow = dsBranch.Tables["Branches"].NewRow();
newRow["BRHBRANCH"] = b.BranchNr;
newRow["BRHBRHDES"] = b.Description;
newRow["BRHBCKOFF"] = b.BackOffice;
newRow["BRHBRHBOK"] = b.BookBranch;

dsBranch.Tables["Branches"].Rows.Add(newRow);

clsAlchCustomMeth.CreateInsCmd("INSERT INTO SPRBRH00P (BRHBRANCH, BRHBRHDES, BRHBCKOFF," +
" BRHBRHBOK) VALUES (@Brh, @BrhDes, @BckOff, @BrhBok);");

clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@Brh", OleDbType.VarChar, 3, "BRHBRANCH");
clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@BrhDes", OleDbType.VarChar, 35, "BRHBRHDES");
clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@BckOff", OleDbType.VarChar, 1, "BRHBCKOFF");
clsAlchCustomMeth.myAdapter.InsertCommand.Parameters.Add("@BrhBok", OleDbType.VarChar, 3, "BRHBRHBOK");

try
{
clsAlchCustomMeth.myAdapter.Update(dsBranch, "Branches");
dsBranch.AcceptChanges();
changesOK = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
if (changesOK == true)
{
changesOK = false;
this.ClearForSaveAndNew();
}
}

Poppsie
AnswerRe: Textfield doesn't get focused. HELP! Pin
Rob Graham6-May-07 4:45
Rob Graham6-May-07 4:45 
AnswerRe: Textfield doesn't get focused. HELP! Pin
Muammar©6-May-07 19:53
Muammar©6-May-07 19:53 
AnswerRe: Textfield doesn't get focused. HELP! Pin
AFSEKI7-May-07 1:55
AFSEKI7-May-07 1:55 
QuestionHow to insert multiple values in string efficiently? Pin
Adeel Chaudhry6-May-07 3:33
Adeel Chaudhry6-May-07 3:33 
AnswerRe: How to insert multiple values in string efficiently? Pin
Rob Graham6-May-07 3:51
Rob Graham6-May-07 3:51 
GeneralRe: How to insert multiple values in string efficiently? Pin
Adeel Chaudhry6-May-07 4:08
Adeel Chaudhry6-May-07 4:08 
AnswerRe: How to insert multiple values in string efficiently? Pin
Luc Pattyn6-May-07 4:07
sitebuilderLuc Pattyn6-May-07 4:07 
AnswerRe: How to insert multiple values in string efficiently? Pin
AFSEKI7-May-07 2:02
AFSEKI7-May-07 2:02 
AnswerRe: How to insert multiple values in string efficiently? Pin
gumi_r@msn.com7-May-07 5:26
gumi_r@msn.com7-May-07 5:26 
QuestionStuck with Network Pin
ThanhND3076-May-07 3:23
ThanhND3076-May-07 3:23 
QuestionReduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 3:18
Adeel Chaudhry6-May-07 3:18 
AnswerRe: Reduce multiple characters to one, in a string! Pin
Rob Graham6-May-07 4:03
Rob Graham6-May-07 4:03 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Luc Pattyn6-May-07 4:12
sitebuilderLuc Pattyn6-May-07 4:12 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 4:17
Adeel Chaudhry6-May-07 4:17 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Rob Graham6-May-07 4:40
Rob Graham6-May-07 4:40 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Luc Pattyn6-May-07 5:25
sitebuilderLuc Pattyn6-May-07 5:25 
GeneralRe: Reduce multiple characters to one, in a string! Pin
Adeel Chaudhry6-May-07 4:15
Adeel Chaudhry6-May-07 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.