private void bt_Delete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("คุณต้องการลบข้อมูลที่เช็คหรือไม่", "ลบข้อมูลนี้แล้ว", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                for (int i = 0; i < dataGrid.Items.Count; i++)
                {
                    DataGridRow item   = (DataGridRow)this.dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.Items[i]);
                    CheckBox    cbkdel = (CheckBox)GetVisualChild <CheckBox>(item);

                    if (cbkdel.IsChecked.Value)
                    {
                        object itemz  = dataGrid.Items[i];
                        string showid = (dataGrid.SelectedCells[9].Column.GetCellContent(itemz) as TextBlock).Text;
                        con.Open();
                        string       sql = "DELETE from checkwork where checkworkID='" + showid + "'";
                        MySqlCommand cmd = new MySqlCommand(sql, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }
                MessageBox.Show("ลบเรียบร้อยแล้ว!!!");
                this.Close();
                ManageCheckwork go = new ManageCheckwork();
                go.Show();
            }
        } //ปิด Event Delete
Ejemplo n.º 2
0
        private void MenuItem3_Click(object sender, RoutedEventArgs e)
        {
            ManageCheckwork go = new ManageCheckwork();

            go.Show();
        }