在使用mvvm在wpf c#中将数据保存到数据库之前输入验证 [英] input validation before saving data into the database in wpf c# using mvvm

查看:75
本文介绍了在使用mvvm在wpf c#中将数据保存到数据库之前输入验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对WPf概念更新鲜。我想做一个基于雇员登记的项目。这项工作需要输入字段名称,年龄,年龄,名称,工资。这些细节只有在验证后才能保存在sql数据库中。 name字段应该只包含字母表,age字段应该只包含numbers.can我们使用mvvm来解决这个问题?如何使用mvvm概念实现这个?

i am fresher to WPf concept. i want to do a project based on "employement registration".this work needs the input fields name,age,depatrment,designation,salary.these details should be saved in sql database only after the validation. the name field should only contains alphabets and age field should contain only numbers.can we use mvvm to this??how can i implement this using mvvm concept?

推荐答案

你好,请点击此处。

显然,为简单起见,您的域名模型 - >员工需要继承
Hi , check here.
Obviously for simplicity your domain model -> Employee needs to inherit
IDataErrorInfo



然后在此域模型属性中实现(在此界面中声明):


then implement in this domain model property (which is a declared in this interface):

public string this[string columnName]



并在内部检查您的字段,如果有不合适的数据每个属性都以字符串数据的格式通知它。

你也可以在这里查看:

idataerrorinfo-for-validation-in-mvvm-with-silverlight-and-wpf / [ ^ ]


这篇关于在使用mvvm在wpf c#中将数据保存到数据库之前输入验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