WPF与我们之前做的MVC是不太一样的,因为WPF的服务端Client需要与服务器Service连接,还要在数据库SQL Server里写存储过程(在数据库SQL Server写存储过程,在服务器Service调用存储过程,在客户端Client引用服务器,三者一一嵌套。所以我们的查询与之前的查询不太一样,但逻辑是一样的)
一、先在数据库的存储过程把数据查出来
BEGIN
SELECT
ROW_NUMBER() over(order by t_operators.operator_id) AS number,
t_operators.operator_id, t_operators.staff_id,
RTRIM(t_staff.staff_name) AS name,
RTRIM(t_operators.operator_accounts) AS accounts,
RTRIM(t_operators.operator_password) AS password,
RTRIM(case WHEN t_operators.effective='true' THEN '有效' ELSE ' 无效' END) AS effective,
RTRIM(t_operators.note) AS note
FROM t_operators INNER JOIN
t_staff ON t_operators.staff_id = t_staff.staff_id
ORDER BY t_operators.operator_id DESC
END
二、在service服务器调用数据库的存储过程
SqlParameter[] mySqlParameters =
{
//定义传递参数,以及传递参数的类型
new SqlParameter("@type",SqlDbType.NChar),
};
mySqlParameters[0].Value = "UserControl_Loaded_SelectStaffAccountManage";//获取执行的存储过程名称
DataSet ds = myDALMethod.QueryDataSet("UC_StaffAccountManage", mySqlParameters);
//返回值
return ds;
三、在client客户端编写代码(在这里的查询数据是先实例化然后初始化表格再调用表格数据)
最终结果如二、在service服务器调用数据库的存储过程下: