⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 departschedule.aspx.cs

📁 办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统办公系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Office.DAL;
using Office.Model;
using Office.BLL;

public partial class ScheduleManage_DepartSchedule_DepartSchedule : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
           this.ddl_organ.DataSource = BranchInfoManager.GetAllBranchInfos();
           this.ddl_organ.DataTextField = "BranchName";
           this.ddl_organ.DataValueField = "BranchId";
           this.ddl_organ.DataBind();
           this.ddl_organ.Items.Insert(0,new ListItem("--请选择--"));
        }
    }

    //机构与部门信息数据帮定
    protected void ddl_organ_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.ddl_branch.DataSource = DepartInfoManager.GetDepartInfoByBranchId(Int32.Parse(this.ddl_organ.SelectedValue));
        this.ddl_branch.DataTextField = "DepartName";
        this.ddl_branch.DataValueField = "DepartId";
        this.ddl_branch.DataBind();
    }
    //机构与部门信息数据帮定
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        IList<Schedule> list = ScheduleManager.GetAllSchedules();
        this.GridView1.DataSource = list;
        this.GridView1.DataBind();
    }

    //自定义DataList显示日志信息
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        String time = this.txt_datatime.Text;
        int year = Convert.ToInt32(time.Substring(0, 4));
        int mon = Convert.ToInt32(time.Substring(5, 2));
        int day = Convert.ToInt32(time.Substring(8, 2));
        DateTime date = new DateTime(year, mon, day);
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[0].Text = "人员姓名";
            e.Row.Cells[0].Width = 80;
            char[] weeks = { '日', '一', '二', '三', '四', '五', '六' };
            switch (date.DayOfWeek)
            {
                case DayOfWeek.Sunday:
                    for (int i = 1; i <= weeks.Length; i++)
                    {
                        e.Row.Cells[i].Text = "星期" + weeks[i - 1] + " " + day;
                        e.Row.Cells[i].Width = 80;
                        day++;
                    }

                    break;
                case DayOfWeek.Monday:
                    day -= 1;
                    for (int i = 1; i <= weeks.Length; i++)
                    {
                        e.Row.Cells[i].Text = "星期" + weeks[i - 1] + " " + day;
                        e.Row.Cells[i].Width = 80;
                        day++;
                    }
                    break;
                case DayOfWeek.Tuesday:
                    day -= 2;
                    for (int i = 1; i <= weeks.Length; i++)
                    {
                        e.Row.Cells[i].Text = "星期" + weeks[i - 1] + " " + day;
                        e.Row.Cells[i].Width = 80;
                        day++;
                    }
                    break;
                case DayOfWeek.Wednesday:
                    day -= 3;
                    for (int i = 1; i <= weeks.Length; i++)
                    {
                        e.Row.Cells[i].Text = "星期" + weeks[i - 1] + " " + day;
                        e.Row.Cells[i].Width = 80;
                        day++;
                    }
                    break;
                case DayOfWeek.Thursday:
                    day -= 4;
                    for (int i = 1; i <= weeks.Length; i++)
                    {
                        e.Row.Cells[i].Text = "星期" + weeks[i - 1] + " " + day;
                        e.Row.Cells[i].Width = 80;
                        day++;
                    }
                    break;
                case DayOfWeek.Friday:
                    day -= 5;
                    for (int i = 1; i <= weeks.Length; i++)
                    {
                        e.Row.Cells[i].Text = "星期" + weeks[i - 1] + " " + day;
                        e.Row.Cells[i].Width = 80;
                        day++;
                    }
                    break;
                case DayOfWeek.Saturday:
                    day -= 6;
                    for (int i = 1; i <= weeks.Length; i++)
                    {
                        e.Row.Cells[i].Text = "星期" + weeks[i - 1] + " " + day;
                        e.Row.Cells[i].Width = 80;
                        day++;
                    }
                    break;
            }
        }

        //信息的动态显示
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells.Clear();
            int count = 0;

            IList<Schedule> list = ScheduleManager.GetAllSchedules();
            foreach (Schedule tmp in list)
            {
                if (tmp.CreateTime.Year == year && tmp.CreateTime.Month == mon && tmp.CreateTime.Day == day)
                {
                    IList<UserInfo> users = UserInfoManager.GetAllUserInfos();
                    foreach (UserInfo u in users)
                    {
                        if (tmp.CreateUser.UserId == u.UserId)
                        {
                            IList<DepartInfo> des = DepartInfoManager.GetAllDepartInfos();
                            foreach (DepartInfo d in des)
                            {
                                if (u.DepartId == d.DepartId)
                                {
                                    if (d.DepartName.Equals(this.ddl_branch.SelectedItem.Text))
                                    {
                                        int index = 1;
                                        for (int i = 0; i < 8; i++)
                                        {
                                            e.Row.Cells.Add(new TableCell());                                   
                                        }
                                       
                                        switch (date.DayOfWeek)
                                        {
                                            case DayOfWeek.Sunday:
                                                index = 1;
                                                break;
                                            case DayOfWeek.Monday:
                                                index = 2;
                                                break;
                                            case DayOfWeek.Tuesday:
                                                index = 3;
                                                break;
                                            case DayOfWeek.Wednesday:
                                                index = 4;
                                                break;
                                            case DayOfWeek.Thursday:
                                                index = 5;
                                                break;
                                            case DayOfWeek.Friday:
                                                index = 6;
                                                break;
                                            case DayOfWeek.Saturday:
                                                index = 7;
                                                break;
                                        }

                                        if (e.Row.RowIndex == count)
                                        {
                                            e.Row.Cells[0].Text = tmp.CreateUser.UserName;
         
                                            LinkButton lk = new LinkButton();
                                            lk.Text = "◎" + tmp.CreateTime.Hour + ":" + tmp.CreateTime.Minute + " " + tmp.Title.Substring(0, 3) + "...";
                                            lk.PostBackUrl = "../PersonSchedule/PersonSchedulePlan.aspx?set=" + 1 + "&Sid=" + tmp.ScheduleId ;
                                            e.Row.Cells[index].Controls.Add(lk);
                                        }  
                                    }
                                }
                            }
                            count++;
                            break;
                        }
                    }
                }
            }
            
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -