Exemplo n.º 1
0
        private void StampaRadnogNaloga()
        {
            //  //string dir = Environment.SpecialFolder.MyDocuments + "\\ServisDB\\";

            string dir = System.IO.Path.Combine(Environment.GetFolderPath(
                                                    Environment.SpecialFolder.MyDoc‌​uments), "ServisDB");

            if (Directory.Exists(dir) == false)
            {
                Directory.CreateDirectory(dir);
            }
            object   o          = dgvPrijave.SelectedRows[0].DataBoundItem;
            string   brojnaloga = ((DataRowView)o).Row.ItemArray[1].ToString();
            string   kupac      = ((DataRowView)o).Row.ItemArray[4].ToString();
            string   adresa     = ((DataRowView)o).Row.ItemArray[5].ToString();
            string   telefon    = ((DataRowView)o).Row.ItemArray[6].ToString();
            string   predmet    = ((DataRowView)o).Row.ItemArray[11].ToString();
            DateTime datum      = (DateTime)((DataRowView)o).Row.ItemArray[2];

            string serviser = ((DataRowView)o).Row.ItemArray[13].ToString();

            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("BROJNALOGA", brojnaloga);
            dict.Add("PREDMET", predmet);
            dict.Add("KUPAC", kupac + ", " + telefon + ", " + adresa);
            dict.Add("SERVISER", serviser);
            dict.Add("DATUM", datum.ToString("dd.MM.yyyy"));
            dict.Add("DATUMNALOGA", datum.ToString("dd.MM.yyyy"));

            string fileName = dir + "\\" + brojnaloga.Replace("/", "-") + ".docx";

            WordDocumentBuilder.FillBookmarksUsingOpenXml("RadniNalog.docx", fileName, dict);
            Process.Start(fileName);
        }
Exemplo n.º 2
0
        private void Stampa()
        {
            //  //string dir = Environment.SpecialFolder.MyDocuments + "\\ServisDB\\";

            string dir = System.IO.Path.Combine(Environment.GetFolderPath(
                                                    Environment.SpecialFolder.MyDoc‌​uments), "ServisDB");

            if (Directory.Exists(dir) == false)
            {
                Directory.CreateDirectory(dir);
            }
            object   o         = dgvPrijave.SelectedRows[0].DataBoundItem;
            string   rednibroj = ((DataRowView)o).Row.ItemArray[0].ToString();
            string   kupac     = ((DataRowView)o).Row.ItemArray[5].ToString();
            string   adresa    = ((DataRowView)o).Row.ItemArray[6].ToString();
            string   lk        = ((DataRowView)o).Row.ItemArray[4].ToString();
            string   jmbg      = ((DataRowView)o).Row.ItemArray[3].ToString();
            decimal  uplaceno  = (decimal)((DataRowView)o).Row.ItemArray[10];
            string   brojrata  = ((DataRowView)o).Row.ItemArray[14].ToString();
            DateTime datum     = (DateTime)((DataRowView)o).Row.ItemArray[1];
            decimal  iznos     = (decimal)((DataRowView)o).Row.ItemArray[13];
            string   napomena  = ((DataRowView)o).Row.ItemArray[18].ToString();

            List <UgovorRata> rate = PersistanceManager.ReadUgovorRata(rednibroj);
            string            plan = "";

            for (int i = 0; i < rate.Count; i++)
            {
                plan = plan + Environment.NewLine + (i + 1).ToString() + ". do " + rate[i].RokPlacanja.ToString("dd.MM.yyyy") + " - iznos: " + rate[i].Iznos.ToString("N2") + " KM";
            }


            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("OTPLATNIPLAN", plan);
            dict.Add("KUPAC", kupac);
            dict.Add("ADRESA", adresa);
            dict.Add("LK", lk);
            dict.Add("JMBG", jmbg);
            dict.Add("UPLACENO", uplaceno.ToString("N2"));
            dict.Add("BROJRATA", brojrata.ToString());
            dict.Add("DATUM", datum.ToString("dd.MM.yyyy"));
            dict.Add("IZNOSRATE", (Math.Round((iznos - uplaceno) / int.Parse(brojrata), 2, MidpointRounding.AwayFromZero)).ToString("N2"));
            dict.Add("UKUPANIZNOS", (iznos).ToString("N2"));
            dict.Add("PREDMET", napomena);
            string fileName = dir + "\\" + rednibroj.Replace("/", "-") + ".docx";

            WordDocumentBuilder.FillBookmarksUsingOpenXml("Ugovor.docx", fileName, dict);
            Process.Start(fileName);
        }
