C#--工作笔记(检索页面)

<Window x:Class="Health365IIProjectView.PatientCases"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Ctrl="clr-namespace:Health365IIProjectView"
        xmlns:my="clr-namespace:Health365IIProjectView"
        Title="PatientCases" 
        Height="560" Width="800" MinHeight="560" MinWidth="800" Loaded="Window_Loaded" 
        x:Name="Windows"
        
        >
    <Window.Resources>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="BorderBrush" Value="#000000"/>
            <Setter Property="BorderThickness" Value="2"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="AllowDrop" Value="True"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"  CornerRadius="5" Background="{TemplateBinding Background}">
                            <ScrollViewer x:Name="PART_ContentHost"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
      
    </Window.Resources>

        <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <WrapPanel Orientation="Horizontal" Grid.Row="0" >

            <StackPanel  Height="40" Width="Auto" Margin="10" Orientation="Horizontal" >

                <Label Content="用户姓名"  Width="60" Height="35" Margin="5" />
                <TextBox Name="TextBoxName"   Width="150" Height="25"  TextChanged="TextBoxAllocationNum_TextChanged"/>
                <Label Content="用户编号"  Width="60" Height="35" Margin="5"/>
                <TextBox Name="TextBoxNum"  Width="150" Height="25" TextChanged="TextBoxAllocationNum_TextChanged" />
                <Label Content="文件名称"  Width="60" Height="35" Margin="5" />
                <TextBox Name="TextBoxFileName"  Width="150" Height="25" TextChanged="TextBoxAllocationNum_TextChanged" />
            </StackPanel>

            <StackPanel Height="40" Width="Auto" Orientation="Horizontal" Margin="10" >
                <Label Content="分配客服编号"   Width="85" Height="35" Margin="5"  />
                <TextBox Name="TextBoxAllocationNum"   Width="150" Height="25" TextChanged="TextBoxAllocationNum_TextChanged" />
                <Label Content="生成客服编号"   Width="85" Height="35" Margin="5"/>
                <TextBox Name="TextBoxCreateNum"   Width="150" Height="25" TextChanged="TextBoxAllocationNum_TextChanged" />
            
        </StackPanel>

            <StackPanel  Height="40" Width="Auto"  Orientation="Horizontal" Margin="10">
                <Label Content="专家评估报告生成时间范围"  Width="170" Height="35" Margin="5" />
                    <Label Content="开始时间"  Width="60" Height="35" Margin="5" />
                <Ctrl:DateTimeControl x:Name="dateTimeControlstart"  Width="150" Height="35" Margin="5,1,5,5"/>
                    <Label  Content="结束时间"  Width="60" Height="35" Margin="5" />
                    <my:DateTimeControl x:Name="dateTimeControlend"  Width="150" Height="35" Margin="5,1,5,5" />
                <!--<Button Content="时间清零" Height="20" Name="btn1" Width="58" Margin="10" Click="btn_TimeOnClick" />-->
                    <Button Content="检索"  Height="30" Name="btn" Width="65"   Click="btnCommit_Click" />
            </StackPanel>

            <StackPanel  Height="40" Width="Auto"  Orientation="Horizontal" Margin="10" >
                <Label  Content="专家评估报告状态"  Width="110" Height="25" Margin="5" />
                    <CheckBox Content="未生成"  Height="15" Width="50" Name="checkBox1"  IsChecked="True" />
                    <CheckBox Content="未提交" Height="15" Name="checkBox2" Width="50" IsChecked="True" />
            <!--<CheckBox Content="未审核" Height="20" Name="checkBox3" IsChecked="False"  />
            <CheckBox Content="未发布" Height="20" Name="checkBox4" IsChecked="False" />-->
                    <CheckBox Content="已发布"  Height="15" Name="checkBox5" Width="50" IsChecked="False" />
            </StackPanel>
          
        </WrapPanel>

        <DataGrid x:Name="dataGrid"  CanUserAddRows="False"  Background="White"  AutoGenerateColumns="True" ColumnWidth="140" Grid.Row="1" ItemsSource="{Binding}" IsReadOnly="True" SelectionUnit="FullRow" SelectionMode="Single" Sorting="dataGrdi_Sorting">
            <DataGrid.RowHeaderStyle>
                <Style TargetType="DataGridRowHeader" >  
                    <Setter Property="Width" Value="15"/>
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                <GradientStop Color="White" Offset="0" />
                                <GradientStop Color="#323433" Offset="1" />
                            </LinearGradientBrush>   
                        </Setter.Value> 
                    </Setter> 
                  </Style>
                </DataGrid.RowHeaderStyle>


           


            <DataGrid.RowStyle>
                <Style  TargetType="DataGridRow">
                    <Setter Property="Background" Value="#e7e7e7" />
                    <Setter Property="Height" Value="25"/>
                    <Setter Property="Foreground" Value="Black" />
                    <Style.Triggers>
                        <!--隔行换色-->
                        <Trigger Property="AlternationIndex" Value="0" >
                            <Setter Property="Background" Value="#e7e7e7" />
                        </Trigger>
                        <Trigger Property="AlternationIndex" Value="1" >
                            <Setter Property="Background" Value="#f2f2f2" />
                        </Trigger>

                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="LightGray"/>
                            
                        </Trigger>

                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="Black"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.RowStyle>

        </DataGrid>


    </Grid>
