作者:李坤凤
本次任务完成时间:2019年6月15日
开发工具与关键技术:开发工具:VS 关键技术: 新增员工信息
一、 编写数据的存储过程语句
1、 新建存储语句,编写存储语句,新增一条数据;
2、定义传递参数,传递参数的类型,在存储过程中就定义好了,给参数类型赋值,
3、在服务端写服务契约,然后启动,到客户端引用服务或者更新服务;
//OperationContract(操作契约)新增账号信息数据
[OperationContract]
public int btn_Save_Click_InsertStaffAccountManage(int intID,string strAccounts,string strPassword,bool blEffective,string strNote)
{
//实例化对象数组
SqlParameter[] mySqlParameters ={
//定义传递参数,以及传递参数的类型
new SqlParameter("@type",SqlDbType.NChar),
new SqlParameter("@staff_id",SqlDbType.Int),
new SqlParameter("@operator_accounts",SqlDbType.NChar),
new SqlParameter("@operator_password",SqlDbType.NChar),
new SqlParameter("@effective",SqlDbType.Bit),
new SqlParameter("@note",SqlDbType.NChar),
};
//给对象赋值
mySqlParameters[0].Value = "btn_Save_Click_InsertStaffAccountManage";
mySqlParameters[1].Value = intID;
mySqlParameters[2].Value = strAccounts;
mySqlParameters[3].Value = strPassword;
mySqlParameters[4].Value = blEffective;
mySqlParameters[5].Value = strNote;
int count = myDALMethod.UpdateData("UC_StaffAccountManage", mySqlParameters);
//返回数值
return count; }
4、在客户端这边写新增保存按钮的功能,判断新增的数据是不是唯一性,或者新增的数据重复新增,需要新增信息数据的唯一性,使用if…else语句判断新增信息数据没有填写完整点击保存,则会显示数据没有填写完整,需要填写完整才可以保存;