Beispiel #1
0
        protected void gvwResult1_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (PoslovniKlubBL temp = new PoslovniKlubBL())
            {
                GridViewRow row = gvwResult1.SelectedRow;
                int userID = temp.GetKorisnikID(row.Cells[1].Text);
                string user = row.Cells[2].Text + " " + row.Cells[3].Text + "; " + row.Cells[1].Text + "; " + row.Cells[6].Text + "; " + row.Cells[7].Text;

                //Response.Redirect("UnosOglasa.aspx?" + "&SporazumBroj=" + userID); ovo sam koristio prije uvođenja novog prozora za novi oglas

                string url = "UnosOglasa.aspx?" + "&SporazumBroj=" + userID +"&korisnik=" + Server.UrlEncode(user);
                StringBuilder sb = new StringBuilder();
                sb.Append("<script type = 'text/javascript'>");
                sb.Append("window.open('");
                sb.Append(url);
                sb.Append("');");
                sb.Append("</script>");
                ClientScript.RegisterStartupScript(this.GetType(), "script", sb.ToString());
            }
        }
Beispiel #2
0
        protected void gvwAktivni_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (PoslovniKlubBL temp = new PoslovniKlubBL())
            {
                string subPath = "c:/prenos/Pisma"; // your code goes here
                bool isExists = System.IO.Directory.Exists(subPath);
                if (!isExists)
                    System.IO.Directory.CreateDirectory(subPath);

                using (DocX pismo = DocX.Load(Server.MapPath("~/Content/60dana.docx")))
                {
                    //DirectoryInfo di = new DirectoryInfo("c:/Pisma/");

                    GridViewRow row = gvwAktivni.SelectedRow;

                    user = (Data.EntityFramework.DAL.Users)Session["LoggedUser"];
                    int uid = temp.GetUserIDByName(user.UserName);
                    temp.SavePismo(row.Cells[0].Text, temp.GetKorisnikID(row.Cells[1].Text), uid);

                    string imePrezime = row.Cells[2].Text + " " + row.Cells[3].Text;
                    string adresKorisnika = row.Cells[4].Text;
                    string mjestoPTT = row.Cells[5].Text + " " + row.Cells[6].Text;
                    pismo.ReplaceText("imeKorisnika", imePrezime);
                    pismo.ReplaceText("adresaKorisnika", adresKorisnika);
                    pismo.ReplaceText("mjestoKorisnika", mjestoPTT);
                    pismo.ReplaceText("clanDo", row.Cells[8].Text);
                    DateTime date = DateTime.Now;
                    pismo.ReplaceText("today", date.ToString("d"));

                    MemoryStream ms = new MemoryStream();
                    pismo.SaveAs(ms);

                    Response.Clear();
                    Response.AddHeader("content-disposition", "attachment; filename=\\60dana_" + imePrezime + ".docx");
                    Response.ContentType = "application/msword";

                    ms.WriteTo(Response.OutputStream);
                    Response.End();
                }
            }
        }