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

📄 dutylistmain.aspx.cs

📁 值班管理系统源码 net2005+sqlserver2005 ,三层模式
💻 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;

public partial class DutyListMain : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!this.IsPostBack)
        {
            bindDepartDrop();
            bindUserDrop();

            bindDutyData();

        }
    }

    private void bindDutyData()
    {
        if (DutyDao.dsDuty() == null || (DutyDao.dsDuty()).Tables[0].Rows.Count == 0)
        {
            this.Label1.Visible = true;
            this.GridView1.Visible = false;
        }
        else
        {
            this.Label1.Visible = false;
            this.GridView1.Visible = true;
            this.GridView1.DataSource = DutyDao.dsDuty();
            this.GridView1.DataBind();
        }
    }

    private void bindDepartDrop()
    {
        DataTable dt = DepartmentDao.dsDepartment().Tables[0];
        this.DropDownList1.DataSource = dt;
        this.DropDownList1.DataTextField = dt.Columns[1].ToString();
        this.DropDownList1.DataValueField = dt.Columns[0].ToString();
        this.DropDownList1.DataBind();
        this.DropDownList1.Items.Insert(0, new ListItem("请选择", "0"));
    }

    private void bindUserDrop()
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if(!this.Calendar1.Visible)
        this.Calendar1.Visible = true;
        else
        this.Calendar1.Visible = false;
    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        this.TextBox1.Text = this.Calendar1.SelectedDate.ToShortDateString();
        this.Calendar1.Visible = false;
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.DropDownList1.SelectedIndex != 0)
        {
            this.DropDownList2.Items.Clear();
            this.DropDownList2.DataSource = StaffDao.dsStaff(int.Parse(this.DropDownList1.SelectedValue.ToString())).Tables[0];
            this.DropDownList2.DataTextField = StaffDao.dsStaff(int.Parse(this.DropDownList1.SelectedValue.ToString())).Tables[0].Columns[1].ToString();
            this.DropDownList2.DataValueField = StaffDao.dsStaff(int.Parse(this.DropDownList1.SelectedValue.ToString())).Tables[0].Columns[0].ToString();
            this.DropDownList2.DataBind();
        }
       
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        if (!this.Calendar2.Visible)
            this.Calendar2.Visible = true;
        else
            this.Calendar2.Visible = false;
    }
    protected void Calendar2_SelectionChanged(object sender, EventArgs e)
    {
        this.TextBox3.Text = this.Calendar2.SelectedDate.ToShortDateString();
        this.Calendar2.Visible = false;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (this.DropDownList1.SelectedIndex == 0)
        {
            this.Label2.Text = "请选择部门!";

        }
        else if (this.DropDownList2.SelectedIndex == -1)
        {
            this.Label2.Text = "请选择人员!";
        }
        else if (string.IsNullOrEmpty(this.TextBox1.Text))
        {
            this.Label2.Text = "请选择开始时间!";
        }
        else if (string.IsNullOrEmpty(this.TextBox3.Text))
        {
            this.Label2.Text = "请选择结束时间!";
        }
        else if ((DateTime.Parse(this.TextBox1.Text)).CompareTo(DateTime.Parse(this.TextBox3.Text)) == 1)
        {
            this.Label2.Text = "开始时间不应大于结束时间";
        }
        else
        {
            int departId = int.Parse(this.DropDownList1.SelectedValue.ToString());
            int userId = int.Parse(this.DropDownList2.SelectedValue.ToString());

            DateTime begin = DateTime.Parse(this.TextBox1.Text);
            DateTime end = DateTime.Parse(this.TextBox3.Text);

            string comment = this.TextBox2.Text;

            DutyPO dp = new DutyPO();
            dp.DepartId = departId;
            dp.StaffId = userId;
            dp.DutyDateBegin = begin;
            dp.DutyDateEnd = end;
            dp.DutyComment = comment;
            DutyDao.insertDuty(dp);
            bindDutyData();
            this.Label2.Text = "";
        }
        
    }
}

⌨️ 快捷键说明

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