Click here to Skip to main content
15,925,133 members
Home / Discussions / C#
   

C#

 
GeneralRe: extract email id from a text file Pin
jazeelkm14-May-07 21:04
jazeelkm14-May-07 21:04 
Questionicons on listview.... Pin
jazeelkm14-May-07 17:58
jazeelkm14-May-07 17:58 
AnswerRe: icons on listview.... Pin
MatrixCoder14-May-07 18:11
MatrixCoder14-May-07 18:11 
GeneralRe: icons on listview.... Pin
jazeelkm14-May-07 18:14
jazeelkm14-May-07 18:14 
GeneralRe: icons on listview.... Pin
MatrixCoder14-May-07 18:23
MatrixCoder14-May-07 18:23 
GeneralRe: icons on listview.... Pin
jazeelkm14-May-07 18:26
jazeelkm14-May-07 18:26 
GeneralRe: icons on listview.... Pin
Jabeerbe15-May-07 1:21
Jabeerbe15-May-07 1:21 
Questionadding drop-down box functionality to an entry form Pin
heroz10014-May-07 16:46
heroz10014-May-07 16:46 
I am just a beginner in C# and need to create a basic C# form to enter student information:
 first and last name
 email
 graduation year
 month of graduation
I have to use some type of menu for the graduation year and month (dropdown, radio button list or checkbox list).

I have used C# code generator to create the following code:
using System;

namespace SIU.Student.Graduation
{
public class EntryForm
{
// private members
string strFirstName;
string strLastName;
string strEMail;
string strGraduationYear;
string strGraduationMonth;


// empty constructor
public EntryForm ()
{
}


// full constructor
public EntryForm (string FirstName, string LastName, string EMail, string GraduationYear, string GraduationMonth)
{
this.strFirstName = FirstName;
this.strLastName = LastName;
this.strEMail = EMail;
this.strGraduationYear = GraduationYear;
this.strGraduationMonth = GraduationMonth;
}

// public accessors
public string FirstName
{
get { return strFirstName;}
set { strFirstName = value; }
}
public string LastName
{
get { return strLastName;}
set { strLastName = value; }
}
public string EMail
{
get { return strEMail;}
set { strEMail = value; }
}
public string GraduationYear
{
get { return strGraduationYear;}
set { strGraduationYear = value; }
}
public string GraduationMonth
{
get { return strGraduationMonth;}
set { strGraduationMonth = value; }
}


}
}
using System;
using System.Data;
using System.Data.Client;

namespace SIU.Student.Graduation.Data
{
public class SqlDataProvider
{

public SqlDataProvider(){}



public void AddEntryForm(EntryForm EntryForm)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_Add", conn);
cmd.CommandType = CommandType.StoredProcedure;

// Add Parameters
cmd.Parameters.Add("@firstName", EntryForm.FirstName);
cmd.Parameters.Add("@lastName", EntryForm.LastName);
cmd.Parameters.Add("@eMail", EntryForm.EMail);
cmd.Parameters.Add("@graduationYear", EntryForm.GraduationYear);
cmd.Parameters.Add("@graduationMonth", EntryForm.GraduationMonth);

conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public void UpdateEntryForm(EntryForm EntryForm)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_Update", conn);
cmd.CommandType = CommandType.StoredProcedure;

// Update Parameters
cmd.Parameters.Add("@firstName", EntryForm.FirstName);
cmd.Parameters.Add("@lastName", EntryForm.LastName);
cmd.Parameters.Add("@eMail", EntryForm.EMail);
cmd.Parameters.Add("@graduationYear", EntryForm.GraduationYear);
cmd.Parameters.Add("@graduationMonth", EntryForm.GraduationMonth);

conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public void DeleteEntryForm(EntryForm EntryFormID)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_Delete", conn);
cmd.CommandType = CommandType.StoredProcedure;

// Delete Parameters
cmd.Parameters.Add("@EntryFormID", EntryFormID);

conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public EntryForm GetEntryFormByID(EntryForm EntryFormID)
{
// Initialize SPROC
SqlConnection conn = new SqlConnection(Globals.ConnectionString);
SqlCommand cmd = new SqlCommand("KSU.Student.Graduation_EntryForm_GetByID", conn);
cmd.CommandType = CommandType.StoredProcedure;

SqlDataReader reader = null;
EntryForm entryForm = null;

// GetByID Parameters
cmd.Parameters.Add("@EntryFormID", EntryFormID);

// Execute
conn.Open();
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

if(reader.Read())
{
entryForm = SqlDataHelpers.PopulateEntryFormFromSqlDataReader(reader);
}

conn.Close();


return entryForm;
}
public static EntryForm PopulateEntryFormFromSqlDataReader(SqlDataReader dr)
{
EntryForm entryForm = new EntryForm();

entryForm.FirstName = Convert.ToString(dr["firstName"]);
entryForm.LastName = Convert.ToString(dr["lastName"]);
entryForm.EMail = Convert.ToString(dr["eMail"]);
entryForm.GraduationYear = Convert.ToString(dr["graduationYear"]);
entryForm.GraduationMonth = Convert.ToString(dr["graduationMonth"]);


return entryForm;
}

}
}

