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(); }
protected void Page_Load(object sender, EventArgs e) { ClientScript.RegisterStartupScript(this.GetType(), "title", "<script>document.title='-'</script>"); Label3.Style["Text-align"] = "left"; string maBP = Request.QueryString[0].ToString(); string ngayDau = Request.QueryString[1].ToString(); string ngayCuoi = Request.QueryString[2].ToString(); lbNgay.Text = "Từ ngày " + ngayDau + " đến ngày " + ngayCuoi; string[] split = ngayDau.Split(new Char[] { '/' }); ngayDau = split[1].ToString() + "/" + split[0].ToString() + "/" + split[2].ToString(); split = ngayCuoi.Split(new Char[] { '/' }); ngayCuoi = split[1].ToString() + "/" + split[0].ToString() + "/" + split[2].ToString(); Class1 ob = new Class1(); GridView2.DataSource = ob.zShowThongKe(maBP, ngayDau, ngayCuoi); GridView2.DataBind(); string st = "select * from Bophan where MaBP=" + maBP; DataSet ds = ob.zSelect(st); lbBoPhan.Text = "Đơn vị : " + ds.Tables[0].Rows[0][1].ToString(); lbHaNoi.Text = "Hà Nội, ngày " + DateTime.Today.Day + " tháng " + DateTime.Today.Month + " năm " + DateTime.Today.Year; maBP = "<script>window.print();</script>"; ClientScript.RegisterStartupScript(this.GetType(), "windowKey", maBP); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string lyDo = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text; string id = GridView1.Rows[e.RowIndex].Cells[1].Text; string user = UserInfo.Username; string st = string.Format("SELECT COUNT(*) FROM zRecordData WHERE zIDCard='{0}' AND DATEDIFF(DD, zThoiGian, '{1}')=0", id, eChonngay.Text); Class1 ob = new Class1(); if (ob.zSelect(st).Tables[0].Rows[0][0].ToString() == "0") { st = string.Format("INSERT INTO zRecordData (zIDCard, zThoiGian, zReson, zUser, zWrite) VALUES ('{0}', '{1}', N'{2}', '{3}', getdate())", id, eChonngay.Text, lyDo, user); ob.zInsert(st); } else { st = string.Format("UPDATE zRecordData SET zReson=N'{0}', zUser='******', zWrite=GETDATE() WHERE zIDCard='{2}' AND DATEDIFF(DD, zThoiGian, '{3}')=0", lyDo, user, id, eChonngay.Text); ob.zInsert(st); } GridView1.EditIndex = -1; GridView1.DataSource = ob.zShowGridView(eBophan.Text, eChonngay.Text); GridView1.DataBind(); }