C#表/数据库类 [英] c# table/database class

查看:64
本文介绍了C#表/数据库类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建此表格.但是只设法创建了表单本身的最终外观,没有任何编码.有人可以解决这个问题吗?

在C#中实现类型为Student的类,该类应包含在Student.cs文件中.该类应符合以下规范:

属性-示例数据-验证

名-罗勒"-不为空白
SecondName-"Fawlty"-不为空
生日1946年3月23日-不可以空白
课程-"MA酒店管理"-非空白
入学人数-12345-在10000至99999范围内
年标记-55-范围0 -100

以及与属性关联的get/set方法,您的类也应具有
以下方法:
方法说明
hasPassed()如果学生的年份标记为> = 40或
,则应返回True 如果标记是< 40
,则返回false
toString()应该返回包含
摘要的单个字符串 班级内的学生详细资料
例如
"12345 Basil Fawlty,1946年8月23日"


这些按钮应执行以下功能:
设置:获取文本框中包含的值并更新Student类
特性.
清除:删除文本框的内容(不更改
的任何属性 班级)
获取:使用Student类方法的值更新文本框.
应该使用Student.hasPassed()方法更新通过/失败标签.
应该使用Student.toString()

I need to create this form. But only managed to create a final outlook of form itself,without any coding.Can someone help solve this?

Implement a class of type Student in C#, the class should be contained within a file Student.cs. The class should conform the following specification:

Property - Example Data -Validation

FirstName -"Basil" -Not blank
SecondName -"Fawlty"- Not blank
Date Of Birth -23/08/1946 -Not blank
Course -"MA Hotel Management" -Not blank
Matriculation Number -12345 -In the range 10000 to 99999
Year Mark- 55 -In range 0 -100

As well as get/set methods associated with properties, you class should have the
following methods:
Method Notes
hasPassed() Should return True if the student has a year mark >= 40 or
false if the marks is <40

toString() Should return a single string containing a summary of the
student details held within the class
e.g.
"12345 Basil Fawlty, 23/08/1946"


The buttons should perform the following functions:
Set: Takes the values contained in the text boxes and updates the Student class
properties.
Clear: Removes the contents of the text boxes (does not change any properties of
the class)
Get: Uses the values of the Student class methods to update the text boxes. The
Student.hasPassed() method should be used to update the pass/fail label. The
Student details summary should be updated by using Student.toString ()

推荐答案

来更新学生详细信息摘要,这很简单:
It''s pretty easy:
private string _FirstName;
public string FirstName
   {
   get { return _FirstName; }
   set
      {
      if (string.IsNullOrWhiteSpace(value))
           {
           throw new Exception("FirstName cannot be blank");
           }
      _FirstName = value;
      }
   }

其他与此类似.


这意味着您需要服务器端验证.你这样写函数:

It means u want server side validation . u write function like that :

Protected string fnValidate()
 {
    string strMsg = string.Empty;
     try
     {
       // For checking textbox is blank or not
         if (textbox1.Text ==string.Empty )
            {
             strMsg ="Enter Name";
              return strMsg;
             }
        return strMsg;
     }
     catch (Exception ex)
     {

         strMsg ="Exception error occured.!";
         return strMsg;
     }
 }


您可以尝试像这样进行控制.
假设您正在验证您的按钮单击事件,那么您应该在该事件上调用此函数.


u can try like that for your controls.
suppose u r validating on your button click event then u should call this function on that event.


这篇关于C#表/数据库类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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