예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label3.Style["Text-align"] = "left";
            Label4.Style["Text-align"] = "left";
            Class1 ob = new Class1();
            if (ob.zConnect())
            {
                DropDownList2.Enabled = true;
                ddNgayDau.Enabled = true;
                if (!IsPostBack)
                {
                    int id = UserInfo.UserID;
                    //eBophan.Text = ob.zBoPhan(id);
                    eBophan.Text = ob.zUyQuyen(id);
                    if ((eBophan.Text == "2") || (eBophan.Text == "3"))
                    {
                        DropDownList1.Enabled = true;
                        string st = "SELECT * FROM BoPhan";
                        DataSet ds = ob.zSelect(st);
                        DropDownList1.DataSource = ds.Tables[0];
                        DropDownList1.DataTextField = "TenBP";
                        DropDownList1.DataValueField = "MaBP";
                        DropDownList1.DataBind();
                        if (eBophan.Text == "3") DropDownList1.SelectedIndex = 1;
                    }
                    else
                    {
                        string st = "SELECT * FROM BoPhan where MaBP=" + eBophan.Text; ;
                        DataSet ds = ob.zSelect(st);
                        DropDownList1.DataSource = ds.Tables[0];
                        DropDownList1.DataTextField = "TenBP";
                        DropDownList1.DataValueField = "MaBP";
                        DropDownList1.DataBind();
                    }
                    int selectedIndex;
                    DropDownList2.DataSource = ob.zDistinctNgay(0, "1/1/1900", out selectedIndex);
                    DropDownList2.DataTextField = "NgayThu";
                    DropDownList2.DataValueField = "Ngay";
                    DropDownList2.DataBind();
                    DropDownList2.SelectedIndex = selectedIndex;
                    ddNgayDau.DataSource = ob.zDistinctNgay(1, "1/1/1900", out selectedIndex);
                    ddNgayDau.DataTextField = "NgayThu";
                    ddNgayDau.DataValueField = "Ngay";
                    ddNgayDau.DataBind();
                    ddNgayDau.SelectedIndex = selectedIndex;
                    eChonngay.Text = Convert.ToDateTime(DropDownList2.SelectedValue).ToString("MM/dd/yyyy");
                    lbChamCong.Text = "In bảng chấm công tháng " + DateTime.Today.AddMonths(-1).ToString("MM/yyyy");
                    GridView1.DataSource = ob.zShowGridView(eBophan.Text, eChonngay.Text);
                    GridView1.DataBind();
                }
            }

            this_Month();
        }
예제 #2
0
 protected void ddNgayDau_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!ddNgayDau.SelectedValue.StartsWith("1/1/1900"))
     {
         Class1 ob = new Class1();
         int selectedIndex;
         ddNgayCuoi.DataSource = ob.zDistinctNgay(2, ddNgayDau.SelectedValue, out selectedIndex);
         ddNgayCuoi.DataTextField = "NgayThu";
         ddNgayCuoi.DataValueField = "Ngay";
         ddNgayCuoi.DataBind();
         ddNgayCuoi.SelectedIndex = selectedIndex;
         ddNgayCuoi.Enabled = true;
     }
 }