private void bt_bus_edit_Click(object sender, RoutedEventArgs e) { if (busListBox.SelectedIndex == -1) { lbNotice.Content = "未选中编辑对象!"; return; } try { Int32.Parse(tbBus.Text); } catch (FormatException error) { lbNotice.Content = "公交必须是数字!"; return; } MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); if (mysql.UpdateData("UPDATE businfo SET no = '" + tbBus.Text + "' WHERE id = " + busLinkList.IndexOf(busListBox.SelectedIndex + 1).ID + ";") > 0) { //链表!! busLinkList.IndexOf(stationListBox.SelectedIndex + 1).BusNo = Int32.Parse(tbBus.Text); //链表!! lbNotice.Content = "更新成功。"; initListBox(); } else { lbNotice.Content = "更新失败。"; } mysql.Close(); }
private void bt_bus_del_Click(object sender, RoutedEventArgs e) { if (tbBus.Text.Equals("")) { lbNotice.Content = "未输入公交号!"; return; } MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); if (mysql.UpdateData("DELETE FROM businfo WHERE no = '" + tbBus.Text + "';") > 0) { //链表!! for (int i = 1; i <= busLinkList.Length(); i++) { if (busLinkList.IndexOf(i).BusNo.Equals(tbBus.Text)) { busLinkList.Delete(i); } } //链表!! lbNotice.Content = "删除成功。"; initListBox(); } else { lbNotice.Content = "删除失败。"; } mysql.Close(); }
private void bt_station_del_Click(object sender, RoutedEventArgs e) { if (tbStation.Text.Equals("")) { lbNotice.Content = "未输入站点名!"; return; } MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); if (mysql.UpdateData("DELETE FROM station WHERE name = '" + tbStation.Text + "';") > 0) { //链表!! for (int i = 1; i <= stationLinkList.Length(); i++) { if (stationLinkList.IndexOf(i).Name.Equals(tbStation.Text)) { stationLinkList.Delete(i); } } //链表!! lbNotice.Content = "删除成功。"; initListBox(); } else { lbNotice.Content = "删除失败。"; } mysql.Close(); }
private void bt_acc_del_Click(object sender, RoutedEventArgs e) { if (tbAcc.Text.Equals("")) { lbNotice.Content = "未输入用户名"; return; } MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); if (mysql.UpdateData("DELETE FROM manager WHERE username = '******';") > 0) { //链表!! for (int i = 1; i <= managerLinkLists.Length(); i++) { if (managerLinkLists.IndexOf(i).Username.Equals(tbAcc.Text)) { managerLinkLists.Delete(i); } } //链表!! lbNotice.Content = "删除成功。"; initListBox(); } else { lbNotice.Content = "删除失败。"; } mysql.Close(); }
private void bt_station_edit_Click(object sender, RoutedEventArgs e) { if (stationListBox.SelectedIndex == -1) { lbNotice.Content = "未选中编辑对象!"; return; } try { Int32.Parse(tbDis.Text); } catch (FormatException error) { lbNotice.Content = "里程必须是数字!"; return; } MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); string sql = "UPDATE station SET name = '" + tbStation.Text + "',distance = '" + tbDis.Text + "' WHERE id = " + stationLinkList.IndexOf(stationListBox.SelectedIndex + 1).ID + ";"; if (mysql.UpdateData(sql) > 0) { //链表!! stationLinkList.IndexOf(stationListBox.SelectedIndex + 1).Distance = Int32.Parse(tbDis.Text); stationLinkList.IndexOf(stationListBox.SelectedIndex + 1).Name = tbStation.Text; //链表!! lbNotice.Content = "更新成功。"; initListBox(); } else { lbNotice.Content = "更新失败。"; } mysql.Close(); }
private void bt_acc_edit_Click(object sender, RoutedEventArgs e) { if (userListBox.SelectedIndex == -1) { lbNotice.Content = "未选中编辑对象!"; return; } try { Int32.Parse(tbLv.Text); } catch (FormatException error) { lbNotice.Content = "权限必须是数字!"; return; } MysqlUtil mysql = new MysqlUtil(); mysql.GetConnection(); if (mysql.UpdateData("UPDATE manager SET username = '******',password = '******',level = '" + tbLv.Text + "' WHERE id = " + managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).ID + ";") > 0) { //链表!! managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).Level = Int32.Parse(tbLv.Text); managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).Username = tbAcc.Text; managerLinkLists.IndexOf(userListBox.SelectedIndex + 1).Password = tbPw.Text; //链表!! lbNotice.Content = "更新成功。"; initListBox(); } else { lbNotice.Content = "更新失败。"; } mysql.Close(); }