Click here to Skip to main content
15,889,281 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to create a fax manager program! Pin
Judah Gabriel Himango19-Nov-07 9:32
sponsorJudah Gabriel Himango19-Nov-07 9:32 
QuestionDynamic plugin handling? Pin
shuqi19-Nov-07 8:51
shuqi19-Nov-07 8:51 
AnswerRe: Dynamic plugin handling? Pin
Kristian Sixhøj19-Nov-07 9:03
Kristian Sixhøj19-Nov-07 9:03 
GeneralRe: Dynamic plugin handling? Pin
shuqi19-Nov-07 9:10
shuqi19-Nov-07 9:10 
GeneralRe: Dynamic plugin handling? Pin
Kristian Sixhøj19-Nov-07 9:18
Kristian Sixhøj19-Nov-07 9:18 
Questionplz help - AVI File Format Specification Pin
Mahmoud El-Shaffie19-Nov-07 8:17
Mahmoud El-Shaffie19-Nov-07 8:17 
AnswerRe: plz help - AVI File Format Specification Pin
Anthony Mushrow19-Nov-07 10:07
professionalAnthony Mushrow19-Nov-07 10:07 
QuestionInsert Data in to DB Table after verification [modified] Pin
Skanless19-Nov-07 8:00
Skanless19-Nov-07 8:00 
I have written the code belowin anticipation of verifying, assigning and lastly insert the Value into a DB table. The ver ification work as inteded but if I can all it in the Insert Method or in the Submit click event it does not work. if the field contains data it saves it to the DB but no everification is done. The Validation itself works fine but when called in the insert method it does not validate and the inserts execut without validating the values. Any assistance will be greatlly apprciated.
  private bool isUserIDEmpty()
    {
        return(txtUserID.Text.Length==0);
    }

private bool isFNameEmpty()
    {
        return(txtFName.Text.Length==0);
    }

private bool isMidNameEmpty()
    {
        return(txtMidInitial.Text.Length==0);
    }

private bool isLNameEmpty()
    {
            return(this.txtLName.Text.Length==0);
    }

private bool isSSNEmpty()
    {
        return(this.txtSSN.Text.Length == 0);
    }


  internal void ValidateAndAssignValues()
{
    Queue messages = new Queue();
    Control focusControl = null;

if(!isUserIDEmpty())
    {
        EmpID = this.txtUserID.Text;
    }
else
        {
        messages.Enqueue("Please Enter a User ID");
        focusControl = this.txtUserID;
    }

if (!isFNameEmpty())
    {
        FName = this.txtFName.Text;
    }
else
    {
        messages.Enqueue("Please Enter a First Name.");
        if(focusControl == null)
            focusControl = this.txtFName;
    }
       if(!isSSNEmpty())
    {//validating
        //validate integer
        if(isSSNNineDigits()!= true)
          {
              messages.Enqueue("You have not enter nine characters");
            if (focusControl == null)
                focusControl = this.txtSSN;
            }
        else
            {
            try
               {
                  SSN = int.Parse(this.txtSSN.Text);
                }
            catch
                 {
                messages.Enqueue("Please Enter a valid SSN.                                         Please ensure that you have entered numbers only.");

                if (focusControl == null)
                    focusControl = this.txtSSN;
            }
              }
                }

            if (messages.Count > 0)
    {
        StringBuilder sb = new StringBuilder();
        bool first = true;
        foreach (string message in messages)
        {
            if (first)
                first = false;
            else
                sb.Append('\n');
            sb.Append(message);
        }

        lblError.Visible = true;
        lblError.Text = sb.ToString();
    }
    else
         {
             lblError.Visible = false;
               lblError.Text = "";
            }

          if (focusControl != null)
        focusControl.Focus();


        }

internal void InsertIntoDatabase()
    {
        ValidateAndAssignValues()


        try
        {
            SqlCommand cmd = newSqlCommand                                   ("SP_InsertEmployeeRecord",conDatabase);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Emp_Login_ID",EmpID ));
            cmd.Parameters.Add(new SqlParameter("@Emp_SSN", SSN));
            cmd.Parameters.Add(new SqlParameter("@Emp_First_Name", FName));
            cmd.Parameters.Add(new SqlParameter("@Emp_Middle_Name", MidName));
            cmd.Parameters.Add(new SqlParameter("@Emp_Last_Name", LName));
            cmd.Parameters.Add(new SqlParameter("@Emp_Birth_Date", DOB));
            cmd.Parameters.Add(new SqlParameter("@Emp_Hire_Date", HireDate));
            cmd.Parameters.Add(new SqlParameter("@Emp_Position", Position));
            cmd.Parameters.Add(new SqlParameter("@Emp_Sex", Sex));

            conDatabase.Open();
            cmd.ExecuteNonQuery();
        }
        catch(Exception G)
        {
            this.lblError.Text = (G.Message);
            this.lblError.Visible=true;

        }

        conDatabase.Close();

        this.lblError.Visible=true;
        this.lblError.Text = "You record have been saved";

    }






-- modified at 15:38 Monday 19th November, 2007

Skan

If you knew it would not compile why didn't you tell me?!?!?!

AnswerRe: Insert Data in to DB Table after verification Pin
pmarfleet19-Nov-07 8:48
pmarfleet19-Nov-07 8:48 
GeneralRe: Insert Data in to DB Table after verification Pin
Skanless19-Nov-07 11:53
Skanless19-Nov-07 11:53 
GeneralRe: Insert Data in to DB Table after verification Pin
pmarfleet19-Nov-07 12:13
pmarfleet19-Nov-07 12:13 
GeneralRe: Insert Data in to DB Table after verification Pin
Skanless20-Nov-07 6:17
Skanless20-Nov-07 6:17 
Questionproblems with FileSystemWatcher Pin
stephan_00719-Nov-07 6:49
stephan_00719-Nov-07 6:49 
AnswerRe: problems with FileSystemWatcher Pin
Giorgi Dalakishvili19-Nov-07 7:50
mentorGiorgi Dalakishvili19-Nov-07 7:50 
GeneralRe: problems with FileSystemWatcher Pin
stephan_00719-Nov-07 10:49
stephan_00719-Nov-07 10:49 
GeneralRe: problems with FileSystemWatcher Pin
stephan_00719-Nov-07 22:06
stephan_00719-Nov-07 22:06 
AnswerRe: problems with FileSystemWatcher Pin
KKrista20-Nov-07 1:40
KKrista20-Nov-07 1:40 
QuestionFile Manipulation Pin
LCI19-Nov-07 6:40
LCI19-Nov-07 6:40 
AnswerRe: File Manipulation Pin
pmarfleet19-Nov-07 8:39
pmarfleet19-Nov-07 8:39 
GeneralRe: File Manipulation Pin
LCI19-Nov-07 16:43
LCI19-Nov-07 16:43 
Questionlogin page problem Pin
rocky81119-Nov-07 6:22
rocky81119-Nov-07 6:22 
AnswerRe: login page problem Pin
Anthony Mushrow19-Nov-07 6:33
professionalAnthony Mushrow19-Nov-07 6:33 
GeneralRe: login page problem Pin
rocky81119-Nov-07 6:34
rocky81119-Nov-07 6:34 
QuestionGeneral Questions using Attach Process [modified] Pin
Khoramdin19-Nov-07 6:18
Khoramdin19-Nov-07 6:18 
QuestionSome issue with thread synchronization & events Pin
Karma Komae19-Nov-07 5:44
Karma Komae19-Nov-07 5:44 

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.