Esempio n. 1
0
 protected void btnKomentar_Click(object sender, EventArgs e)
 {
     using (PoslovniKlubBL temp = new PoslovniKlubBL())
     {
         user = (Data.EntityFramework.DAL.Users)Session["LoggedUser"];
         int uid = temp.GetUserIDByName(user.UserName);
         if (!string.IsNullOrWhiteSpace(txtKomentar.Text))
         {
             temp.SaveComment(txtKomentar.Text, uid, temp.GetUserBySpBr(txtSporazum.Text));
             ResetFields();
         }
         else
             ClientScript.RegisterStartupScript(this.GetType(), "Greška!", "alert('Žao mi je, ali ne možete upisati prazan komentar!');", true);
     }
 }
Esempio n. 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();
                }
            }
        }