protected void GridViewItemsList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Download") { int id = int.Parse(e.CommandArgument.ToString()); DownloadUserForms duf = new DownloadUserForms(); List<DownloadUserForm> list = duf.GetByFileID(id); DownloadFiles df = new DownloadFiles(); var file = df.GetById(id); ReportOptions ro = new ReportOptions(); ro.Columns = "Email,FirstName,LastName"; ro.HeaderText = "Email,Имя,Фамилия"; ro.FileName = string.Format("csvreport_{0}_file.csv",file.FileName); new CsvHelper().WriteToCSV(list, ro); } }
protected void imgSubmit_Click(object sender, EventArgs e) { if (IsValid()) { //IsFormSubmitted = true; try { //SeminarRegistration sr = new SeminarRegistration //{ // CompanyName = txtCompanyName.Text, // Email = txtEmail.Text, // FIO = txtFio.Text, // JobAction = Convert.ToInt32(ddlFirmAction.SelectedValue), // JobTitle = txtJobTitle.Text, // TypeID = 1, // Site = txtSite.Text.ToLower().StartsWith("http://") ? txtSite.Text : "http://" + txtSite.Text //}; //SeminarRegistrations.Add(sr); // SendMail(); try { Session["email"] = txtEmail.Text; Session["firstname"] = txtFirstName.Text; Session["lastname"] = txtLastName.Text; } catch (Exception) { throw; } int id = 0; if (Session["id"] != null && !string.IsNullOrEmpty(Session["id"].ToString())) { try { id = Int32.Parse(Session["id"].ToString()); } catch (Exception) { id = -1; } } DownloadUserForm duf = new DownloadUserForm{Email=txtEmail.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, FileID = id}; DownloadUserForms manager = new DownloadUserForms(); string urlGuid = manager.InsertForm(duf); IsFormSubmitted = true; hlLink.NavigateUrl = "~/DownloadFile.aspx?guid=" + urlGuid; phForm.Visible = false; phLink.Visible = true; Session.Remove("id"); } catch (Exception exc) { IsFormSubmitted = false; Logger.LogException(exc, "DownloadFileForm.ascx"); lbError.Visible = true; lbError.ForeColor = Color.Red; lbError.Text = "Произошла внутрення ошибка. Обратитесь к администратору."; } } else { lbError.Visible = true; lbError.ForeColor = Color.Red; lbError.Text = "Просьба заполните все поля"; } }