Exemplo n.º 3
0
        private void StampaPotvrdaPlacanja()
        {
            //  //string dir = Environment.SpecialFolder.MyDocuments + "\\ServisDB\\";

            string dir = System.IO.Path.Combine(Environment.GetFolderPath(
                                                    Environment.SpecialFolder.MyDoc‌​uments), "ServisDB");

            if (Directory.Exists(dir) == false)
            {
                Directory.CreateDirectory(dir);
            }
            object   o                 = dgvPrijave.SelectedRows[0].DataBoundItem;
            string   rednibroj         = ((DataRowView)o).Row.ItemArray[0].ToString();
            string   kupac             = ((DataRowView)o).Row.ItemArray[5].ToString();
            string   adresa            = ((DataRowView)o).Row.ItemArray[6].ToString();
            string   lk                = ((DataRowView)o).Row.ItemArray[4].ToString();
            string   jmbg              = ((DataRowView)o).Row.ItemArray[3].ToString();
            decimal  inicijalnoplaceno = (decimal)((DataRowView)o).Row.ItemArray[10];
            string   brojrata          = ((DataRowView)o).Row.ItemArray[14].ToString();
            DateTime datum             = (DateTime)((DataRowView)o).Row.ItemArray[1];
            decimal  iznos             = (decimal)((DataRowView)o).Row.ItemArray[13];
            string   napomena          = ((DataRowView)o).Row.ItemArray[18].ToString();
            string   brojracuna        = tbBrojRacuna.Text;
            int      brojrate          = int.Parse(tbBrojRate.Text);
            //decimal inicijalnoplaceno = decimal.Parse(tbInicijalnoUplaceno.Text);
            List <UgovorRata> rate = PersistanceManager.ReadUgovorRata(tbRedniBroj.Text);

            decimal?sumauplata = rate.Sum(r => r.Uplaceno);

            decimal  uplacenoPoRati = decimal.Parse(tbUplaceno.Text);
            DateTime datumPlacanja  = dtpDatumUplate.Value;

            string            uplacenerate = "";
            List <UgovorRata> uplate       = rate.Where(ss => ss.Iznos <= ss.Uplaceno).ToList();

            for (int i = 0; i < uplate.Count; i++)
            {
                uplacenerate = uplacenerate + Environment.NewLine + uplate[i].BrojRate.ToString() + ". " + "rata - uplaćeno: " + uplate[i].Uplaceno.Value.ToString("N2") + "" + " KM ";
            }
            string            neplacenerate = "";
            List <UgovorRata> neplaceneRate = rate.Where(ss => ss.Iznos > ss.Uplaceno).ToList();

            for (int i = 0; i < neplaceneRate.Count; i++)
            {
                neplacenerate = neplacenerate + Environment.NewLine + neplaceneRate[i].BrojRate.ToString() + ". rata" + " do " + neplaceneRate[i].RokPlacanja.ToString("dd.MM.yyyy") + " - iznos od " + neplaceneRate[i].Iznos.ToString("N2") + " KM";
            }

            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("DATUMPLACANJA", datumPlacanja.ToString("dd.MM.yyyy"));
            dict.Add("IZNOS", uplacenoPoRati.ToString());
            dict.Add("UPLACENERATE", uplacenerate);
            dict.Add("NEPLACENERATE", neplacenerate);
            dict.Add("KUPAC", kupac);
            dict.Add("ADRESA", adresa);
            dict.Add("LK", lk);
            dict.Add("JMBG", jmbg);
            dict.Add("UPLACENO", inicijalnoplaceno.ToString("N2"));
            dict.Add("BROJRATA", brojrata.ToString());
            dict.Add("DATUM", datum.ToString("dd.MM.yyyy"));
            dict.Add("IZNOSRATE", (Math.Round((iznos - inicijalnoplaceno) / int.Parse(brojrata), 2, MidpointRounding.AwayFromZero)).ToString("N2"));
            dict.Add("UKUPANIZNOS", (iznos).ToString("N2"));
            dict.Add("PREDMET", napomena);
            dict.Add("BROJRATE", brojrate.ToString());
            dict.Add("BROJRACUNA", brojracuna);
            dict.Add("BROJUGOVORA", rednibroj);
            dict.Add("INICIJALNOPLACENO", inicijalnoplaceno.ToString("N2"));
            dict.Add("UKUPNOPLACENO", (inicijalnoplaceno + sumauplata.Value).ToString("N2"));
            dict.Add("PREOSTALO", (iznos - inicijalnoplaceno - sumauplata.Value).ToString("N2"));
            string fileName = dir + "\\" + rednibroj.Replace("/", "-") + ".docx";

            WordDocumentBuilder.FillBookmarksUsingOpenXml("PotvrdaPlacanjaRate.docx", fileName, dict);
            Process.Start(fileName);
        }