I need to figure out way to code the drop-down menu for GraduationYear and GraduationMonth fields.
Can somebody provide a ready code snippet to insert it in the above code pls?Unsure | :~

Do I miss any other important coding for this entry form?Roll eyes | :rolleyes:

Thanks so much!Smile | :)


heroz100

QuestionCase Sensitive Issue with XML Pin
Latheesan14-May-07 16:17
Latheesan14-May-07 16:17 
AnswerRe: Case Sensitive Issue with XML Pin
Stefan Troschuetz14-May-07 21:11
Stefan Troschuetz14-May-07 21:11 
Questioncreate dynamic objects during run time... Pin
Aint14-May-07 15:26
Aint14-May-07 15:26 
AnswerRe: create dynamic objects during run time... Pin
~~~Johnny~~~14-May-07 15:46
~~~Johnny~~~14-May-07 15:46 
QuestionEdit date in DataGridView using MySQL provider [modified] Pin
Marooned14-May-07 13:01
Marooned14-May-07 13:01 
QuestionForce a Form to Close Pin
Latheesan14-May-07 12:55
Latheesan14-May-07 12:55 
AnswerRe: Force a Form to Close Pin
Luc Pattyn14-May-07 13:05
sitebuilderLuc Pattyn14-May-07 13:05 
GeneralRe: Force a Form to Close Pin
Latheesan14-May-07 13:13
Latheesan14-May-07 13:13 
GeneralRe: Force a Form to Close Pin
MatrixCoder14-May-07 13:24
MatrixCoder14-May-07 13:24 
GeneralRe: Force a Form to Close Pin
Latheesan14-May-07 13:30
Latheesan14-May-07 13:30 
GeneralRe: Force a Form to Close Pin
Luc Pattyn14-May-07 13:36
sitebuilderLuc Pattyn14-May-07 13:36 
GeneralRe: Force a Form to Close Pin
MatrixCoder14-May-07 13:51
MatrixCoder14-May-07 13:51 
GeneralRe: Force a Form to Close Pin
Leslie Sanford14-May-07 14:19
Leslie Sanford14-May-07 14:19 
AnswerRe: Force a Form to Close Pin
MatrixCoder14-May-07 13:26
MatrixCoder14-May-07 13:26 
GeneralRe: Force a Form to Close Pin
Latheesan14-May-07 13:32
Latheesan14-May-07 13:32 
AnswerRe: Force a Form to Close Pin
Leslie Sanford14-May-07 13:38
Leslie Sanford14-May-07 13:38 
GeneralRe: Force a Form to Close Pin
Latheesan14-May-07 13:48
Latheesan14-May-07 13:48 

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.