Esempio n. 1
0
        private void PrikaziZbirove(int mTUD)
        {
            clsFormInitialisation fi = new clsFormInitialisation();
            string ssel = " SElect AlijasPolja from RecnikPodataka Where TotalVSubtotal='S'  and Dokument =@param0" + " AND Width>0";

            t = db.ParamsQueryDT(ssel, Dokument);
            for (int k = 0; k < t.Rows.Count; k++)
            {
                var    pb    = forma.Controls.OfType <Field>().FirstOrDefault(n => n.IME == t.Rows[k]["AlijasPolja"].ToString());
                string ssel1 = "Select sum(" + t.Rows[k]["AlijasPolja"].ToString() + ") as zbir from Unija" + Dokument + " " + WWhere;
                Console.WriteLine(ssel1);
                tt = db.ReturnDataTable(ssel1);
                if (tt.Rows.Count > 0)
                {
                    Console.WriteLine(tt.Rows[0]["zbir"].ToString());
                    if (string.IsNullOrEmpty(tt.Rows[0]["zbir"].ToString()))
                    {
                        pb.Vrednost = "0";
                    }
                    else
                    {
                        pb.Vrednost = tt.Rows[0]["zbir"].ToString();
                    }
                    pb.textBox.Text = fi.FormatirajPolje(pb.Vrednost, pb.cTip);
                    //pb.textBox.Text=string.Format("{0:###,##0.00}", tt.Rows[0]["zbir"]);
                }
            }
        }
        public Double CalculatedField(Form forma, string dokument, string iddok)
        {
            CcalculatedVal cv  = new CcalculatedVal();
            clsEvaluation  cev = new clsEvaluation();
            DataBaseBroker db  = new DataBaseBroker();

            string KojaValuta;

            // Jovana 04.11.21
            //KojaValuta = "RSD";
            KojaValuta = Program.DomacaValuta;
            string KojePolje;
            double mvrednost = 0;
            string formula   = "";
            Dictionary <string, string> Broj = new Dictionary <string, string>();

            foreach (var pb in forma.Controls.OfType <Field>())
            {
                if (pb.cPolje.Contains("IzvodiSe") == true)
                {
                    if (pb.cFormulaForme.Trim() == "")
                    {
                        pb.Vrednost = "0";
                    }
                    else
                    {
                        formula = pb.cFormulaForme.Trim();
                        string aaa = cv.CalculateValue(forma, formula); //textBox.Text = Convert.ToString(float.Parse(dt.Rows[j][dt.Columns[k].ColumnName].ToString()).ToString("###,##0.00"));
                        string rez = cev.Evaluate(aaa);
                        pb.Vrednost = Convert.ToString(rez);
                        if (pb.Vrednost.Trim() != "" || pb.Vrednost != null)
                        {
                            //pb.textBox.Text = Convert.ToString(float.Parse(rez.ToString()).ToString("###,##0.00"));
                            //Jovana 05.01.21
                            clsFormInitialisation fi = new clsFormInitialisation();
                            pb.textBox.Text = fi.FormatirajPolje(rez.ToString(), pb.cTip);
                        }
                    }
                }
            }

            foreach (var ctrls in forma.Controls.OfType <Field>())
            {
                if (ctrls.IME == "OznVal")
                {
                    // Jovana 04.11.21
                    //if (ctrls.Vrednost != "RSD")/// DomacaValuta Then
                    if (ctrls.Vrednost != Program.DomacaValuta)
                    {
                        KojaValuta = ctrls.Vrednost;
                        break;
                    }
                }
            }

            foreach (var pb in forma.Controls.OfType <Field>())
            {
                if (pb.cPolje.Contains("Slovima") == true)
                {
                    if (pb.cFormulaForme == "")
                    {
                        KojePolje = "Suma" + dokument.Trim();
                    }
                    else
                    {
                        KojePolje = pb.cFormulaForme;
                    }
                    foreach (var ct in forma.Controls.OfType <Field>())
                    {
                        if (ct.IME == KojePolje)
                        {
                            if (ct.Vrednost.Trim() != "")
                            {
                                mvrednost = Convert.ToDouble(ct.Vrednost) * 100;
                                // jovana 05.01.21
                                mvrednost = Convert.ToInt64(mvrednost);
                                if (mvrednost != 0)
                                {
                                    Console.WriteLine(mvrednost);
                                    pb.textBox.Text = cv.Slovima(mvrednost, KojaValuta);
                                    // jovana 05.01.21
                                    //Broj =  db.ExecuteStoreProcedure("BrojSlovima", "KojiBroj:" + mvrednost, "KojaValuta:"+ KojaValuta, "Slovima:") ;
                                    //pb.textBox.Text = Broj["@Slovima"].Trim();
                                }
                            }
                        }
                    }
                }
            }
            return(mvrednost);
            //neki komentar 01.12.2020.
        }
        private void writeFrom(Form forma, string dokument, string iddok, string DokumentJe)
        {
            string Uslov = "";
            string tUpit = "";

            string[] separators = new[] { "," };


            string selu = " SELECT Upit,ime  FROM dbo.Upiti  WHERE(NazivDokumenta = @param0" + ")";

            selu += " AND Ime LIKE N'ggrr%'  AND (TUD = 0)";
            DataTable tt = db.ParamsQueryDT(selu, dokument);

            for (int i = 0; i < tt.Rows.Count; i++)
            {
                string KojiSegment = tt.Rows[i]["ime"].ToString();
                KojiSegment = KojiSegment.Substring(4, KojiSegment.Length - 4);
                string mUpit = tt.Rows[i]["Upit"].ToString();

                if (DokumentJe == "I")
                {
                    Uslov = Program.WWhere;
                    clsObradaOsnovnihSifarnika os = new clsObradaOsnovnihSifarnika();
                    string res = os.DodajRestrikcije(dokument, "0");

                    if (res.Trim() != "")
                    {
                        Uslov += " AND " + res;
                    }
                    mUpit += Uslov;
                    tUpit  = mUpit;
                }
                else
                {
                    tUpit = CreateQuery(mUpit, KojiSegment, iddok, dokument, DokumentJe);
                }

                Console.WriteLine(tUpit);
                DataTable dt = db.ReturnDataTable(tUpit);
                if (dt.Rows.Count > 0)
                {
                    for (int k = 0; k < dt.Columns.Count; k++)
                    {
                        Console.WriteLine(dt.Columns[k].ColumnName.ToUpper().ToString());
                        if (dt.Columns[k].ColumnName.ToUpper().ToString().Contains("ID_") == false)
                        {
                            Field ctrls = (Field)forma.Controls[dt.Columns[k].ColumnName];

                            //Field ctrls = forma.Controls.OfType<Field>().FirstOrDefault(n => n.IME == dt.Columns[k].ColumnName.ToString());
                            if (ctrls != null)
                            {
                                //Djora 16.07.21  poc -------------------------------------
                                if (DokumentJe == "I")
                                {
                                    //Jovana 03.08.21

                                    //Djora 16.07.21
                                    if (ctrls.cIzborno != "")
                                    {
                                    }
                                    else
                                    {
                                        ctrls.Vrednost = dt.Rows[0][dt.Columns[k].ColumnName].ToString();
                                    }
                                    // Jovana 03.08.21
                                    if (ctrls.Vrednost != "")
                                    {
                                        switch (ctrls.VrstaKontrole)
                                        {
                                        case "tekst":
                                            clsFormInitialisation fi = new clsFormInitialisation();
                                            ctrls.textBox.Text = fi.FormatirajPolje(ctrls.Vrednost, ctrls.cTip);
                                            break;

                                        case "datum":
                                            ctrls.dtp.Text = string.Format("{0:dd.MM.yy}", ctrls.Vrednost.ToString());
                                            break;

                                        case "combo":
                                            ctrls.comboBox.Text = ctrls.Vrednost.ToString();
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    //Djora 16.07.21  kraj -------------------------------------
                                    ctrls.ID       = "1";
                                    ctrls.Vrednost = dt.Rows[0][dt.Columns[k].ColumnName].ToString();

                                    switch (ctrls.VrstaKontrole)
                                    {
                                    case "tekst":
                                        if (ctrls.IME == "BrDok")
                                        {
                                            forma.Controls["lBrDok"].Text = ctrls.Vrednost;
                                        }
                                        string sadrzaj           = dt.Rows[0][dt.Columns[k].ColumnName].ToString();
                                        clsFormInitialisation fi = new clsFormInitialisation();
                                        ctrls.textBox.Text = fi.FormatirajPolje(sadrzaj, ctrls.cTip);


                                        if (dokument == "IzlazniJCI")
                                        {
                                            Console.WriteLine(dt.Rows[0][dt.Columns[k].ColumnName].ToString());
                                            if (dt.Columns[k].ColumnName.ToString() == "DatumIstupa" && (string.IsNullOrEmpty(dt.Rows[0][dt.Columns[k].ColumnName].ToString())))
                                            {
                                                break;
                                            }
                                            else
                                            {
                                                if (dt.Columns[k].ColumnName.ToString() == "DatumIstupa")
                                                {
                                                    DateTime mdat = Convert.ToDateTime(dt.Rows[0][dt.Columns[k].ColumnName].ToString());
                                                    ctrls.textBox.Text = mdat.ToString("dd.MM.yy");
                                                }
                                                //Jovana 16.04.21 - ne treba mi ovo ispod
                                                //else
                                                //    ctrls.textBox.Text = dt.Rows[0][dt.Columns[k].ColumnName].ToString();
                                            }
                                        }
                                        break;

                                    case "datum":
                                        ctrls.dtp.Text = string.Format("{0:dd.MM.yy}", dt.Rows[0][dt.Columns[k].ColumnName].ToString());
                                        if (ctrls.IME == "Datum")
                                        {
                                            forma.Controls["lDatum"].Text = ctrls.dtp.Text;
                                        }
                                        break;

                                    case "combo":
                                        //ivana 24.12.2020.
                                        if (ctrls.IME.Contains("NazivSkl"))
                                        {
                                            // jovana 13.01.21
                                            if (ctrls.IME.Length == 8)
                                            {
                                                ((Bankom.frmChield)forma).NazivSkladista = dt.Rows[0][dt.Columns[k].ColumnName].ToString();
                                            }
                                            else if (ctrls.IME.Substring(8) == ((Bankom.frmChield)forma).nastavakSkladista1)
                                            {
                                                ((Bankom.frmChield)forma).NazivSkladista1 = dt.Rows[0][dt.Columns[k].ColumnName].ToString();
                                            }
                                            else
                                            {
                                                ((Bankom.frmChield)forma).NazivSkladista2 = dt.Rows[0][dt.Columns[k].ColumnName].ToString();
                                            }
                                        }
                                        ctrls.comboBox.Text = dt.Rows[0][dt.Columns[k].ColumnName].ToString();
                                        string kojiid;
                                        kojiid = "ID_" + ctrls.cAlijasTabele;
                                        for (int kk = 0; kk <= dt.Columns.Count - 1; kk++)
                                        {
                                            if (dt.Columns[kk].ColumnName.ToString() == kojiid)
                                            {
                                                string ccc = dt.Rows[0][dt.Columns[kk].ColumnName].ToString();
                                                ctrls.ID = dt.Rows[0][dt.Columns[kk].ColumnName].ToString();
                                                break;
                                            }
                                        }

                                        break;

                                    case "cek":
                                        if (dt.Rows[0][dt.Columns[k].ColumnName].ToString() == "1")
                                        {
                                            ctrls.cekboks.Checked = true;
                                        }
                                        else
                                        {
                                            ctrls.cekboks.Checked = false;
                                        }
                                        break;
                                    }
                                    //Djora 16.07.21
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var ctrls in forma.Controls.OfType <Field>().Where(g => String.Equals(g.cSegment, KojiSegment)))
                    {
                        // Jovana 09.11.21
                        //ctrls.ID = "1";
                        switch (ctrls.VrstaKontrole)
                        {
                        case "tekst":
                            // Jovana 09.11.21
                            ctrls.ID = "1";
                            if (ctrls.IME == "BrDok")
                            {
                                ctrls.Text         = ((Bankom.frmChield)forma).brdok;
                                ctrls.Vrednost     = ctrls.Text;
                                ctrls.textBox.Text = ctrls.Text;
                            }
                            break;

                        case "datum":
                            // Jovana 09.11.21
                            ctrls.ID = "1";
                            if (ctrls.IME == "Datum")
                            {
                                ctrls.dtp.Text = ((Bankom.frmChield)forma).datum;
                                //zajedno 15.6.2021.
                                if (ctrls.dtp.Text.Trim() != "")
                                {
                                    ctrls.dtp.Value = Convert.ToDateTime(ctrls.dtp.Text);
                                }
                                else
                                {
                                    ctrls.dtp.Value = DateTime.Today;
                                }
                            }
                            break;

                        case "cek":
                            // Jovana 09.11.21
                            ctrls.ID = "1";
                            break;
                        }
                    }
                }
            }
        }