public searchByDeptID() { InitializeComponent(); conn = new MySqlConnection(cs); conn.Open(); depIdSearch.Hide(); Search_button.Show(); }
private void DeletAccount_Click(object sender, RoutedEventArgs e) { SqlCommand cmd = new SqlCommand(); cmd.Connection = Temp.GetConn(); if (MessageBox.Show("您确定要删除该账号吗?", "系统提示:", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { try { cmd.CommandText = "delete from ArmsUsers where Usersname= '" + Accounts.Text.ToString() + "'"; cmd.ExecuteNonQuery(); } catch (Exception ae) { MessageBox.Show("删除失败!"); } } SearchText.Text = TempSearch; Accounts.ItemsSource = null; Search_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); }
private void Submit_Click(object sender, RoutedEventArgs e) { try { SqlCommandBuilder sqlcb = new SqlCommandBuilder(ado); SqlCommandBuilder sqlcb1 = new SqlCommandBuilder(bdo); Mydataset.Tables["person"].Rows[0]["RyId"] = number.Text; Mydataset.Tables["person"].Rows[0]["RyName"] = name.Text; Mydataset.Tables["person"].Rows[0]["Sex"] = sex.SelectionBoxItem.ToString(); Mydataset.Tables["person"].Rows[0]["Title"] = post.Text; Mydataset.Tables["person"].Rows[0]["Nationalty"] = nation.Text; Mydataset.Tables["person"].Rows[0]["Marital_Condition"] = maritalstatus.SelectionBoxItem.ToString(); Mydataset.Tables["person"].Rows[0]["Birth"] = birthday.Text; Mydataset.Tables["person"].Rows[0]["Rank"] = rank.Text; Mydataset.Tables["person"].Rows[0]["Culture_Level"] = Education_level.Text; Mydataset.Tables["person"].Rows[0]["Family_Place"] = Family_Place.Text; Mydataset.Tables["person"].Rows[0]["Political_Party"] = Politicalstatus.Text; Mydataset.Tables["person"].Rows[0]["Id_Card"] = id.Text; Mydataset.Tables["person"].Rows[0]["Dep_Id"] = DepartmentNum.Text; Mydataset.Tables["person"].Rows[0]["Position"] = jobs.Text; Mydataset.Tables["person"].Rows[0]["UpperId"] = LeadershipNum.Text; AccountSet.Tables[0].Rows[Accounts.SelectedIndex]["User_type"] = Competence.SelectionBoxItem.ToString(); bdo.Update(AccountSet, "Table1"); AccountSet.Tables["Table1"].AcceptChanges(); ado.Update(Mydataset, "person"); Mydataset.Tables["person"].AcceptChanges(); } catch (Exception se) { MessageBox.Show("提交失败!" + se); return; } MessageBox.Show("修改成功!"); Search_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); }