public frmLineModify(LineDataBean line) { InitializeComponent(); agent = SQLAgent.GetInstance(); cityList = agent.GetCityList(); foreach (var city in cityList) { cmbDep.Items.Add(city.cityName); cmbArr.Items.Add(city.cityName); if (city.cityId.Equals(line.depCity.ToString())) { cmbDep.Text = city.cityName; } if (city.cityId.Equals(line.arrCity.ToString())) { cmbArr.Text = city.cityName; } } id = line.id; txtNum.Text = line.trainNum; txtPrice.Text = line.price.ToString(); dateArr.Value = line.arrDate; dateDep.Value = line.depDate; }
public frmLineRUD(bool login, string user_id) { InitializeComponent(); agent = SQLAgent.GetInstance(); isLogin = login; this.user_id = user_id; }
private void frmViewCity_Load(object sender, EventArgs e) { SQLAgent agent = SQLAgent.GetInstance(); List <CityDataBean> cityList = agent.GetCityList(); dataView.Columns.Add("city_id", "城市ID"); dataView.Columns.Add("city_name", "城市名称"); for (int i = 0; i < cityList.Count; i++) { dataView.Rows.Add(cityList[i].cityId, cityList[i].cityName); } }
private void btnOK_Click(object sender, EventArgs e) { SQLAgent agent = SQLAgent.GetInstance(); if (!txtPass.Text.Equals(string.Empty) && !txtId.Text.Equals(string.Empty) && !txtRName.Text.Equals(string.Empty) && !txtTel.Text.Equals(string.Empty) && !txtUser.Text.Equals(string.Empty) && cmbSex.Items.Contains(cmbSex.Text)) { agent.AddUser(txtId.Text, txtRName.Text, cmbSex.SelectedIndex, txtTel.Text, txtUser.Text, txtPass.Text); MessageBox.Show("Registered", "Finished", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Not enough information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtUser.Text != string.Empty && txtPass.Text != string.Empty) { try { var sqlAgent = SQLAgent.GetInstance(); sqlAgent.Connect(File.ReadAllText("server.inf")); if (!sqlAgent.AdminLogin(txtUser.Text, txtPass.Text)) { MessageBox.Show("User name or password incorrect", "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Hide(); frmFunctions functions = new frmFunctions(); functions.Show(); } catch (Exception ex) { MessageBox.Show("Error connecting server\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (ex is WebException) { frmServerConfigure frm = new frmServerConfigure(); this.Enabled = false; frm.FormClosed += (o, arg) => { this.Enabled = true; }; frm.Show(); } } } else { MessageBox.Show("Please enter both user name and password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public frmLineRUD() { InitializeComponent(); agent = SQLAgent.GetInstance(); }
public frmAddCity() { InitializeComponent(); agent = SQLAgent.GetInstance(); cityList = new List <CityDataBean>(); }