做时间的朋友😭
C#获取ListBox里的数据

C#获取ListBox里的数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public List<string> SelectedFileNames
{
get
{
List<string> temp = new List<string>();
foreach (var item in listBox.SelectedItems)
{
temp.Add(item.ToString());
}
//排序
temp.Sort()
return temp;
}
}

DataTable的操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
string stuName = "";// X
string stuName = string.Empty;// √
stuName.Equals("Tom");// √
string.IsNullOrEmpty(stuName);// √

// 过滤 DataTable 中的数据
var filter = string.Format("ID = {0} AND STUNAME <> '{1}' AND AGE = {2} AND SEX IS NOT NULL", id, stuName, 12);
var stuRow = stuTable.Select(filter);
// 存在数据
if (stuRow.Length > 0)
{
// 克隆表结构
var itemStuTable = stuTable.Clone();
// 遍历过滤出的数据
foreach(DataRow row in stuRow )
{
// 添加数据到新表中
itemStuTable.ImportRow(row);
}
}
}

// 如果SchoolObject这个DataSet不存在这个表
if(!SchoolObject.Tables.Contains(TableNames.stuTable))
{
//
}

调用Command,获取userid

1
2
3
4
5
var getUserNameCommand = new GetUserNameCommand();
getUserNameCommand.SetUser(userid);
var result = Context.Current.ExecuteUICommand(getUserNameCommand);
var userTable = result.Value.Tables[0];
string userid = userTable.Rows[0][ColumnNames.USERID].ToString();

Command内容

1
2
3
4
5
6
7
8
public class GetUserNameCommand : ApiCommand
{
private const string NAME = "GetUserName";
public GetUserNameCommand()
: base(NAME)
{
Component = CommonAPI;
}
1
2
3
4
5
6
7
8
/// <summary>
/// 取得したいユーザIDを設定
/// </summary>
/// <param name="userid">ユーザID/param>
public void SetUser(string userid)
{
ArgumentUtil.SetValue(Argument, ColumnNames.USERID, userid);
}

遍历

1
2
3
foreach (DataRow rows in tstList.Rows)
foreach (DataRowView rowView in ttstRows)
foreach (var row in e.Rows.Select(rowView => rowView.Row))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dat0 = GetInf(data01, data02, data03, data04, false);
/// </summary>
/// <param name="data01"></param>
/// <param name="data02"></param>
/// <param name="data03"></param>
/// <param name="data04"></param>
/// <param name="multiFlag"></param>
/// <returns></returns>
private static string GetInf(string data01, string data02, string data03, string data04, bool multiFlag)

private static List<decimal> GetUserInf(ListEventArgs e)

private static DataTable GetUserInf(IList<DataRowView> ttstRows)

private static string GetUserInf(string data01, string data02, string data03, string data04)
C# WPF
利用Hexo创建博客
自动化测试
© 2022 Sk8erBoi
Powered by hexo | Theme is blank
Title - Artist
0:00