CYQ.Data 数据层框架

CYQ.Data 是一款由路过秋天创作的支持多数据库应用[Txt,Xml,Access,MSSQL,Oracle,SQLite,MySql]的底层数据库操作类库,使用本类库可以轻松快速开发项目(QQ群:6033006)。

CYQ.Data Components Getting Started Guide [Part 3]-[MAction Get And Set Value]

快速使用帮助 | | | 发表日期 :2011/7/2 17:44:32#楼主  

In this section:

continue on a content, this section describes all the values ​​associated with the assignment operator.

 1: UI operation: GetFrom and SetTo
 
 2: non-UI operations: Get and Set
 
 3: DrowDownList operation of the UI controls such as list

 

Common part of the code described earlier, we assume that the query through the following methods to complete row of data

using(MAction action = new MAction(TableNames.Users))
{
        if (action.Fill(888
))
       {
              //This is to say in this section and the assignment of values

       }
}

I: UI Operation

Description: Controls ID to comply with naming convention: any three-letter prefix + field name

For example, a TextBox control with ID: txtUserName
 Compared txt (any prefix) + UserName (the database field name)

1:GetFrom - Get value from control and set value to MDataRow

Method Prototype:

public void
GetFrom(Control ct)

public void GetFrom(Control ct, object
value)

Example 1:

action.GetFrom(txtUserName);//Get value from control and set value to MDataRow
 
//Equivalent to

action.Data["UserName"].Value=txtUserName.Text;

Example 2:

action.GetFrom(txtUserName, "cyqdata");//Value assigned to the custom data line, ignoring the value of the control.
 
//Equivalent to

action.Data["UserName"].Value="cyqdata";

2:SetTo 将数据行中的数据设置到控件

Method Prototype:
 
public void SetTo(Control ct)

public void SetTo(Control ct, object
value)

public void SetTo(Control ct, object value, bool
isControlEnabled)

Example 1:

action.SetTo(txtUserName);//Get value from MDataRow and set value to txtUserName control。

//Equivalent to
 
txtUserName.Text=action.Data["UserName"].Value.ToString();

Example 2:

action.SetTo(txtUserName,"cyqdata");//Assigned to the control, data from the custom values

//Equivalent to

txtUserName.Text="cyqdata";

Example 3

action.SetTo(txtUserName,null,false);//Assigned to the control, and set the Enable property of the control

//Equivalent to
 
txtUserName.Text=action.Data["UserName"].Value.ToString();

txtUserName.Enabled
=false;

二:Non-UI Operation

1:Get - get value from MDataRow

Method Prototype : public T Get<T>(object key)

Example 1:

string userName = action.Get<string>(Users.UserName);//get value from MDataRow

//Equivalent to

string userName = action.Data["UserName"].Value.ToString();

2:Set - set value to MDataRow

Method Prototype : public void Set(object key,object value)

Example 1:

action.Set(Users.UserName, "cyqdata");//set value 'cyqdata' to MdataRow's column 'UserName'

//Equivalent to
 
action.Data["UserName"].Value = "cyqdata";

III:UI Operation:dropdown list of controls and other UI operations

Method Prototype :

public MAction Bind((object control)
 
public MAction Bind(string control, string where)
 
public MAction Bind((object control, string where, object text, object value)

Example 1:

using(MAction action = new MAction(TableNames.Users))
{
        
   action.Bind(ddlUserName);//Query the data and bind the drop-down list, text field for the UserName [remove three arbitrary prefix], range of ID
 }

Example 2

using(MAction action = new MAction(TableNames.Users))
{
        
   action.Bind(ddlUserName,"id>10");//Query data and bound by conditions of the drop-down list, text field for the UserName, range of ID
 }

Example 3:

using(MAction action = new MAction(TableNames.Users))
{
        
   action.Bind(ddlUserName,"id>10",Users.NickName,Users.ID);//Query data and bound by conditions of the drop-down list, text field is NickName, range of ID
 }

Chinese version of the link:http://cyqdata.com/cyqdata/article-detail-413

More tutorials:

 



新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"
https://royalcbd.com[89.28.10.*]2020/9/28 23:52:44#4
8i3qOB I truly appreciate this post.Thanks Again. Will read on
is cbd legal in wash[89.28.10.*]2020/9/25 20:24:08#3
OXGmBZ Very good info. Lucky me I found your website by chance (stumbleupon). I ave saved as a favorite for later!
Silvia[62.210.78.*]2014/8/25 3:40:56#2
Hot damn, looikng pretty useful buddy.
Idana[183.177.122.*]2011/10/7 21:17:11#1
It's about time soomene wrote about this.

发表评论

论坛公告

    数据框架 CYQ.Data QQ群:6033006
    使用本框架进行开发,入门简单,开发效率高,性能优越,更有详尽的API文档,有相关的使用帮助文章、示例文章、更甚有相关的视频教程及辅助工具。 关键还是免费与开源,实在是居家旅行、项目开发、学习研究的必备良品!!!!!!


    在线帮助:欢迎联系

帖子搜索