看到一段代码,不明白,向大家请教
代码一是使用方法,如果窗体没使用tabControl控件,代码二应该怎么修改呢?
附件代码一
MyMC.Part_SaveClass(All_Field, S_0.Text.Trim(), "", tabControl1.TabPages[0].Controls, "S_", "tb_Stuffbusic", 30, hold_n);
附件代码二
#region 保存添加或修改的信息
/// <summary>
/// 保存添加或修改的信息.
/// </summary>
/// <param name="Sarr">数据表中的所有字段</param>
/// <param name="ID1">第一个字段值</param>
/// <param name="ID2">第二个字段值</param>
/// <param name="Contr">指定控件的数据集</param>
/// <param name="BoxName">要搜索的控件名称</param>
/// <param name="TableName">数据表名称</param>
/// <param name="n">控件的个数</param>
/// <param name="m">标识,用于判断是添加还是修改</param>
public void Part_SaveClass(string Sarr, string ID1, string ID2, Control.ControlCollection Contr, string BoxName, string TableName, int n, int m)
{
string tem_Field = "", tem_Value = "";
int p = 2;
if (m == 1){ //当m为1时,表示添加数据信息
if (ID1 != "" && ID2 == ""){ //根据参数值判断添加的字段
tem_Field = "ID";
tem_Value = "'" + ID1 + "'";
p = 1;
}
else{
tem_Field = "Sut_id,ID";
tem_Value = "'" + ID1 + "','" + ID2 + "'";
}
}
else
if (m == 2){ //当m为2时,表示修改数据信息
if (ID1 != "" && ID2 == ""){ //根据参数值判断添加的字段
tem_Value = "ID='" + ID1 + "'";
p = 1;
}
else
tem_Value = "Sut_ID='" + ID1 + "',ID='" + ID2 + "'";
}
if (m > 0){ //生成部份添加、修改语句
string[] Parr = Sarr.Split(Convert.ToChar(','));
for (int i = p; i < n; i++)
{
string sID = BoxName + i.ToString(); //通过BoxName参数获取要进行操作的控件名称
foreach (Control C in Contr){ //遍历控件集中的相关控件
if (C.GetType().Name == "TextBox" | C.GetType().Name == "MaskedTextBox" | C.GetType().Name == "ComboBox")
if (C.Name == sID){ //如果在控件集中找到相应的组件
string Ctext = C.Text;
if (C.GetType().Name == "MaskedTextBox") //如果当前是MaskedTextBox控件
Ctext = Date_Format(C.Text); //对当前控件的值进行格式化
if (m == 1){ //组合SQL语句中insert的相关语句
tem_Field = tem_Field + "," + Parr[i];
if (Ctext == "")
tem_Value = tem_Value + "," + "NULL";
else
tem_Value = tem_Value + "," + "'" + Ctext + "'";
&n