Ejemplo n.º 1
0
        private void KreirajDIsketu()
        {
            string strPoziv = this.sifraugovaratelja.Text + "90";

            strPoziv = strPoziv + Razno.KontrolniBroj(strPoziv);
            string         str     = "up5924-" + this.rkdp.Text + "-" + strPoziv;
            SaveFileDialog dialog2 = new SaveFileDialog
            {
                InitialDirectory = Conversions.ToString(0),
                FileName         = str,
                RestoreDirectory = true
            };
            SaveFileDialog dialog = dialog2;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (this.SnimiDisketuZaHZZO(dialog.FileName))
                {
                    MessageBox.Show("Datoteka za HZZO uspješno kreirana.");
                }
                else
                {
                    MessageBox.Show("Greška prilikom kreiranja HZZO datoteke.");
                }
            }
        }
Ejemplo n.º 2
0
        private bool SnimiDisketuZaHZZO(string strNazivDatoteke)
        {
            bool flag = false;

            if (this.olaksica == -1)
            {
                Interaction.MsgBox("Potrebno je odabrati olakšicu za koju želite izraditi datoteku", MsgBoxStyle.OkOnly, null);
                return(flag);
            }
            try
            {
                IEnumerator    enumerator    = null;
                SqlConnection  connection    = new SqlConnection(Configuration.ConnectionString);
                SqlCommand     selectCommand = new SqlCommand();
                SqlDataAdapter adapter       = new SqlDataAdapter(selectCommand);
                selectCommand.Connection = connection;
                S_OD_REKAP_OLAKSICEDataAdapter adapter2 = new S_OD_REKAP_OLAKSICEDataAdapter();
                S_OD_REKAP_OLAKSICEDataSet     dataSet  = new S_OD_REKAP_OLAKSICEDataSet();
                object obj2 = adapter2.Fill(dataSet, this.Obracun);
                if (dataSet.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("Ne postoje obračunate olakšice!");
                    return(flag);
                }
                DataView view = new DataView {
                    Table = dataSet.S_OD_REKAP_OLAKSICE
                };
                decimal      num3   = DB.N20(RuntimeHelpers.GetObjectValue(view.Table.Compute("Sum(IZNOSOLAKSICE)", "IDOLAKSICE=" + Conversions.ToString(this.olaksica))));
                decimal      num    = DB.N20(RuntimeHelpers.GetObjectValue(view.Table.Compute("count(idradnik)", "IDOLAKSICE=" + Conversions.ToString(this.olaksica))));
                StreamWriter writer = new StreamWriter(strNazivDatoteke, false, Encoding.ASCII);
                writer.Write("0:5924-");
                writer.Write(DB.BrojVodeceNule(this.rkdp.Text, 5, 0, false, ""));
                string strPoziv = this.sifraugovaratelja.Text + "90";
                strPoziv = strPoziv + Razno.KontrolniBroj(strPoziv);
                writer.Write("-");
                writer.Write(strPoziv);
                writer.Write(":");
                writer.Write(this.nazivkorisnika);
                writer.Write("  :");
                writer.Write(Conversions.ToDate(this.datum.Value).ToString("dd.MM.yyyy"));
                writer.Write(":  ");
                writer.Write(num3.ToString("0.00").Replace(",", "."));
                writer.Write(":" + Conversions.ToString(num));
                writer.WriteLine(":");
                int num2 = 0;
                try
                {
                    enumerator = view.Table.Rows.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        DataRow current = (DataRow)enumerator.Current;
                        if (Operators.ConditionalCompareObjectEqual(current["idolaksice"], this.olaksica, false))
                        {
                            num2++;
                            writer.Write("1:5924-");
                            writer.Write(this.rkdp.Text + "-");
                            writer.Write(RuntimeHelpers.GetObjectValue(current["ZADPOJEDINACNIPOZIV"]));
                            writer.Write(":");
                            writer.Write(RuntimeHelpers.GetObjectValue(current["prezime"]));
                            writer.Write(Operators.ConcatenateObject(" ", current["ime"]));
                            writer.Write(":");
                            writer.Write(Conversions.ToDate(this.datum.Value).ToString("dd.MM.yyyy"));
                            writer.Write(":  ");
                            decimal num4 = Conversions.ToDecimal(current["iznosolaksice"]);
                            writer.Write(num4.ToString("0.00").Replace(",", "."));
                            writer.Write(":");
                            writer.Write(num2);
                            writer.WriteLine(":");
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                writer.Close();
                flag = true;
            }
            catch (System.Exception exception1)
            {
                throw exception1;

                //Interaction.MsgBox("Greška prilikom kreiranja datoteke za HZZO", MsgBoxStyle.OkOnly, null);
                //flag = false;
            }
            return(flag);
        }