protected void btnLozinka_Click(object sender, EventArgs e) { Baza baza = new Baza(); string lozinka = ""; string email = ""; if (txtKorIme.Text != null) { lozinka = baza.DohvatiVrijednost("select lozinka from korisnici where korisnicko_ime='" + txtKorIme.Text + "'"); email = baza.DohvatiVrijednost("select email from korisnici where korisnicko_ime='" + txtKorIme.Text + "'"); } else if (txtEmail.Text != null) { lozinka = baza.DohvatiVrijednost("select lozinka from korisnici where email='" + txtEmail.Text + "'"); email = txtEmail.Text; } Response.Write("Poslana vam je lozinka na email!"); Mail mail = new Mail(); mail.saljiMail("*****@*****.**", email, "Zaboravljena lozinka", "Zatražili ste slanje vaše lozinke na mail! \nVaša lozinka je: " + lozinka, null); }
protected void Button1_Click(object sender, EventArgs e) { Baza baza = new Baza(); string JQueryVer = "1.7.1"; ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition { Path = "~/Scripts/jquery-" + JQueryVer + ".min.js", DebugPath = "~/Scripts/jquery-" + JQueryVer + ".js", CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + JQueryVer + ".min.js", CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + JQueryVer + ".js", CdnSupportsSecureConnection = true, LoadSuccessExpression = "window.jQuery" }); if (IsPostBack) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["E-nabavaConnectionString"].ConnectionString); conn.Open(); string provjeriKorisnika = "select count(*) from Korisnici where korisnicko_ime='" + tbUname.Text + "'"; SqlCommand comm = new SqlCommand(provjeriKorisnika, conn); int temp = Convert.ToInt32(comm.ExecuteScalar().ToString()); conn.Close(); if (temp == 1) { conn.Open(); string passwordQuery = "select lozinka from Korisnici where korisnicko_ime='" + tbUname.Text + "'"; SqlCommand passComm = new SqlCommand(passwordQuery, conn); string password = passComm.ExecuteScalar().ToString().Replace(" ", ""); if (password == tbPass.Text) { if (baza.DohvatiVrijednost("SELECT aktiviran FROM korisnici WHERE korisnicko_ime='" + tbUname.Text + "'").Equals("1")) { string sessionQuery = "select tip_korisnika from Korisnici where korisnicko_ime='" + tbUname.Text + "'"; SqlCommand sessComm = new SqlCommand(sessionQuery, conn); string tip = sessComm.ExecuteScalar().ToString().Replace(" ", ""); if (tip.Equals(referent)) { Session["sesija"] = referent; Session["korIme"] = tbUname.Text; Response.Write("Password is correct!"); Response.Redirect("Pregled_ponuda.aspx"); } else if (tip.Equals(dobavljac)) { Session["sesija"] = dobavljac; Session["korIme"] = tbUname.Text; Response.Write("Password is correct!"); Response.Redirect("Dobavljac.aspx"); } } else { Response.Write("Korisnik nije aktiviran!"); } } else { Response.Write("Password is incorrect!"); } } else { Response.Write("Username is incorrect!"); } conn.Close(); } }
protected string kreirajPDF() { Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35); //putanja je hardkodirana string fullPath = @"C:\Pdf\Ponuda" + Session["korIme"].ToString() + ".pdf"; int count = 1; string fileNameOnly = Path.GetFileNameWithoutExtension(fullPath); string extension = Path.GetExtension(fullPath); string path = Path.GetDirectoryName(fullPath); string newFullPath = fullPath; while (File.Exists(newFullPath)) { string tempFileName = string.Format("{0}({1})", fileNameOnly, count++); newFullPath = Path.Combine(path, tempFileName + extension); fullPath = newFullPath; } FontFactory.RegisterDirectories(); Font fontBoldArial = new Font(FontFactory.GetFont("Arial", 16, Font.BOLD)); FontFactory.RegisterDirectories(); Font fontBoldArial12 = new Font(FontFactory.GetFont("Arial", 12, Font.BOLD)); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(fullPath, FileMode.Create)); doc.Open(); //putanja je hardkodirana string imagepath = @"C:\Users\Luka\Desktop\HopSamonikBlazek\E-nabava\E-nabava\img\logo.png"; iTextSharp.text.Image slika = iTextSharp.text.Image.GetInstance(imagepath); slika.Alignment = Element.ALIGN_CENTER; doc.Add(slika); Paragraph naslov = new Paragraph("Kreirana ponuda za Metalsku industriju Varazdin d.d.\n", fontBoldArial); naslov.Alignment = Element.ALIGN_CENTER; doc.Add(naslov); DateTime izdavanje = DateTime.Now; Baza baza = new Baza(); string naziv = baza.DohvatiVrijednost("SELECT naziv FROM korisnici WHERE korisnicko_ime ='" + Session["korIme"] + "'"); string brojTel = baza.DohvatiVrijednost("SELECT broj_telefona FROM korisnici WHERE korisnicko_ime ='" + Session["korIme"] + "'"); string email = baza.DohvatiVrijednost("SELECT email FROM korisnici WHERE korisnicko_ime ='" + Session["korIme"] + "'"); Paragraph gore = new Paragraph("Podaci o izdavacu: \n", fontBoldArial12); doc.Add(gore); Paragraph paragraph = new Paragraph( "Ponuda od " + Session["korIme"] + "\n" + "Izdao: " + naziv + "\n" + "Korisnicko ime izdavaca: " + Session["korIme"] + "\n" + "Email: " + email + "\n" + "Broj telefona: " + brojTel + "\n" + "Datum izdavanja: " + izdavanje + "\n\n"); doc.Add(paragraph); Paragraph naslovStavke = new Paragraph("Stavke ponude: \n\n", fontBoldArial); naslovStavke.Alignment = Element.ALIGN_CENTER; doc.Add(naslovStavke); PdfPTable table = new PdfPTable(10); table.AddCell(new Phrase("Red. br.")); table.AddCell(new Phrase("Artikl")); table.AddCell(new Phrase("Kol")); table.AddCell(new Phrase("Cijena")); table.AddCell(new Phrase("Rok placanja")); table.AddCell(new Phrase("Rok isporuke")); table.AddCell(new Phrase("Nacin placanja")); table.AddCell(new Phrase("Kvaliteta")); table.AddCell(new Phrase("Napomena")); table.AddCell(new Phrase("Alt")); table.HeaderRows = 1; float[] widths = new float[] { 1f, 3f, 1f, 2f, 2f, 2f, 2f, 2f, 2f, 1f }; table.SetWidths(widths); for (int i = 0; i < gwPonuda.Rows.Count; i++) { table.AddCell(new Phrase((i + 1).ToString())); for (int j = 1; j < 10; j++) { table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[j].Text)); } /*table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[1].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[2].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[3].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[4].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[5].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[6].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[7].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[8].Text)); * table.AddCell(new Phrase(gwPonuda.Rows[i].Cells[9].Text));*/ table.WidthPercentage = 100; } doc.Add(table); doc.Close(); return(fullPath); }