求高人指点,C#中保存按钮的事件写好了,运行时总是出错,提示对象设置没有引用到实例的对象,这是什么原因啊?
代码如下: private void btSave_Click(object sender, EventArgs e)
{
GenerricInfo(btSave.Name.ToString());
}
private void Save()
{
if (!CheckBeforeSave()) return;
WaybillcodeKindDelegate objWaybillCKDelegate = new WaybillcodeKindDelegate();
WaybillcodekindColumns objColumns = new WaybillcodekindColumns();
string strOperId = GlobalData.OperID.ToString();
gbSet.BuildColumns(objColumns);
DataSet dsSaveResult = objWaybillCKDelegate.Save(objColumns, strOperId);
if (DataSetUtil.IsNull(dsSaveResult))
{
MessageBox.Show("保存成功,没有返回数据", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (DataTableUtil.IsNull(dsSaveResult.Tables[0]))
{
MessageBox.Show("保存成功", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
MessageBox.Show("保存成功", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
dgvWaybillcodeKind.DataSource = dsSaveResult.Tables[0];
}
private void GenerricInfo(string strButtonName)
{
try
{
this.Cursor = Cursors.WaitCursor;
switch (strButtonName)
{
case "btDelete":
Delete();
break;
case "btSave":
Save();
break;
}
}
catch (Exception ex)
{
MessageBox.Show("操作失败,失败原因:" + ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
this.Cursor = Cursors.Default;
}