Beispiel #1
0
        // zavrseno
        internal bool SacuvajRazmenu(RazmenaRobe rr)
        {
            try
            {
                Zahtev zahtev = new Zahtev {
                    Objekat = rr, Operacija = Operacija.DodajRazmenu
                };
                formatter.Serialize(stream, zahtev);
                Odgovor odgovor = (Odgovor)formatter.Deserialize(stream);
                switch (odgovor.Signal)
                {
                case Signal.Ok:
                    return(true);

                case Signal.Error:
                    return(false);
                }
                return(false);
            }
            catch (IOException e)
            {
                Debug.WriteLine(">>> " + e.Message);
                klijent.Close();
                throw new ExceptionServer("Server je zaustavljen!");
            }
        }
Beispiel #2
0
        internal void PotvrdiRazmenu(TextBox tbTrazenaKolicinaRobe, DateTimePicker dtpDatumRazmeneRobe)
        {
            if (MessageBox.Show("Da li želite da izvršite razmenu?", "Pitanje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (tbTrazenaKolicinaRobe.BackColor == Color.Green)
                {
                    trazenaRoba.KolicinaRobe -= Convert.ToInt32(tbTrazenaKolicinaRobe.Text);
                    RazmenaRobe rr = new RazmenaRobe
                    {
                        DatumRazmeneRobe    = dtpDatumRazmeneRobe.Value,
                        KolicinaRobe        = Convert.ToInt32(tbTrazenaKolicinaRobe.Text),
                        KorisnikTrazeneRobe = trazenaRoba.KorisnikRobe,
                        KorisnikUlozeneRobe = Sesija.Instance.Korisnik,
                        TrazenaRoba         = trazenaRoba,
                        UlozenaRoba         = ulozenaRoba.ToList(),
                    };

                    bool uspesno = Komunikacija.Instance.SacuvajRazmenu(rr);

                    if (uspesno)
                    {
                        MessageBox.Show("Uspešno sačuvana razmena!", "Obavestenje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        FrmClose();
                    }
                    else
                    {
                        MessageBox.Show("Neuspešno sačuvana razmena!", "Obavestenje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Tražena roba nije lepo uneta!", "Greska", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #3
0
        //
        public bool PotvrdiRazmenuRobe(RazmenaRobe razmenaRobe)
        {
            OpstaSistemskaOperacija sistemskaOperacija = new PotvrdiRazmenuRobeSO();

            sistemskaOperacija.Izvrsi(razmenaRobe);
            return(((PotvrdiRazmenuRobeSO)sistemskaOperacija).Izmenjeno);
        }
Beispiel #4
0
        //
        public bool ObrisiRazmenu(RazmenaRobe razmenaRobe)
        {
            OpstaSistemskaOperacija sistemskaOperacija = new ObrisiRazmenuSO();

            sistemskaOperacija.Izvrsi(razmenaRobe);
            return(((ObrisiRazmenuSO)sistemskaOperacija).Obrisano);
        }
Beispiel #5
0
        // ...#...
        private Odgovor DodajRazmenu(RazmenaRobe razmenaRobe)
        {
            bool    uspesno = Kontroler.Kontroler.Instance.SacuvajRazmenu(razmenaRobe);
            Odgovor odgovor = new Odgovor();

            if (uspesno == true)
            {
                odgovor.Signal = Signal.Ok;
            }
            else
            {
                odgovor.Signal = Signal.Error;
            }
            return(odgovor);
        }
Beispiel #6
0
        //
        private Odgovor PotvrdaRazmeneRobe(RazmenaRobe razmenaRobe)
        {
            bool    izmena  = Kontroler.Kontroler.Instance.PotvrdiRazmenuRobe(razmenaRobe);
            Odgovor odgovor = new Odgovor();

            if (izmena == true)
            {
                odgovor.Signal = Signal.Ok;
            }
            else
            {
                odgovor.Signal = Signal.Error;
            }
            return(odgovor);
        }
Beispiel #7
0
        //
        private Odgovor ObrisiRazmenu(RazmenaRobe razmenaRobe)
        {
            bool    izmena  = Kontroler.Kontroler.Instance.ObrisiRazmenu(razmenaRobe);
            Odgovor odgovor = new Odgovor();

            if (izmena == true)
            {
                odgovor.Signal = Signal.Ok;
            }
            else
            {
                odgovor.Signal = Signal.Error;
            }
            return(odgovor);
        }
Beispiel #8
0
        // ponistena razmena
        public int PonistiSlozen(IDomenskiObjekat objekat)
        {
            RazmenaRobe rr  = (RazmenaRobe)objekat;
            int         ret = 0;

            Izmeni(objekat);

            foreach (Roba r in rr.UlozenaRoba)
            {
                SqlCommand command1 = new SqlCommand($"UPDATE {r.VratiImeKlase()} SET KolicinaRobe = KolicinaRobe + {r.KolicinaRobe} WHERE NazivRobe = '{r.NazivRobe}' AND KorisnikRobe = {rr.KorisnikUlozeneRobe.KorisnikID} AND RazmenaUlozeneRobe IS NULL", connection, transaction);
                ret = command1.ExecuteNonQuery();
            }

            SqlCommand command2 = new SqlCommand($"UPDATE {rr.TrazenaRoba.VratiImeKlase()} SET KolicinaRobe = KolicinaRobe + {rr.KolicinaRobe} WHERE NazivRobe = '{rr.TrazenaRoba.NazivRobe}' AND KorisnikRobe = {rr.KorisnikTrazeneRobe.KorisnikID} AND RazmenaUlozeneRobe IS NULL", connection, transaction);

            return(command2.ExecuteNonQuery() + ret);
        }
Beispiel #9
0
        // ...#...SO
        public bool SacuvajRazmenu(RazmenaRobe razmenaRobe)
        {
            OpstaSistemskaOperacija sistemskaOperacija = new DodajRazmenuSO();

            sistemskaOperacija.Izvrsi(razmenaRobe);
            return(((DodajRazmenuSO)sistemskaOperacija).Sacuvano);
            //try
            //{
            //    broker.OtvoriKonekciju();
            //    broker.PokreniTransakciju();
            //    broker.SacuvajRazmenu(rr, ulozenaRoba);
            //    broker.Commit();
            //    return true;
            //}
            //catch (Exception)
            //{
            //    broker.Rollback();
            //    return false;
            //}
            //finally
            //{
            //    broker.ZatvoriKonekciju();
            //}
        }
Beispiel #10
0
        // export to pdf 2
        internal void exportRowToPdf(RazmenaRobe razmena, string filename)
        {
            BaseFont bf = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, BaseFont.EMBEDDED);

            var saveFileDialog = new SaveFileDialog();

            saveFileDialog.FileName   = filename;
            saveFileDialog.DefaultExt = ".pdf";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (FileStream stream = new FileStream(saveFileDialog.FileName, FileMode.Create))
                {
                    Document pdfDoc      = new Document(PageSize.A4_LANDSCAPE);
                    Font     font        = FontFactory.GetFont(Font.FontFamily.TIMES_ROMAN.ToString(), 15, BaseColor.BLACK);
                    Font     fontTitle   = FontFactory.GetFont(Font.FontFamily.TIMES_ROMAN.ToString(), 20, Font.BOLD, BaseColor.BLACK);
                    Font     fontForLine = FontFactory.GetFont(Font.FontFamily.TIMES_ROMAN.ToString(), 20, Font.UNDERLINE, BaseColor.BLACK);

                    PdfWriter.GetInstance(pdfDoc, stream);
                    pdfDoc.Open();

                    System.Drawing.Image image1 = System.Drawing.Image.FromFile("C://Users/Nemanja/Desktop/NRCompar.png");
                    Image iTextImage1           = Image.GetInstance(image1, System.Drawing.Imaging.ImageFormat.Png);
                    iTextImage1.Alignment = Element.ALIGN_CENTER;
                    pdfDoc.Add(iTextImage1);

                    Paragraph parag1 = new Paragraph("IZVEŠTAJ RAZMENE", fontTitle);
                    parag1.Alignment = Element.ALIGN_CENTER;
                    pdfDoc.Add(parag1);
                    pdfDoc.Add(new Paragraph("Datum podnošenja razmene: " + razmena.DatumRazmeneRobe.ToString("dd.MM.yyyy"), font));

                    PdfPCell  cel1;
                    PdfPCell  cel2;
                    PdfPCell  cel3;
                    PdfPCell  cel4;
                    PdfPCell  cel5;
                    PdfPTable table;
                    PdfPTable t2;

                    // detalji Trazene robe
                    {
                        Paragraph parTrazeneRobe = new Paragraph("Detalji korisnika Tražene robe:", font);
                        parTrazeneRobe.SpacingAfter = 5;
                        pdfDoc.Add(parTrazeneRobe);

                        table = new PdfPTable(1);

                        cel1 = new PdfPCell(new Phrase("Korisnik: " + razmena.KorisnikTrazeneRobe.ImeKorisnika + " " + razmena.KorisnikTrazeneRobe.PrezimeKorisnika, font));
                        cel2 = new PdfPCell(new Phrase("Adresa: " + razmena.KorisnikTrazeneRobe.Adresa + ", " + razmena.KorisnikTrazeneRobe.Lokacija.NazivOpstine, font));
                        cel3 = new PdfPCell(new Phrase("Tražena roba: " + razmena.TrazenaRoba.NazivRobe, font));
                        cel4 = new PdfPCell(new Phrase("Količina tražene robe: " + razmena.TrazenaRoba.KolicinaRobe + "g", font));
                        cel5 = new PdfPCell(new Phrase("Broj telefona: " + razmena.KorisnikTrazeneRobe.BrojTelefona, font));

                        cel1.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                        cel2.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                        cel3.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                        cel4.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                        cel5.HorizontalAlignment = Element.ALIGN_JUSTIFIED;

                        cel1.Border = Rectangle.NO_BORDER;
                        cel2.Border = Rectangle.NO_BORDER;
                        cel3.Border = Rectangle.NO_BORDER;
                        cel4.Border = Rectangle.NO_BORDER;
                        cel5.Border = Rectangle.NO_BORDER;

                        table.AddCell(cel1);
                        table.AddCell(cel2);
                        table.AddCell(cel3);
                        table.AddCell(cel4);
                        table.AddCell(cel5);

                        table.SpacingAfter  = 20;
                        table.SpacingBefore = 10;

                        t2 = new PdfPTable(1);
                        t2.AddCell(table);
                        pdfDoc.Add(t2);
                    }

                    // detalji Ulozene robe
                    {
                        Paragraph parUlozeneRobe = new Paragraph("Detalji korisnika Uložene robe:", font);
                        parUlozeneRobe.SpacingAfter = 5;
                        pdfDoc.Add(parUlozeneRobe);

                        table = new PdfPTable(1);

                        cel1 = new PdfPCell(new Phrase("Korisnik: " + Sesija.Instance.Korisnik.ImeKorisnika + " " + Sesija.Instance.Korisnik.PrezimeKorisnika, font));
                        cel2 = new PdfPCell(new Phrase("Adresa: " + Sesija.Instance.Korisnik.Adresa + ", " + Sesija.Instance.Korisnik.Lokacija.NazivOpstine, font));
                        cel3 = new PdfPCell(new Phrase("Uložene roba: " + razmena.UlozenaRobaString.Replace("\n", " "), font));
                        cel4 = new PdfPCell(new Phrase("Broj telefona: " + Sesija.Instance.Korisnik.BrojTelefona, font));

                        cel1.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                        cel2.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                        cel3.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                        cel4.HorizontalAlignment = Element.ALIGN_JUSTIFIED;

                        cel1.Border = Rectangle.NO_BORDER;
                        cel2.Border = Rectangle.NO_BORDER;
                        cel3.Border = Rectangle.NO_BORDER;
                        cel4.Border = Rectangle.NO_BORDER;

                        table.AddCell(cel1);
                        table.AddCell(cel2);
                        table.AddCell(cel3);
                        table.AddCell(cel4);

                        table.SpacingAfter  = 20;
                        table.SpacingBefore = 10;

                        t2 = new PdfPTable(1);
                        t2.AddCell(table);
                        pdfDoc.Add(t2);
                    }

                    // potpisi
                    pdfDoc.Add(new Paragraph("                    ", fontForLine));

                    pdfDoc.Add(new Paragraph(" "));

                    pdfDoc.AddAuthor(Sesija.Instance.Korisnik.ImeKorisnika + " " + Sesija.Instance.Korisnik.PrezimeKorisnika);

                    pdfDoc.Close();
                    stream.Close();
                }
            }
        }