【发布时间】:2013-05-03 00:20:33
【问题描述】:
- 我想在windows应用程序中创建5-6个表单来插入数据。
- 每个表单至少包含 15-20 个控件。所有表格都属于 不同的表。但有些是一样的。
- 我必须在每个表单上创建存储的“下一步”命名按钮,这样
当我单击下一个按钮时,该按钮上填写的所有信息都会存储在某个位置
并以这种方式将信息存储在提交按钮所在的最后一个按钮上 拖动,单击该提交按钮,所有数据都保存到数据库中。 - 请告诉我如何存储以前表单中插入的数据并在提交按钮的点击事件中调用它。
现在我在同一页面上拥有所有控件,并且我已使用这些代码进行插入。
private void submit_addbtn_Click(object sender, EventArgs e)
{
try
{
//personal data insert
Personal per = new Personal();
per.Name = nametxt.Text;
per.FatherName = f_nametxt.Text;
per.MotherName = m_nametxt.Text;
per.Gotra = gotra_txt.Text;
per.Panth = panthcb.Text;
per.FamilyHead = fhntext.Text;
per.Educationlvl = edulvlcb.Text;
per.Education = educb.Text;
per.Blood = bloodcb.Text;
per.Gender = genderlist.Text;
per.Marrital = MarritalStatus;
per.DateOfBirth = dobdtp.Text;
if (new InsertAction().Insertpersonal(per))
{
MessageBox.Show("Personal Insertion Happen ");
}
else
{
MessageBox.Show(" Personal Insertion does not Happen ");
}
// spouse data insert
Spouse sps = new Spouse();
sps.Spousename = s_nametxt.Text;
sps.Spouseeducationlvl = s_edulvlcb.Text;
sps.Spouseeducation = s_educb.Text;
sps.Spouseblood = s_bgcb.Text;
sps.Spousedob = s_dobdtp.Text;
if (new InsertAction().Insertspouse(sps))
{
MessageBox.Show(" Spouse Insertion Happen ");
}
else
{
MessageBox.Show(" Spouse Insertion does not Happen ");
}
// Resident data insert
Ressident resi = new Ressident();
resi.RessiHnumber = ressi_numtxt.Text;
resi.RessihCmplx = ressi_complextxt.Text;
resi.RessiStrt = ressi_streettxt.Text;
resi.RessiLandmrk = ressi_landtxt.Text;
resi.RessiArea = ressi_areatxt.Text;
resi.RessiCity = ressi_citytxt.Text;
resi.RessiPhone = Convert.ToInt64(ressi_phnotxt.Text);
resi.RessiMobile = Convert.ToInt64(mobi_notxt.Text);
if (new InsertAction().Insertressident(resi))
{
MessageBox.Show(" Ressident Insertion Happen ");
}
else
{
MessageBox.Show(" Ressident Insertion does not Happen ");
}
//occupation data insert
Occupation ocp = new Occupation();
ocp.Occuptype = occup_typetxt.Text;
ocp.Occupadd = office_addresstxt.Text;
ocp.Occupnature = occup_naturecb.Text;
ocp.Occupphone = Convert.ToInt64(office_phno1txt.Text);
ocp.Occupmobile = Convert.ToInt64(office_mobnotxt.Text);
if (new InsertAction().Insertoccupation(ocp))
{
MessageBox.Show(" Occupation Insertion Happen ");
}
else
{
MessageBox.Show(" Occupation Insertion does not Happen ");
}
}
请帮助我。 谢谢。
【问题讨论】:
-
您还可以创建 5-6 个与您的表单相关的类对象(每个表单一个类)和公共定义(set;get;)也与每个表单上的每个对象相关。在每个“下一个”之后" 点击,您可以将有关该表单的所有属性保留在其 classObject 中。希望对您有所帮助
标签: c# .net winforms sql-server-2008