private void ShowGrid() { DataSet oDs = GetGridData(); double dTotal = 0; this.LblFrom.Text = this.cc2DateSelector.StartDate().ToString("d MMMM yyyy"); this.LblTo.Text = this.cc2DateSelector.EndDate().ToString("d MMMM yyyy"); foreach (DataRow oDr in oDs.Tables[0].Rows) { dTotal += double.Parse(oDr["Hours"].ToString()); } ViewState["TotalHours"] = dTotal.ToString(); this.GridTime.DataSource = oDs; this.GridTime.DataBind(); // Time events which are locked cannot be edited or deleted. ClassTime oTim = new ClassTime(); foreach (GridViewRow oRow in GridTime.Rows) { ImageButton oDel = (ImageButton)oRow.FindControl("ImgTrash"); if (oDel != null) { oTim.Load(Int32.Parse(oDel.CommandArgument)); if (oTim.Locked) { oDel.ToolTip = ""; oDel.Enabled = false; oDel.ImageUrl = "~/Images/BlankIcon.gif"; } } } }
private void ShowGrid(Int32 PageNo) { DateTime DateStart = this.cc2DateSelector.StartDate(); DateTime DateEnd = this.cc2DateSelector.EndDate(); this.LblFrom.Text = DateStart.ToString("dd MMM yyyy"); this.LblTo.Text = DateEnd.ToString("dd MMM yyyy"); ClassReport oRep = new ClassReport(); DataSet oDs = oRep.GetTimeSheet(Int32.Parse(ViewState["UserId"].ToString()), DateStart, DateEnd); double dTotal = 0; foreach (DataRow oDr in oDs.Tables[0].Rows) dTotal += double.Parse(oDr["Hours"].ToString()); ViewState["TotalHours"] = dTotal.ToString(); this.GridTime.DataSource = oDs; this.GridTime.PageIndex = (PageNo >= 0) ? PageNo : 0; this.GridTime.DataBind(); if (Int32.Parse(ViewState["TimeId"].ToString()) == 0) { this.BtnSubmit.Text = "Submit"; this.LblTimeId.Text = "New"; } else { this.BtnSubmit.Text = "Update"; this.LblTimeId.Text = string.Format("Update ({0})", Int32.Parse(ViewState["TimeId"].ToString())); } // Time events which are locked cannot be edited or deleted. ClassTime oTim = new ClassTime(); foreach (GridViewRow oRow in GridTime.Rows) { ImageButton oDel = (ImageButton)oRow.FindControl("ImgTrash"); if (oDel != null) { oTim.Load(Int32.Parse(oDel.CommandArgument)); if (oTim.Locked) { oDel.ToolTip = ""; oDel.Enabled = false; oDel.ImageUrl = "~/Images/BlankIcon.gif"; } } } ShowTimeError(""); }