日期:2014-05-19  浏览次数:21035 次

关于添加问题???????
*******我是模仿清华大学出版社的 < <Visual   C#.NET数据库开发经典案例解析> > 人力资源管理系统写的,但不知怎么添加不了,但修改却能用?????
另外,我使用sqldataAdapter配置的,自动有添加和删除,更新*********
private   void   HotelType_Load(object   sender,   System.EventArgs   e)
{
try
{
this.sqlDataAdapter1.Fill(tempTable);
this.dataGrid1.DataSource=tempTable.DefaultView;
this.DataGridStateControl();
                                                                        //我不知这个是干什么得,我只是模仿着写
CM   =   (CurrencyManager)   BindingContext[tempTable];
}
catch(Exception   express)
{
MessageBox.Show(express.ToString(), "错误 ");
}
}
                                    //绑定到文本筐
private   void   DataGridStateControl()
{
this.textBox1.DataBindings.Add( "Text ",tempTable, "RoomTypeName ");
this.textBox2.DataBindings.Add( "Text ",tempTable, "Area ");
this.textBox3.DataBindings.Add( "Text ",tempTable, "BedNum ");
this.textBox4.DataBindings.Add( "Text ",tempTable, "Price ");
this.television.DataBindings.Add( "Checked ",tempTable, "Television ");
this.phone.DataBindings.Add( "Checked ",tempTable, "Phone ");
this.airconditon.DataBindings.Add( "Checked ",tempTable, "AirCondition ");
this.toilet.DataBindings.Add( "Checked ",tempTable, "Toilet ");        
}
//判断是否为空
private   bool   isempty()
{
if(this.textBox1.Text== " ")
{
MessageBox.Show(this.label1.Text+ "不能为空!! ");
textBox1.Focus();      
return   true;
}
return   false;
}
//对编辑进行提交
private   void   submit()
{
CM.EndCurrentEdit();
if   (tempTable.GetChanges()   !=   null)
{
try
{
this.sqlDataAdapter1.Update(tempTable);
}
catch(Exception   express)
{
MessageBox.Show(express.ToString(), "提示 ",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.tempTable.RejectChanges();
}

}
}
  //添加记录(***这个不能实现,我不知道是怎么触发的***)
private   void   AddType_Click(object   sender,   System.EventArgs   e)
{
if(!isempty())
CM.AddNew();
}
                                    //修改记录(这个我也不知道是怎么触发的好象是自动的吧,但能实现!!)
private   void   EditType_Click(object   sender,   System.EventArgs   e)
{
          if(!isempty())
this.submit();
}

谢谢高手了!!!!!!!!!!!!!!!
另外,你们谁看过光盘里的人力资源管理系统,里面的
职员信息管理--> 职员信息维护--> 点添加怎么就文本筐都为空了,我实在看不懂??
帮帮忙,谢谢了!!!!!!!!


------解决方案--------------------
不能实现

是报错 还是什么情况?

你跟跟代码 看看有没有执行到cm.addnew();

==============================================================
另外,你们谁看过光盘里的人力资源管理系统,里面的
职员信息管理--&