大家好,我使用 VC#2008 编写了一个代码,允许用户根据需要使用是/否对话框DataRows
结果使用索引按顺序输入许多。dataTable
首先,用户使用文本框和组合框使用函数输入他的数据,然后 dilodresult 弹出“你想输入更多记录吗?” 如果是,请清除文本框并调用函数并加上index
并在 datagridview 显示数据,but it doesnot show any data at the datagridviewand the dialogResult countinue showing without performing anything
这是功能代码:
public DataTable showout2(int index, bool bl)
{
DataTable dtab = new DataTable();
DataRow row = dtab.NewRow();
string[] newRow = new string[14];
try
{
DataColumn dc1 = new DataColumn("رقم المتسلسل");
DataColumn dc2 = new DataColumn("رقم الحساب");
DataColumn dc3 = new DataColumn("أسم الحساب");
DataColumn dc4 = new DataColumn("المالك");
DataColumn dc5 = new DataColumn("تاريخ");
DataColumn dc6 = new DataColumn("قيمة");
DataColumn dc7 = new DataColumn("نوع العملة");
DataColumn dc8 = new DataColumn("البيان");
DataColumn dc9 = new DataColumn("الدائن");
DataColumn dc10 = new DataColumn("المدين");
DataColumn dc11 = new DataColumn(" اجمالي الدائن");
DataColumn dc12 = new DataColumn("اجمالي المدين");
DataColumn dc13 = new DataColumn("تفاصيل");
DataColumn dc14 = new DataColumn("التأكيد");
dtab.Columns.Add(dc1);
dtab.Columns.Add(dc2);
dtab.Columns.Add(dc3);
dtab.Columns.Add(dc4);
dtab.Columns.Add(dc5);
dtab.Columns.Add(dc6);
dtab.Columns.Add(dc7);
dtab.Columns.Add(dc8);
dtab.Columns.Add(dc9);
dtab.Columns.Add(dc10);
dtab.Columns.Add(dc11);
dtab.Columns.Add(dc12);
dtab.Columns.Add(dc13);
dtab.Columns.Add(dc14);
DateTime date = new DateTime();
date = DateTime.Today;
row[0] = numb.Text.ToString();
row[1] = Account_numb.Text.ToString();
row[2] = account_nam.Text.ToString();
row[3] = owner.Text;
row[4] = curency.Text.ToString();
row[5] = date.ToString();
row[6] = curncyval.Text;
row[7] = note.Text;
row[8] = Depet.Text;
row[9] = criedt.Text;
row[10] = Total_depet.Text;
row[11] = Total_credit.Text;
row[12] = Details.Text;
row[13] = "false";
dtab.Rows.InsertAt(row, index);
dataGridView1.DataSource = dtab;
dataGridView1.DataSource = dtab;
DialogResult dialogResult = MessageBox.Show("تريد أدخال سجل أخر؟", "Some Title", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
row[0] = numb.Text.ToString();
row[1] = Account_numb.Text.ToString();
row[2] = account_nam.Text.ToString();
row[3] = owner.Text;
row[4] = curency.Text.ToString();
row[5] = date.ToString();
row[6] = curncyval.Text;
row[7] = note.Text;
row[8] = Depet.Text;
row[9] = criedt.Text;
row[10] = Total_depet.Text;
row[11] = Total_credit.Text;
row[12] = Details.Text;
row[13] = "false";
numb.Clear();
owner.Clear();
Account_numb.Text = " ";
account_nam.Text = " ";
curency.Text = " ";
curncyval.Clear();
Total_credit.Clear();
Total_depet.Clear();
note.Clear();
Details.Clear();
criedt.Clear();
Depet.Clear();
return showout2(++index, true);
}
else if (dialogResult == DialogResult.No)
{
return dtab;
}
}