Exemplo n.º 1
0
        }//获得第一个表中的数据

        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                Member  SelectedElement  = (Member)dataGrid.SelectedItem;
                Member2 SelectedElement1 = (Member2)dataGrid1.SelectedItem;
                if (SelectedElement != null && SelectedElement1 != null)
                {
                    string result1 = SelectedElement.Name.ToString();//获得当前病历号
                    //string result = SelectedElement1.Num.ToString();//获得该病历号的次数
                    int    a             = Convert.ToInt32(SelectedElement1.Num) - 1;
                    string result        = Numtoshow.ElementAt(a); //获得该病历号的次数
                    string NameToDispaly = result1 + result;       //获得需要显示的文件名
                    //在这里添加显示的代码

                    //显示单点还是显示足底根据IsForfoot判断
                    if (IsForfoot)
                    {
                        ContentControlDisplay.Content = new FootShow(NameToDispaly);
                    }
                    else
                    {
                        ContentControlDisplay.Content = new SingleShow(NameToDispaly);
                    }
                }
            }
            catch
            {
            }
        }//获得第二个表中的数据
Exemplo n.º 2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)//删除记录按钮按下
        {
            string  NameToDelete     = null;
            string  NameToDelete1    = null;
            bool    DetelteAll       = false;
            int     max_delete       = 0;
            bool    delete           = false;
            Member  SelectedElement  = (Member)dataGrid.SelectedItem;
            Member2 SelectedElement1 = (Member2)dataGrid1.SelectedItem;

            if (SelectedElement == null)
            {
                CMessageBox.Show("请首先选择一个病人信息!", CMessageBoxButton.OK);
            }
            else
            {
                if (SelectedElement1 == null)
                {
                    CMessageBoxResult confirmToDel = CMessageBox.Show("确定要删除该病人的所有记录吗?", CMessageBoxButton.OKCancel);
                    if (confirmToDel == CMessageBoxResult.OK)
                    {
                        CMessageBoxResult confirmToDel2 = CMessageBox.Show("您确定吗?", CMessageBoxButton.OKCancel);
                        if (confirmToDel2 == CMessageBoxResult.OK)
                        {
                            if (SelectedElement != null)
                            {
                                string result1 = SelectedElement.Name.ToString();//获得当前病历号
                                NameToDelete  = result1;
                                NameToDelete1 = result1;
                                HMSDATA.Connect();
                                HMSDATA.SheetCon();
                                HMSDATA.DeleteRows(result1);
                                HMSDATA.CloseCon();
                                DetelteAll = true;
                                max_delete = dataGrid1.Items.Count;
                                delete     = true;
                            }
                        }
                    }
                }
                else
                {
                    CMessageBoxResult confirmToDel = CMessageBox.Show("确定要删除该条记录吗?", CMessageBoxButton.OKCancel);
                    if (confirmToDel == CMessageBoxResult.OK)
                    {
                        SelectRowNum_Change = dataGrid.SelectedIndex;
                        if (SelectedElement != null && SelectedElement1 != null)
                        {
                            string result1 = SelectedElement.Name.ToString();//获得当前病历号
                            //string result = SelectedElement1.Num.ToString();//获得该病历号的次数
                            int    a      = Convert.ToInt32(SelectedElement1.Num) - 1;
                            string result = Numtoshow.ElementAt(a);//获得该病历号的次数
                            NameToDelete  = result1 + result + ".fot";
                            NameToDelete1 = result1;
                            DetelteAll    = false;
                            HMSDATA.Connect();
                            HMSDATA.SheetCon();
                            HMSDATA.DeleteRow(result1 + result);
                            HMSDATA.CloseCon();
                            delete = true;
                        }
                    }
                }
                if (delete)
                {
                    //重新载入表格2
                    HMSDATA.Clear();
                    if (IsForfoot)
                    {
                        HMSDATA.SetPlace("TestData.accdb");
                        FileName = "TestData.accdb";
                    }
                    else
                    {
                        HMSDATA.SetPlace("TestData2.accdb");
                        FileName = "TestData2.accdb";
                    }
                    Saved = true;
                    LoadFile();
                    if (HMSDATA.IfCon == false)
                    {
                        CMessageBox.Show("连接失败!", CMessageBoxButton.OK);
                    }
                    DataGridView1.DataSource = HMSDATA.GetData().Tables[0];
                    for (int i = 0; i < 12; i++)
                    {
                        DataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; DataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    }
                    if (dataGrid_SelectedElement != null)
                    {
                        string result = dataGrid_SelectedElement.Name.ToString();
                        choosed = Convert.ToInt32(result);

                        Searchboard.Clear();
                        final[0]  = null;                                     //床号
                        final[1]  = null;                                     //性别
                        final[2]  = dataGrid_SelectedElement.Name.ToString(); //病历号
                        final[3]  = dataGrid_SelectedElement.Age.ToString();  //姓名
                        final[4]  = null;                                     //年龄
                        final[5]  = null;                                     //最大次数
                        final[6]  = null;                                     //住院日期
                        final[7]  = null;                                     //次数
                        final[8]  = null;                                     //备注
                        final[9]  = null;                                     //发布日期
                        final[10] = null;                                     //修改日期
                        LoadGrid1();
                        fflushSearch(dpt.Search(final, Date, SearchOpiton));
                        SearchboardOpen          = true;
                        DataGridView1.DataSource = Searchboard;
                        for (int i = 0; i < 12; i++)
                        {
                            DataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        }
                        LoadGrid2();

                        try
                        {
                            DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(SelectRowNum_Change);
                            if (row == null)
                            {
                                dataGrid.UpdateLayout();
                                dataGrid.ScrollIntoView(dataGrid.Items[SelectRowNum_Change]);
                                row            = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(SelectRowNum_Change);
                                row.IsSelected = true;
                            }
                        }
                        catch
                        {
                        }
                        if (DetelteAll == false)
                        {
                            if (IsForfoot)
                            {
                                if (System.IO.File.Exists("footshow/" + NameToDelete))
                                {
                                    System.IO.File.Delete("footshow/" + NameToDelete);
                                }
                            }
                            else
                            {
                                if (System.IO.File.Exists("singleshow/" + NameToDelete))
                                {
                                    System.IO.File.Delete("singleshow/" + NameToDelete);
                                }
                            }
                        }
                        else
                        {
                            if (IsForfoot)
                            {
                                for (int i = 1; i < max_delete + 1; i++)
                                {
                                    if (System.IO.File.Exists("footshow/" + NameToDelete1 + i.ToString() + ".fot"))
                                    {
                                        System.IO.File.Delete("footshow/" + NameToDelete1 + i.ToString() + ".fot");
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 1; i < max_delete + 1; i++)
                                {
                                    if (System.IO.File.Exists("singleshow/" + NameToDelete1 + i.ToString() + ".fot"))
                                    {
                                        System.IO.File.Delete("singleshow/" + NameToDelete1 + i.ToString() + ".fot");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }