| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 568 人关注过本帖
标题:求高人指点,C#中保存按钮的事件写好了,运行时总是出错,提示对象设置没有 ...
只看楼主 加入收藏
zihaobiao
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-10-18
收藏
 问题点数:0 回复次数:0 
求高人指点,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;
            }
搜索更多相关主题的帖子: private return 
2011-10-27 11:56
快速回复:求高人指点,C#中保存按钮的事件写好了,运行时总是出错,提示对象设置 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050306 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved