(排班表二)后台动态绘制Grid表格
后台动态绘制值班表(Grid表格 列名不固定)
要求:表头除了值班人姓名,还要显示日期,及每天的星期值,用斜杠‘/’分隔。即:几号/星期几
最终实现的效果:根据查询的年月显示每个值班人查询月份每天的值班信息
注:当查询月份不足31天时,显示空白列。如下图:
1.前台页面(WPF页面.xaml)显示
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height=""></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<!--<RowDefinition Height=""></RowDefinition>
<RowDefinition Height="0.5*"></RowDefinition>-->
</Grid.RowDefinitions> <!--筛选条件-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=""></ColumnDefinition>
<ColumnDefinition Width=""></ColumnDefinition>
<ColumnDefinition Width=""></ColumnDefinition>
<ColumnDefinition Width=""></ColumnDefinition>
<ColumnDefinition Width=""></ColumnDefinition>
<ColumnDefinition Width=""></ColumnDefinition>
</Grid.ColumnDefinitions> <!-- 日期星期(方法一)-->
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="5 0">
<TextBlock Text=" 年度:" VerticalAlignment="Center"></TextBlock>
<telerik:RadComboBox x:Name="rcb_year" VerticalAlignment="Center" HorizontalContentAlignment="Right" Width="" SelectionChanged="rcb_year_SelectionChanged"/>
</StackPanel> <StackPanel Grid.Column="" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text=" 月份:" VerticalAlignment="Center"></TextBlock>
<telerik:RadComboBox x:Name="rcb_month" VerticalAlignment="Center" HorizontalContentAlignment="Right" Width="" SelectionChanged="rcb_month_SelectionChanged"/>
</StackPanel> <!--导出-->
<telerik:RadButton Grid.Row="" Grid.Column="" x:Name="btn_export_1" Background="#FA824F" Margin="" CornerRadius="" FontSize="" Click="btn_export_1_Click">
<StackPanel Orientation="Horizontal">
<Image Source="/PMS_BZ;component/Images/edit.png" Margin="" Height=""></Image>
<TextBlock Text=" 导出值班表 " Foreground="#FFFFFF" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</telerik:RadButton>
<!--刷新-->
<telerik:RadButton Grid.Row="" Grid.Column="" x:Name="btn_refresh_1" Background="Orange" Margin="" CornerRadius="" FontSize="" Click="btn_refresh_1_Click">
<StackPanel Orientation="Horizontal">
<Image Source="/PMS_BZ;component/Images/reset.png" Margin="" Height=""></Image>
<TextBlock Text=" 刷 新 " Foreground="#FFFFFF" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</telerik:RadButton> <!--添加值班-->
<telerik:RadButton Grid.Row="" Grid.Column="" x:Name="btn_add_schedule" Background="#1DA02B" Margin="" CornerRadius="" FontSize="" Click="btn_add_schedule_Click" Visibility="Collapsed">
<StackPanel Orientation="Horizontal">
<Image Source="/PMS_BZ;component/Images/input.png" Margin="" Height=""></Image>
<TextBlock Text=" 值班信息管理 " Foreground="#FFFFFF" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</telerik:RadButton> <!--添加案件录入权限信息-->
<telerik:RadButton Grid.Row="" Grid.Column="" x:Name="btn_add_power" Background="DarkGoldenrod" Margin="" CornerRadius="" FontSize="" Click="btn_add_power_Click" Visibility="Collapsed">
<StackPanel Orientation="Horizontal">
<Image Source="/PMS_BZ;component/Images/comp.png" Margin="" Height=""></Image>
<TextBlock Text=" 案件录入权限管理 " Foreground="#FFFFFF" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</telerik:RadButton>
</Grid>
<!--排班表-->
<ScrollViewer x:Name="sv_data" Grid.Row="" BorderBrush="#25A0DA" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <Grid x:Name="rgv_schedule" Background="White" Width=""></Grid> </ScrollViewer> <!--案件录入权限表-->
<!--<StackPanel Grid.Row="" Background="#25A0DA" Orientation="Horizontal">
<Image Source="/PMS_BZ;component/Images/grid.png" Height="" Margin="5 0"></Image>
<TextBlock Text="案件录入权限表" FontSize="" VerticalAlignment="Center" Foreground="White" Margin="5 0"></TextBlock> <telerik:RadButton Grid.Row="" Grid.Column="" x:Name="btn_export_power" Background="#FA824F" Margin="5 2" CornerRadius="" FontSize="" Click="btn_export_power_Click">
<StackPanel Orientation="Horizontal">
<Image Source="/PMS_BZ;component/Images/edit.png" Margin="" Height=""></Image>
<TextBlock Text=" 导出录入权限表 " Foreground="#FFFFFF" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</telerik:RadButton>
</StackPanel> <ScrollViewer x:Name="sv_data_power" Grid.Row="" BorderBrush="#25A0DA" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Grid x:Name="rgv_power" Background="White" Width=""></Grid>
</ScrollViewer>--> </Grid>
显示页面代码
2.初始化年度、月份下拉框数据:年度只显示最近5年的年度
// 设置时间控件的默认值
private void SetDateControl()
{
try
{
RadComboBoxItem cmbi_year;
RadComboBoxItem cmbi_month;
int years = DateTime.Now.Year;
//设置年度
for (int i = ; i < ; i++)
{
int year = years - i;
cmbi_year = new RadComboBoxItem();
cmbi_year.Tag = cmbi_year.Content = year;
rcb_year.Items.Add(cmbi_year);
if (year == DateTime.Now.Year)
{
rcb_year.SelectedItem = cmbi_year;
}
}
//设置月份
for (int i = ; i <= ; i++)
{
cmbi_month = new RadComboBoxItem();
cmbi_month.Tag = i;
cmbi_month.Content = i.ToString() + "月";
rcb_month.Items.Add(cmbi_month);
}
if (Convert.ToInt32((rcb_year.SelectedItem as RadComboBoxItem).Tag) == DateTime.Now.Year)
{
rcb_month.SelectedIndex = DateTime.Now.Month - ;
}
else
rcb_month.SelectedIndex = ;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} // 窗体加载
private void Page_Loaded(object sender, RoutedEventArgs e)
{
MyRadBusy.IsBusy = true; System.Threading.ThreadPool.QueueUserWorkItem((threadState) =>
{
System.Threading.Thread.Sleep();
Dispatcher.BeginInvoke((Action)delegate()
{
try
{
SetDateControl();//时间变化
}
catch (Exception ex)
{
RadWindow.Alert(ex.Message);
}
});
});
}
设置年度、月份
3.当年度或月份发生改变时,值班表信息也相应的发生改变
//年度发生改变
private void rcb_year_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
BindingScheduleGrid();
}
//月份发生改变
private void rcb_month_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
BindingScheduleGrid();
}
下拉框改变事件
4.绑定表格数据
//绑定表格值班信息
public void BindingScheduleGrid()//rgv_schedule
{
//选择的时间
int select_year = rcb_year.SelectedItem == null ? DateTime.Now.Year : Convert.ToInt32((rcb_year.SelectedItem as RadComboBoxItem).Tag);
int select_month = rcb_month.SelectedItem == null ? DateTime.Now.Month : Convert.ToInt32((rcb_month.SelectedItem as RadComboBoxItem).Tag); #region
//判断该月有多少天
totalDays = DateTime.DaysInMonth(select_year, select_month);//selectTime.Year, selectTime.Month //清空列表
rgv_schedule.Children.Clear();
//添加第一行(表头)
RowDefinition row = new RowDefinition() { Height = new GridLength() };
rgv_schedule.RowDefinitions.Add(row);
//姓名列
ColumnDefinition col_name = new ColumnDefinition() { Width = new GridLength() };
rgv_schedule.ColumnDefinitions.Add(col_name); System.Windows.Controls.Border b_name = new System.Windows.Controls.Border() { BorderThickness = new Thickness(, , , ), BorderBrush = new SolidColorBrush(System.Windows.Media.Colors.Black) };
TextBlock txt_name = new TextBlock() { Text = "姓名", FontSize = , FontWeight = FontWeights.Black, VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
b_name.Child = txt_name;
b_name.SetValue(Grid.ColumnProperty, );//设置边框所在列
b_name.SetValue(Grid.RowProperty, );//设置边框所在行
rgv_schedule.Children.Add(b_name);//将边框添加到表格中
for (int i = ; i <= ; i++)
{
string cols = "";
if (i <= totalDays)
{
DateTime dtime = Convert.ToDateTime(select_year + "-" + select_month + "-" + i);
cols = i + "号/" + week_str[Convert.ToInt16(dtime.DayOfWeek)];
} //添加日期列 rgv_schedule
ColumnDefinition colum = new ColumnDefinition() { Width = new GridLength() };
rgv_schedule.ColumnDefinitions.Add(colum); System.Windows.Controls.Border b_3 = new System.Windows.Controls.Border() { BorderThickness = new Thickness(, , , ), BorderBrush = new SolidColorBrush(System.Windows.Media.Colors.Black) };
TextBlock txt_3 = new TextBlock() { Text = cols, FontSize = , FontWeight = FontWeights.Black, VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
b_3.Child = txt_3;
//设置TextBlock在Grid中的位置
b_3.SetValue(Grid.ColumnProperty, i);
b_3.SetValue(Grid.RowProperty, );
rgv_schedule.Children.Add(b_3);
} MyRadBusy.IsBusy = true;
System.Threading.ThreadPool.QueueUserWorkItem((threadState) =>
{
System.Threading.Thread.Sleep();
Dispatcher.BeginInvoke((Action)delegate()
{
try
{ InterFace.Service.AllSchePowerByWhereAsync(totalDays, Session.CurrentLoginUser.sysorgno, select_year, select_month);
InterFace.Service.AllSchePowerByWhereCompleted += Service_AllSchePowerByWhereCompleted;
}
catch (Exception ex)
{
RadWindow.Alert(ex.Message);
}
});
});
#endregion
}
设置值班表
//值班表与录入权限表数据合并显示:显示优先顺序班 > 录 > 休
void Service_AllSchePowerByWhereCompleted(object sender, AllSchePowerByWhereCompletedEventArgs e)
{
InterFace.Service.AllSchePowerByWhereCompleted -= Service_AllSchePowerByWhereCompleted;
try
{
if (e.Result != null && e.Result.Count() > )
{
List<ScheduleModel> ltDataSchedule = new List<ScheduleModel>();
ltDataSchedule = e.Result.ToList();
btn_export_1.IsEnabled = true; for (int i = ; i < ltDataSchedule.Count(); i++)
{
//添加行
RowDefinition row = new RowDefinition() { Height = new GridLength() };
rgv_schedule.RowDefinitions.Add(row); //姓名列
ColumnDefinition col_name = new ColumnDefinition() { Width = new GridLength() };
rgv_schedule.ColumnDefinitions.Add(col_name); System.Windows.Controls.Border b_name = new System.Windows.Controls.Border() { BorderThickness = new Thickness(, , , ), BorderBrush = new SolidColorBrush(System.Windows.Media.Colors.Black) };
TextBlock txt_name = new TextBlock() { Text = ltDataSchedule[i].name, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
b_name.Child = txt_name;
b_name.SetValue(Grid.ColumnProperty, );
b_name.SetValue(Grid.RowProperty, i + );
rgv_schedule.Children.Add(b_name); for (int j = ; j <= ; j++)
{
ColumnDefinition col_j = new ColumnDefinition() { Width = new GridLength() };
rgv_schedule.ColumnDefinitions.Add(col_j); System.Windows.Controls.Border b_j = new System.Windows.Controls.Border() { BorderThickness = new Thickness(, , , ), BorderBrush = new SolidColorBrush(System.Windows.Media.Colors.Black) };
TextBlock txt_j = null;
#region 填充列值 if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day1, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day1 != null && ltDataSchedule[i].day1.Contains("班") || ltDataSchedule[i].day1.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day2, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day2 != null && ltDataSchedule[i].day2.Contains("班") || ltDataSchedule[i].day2.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day3, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day3 != null && ltDataSchedule[i].day3.Contains("班") || ltDataSchedule[i].day3.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day4, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day4 != null && ltDataSchedule[i].day4.Contains("班") || ltDataSchedule[i].day4.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day5, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day5 != null && ltDataSchedule[i].day5.Contains("班") || ltDataSchedule[i].day5.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day6, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day6 != null && ltDataSchedule[i].day6.Contains("班") || ltDataSchedule[i].day6.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day7, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day7 != null && ltDataSchedule[i].day7.Contains("班") || ltDataSchedule[i].day7.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day8, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day8 != null && ltDataSchedule[i].day8.Contains("班") || ltDataSchedule[i].day8.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day9, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day9 != null && ltDataSchedule[i].day9.Contains("班") || ltDataSchedule[i].day9.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day10, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day10 != null && ltDataSchedule[i].day10.Contains("班") || ltDataSchedule[i].day10.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day11, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day11 != null && ltDataSchedule[i].day11.Contains("班") || ltDataSchedule[i].day11.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day12, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day12 != null && ltDataSchedule[i].day12.Contains("班") || ltDataSchedule[i].day12.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day13, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day13 != null && ltDataSchedule[i].day13.Contains("班") || ltDataSchedule[i].day13.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day14, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day14 != null && ltDataSchedule[i].day14.Contains("班") || ltDataSchedule[i].day14.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day15, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day15 != null && ltDataSchedule[i].day15.Contains("班") || ltDataSchedule[i].day15.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day16, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day16 != null && ltDataSchedule[i].day16.Contains("班") || ltDataSchedule[i].day16.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day17, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day17 != null && ltDataSchedule[i].day17.Contains("班") || ltDataSchedule[i].day17.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day18, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day18 != null && ltDataSchedule[i].day18.Contains("班") || ltDataSchedule[i].day18.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day19, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day19 != null && ltDataSchedule[i].day19.Contains("班") || ltDataSchedule[i].day19.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day20, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day20 != null && ltDataSchedule[i].day20.Contains("班") || ltDataSchedule[i].day20.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day21, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day21 != null && ltDataSchedule[i].day21.Contains("班") || ltDataSchedule[i].day21.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day22, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day22 != null && ltDataSchedule[i].day22.Contains("班") || ltDataSchedule[i].day22.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day23, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day23 != null && ltDataSchedule[i].day23.Contains("班") || ltDataSchedule[i].day23.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day24, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day24 != null && ltDataSchedule[i].day24.Contains("班") || ltDataSchedule[i].day24.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day25, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day25 != null && ltDataSchedule[i].day25.Contains("班") || ltDataSchedule[i].day25.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day26, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day26 != null && ltDataSchedule[i].day26.Contains("班") || ltDataSchedule[i].day26.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day27, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day27 != null && ltDataSchedule[i].day27.Contains("班") || ltDataSchedule[i].day27.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day28, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day28 != null && ltDataSchedule[i].day28.Contains("班") || ltDataSchedule[i].day28.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day29, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day29 != null && ltDataSchedule[i].day29.Contains("班") || ltDataSchedule[i].day29.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day30, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day30 != null && ltDataSchedule[i].day30.Contains("班") || ltDataSchedule[i].day30.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else if (j == )
{
txt_j = new TextBlock() { Text = ltDataSchedule[i].day31, FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
if (ltDataSchedule[i].day31 != null && ltDataSchedule[i].day31.Contains("班") || ltDataSchedule[i].day31.Contains("录"))
{ txt_j.Foreground = new SolidColorBrush(System.Windows.Media.Colors.Red); }
}
else
{
txt_j = new TextBlock() { Text = "", FontSize = , VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center };
} #endregion
b_j.Child = txt_j;
b_j.SetValue(Grid.ColumnProperty, j);
b_j.SetValue(Grid.RowProperty, i + );
rgv_schedule.Children.Add(b_j);
}
}
}
else
{
// RadWindow.Alert("当前查询月份暂无排班信息!");
ltDataSchedule = null;
btn_export_1.IsEnabled = false;
}
}
catch (Exception)
{
RadWindow.Alert(e.Error.Message);
}
finally { MyRadBusy.IsBusy = false; }
}
绑定值班表数据
5.Wcf获取值班表数据
/// <summary>
/// 值班表与录入权限表信息合并
/// </summary>
/// <param name="p_days">月天数</param>
/// <param name="p_sysorgno">所属机构</param>
/// <param name="p_year">年份</param>
/// <param name="p_month">月份</param>
/// <returns></returns>
[OperationContract]
public List<ScheduleModel> AllSchePowerByWhere(int p_days, string p_sysorgno, int p_year, int p_month)
{
//审核人员
string sqlStr = string.Format(@"select username ,des from sys_users where roleno = '0002' and sysorgno='{0}';", p_sysorgno); //值班表
sqlStr += string.Format(@"select schedule01 as loginname,schedule02 as name");
for (int i = ; i <= p_days; i++)
{
sqlStr += string.Format(@",max(case when scheduleday={0} then (CASE WHEN state= 1 THEN '班' ELSE '休' END) end) as day{0} ", i);
}
sqlStr += string.Format(@"from loc_schedule where sysorgno='{0}' and scheduleyear={1} and schedulemonth={2} group by schedule01,schedule02 order by schedule01 ;"
, p_sysorgno, p_year, p_month);
//录入权限表
sqlStr += string.Format(@"select power01 as loginname,power02 as name");
for (int i = ; i <= p_days; i++)
{
sqlStr += string.Format(@",max(case when powerday={0} then (CASE WHEN state= 1 THEN '录' ELSE '禁' END) end) as day{0} ", i);
}
sqlStr += string.Format(@"from loc_power where sysorgno='{0}' and poweryear={1} and powermonth={2} group by power01 ,power02 order by power01 ;"
, p_sysorgno, p_year, p_month); DataSet ds = pgSqlService.Query(sqlStr.ToString());
List<sys_users> ltdate = pgSqlService.ConvertToModel<sys_users>(ds.Tables[]); //审核人员
List<ScheduleModel> ltdata_1 = pgSqlService.ConvertToModel<ScheduleModel>(ds.Tables[]); //值班表
List<ScheduleModel> ltdata_2 = pgSqlService.ConvertToModel<ScheduleModel>(ds.Tables[]);//录入权限表 List<ScheduleModel> dataList = new List<ScheduleModel>();
var data = from t in ltdate
join t1 in ltdata_1 on t.UserName equals t1.Loginname into temp1
from a in temp1.DefaultIfEmpty()
join t2 in ltdata_2 on t.UserName equals t2.Loginname into temp2
from b in temp2.DefaultIfEmpty()
select new { t, t1 = a, t2 = b };
//取出数据
ScheduleModel _model; foreach (var item in data)
{
_model = new ScheduleModel();
_model.Loginname = item.t.UserName;//编号
_model.Name = item.t.Des;//姓名 if (item.t1 != null || item.t2 != null)
{
#region 显示的优先顺序:班>录>休 if (item.t1 != null && item.t1.Day1.Equals("班"))
_model.Day1 = item.t1.Day1;
else if (item.t2 != null && item.t2.Day1.Equals("录"))
_model.Day1 = item.t2.Day1;
else { _model.Day1 = "休"; }
if (item.t1 != null && item.t1.Day2.Equals("班"))
_model.Day2 = item.t1.Day2;
else if (item.t2 != null && item.t2.Day2.Equals("录"))
_model.Day2 = item.t2.Day2;
else { _model.Day2 = "休"; } if (item.t1 != null && item.t1.Day3.Equals("班"))
_model.Day3 = item.t1.Day3;
else if (item.t2 != null && item.t2.Day3.Equals("录"))
_model.Day3 = item.t2.Day3;
else { _model.Day3 = "休"; } if (item.t1 != null && item.t1.Day4.Equals("班"))
_model.Day4 = item.t1.Day4;
else if (item.t2 != null && item.t2.Day4.Equals("录"))
_model.Day4 = item.t2.Day4;
else { _model.Day4 = "休"; }
if (item.t1 != null && item.t1.Day5.Equals("班"))
_model.Day5 = item.t1.Day5;
else if (item.t2 != null && item.t2.Day5.Equals("录"))
_model.Day5 = item.t2.Day5;
else { _model.Day5 = "休"; } if (item.t1 != null && item.t1.Day6.Equals("班"))
_model.Day6 = item.t1.Day6;
else if (item.t2 != null && item.t2.Day6.Equals("录"))
_model.Day6 = item.t2.Day6;
else { _model.Day6 = "休"; } if (item.t1 != null && item.t1.Day7.Equals("班"))
_model.Day7 = item.t1.Day7;
else if (item.t2 != null && item.t2.Day7.Equals("录"))
_model.Day7 = item.t2.Day7;
else { _model.Day7 = "休"; } if (item.t1 != null && item.t1.Day8.Equals("班"))
_model.Day8 = item.t1.Day8;
else if (item.t2 != null && item.t2.Day8.Equals("录"))
_model.Day8 = item.t2.Day8;
else { _model.Day8 = "休"; } if (item.t1 != null && item.t1.Day9.Equals("班"))
_model.Day9 = item.t1.Day9;
else if (item.t2 != null && item.t2.Day9.Equals("录"))
_model.Day9 = item.t2.Day9;
else { _model.Day9 = "休"; }
if (item.t1 != null && item.t1.Day10.Equals("班"))
_model.Day10 = item.t1.Day10;
else if (item.t2 != null && item.t2.Day10.Equals("录"))
_model.Day10 = item.t2.Day10;
else { _model.Day10 = "休"; } if (item.t1 != null && item.t1.Day11.Equals("班"))
_model.Day11 = item.t1.Day11;
else if (item.t2 != null && item.t2.Day11.Equals("录"))
_model.Day11 = item.t2.Day11;
else { _model.Day11 = "休"; } if (item.t1 != null && item.t1.Day12.Equals("班"))
_model.Day12 = item.t1.Day12;
else if (item.t2 != null && item.t2.Day12.Equals("录"))
_model.Day12 = item.t2.Day12;
else { _model.Day12 = "休"; } if (item.t1 != null && item.t1.Day13.Equals("班"))
_model.Day13 = item.t1.Day13;
else if (item.t2 != null && item.t2.Day13.Equals("录"))
_model.Day13 = item.t2.Day13;
else { _model.Day13 = "休"; } if (item.t1 != null && item.t1.Day14.Equals("班"))
_model.Day14 = item.t1.Day14;
else if (item.t2 != null && item.t2.Day14.Equals("录"))
_model.Day14 = item.t2.Day14;
else { _model.Day14 = "休"; }
if (item.t1 != null && item.t1.Day15.Equals("班"))
_model.Day15 = item.t1.Day15;
else if (item.t2 != null && item.t2.Day15.Equals("录"))
_model.Day15 = item.t2.Day15;
else { _model.Day15 = "休"; } if (item.t1 != null && item.t1.Day16.Equals("班"))
_model.Day16 = item.t1.Day16;
else if (item.t2 != null && item.t2.Day16.Equals("录"))
_model.Day16 = item.t2.Day16;
else { _model.Day16 = "休"; } if (item.t1 != null && item.t1.Day17.Equals("班"))
_model.Day17 = item.t1.Day17;
else if (item.t2 != null && item.t2.Day17.Equals("录"))
_model.Day17 = item.t2.Day17;
else { _model.Day17 = "休"; } if (item.t1 != null && item.t1.Day18.Equals("班"))
_model.Day18 = item.t1.Day18;
else if (item.t2 != null && item.t2.Day18.Equals("录"))
_model.Day18 = item.t2.Day18;
else { _model.Day18 = "休"; } if (item.t1 != null && item.t1.Day19.Equals("班"))
_model.Day19 = item.t1.Day19;
else if (item.t2 != null && item.t2.Day19.Equals("录"))
_model.Day19 = item.t2.Day19;
else { _model.Day19 = "休"; }
if (item.t1 != null && item.t1.Day20.Equals("班"))
_model.Day20 = item.t1.Day20;
else if (item.t2 != null && item.t2.Day20.Equals("录"))
_model.Day20 = item.t2.Day20;
else { _model.Day20 = "休"; } if (item.t1 != null && item.t1.Day21.Equals("班"))
_model.Day21 = item.t1.Day21;
else if (item.t2 != null && item.t2.Day21.Equals("录"))
_model.Day21 = item.t2.Day21;
else { _model.Day21 = "休"; } if (item.t1 != null && item.t1.Day22.Equals("班"))
_model.Day22 = item.t1.Day22;
else if (item.t2 != null && item.t2.Day22.Equals("录"))
_model.Day22 = item.t2.Day22;
else { _model.Day22 = "休"; } if (item.t1 != null && item.t1.Day23.Equals("班"))
_model.Day23 = item.t1.Day23;
else if (item.t2 != null && item.t2.Day23.Equals("录"))
_model.Day23 = item.t2.Day23;
else { _model.Day23 = "休"; } if (item.t1 != null && item.t1.Day24.Equals("班"))
_model.Day24 = item.t1.Day24;
else if (item.t2 != null && item.t2.Day24.Equals("录"))
_model.Day24 = item.t2.Day24;
else { _model.Day24 = "休"; } if (item.t1 != null && item.t1.Day25.Equals("班"))
_model.Day25 = item.t1.Day25;
else if (item.t2 != null && item.t2.Day25.Equals("录"))
_model.Day25 = item.t2.Day25;
else { _model.Day25 = "休"; }
if (item.t1 != null && item.t1.Day26.Equals("班"))
_model.Day26 = item.t1.Day26;
else if (item.t2 != null && item.t2.Day26.Equals("录"))
_model.Day26 = item.t2.Day26;
else { _model.Day26 = "休"; } if (item.t1 != null && item.t1.Day27.Equals("班"))
_model.Day27 = item.t1.Day27;
else if (item.t2 != null && item.t2.Day27.Equals("录"))
_model.Day27 = item.t2.Day27;
else { _model.Day27 = "休"; } if (item.t1 != null && item.t1.Day28.Equals("班"))
_model.Day28 = item.t1.Day28;
else if (item.t2 != null && item.t2.Day28.Equals("录"))
_model.Day28 = item.t2.Day28;
else { _model.Day28 = "休"; } if ((item.t1 != null && !string.IsNullOrEmpty(item.t1.Day29)) || (item.t2 != null && !string.IsNullOrEmpty(item.t2.Day29)))
{
if (item.t1 != null && item.t1.Day29.Equals("班"))
_model.Day29 = item.t1.Day29;
else if (item.t2 != null && item.t2.Day29.Equals("录"))
_model.Day29 = item.t2.Day29;
else { _model.Day29 = "休"; }
}
else _model.Day29 = ""; if ((item.t1 != null && !string.IsNullOrEmpty(item.t1.Day30)) || (item.t2 != null && !string.IsNullOrEmpty(item.t2.Day30)))
{
if (item.t1 != null && item.t1.Day30.Equals("班"))
_model.Day30 = item.t1.Day30;
else if (item.t2 != null && item.t2.Day30.Equals("录"))
_model.Day30 = item.t2.Day30;
else { _model.Day30 = "休"; }
}
else _model.Day30 = ""; if ((item.t1 != null && !string.IsNullOrEmpty(item.t1.Day31)) || (item.t2 != null && !string.IsNullOrEmpty(item.t2.Day31)))
{
if (item.t1 != null && item.t1.Day31.Equals("班"))
_model.Day31 = item.t1.Day31;
else if (item.t2 != null && item.t2.Day31.Equals("录"))
_model.Day31 = item.t2.Day31;
else { _model.Day31 = "休"; }
}
else _model.Day31 = ""; #endregion dataList.Add(_model);
}
} return dataList;
}
WCF
(排班表二)后台动态绘制Grid表格的更多相关文章
- C#后台动态添加Grid表格
前面页面: <ScrollViewer x:Name=" BorderBrush="#25A0DA" VerticalScrollBarVisibility=&qu ...
- (排班表三)导出列名不固定的Grid表格到Excel
将班表信息导出Excel表格保存到本地 要求:文档名称为[XXXX]年X月值班表 文档显示的效果: 实现代码: //导出Excel值班表 private void btn_export_1_Click ...
- 使用SQL语句使数据从坚向排列转化成横向排列(排班表)
知识重点: 1.extract(day from schedule01::timestamp)=13 Extract 属于 SQL 的 DML(即数据库管理语言)函数,同样,InterBase 也支持 ...
- (排班表一)使用SQL语句使数据从坚向排列转化成横向排列
知识重点: 1.extract(day from schedule01::timestamp)=13 Extract 属于 SQL 的 DML(即数据库管理语言)函数,同样,InterBase 也支持 ...
- 翻翻git之---可用作课程表/排班表的自定义table库ScrollTableView
转载请注明出处:王亟亟的大牛之路 最近一直在写混合开发的东西,是时候温故下native的了. 一年多之前领导提了一个双性滚动+快点击的"TableView"那时候自己整了2 3天没 ...
- sencha/extjs 动态创建grid表格
//创建普通表格 id,父容器,标题,json数据字符串,列名(逗号分隔),json数据key即store的fields属性(逗号分隔) function createCommonTable(id, ...
- c++实现医院检验科排班程序
c++实现医院检验科排班程序 1.背景: 医院急诊检验科24h×7×365值班.工作人员固定.採取轮班制度.确保24h都有人值班. 本文就通过C++实现编敲代码自己主动排班,并能够转为Excel打印. ...
- iOS可视化动态绘制连通图
上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...
- Unity UGUI图文混排源码(二)
Unity UGUI图文混排源码(一):http://blog.csdn.net/qq992817263/article/details/51112304 Unity UGUI图文混排源码(二):ht ...
随机推荐
- keepalived双机热备实现故障时发送邮件通知
目前项目已经采用nginx来实现负载均衡,但是nginx调度器只有一台,上次还意外的down机一次,导致整个服务应用全部瘫痪,这次准备再加一个调度器来实现站点高可用性,也就是常说的双机热备了. mas ...
- pat1088. Rational Arithmetic (20)
1088. Rational Arithmetic (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue F ...
- java时间处理工具类--DateUtils
package com.hexiang.utils; /** * @(#)DateUtil.java * * * @author kidd * @version 1.00 2007/8/8 */ im ...
- Flex Validator的小BUG
Flex中对同一控件如TextInput进行多种格式校验的情况下,如不注意,可能导致错误信息不显示的BUG,比如 <fx:Array id="validators"> ...
- Vue.js基础语法(二)组件
vue学习的一系列,全部来自于表哥---表严肃,是我遇到过的讲课最通透,英文发音最好听的老师,想一起听课就去这里吧 https://biaoyansu.com/i/hzhj1206 把一段经常要用的东 ...
- (开发)bable - es6转码
参考:http://www.ruanyifeng.com/blog/2016/01/babel.html Babel Babel是一个广泛使用的转码器,可以将ES6代码转为ES5代码,从而在现有环境执 ...
- php支付走过的坑(支付宝篇 注册 秘钥 环境等等配置)
支付这东西,说容易也容易,说难也难 代码这玩意还比较好说 但是 如果没有demo 直接去看官方文档 十有八九一脸懵逼 今天就整理一下 支付这块走过的坑 涉及 微信h5支付 支付宝h5支付 (api文档 ...
- Win10 设备补丁更新
用户对客户端设备补丁更新保持怀疑态度,因为他们担心他们的计算机会在未经许可的情况下突然自己重启,丢失数据.虽然,您可以在更新后推迟重新启动并安排选择的时间,具体取决于更新Windows在未经您许可的情 ...
- python3基础14(有关日期的使用2)
#!/usr/bin/env python# -*- coding:utf-8 -*-import timeimport datetime,shutil,osimport calendar print ...
- ARM实验3 ——串口实验
uart串口实验 实验内容: 编写UART模块程序,通过串口将信息打印到终端. 实验目的: 熟悉开发环境的使用. 掌握exynos4412处理器的UART功能. 实验平台: FS4412开发板,ecl ...