/// <summary> /// 选择绑定对象 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">时间参数</param> private void buttonX3_Click(object sender, EventArgs e) { string bindType = comboBoxEx2.Text; string id = null; string value = null; switch (bindType) { case "场景": { TableSelector.Program tableSelector = new TableSelector.Program(); bool selectFinished = tableSelector.Show(conn, "场景选择器", "Select Name, ID FROM MapList", "Name", "ID", textBoxX3.Text); if (selectFinished) { id = tableSelector.SelectedValue; value = string.Format("{0} ({1})", tableSelector.SelectedValues["Name"], tableSelector.SelectedValues["ID"]); } break; } case "玩家": { MessageBox.Show("默认为当前玩家,不需要选择!", "添加变量", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case "": { MessageBox.Show("请先选择绑定类型!", "添加变量", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } textBoxX3.Text = value; textBoxX3.Tag = id; }
/// <summary> /// 选择数据表中的字段 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void SelectTableField(object sender, EventArgs e) { ButtonX button = sender as ButtonX; int index = int.Parse(button.Tag.ToString()); string oldValue = inputControlList[index].Value.ToString(); string arguments = advTree1.SelectedNode.Tag as string; string[] data = arguments.Split(new char[] { ';' }); string functionInfo = data[index]; string[] information = functionInfo.Split(new char[] { '[' }); string tableName = information[0]; string fieldInfo = information[1].TrimEnd(new char[] { ']' }); string[] fields = fieldInfo.Split(new char[] { ',' }); string valueField = fields[fields.Length - 1]; string catString = ""; for (int i = 0; i < fields.Length - 1; i++) { catString += string.Format("{0},", fields[i]); } catString = catString.TrimEnd(new char[] { ',' }); TableSelector.Program tableSelector = new TableSelector.Program(); bool editSuccess = tableSelector.Show(conn, "参数值选择", string.Format("SELECT * FROM {0}", tableName), catString, valueField, oldValue); if (editSuccess) { int intValue; if (int.TryParse(tableSelector.SelectedValue, out intValue)) { inputControlList[index].Value = intValue; } } }
/// <summary> /// 选择绑定对象 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">时间参数</param> private void buttonX3_Click(object sender, EventArgs e) { string bindType = comboBoxEx2.Text; string id = null; string value = null; switch(bindType) { case "场景": { TableSelector.Program tableSelector = new TableSelector.Program(); bool selectFinished = tableSelector.Show(conn, "场景选择器", "Select Name, ID FROM MapList", "Name", "ID", textBoxX3.Text); if(selectFinished) { id = tableSelector.SelectedValue; value = string.Format("{0} ({1})", tableSelector.SelectedValues["Name"], tableSelector.SelectedValues["ID"]); } break; } case "玩家": { MessageBox.Show("默认为当前玩家,不需要选择!", "添加变量", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case "": { MessageBox.Show("请先选择绑定类型!", "添加变量", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } textBoxX3.Text = value; textBoxX3.Tag = id; }
/// <summary> /// 选择数据表中的字段 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void SelectTableField(object sender, EventArgs e) { ButtonX button = sender as ButtonX; int index = int.Parse(button.Tag.ToString()); string oldValue = inputControlList[index].Value.ToString(); string arguments = advTree1.SelectedNode.Tag as string; string[] data = arguments.Split(new char[] { ';' }); string functionInfo = data[index]; string[] information = functionInfo.Split(new char[] { '[' }); string tableName = information[0]; string fieldInfo = information[1].TrimEnd(new char[] { ']' }); string[] fields = fieldInfo.Split(new char[] { ',' }); string valueField = fields[fields.Length - 1]; string catString = ""; for(int i = 0; i < fields.Length - 1; i++) { catString += string.Format("{0},", fields[i]); } catString = catString.TrimEnd(new char[] { ',' }); TableSelector.Program tableSelector = new TableSelector.Program(); bool editSuccess = tableSelector.Show(conn, "参数值选择", string.Format("SELECT * FROM {0}", tableName), catString, valueField, oldValue); if(editSuccess) { int intValue; if(int.TryParse(tableSelector.SelectedValue, out intValue)) { inputControlList[index].Value = intValue; } } }