所以我正在使用c#和metro ui创建一个个人数据库编辑器。我很抱歉,因为我对编程非常陌生,只是从youtube学习一些东西并尝试将所有东西放在一起。不是我认为最好的代码,但它对我有用。
如果值为true,我要做的是打开此切换按钮。或者如果为true则选中“已选中”复选框。我知道它的确有效,因为我测试了它的值实际上写的是“真实的”。任何帮助都会非常苛刻,我似乎无法找到正确的答案。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MetroFramework.Forms;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
namespace LineageDB_Editor
{
public partial class Form1 : MetroFramework.Forms.MetroForm
{
MySqlConnection connection = new MySqlConnection("Server=localhost;Database=l1jdb;Uid=root;Pwd=root");
MySqlCommand command;
MySqlDataReader mdr;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void metroLabel7_Click(object sender, EventArgs e)
{
}
private void metroLabel22_Click(object sender, EventArgs e)
{
}
private void metroTextBox6_Click(object sender, EventArgs e)
{
}
private void metroButton1_Click(object sender, EventArgs e)
{
connection.Open();
string selectQuery = "SELECT * FROM armor WHERE item_id=" + int.Parse(metroTextBox6.Text);
command = new MySqlCommand(selectQuery, connection);
mdr = command.ExecuteReader();
while (mdr.Read())
{
metroTextBox3.Text = mdr.GetString("name");
metroTextBox4.Text = mdr.GetString("name_id");
metroTextBox5.Text = mdr.GetInt32("itemdesc_id").ToString();
metroTextBox17.Text = mdr.GetInt16("safenchant").ToString();
metroTextBox18.Text = mdr.GetInt32("weight").ToString();
metroTextBox19.Text = mdr.GetInt16("ac").ToString();
metroTextBox13.Text = mdr.GetString("type");
metroTextBox14.Text = mdr.GetInt16("acctype").ToString();
metroTextBox15.Text = mdr.GetInt16("grade").ToString();
metroTextBox16.Text = mdr.GetString("material");
metroTextBox1.Text = mdr.GetInt16("invgfx").ToString();
metroTextBox2.Text = mdr.GetInt16("grdgfx").ToString();
metroTextBox7.Text = mdr.GetInt16("add_str").ToString();
metroTextBox8.Text = mdr.GetInt16("add_con").ToString();
metroTextBox11.Text = mdr.GetInt16("add_dex").ToString();
metroTextBox9.Text = mdr.GetInt16("add_int").ToString();
metroTextBox10.Text = mdr.GetInt16("add_wis").ToString();
metroTextBox12.Text = mdr.GetInt16("add_cha").ToString();
metroTextBox20.Text = mdr.GetInt16("defense_water").ToString();
metroTextBox21.Text = mdr.GetInt16("defense_wind").ToString();
metroTextBox22.Text = mdr.GetInt16("defense_fire").ToString();
metroTextBox23.Text = mdr.GetInt16("defense_earth").ToString();
metroTextBox24.Text = mdr.GetInt16("add_hp").ToString();
metroTextBox25.Text = mdr.GetInt16("add_mp").ToString();
metroTextBox26.Text = mdr.GetInt16("add_hpr").ToString();
metroTextBox27.Text = mdr.GetInt16("add_mpr").ToString();
metroTextBox28.Text = mdr.GetInt16("add_sp").ToString();
metroTextBox29.Text = mdr.GetInt16("m_def").ToString();
metroTextBox30.Text = mdr.GetInt16("regist_stun").ToString();
metroTextBox31.Text = mdr.GetInt16("regist_stone").ToString();
metroTextBox32.Text = mdr.GetInt16("regist_sleep").ToString();
metroTextBox33.Text = mdr.GetInt16("regist_freeze").ToString();
metroTextBox34.Text = mdr.GetInt16("regist_sustain").ToString();
metroTextBox35.Text = mdr.GetInt16("regist_blind").ToString();
metroTextBox36.Text = mdr.GetInt16("regist_DESPERADO").ToString();
metroToggle1.Text = mdr.GetBoolean("use_royal").ToString();
}
}
private void metroLabel38_Click(object sender, EventArgs e)
{
}
}
}