(排班表二)后台动态绘制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 ...
随机推荐
- python单元测试框架-unittest(二)之断言
断言内容是自动化脚本的重要内容,正确设置断言以后才能帮助我们判断测试用例执行结果. 断言方法 assertEqual(a, b) 判断a==b assertNotEqual(a, b) 判断a!=b ...
- PHP速学
基本代码 <?php echo "Hello world";?> 变量定义 <?php $a=true; $bool_value=true; $integer_v ...
- Flyweight_pattern--reference
http://en.wikipedia.org/wiki/Flyweight_pattern In computer programming, flyweight is a software desi ...
- POJ 1456——Supermarket——————【贪心+并查集优化】
Supermarket Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- Ubuntu、Windows 、Linux集合
一.Ubuntu/Windows双系统修复引导 首先说明:在Windows存在的前提下安装Ubuntu(或者Ubuntu系列)是不需要修复引导的.因为grub会自动搜索存在硬盘中的系统. 而在 ...
- OMD开源监控软件
参考 Best Monitoring Solution - OMD (Nagios + Check_MK) 官网 mathias-kettner.com OMD labs.consol.de Conf ...
- http 状态码集合
HTTP常见状态码 200 301 302 404 500 HTTP状态码(HTTP Status Code) 状态码并不是每个都有,为了后期扩展.[update20170505] 一些常见的状态 ...
- 数组:获取GET的键名
1.今天仓鼠遇到这个情况:通过$_GET获取参数,但是参数变成了键名形式 2.那仓鼠想要拿到这个键名,那就要:使用array_keys()获取数组中的所有键名,然后进行转换 代码如下: 结果: 以上 ...
- CRUD全栈式编程架构之控制器的设计
页面 这里界面我采用jquery miniui来做的,当你完全了解了整个设计之后可以轻松切换到其他的js框架,个人认为类似muniui,easyui等等这类可以将web界面做得和winform类似的框 ...
- [转载]——Axure+SVN配置
最近进行考试系统重构,一个小组十几个人,这么多人要同时搞需求画原型.这样原本的合作开发工具SVN已经不能满足现在的需求了,这是就找到了一个新的方法——Axure+SVN. 在SVN服务器端建立一个空的 ...