</Window>

========================================================

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.ComponentModel;

using Health365IIProjectBLL;

namespace Health365IIProjectView
{

    /// <summary>
    /// PatientCases.xaml 的交互逻辑
    /// </summary>
    public partial class PatientCases : Window
    {
        private PopupWindows pw;
        /// <summary>
        /// 当前应用程序
        /// </summary>
        private App _thisApplication;

        //当前主逻辑类
        private Health365IIMainLogic _mainLogic;

        DataTable dt;
        /// <summary>
        /// 添加一行数据
        /// </summary>
        DataRow dr;
        /// <summary>
        /// 开始时间
        /// </summary>
        private string start;
        /// <summary>
        /// 结束时间
        /// </summary>
        private string end;
        /// <summary>
        /// 主窗口
        /// </summary>
        private MainAnalysis wm;
    
        /// <summary>
        /// 记录返回状态
        /// </summary>
        private bool _fir;
        /// <summary>
        /// 记录返回信息
        /// </summary>
        private string _msgin;
        /// <summary>
        /// 用来控制排序的变量
        /// </summary>
        private  bool fir = false;
        public PatientCases()
        {
            _thisApplication = (App)Application.Current;
            _mainLogic = _thisApplication.MainLogic;
            InitializeComponent();

        }
    
        private void btnCommit_Click(object sender, RoutedEventArgs e)
        {
         
            DataRow(0,0);
            
            if (_fir == false)
            {


                Messenger mes = new Messenger();
                mes.Message("提示信息", _msgin);
            }else if (dataGrid.Columns.Count == 0)
            {
               //MessageBox.Show("当前状态没有数据");
                //messenger.Message("提示信息", "当前状态没有数据");
                Messenger mes = new Messenger();
                mes.Message("提示信息", "当前状态没有数据");
            }
          
        }

        void dataGrid_LayoutUpdated(object sender, EventArgs e)
        {
         
            if (dataGrid.Columns.Count >= 14)
            {
                //隐藏行号
                dataGrid.Columns[12].Visibility = Visibility.Hidden;
                dataGrid.Columns[13].Visibility = Visibility.Hidden;
            }
        }

       
        private void MoneyGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
          
        }
        
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
        
