- 我想在windows應用程序的5-6窗體中創建插入數據。
- 每個表格至少包含15-20個控件。所有表格屬於 不同的表格。但有些相同。
- 我要創建的存儲「下一步」命名的每個窗體上按鈕,這樣 當我上單擊下一步按鈕全部填滿該按鈕的信息得到儲存一些地方
並以這種方式儲存的最後信息後按鈕提交按鈕是 拖動,點擊提交按鈕,所有的數據被保存到數據庫中。 - 請告訴我如何存儲先前表單中插入的數據,並在提交按鈕的單擊事件中調用它。
現在我已經在同一頁上的所有控件,我已經使用這些代碼插入。如何在winforms c#中將數據從一種形式傳輸到另一種形式?
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 ");
}
}
請幫幫我。 謝謝。
[從另一種形式的Winforms傳遞值]的可能重複(HTTP://計算器。com/questions/9073267/passing-values-from-another-form-winforms) – 2013-05-02 15:29:31
您也可以創建與您的表單相關的5-6個ClassObjects(每個表單一個類)並且與公共定義(set; get;)相關到每個表單上的每個對象。每次「下一步」單擊後,您可以保留關於該表單的所有屬性在它的classObject.I希望這可以幫助您 – Fuad 2013-05-12 07:37:11