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

📄 bumenschedule.aspx.cs

📁 OA系统源码 办公应用软件源码 asp.net 开发
💻 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 MyOffice.Models;
using MyOffice.BLL;
using System.Collections.Generic;

public partial class ScheduleManage_BuMenSchedule : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            txtTime.Text = DateTime.Now.ToShortDateString();
            List<BranchInfoModel> libr = personManageBLL.AllSeBr();
           // ddlBranchs.Items.Clear();
            foreach (BranchInfoModel bif in libr)
            {
                ListItem li = new ListItem();
                li.Text = bif.BranchName;
                li.Value = bif.BranchId.ToString();
                ddlBranchs.Items.Add(li);
            }
           // int id = personManageBLL.SelecDeId(ddlBranchs.Text);
            List<DepartInfoModel> lide = personManageBLL.SeDeBId(int.Parse(ddlBranchs.Text));
          //  ddlDeparts.Items.Clear();
            foreach (DepartInfoModel dim in lide)
            {
                ListItem lu = new ListItem();
                lu.Text = dim.DepartName;
                lu.Value = dim.DepartId.ToString();
                ddlDeparts.Items.Add(lu);
            }
        }
    }


    protected void DisplayDepartSchedule() {
        UserInfoModel loginUser = (UserInfoModel)Session["User"];
        int departId = int.Parse(ddlDeparts.SelectedValue);
        string selectDay=txtTime.Text;
        string userName=txtUserName.Text.Trim();
        List<ScheduleModel> schedules = scheduleBLL.GetSchedulesByDepartIdAndTime(loginUser.UserId,departId,selectDay,userName);
        gvDepartScheduleInfo.DataSource = schedules;
        gvDepartScheduleInfo.DataBind();

    }
    protected void imgbtnSearch_Click(object sender, ImageClickEventArgs e)
    {
        lblSelectDay.Text = txtTime.Text;
        DisplayDepartSchedule();
    }
    protected void ddlBranchs_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddlDeparts.Items.Clear();
        int id = int.Parse(ddlBranchs.Text);
        List<DepartInfoModel> lide = personManageBLL.SeDeBId(id);
        foreach (DepartInfoModel dim in lide)
        {
            ListItem lite = new ListItem();
            lite.Text = dim.DepartName;
            lite.Value = dim.DepartId.ToString();
            ddlDeparts.Items.Add(lite);
        }
    }
    protected void gvDepartScheduleInfo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //得到选择的日期
        string dateTime = txtTime.Text + " 00:00:00";
        DateTime dates = DateTime.Parse(dateTime);
        if (e.Row.RowType == DataControlRowType.Header) { 
            //循环显示一周各天所对应的日期
            for (int i = 1; i <= 7; i++) {
                int intWeek = i - Convert.ToInt32(dates.DayOfWeek)-1;
                //一周中各天所对应的日期
                string strWeek = dates.AddDays(intWeek).ToString("yyyy-MM-dd");
                DateTime weekDay = DateTime.Parse(strWeek+" 00:00:00");
                if (weekDay.Month.ToString() == dates.Month.ToString()) {
                    //实例化标题控件
                    Label lblWeek = (Label)e.Row.FindControl("lbl"+i+"");
                    lblWeek.Text = weekDay.Day.ToString();
                }
            }
        }
        if (e.Row.RowType == DataControlRowType.DataRow) {
            string userId = gvDepartScheduleInfo.DataKeys[e.Row.RowIndex].Value.ToString();
            UserInfoModel user = companyBLL.SeUser(userId);
            e.Row.Cells[0].Text = user.UserName;
            //循环显示一周中各天所对应的日程内容
            for (int i = 1; i <= 7; i++) {
                int intWeek = i - Convert.ToInt32(dates.DayOfWeek);
                //星期几对应的日期
                string strWeek = dates.AddDays(intWeek).ToString("yyyy-MM-dd");
                //根据用户Id获得日程Id
            /*   int scheduleId = scheduleBLL.GetScheduleId(user.UserId,strWeek);
                if (scheduleId != 0) { 
                    //根据日程Id获得日程信息
                    ScheduleModel schedule = scheduleBLL.SelectIdSche(scheduleId);
                    HyperLink hl = (HyperLink)e.Row.FindControl("hl"+i+"");
                    string titlelength = "";
                    if (schedule.Title.Length > 3)
                    {
                        titlelength = schedule.Title.Substring(0, 3) + "...";
                    }
                    else {
                        titlelength = schedule.Title;
                    }
                    //DateTime tt = schedule.BeginTime;
                    //int tts = schedule.BeginTime.Hour;
                    //int ttss = schedule.BeginTime.Minute;
                    //hl.Text = "@" + tts+ ":" + ttss + " " + titlelength;
                    hl.Text = "@" + schedule.BeginTime.Hour.ToString() + ":" + schedule.BeginTime.Minute.ToString() + " " + titlelength;
                    hl.NavigateUrl = "SaveMySchedule.aspx?DateTimes="+dates.ToShortDateString();
                }*/
                List<ScheduleModel> lis = scheduleBLL.SeUserIdmoneyRiId(user.UserId, strWeek);
                if (lis.Count > 0) {
                    foreach (ScheduleModel schedule in lis)
                    {
                       
                        HyperLink hl = (HyperLink)e.Row.FindControl("hl" + i + "");
                        string titlelength = "";
                        if (schedule.Title.Length > 3)
                        {
                            titlelength = schedule.Title.Substring(0, 3) + "...";
                        }
                        else
                        {
                            titlelength = schedule.Title;
                        }
                        DateTime d = schedule.CreateTime;
                        //DateTime tt = schedule.BeginTime;
                        //int tts = schedule.BeginTime.Hour;
                        //int ttss = schedule.BeginTime.Minute;
                        //hl.Text = "@" + tts+ ":" + ttss + " " + titlelength;
                        hl.Text = "@" + schedule.BeginTime.Hour.ToString() + ":" + schedule.BeginTime.Minute.ToString() + " " + titlelength;
                        hl.NavigateUrl = "SaveMySchedule.aspx?DateTimes=" + dates.ToShortDateString();
                        // hl.NavigateUrl = "SaveMySchedule.aspx?DateTimes=" +schedule.CreateTime.ToShortDateString();
                    }
                }
            }
        }
    }
}

⌨️ 快捷键说明

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