           DataRow(0,0);
          
        
        }
        private void DataRow(int SortIndex,int SortType)
        {
            UserStateList(SortIndex, SortType);
            dt = new DataTable();
            Grid_AddDataLine(dt);
           
            List<UserInfo_BLL> list = _mainLogic.WebQueryReportList();
       
                //数据处理
                foreach (UserInfo_BLL uif in list)
                {

                    dr = dt.NewRow();
                    dr[0] = uif.firstfilename;
                    dr[1] = uif.membercode;
                    dr[2] = uif.username;
                    dr[3] = uif.status;
                    dr[4] = uif.usercode;
                    dr[5] = uif.distributetime;
                    dr[6] = uif.usercode1;
                    dr[7] = uif.servicetime;
                    dr[8] = uif.datatype;
                    dr[9] = uif.structlen;
                    dr[10] = uif.auditingtime;
                    dr[11] = uif.usercode2;
                    dr[12] = uif.monitorid;
                    dr[13] = uif.mserviceid;
                    dt.Rows.Add(dr);
                    dt.AcceptChanges();

                }
            
                dataGrid.LayoutUpdated += new EventHandler(dataGrid_LayoutUpdated);

                dataGrid.MouseDoubleClick += new MouseButtonEventHandler(dataGrid_MouseDoubleClick);
                
                dataGrid.ItemsSource = dt.DefaultView;
            
        }
        /// <summary>
        /// 双击处理DataGird
        /// </summary>
        void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {

            //这块写成null是为了不让第一行被触发
            if (this.dataGrid.SelectedItem == null)
            {
                return;
            }
           

            DataRowItem();
            _mainLogic.GetUserInfoReportByMserviceid();
      
            
            if (pw != null) pw.Close();
            pw = new PopupWindows();
            
            pw.Closed += new EventHandler(pw_Closed);
            pw.ShowDialog();
            this.dataGrid.SelectedItem = null;
        }
        
        void pw_Closed(object sender, EventArgs e)
        {
            if (wm != null) wm.Close();
            wm = new MainAnalysis();
            wm.Title = string.Format("数据文件名:{0}", _mainLogic.UserInfomation.firstfilename);
            wm.textBlockUser.Text = string.Format("用户姓名:{0}   性别:{1}   年龄:{2}", _mainLogic.UserInfomation.fullname, _mainLogic.UserInfomation.sex, _mainLogic.UserInfomation.age);
            wm.textBlockTime.Text = string.Format("采集开始时间:{0}     采集持续时间:{1}", _mainLogic.UserInfomation.starttime, _mainLogic.UserInfomation.timespan);

            wm.WindowState = WindowState.Maximized;
            wm.ShowDialog();
        }

        
        /// <summary>
        /// 提取出来非必须输入的内容
        /// </summary>
        private void UserStateList(int SortIndex, int SortType)
        {
            string username = TextBoxName.Text;
            string membercode = TextBoxNum.Text;
            string firstfilename = TextBoxFileName.Text;
            string usercode2 = TextBoxAllocationNum.Text;
            string usercode1 = TextBoxCreateNum.Text;

            string _startTime = this.dateTimeControlstart.SelectedDateTimesFromTextbox;
            string _endTime = this.dateTimeControlend.SelectedDateTimesFromTextbox;

            if (_startTime.Equals(_endTime))
            {
                start = "1970-1-1 00:00:00";
                
                end = "1970-1-1 00:00:00";
            }
            else
            {

                start = this.dateTimeControlstart.SelectedDateTimesFromTextbox;
                end = this.dateTimeControlend.SelectedDateTimesFromTextbox;

            }
          
            string Cheack1 = (checkBox1.IsChecked == true ? "1" : "0");
            string Cheack2 = (checkBox2.IsChecked == true ? "1" : "0");
            //string Cheack3 = (checkBox3.IsChecked == true ? "1" : "0");
            //string Cheack4 = (checkBox4.IsChecked == true ? "1" : "0");
            string Cheack5 = (checkBox5.IsChecked == true ? "1" : "0");
            string reportStatue = Cheack1 + Cheack2 + "0" + "0" + Cheack5 + "00000";

            string msgin;
            _fir = _mainLogic.Web_QueryReportListIn(out msgin,username,
            membercode, firstfilename, usercode2,
            usercode1, start,
                end,SortIndex,SortType, reportStatue);
            _msgin = msgin;
         
        }
        /// <summary>
        /// 返回单行数据
        /// </summary>
        /// <returns></returns>
        public void DataRowItem()
        {
            DataRowView m = (DataRowView)dataGrid.SelectedItem;
            DataRow dr = m.Row; 
            object[] obj = dr.ItemArray;
             
            _mainLogic.SoloMessage(obj);

        }



        /// <summary>
        /// 添加的标题头
        /// </summary>
        /// <param name="dt"></param>
        private void Grid_AddDataLine(DataTable dt)
        {

            dt.Columns.Add(new DataColumn("数据文件名"));
            dt.Columns.Add(new DataColumn("用户编号"));
            dt.Columns.Add(new DataColumn("用户姓名"));
            dt.Columns.Add(new DataColumn("状态"));
            dt.Columns.Add(new DataColumn("分配客服编号"));
            dt.Columns.Add(new DataColumn("专家评估报告分配时间"));
            dt.Columns.Add(new DataColumn("生成客服编号"));
            dt.Columns.Add(new DataColumn("专家评估生成时间"));
            dt.Columns.Add(new DataColumn("数据类型"));
            dt.Columns.Add(new DataColumn("文件大小"));
            dt.Columns.Add(new DataColumn("发布时间"));
            dt.Columns.Add(new DataColumn("发布人编号"));
            dt.Columns.Add(new DataColumn("数据编号"));
            dt.Columns.Add(new DataColumn("报告数据编号"));
        }


        private void TextBoxAllocationNum_TextChanged(object sender, TextChangedEventArgs e)
       {
            TextBox tb = (TextBox)sender;
           
            if (tb.Text != tb.Text.TrimEnd())
            {
                tb.Text = tb.Text.Trim();
                tb.SelectionStart = tb.Text.Length;
                tb.Focus();
            }
            else if (tb.Text != tb.Text.TrimStart())
            {
                tb.Text = tb.Text.Trim();
                tb.SelectionStart = 0;
                tb.Focus();
            }
        }
       
        private void dataGrdi_Sorting(object sender, DataGridSortingEventArgs e)
        {
            //DataGrid dt = (DataGrid)sender;
            int i = dataGrid.Columns.IndexOf(e.Column);
            
            if (fir == false)
            {
                DataRow(i + 1, 0);
                fir = true;
            }
            else
            {
                DataRow(i + 1, 1);
                fir = false;
            }
            
            //object[] obj = dr.ItemArray;
            e.Handled = true;
            
        }

    }
 
}

=======================================================

开启一个窗口,当前窗口最小化不可操作

 //外部声明
 private PopupWindows pw;
//要触发跳转的地方
if (pw != null) pw.Close();
            pw = new PopupWindows();
            
            pw.Closed += new EventHandler(pw_Closed);
            pw.ShowDialog();
//关闭事件
      void pw_Closed(object sender, EventArgs e)
        {
            if (wm != null) wm.Close();
            wm = new MainAnalysis();
            wm.Title = string.Format("数据文件名:{0}", _mainLogic.UserInfomation.firstfilename);
            wm.textBlockUser.Text = string.Format("用户姓名:{0}   性别:{1}   年龄:{2}", _mainLogic.UserInfomation.fullname, _mainLogic.UserInfomation.sex, _mainLogic.UserInfomation.age);
            wm.textBlockTime.Text = string.Format("采集开始时间:{0}     采集持续时间:{1}", _mainLogic.UserInfomation.starttime, _mainLogic.UserInfomation.timespan);

            wm.WindowState = WindowState.Maximized;
            wm.ShowDialog();
        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值