protected void btnD_Click(object sender, EventArgs e) { string fileName = "Managers.xls"; AssociateServices employeeServices = new AssociateServices(); DataGrid dg = new DataGrid { AllowPaging = false, DataSource = employeeServices.GetAllAssociates() }; dg.DataBind(); System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.Buffer = true; System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.UTF8; System.Web.HttpContext.Current.Response.Charset = ""; System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); System.Web.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlTextWriter = new System.Web.UI.HtmlTextWriter(stringWriter); dg.RenderControl(htmlTextWriter); System.Web.HttpContext.Current.Response.Write(stringWriter.ToString()); System.Web.HttpContext.Current.Response.End(); }
void BindData() { AssociateServices ascServices = new AssociateServices(); lstEmployee.DataSource = ascServices.GetNewAssociates(); lstEmployee.DataBind(); associatesAssigned = ascServices.GetAssociatesCount(); associatesAvailable = totalAssociates - associatesAssigned; }
protected void lstEmployee_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "Del") { int id = Convert.ToInt32(e.CommandArgument); AssociateServices ascServices = new AssociateServices(); ascServices.DeleteAssociate(id); BindData(); successMessage.Text = "Associate successfully terminated."; } }
void BindData() { AssociateServices ascServices = new AssociateServices(); lstEmployee.DataSource = ascServices.GetAllAssociates(); lstEmployee.DataBind(); HiddenField hf = (HiddenField)Parent.FindControl("hidLastTab"); hf.Value = "2"; associatesAssigned = ascServices.GetAssociatesCount(); associatesAvailable = totalAssociates - associatesAssigned; }
protected void btnSubmit_Click(object sender, EventArgs e) { var items = lstEmployee.Items.Where(i => ((CheckBox)i.FindControl("Checkbox")).Checked); foreach (ListViewItem item in items) { HiddenField hid = item.FindControl("HidId") as HiddenField; AssociateServices ascServices = new AssociateServices(); ascServices.AddAssociate(Convert.ToInt32(hid.Value)); } //string prompt = "$.alert('Associate successfully added.');"; //this.Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", prompt, true); Session["added"] = "1"; Response.Redirect("Associates.aspx"); }
public ExceptionTest() { _AssociateServices = new AssociateServices(_session); }
public FunctionalTest() { _AssociateServices = new AssociateServices(_session); }