Ejemplo n.º 1
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            QHS  = Meta.Conn.GetQueryHelper();
            QHC  = new CQueryHelper();

            DataRow   Source       = Meta.SourceRow;
            DataTable TEpaccParent = Source.Table.DataSet.Tables["epacc"];

            if (TEpaccParent == null)
            {
                TEpaccParent = Source.Table.DataSet.Tables["epaccview"];
            }
            DataRow ParEpacc = TEpaccParent.Select(QHC.CmpEq("idepacc", Source["idepacc"]))[0];
            int     nphase   = CfgFn.GetNoNullInt32(ParEpacc["nphase"]);
            string  s_table  = "epacc";

            if (nphase == 1)
            {
                s_table = "epacc1";
            }
            string filterCT = QHS.CmpEq("tablename", s_table);

            GetData.CacheTable(DS.sortingapplicabilityview, filterCT, null, true);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));
            string filterI      = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                           QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive, filterCT)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingapplicabilityview, filterI);
            cmbTipo.DataSource = DS.sortingapplicabilityview;
        }
Ejemplo n.º 2
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            Conn = Meta.Conn;
            QHC  = new CQueryHelper();
            QHS  = Conn.GetQueryHelper();
            string filtereserc = QHS.CmpEq("ayear", Meta.GetSys("esercizio"));

            GetData.SetStaticFilter(DS.fin, QHS.AppAnd(filtereserc, QHS.BitClear("flag", 0)));
            GetData.SetStaticFilter(DS.sortingincomefilter, filtereserc);
            GetData.SetStaticFilter(DS.sortingincomefilterview, filtereserc);

            GetData.CacheTable(DS.upb);

            string filterCT = QHS.CmpEq("tablename", "registry");

            GetData.CacheTable(DS.sortingapplicabilityview, filterCT, null, true);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));
            string filterI      = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                           QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive, filterCT)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingapplicabilityview, filterI);

            string filterI_SK = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                         QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive,
                                                                         QHS.IsNotNull("nphaseincome"))), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingapplicabilityview, filterI_SK);
        }
Ejemplo n.º 3
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            Conn = Meta.Conn;
            QHC  = new CQueryHelper();
            QHS  = Conn.GetQueryHelper();
            string filtereserc = QHS.CmpEq("ayear", Meta.GetSys("esercizio"));
            string filter      = QHS.NullOrEq("flagdalia", "S");

            GetData.SetStaticFilter(DS.service, filter);
            //GetData.CacheTable(DS.service);

            GetData.MarkToAddBlankRow(DS.service);
            GetData.Add_Blank_Row(DS.service);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));
            string filterI      = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                           QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingapplicabilityview, filterI);

            string filterI_SK = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                         QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingkind, filterI_SK);
        }
Ejemplo n.º 4
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            QHC  = new CQueryHelper();
            QHS  = Meta.Conn.GetQueryHelper();
            string    filterCT         = QHS.CmpEq("tablename", "banktransaction");
            DataTable t                = DataAccess.RUN_SELECT(Meta.Conn, "sortingapplicability", null, null, filterCT, null, null, true);
            string    filtroSorting    = QHC.FieldIn("idsorkind", t.Select());
            DataRow   rBankTransaction = Meta.SourceRow.Table.DataSet.Tables["banktransaction"].Rows[0];
            bool      isSpesa          = rBankTransaction["idexp"] != DBNull.Value;
            bool      isEntrata        = rBankTransaction["idinc"] != DBNull.Value;

            if (isSpesa && !isEntrata)
            {
                filtroTipoMov = "(movkind='S')";
            }
            if (isEntrata && !isSpesa)
            {
                filtroTipoMov = "(movkind='E')";
            }
            GetData.SetStaticFilter(DS.sortingapplicabilityview, filtroSorting);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));
            string filterI      = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                           QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive, filterCT)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingapplicabilityview, filterI);
        }
Ejemplo n.º 5
0
        private void btnListino_Click(object sender, EventArgs e)
        {
            if (Meta.IsEmpty)
            {
                return;
            }
            DataRow  Curr     = DS.stock.Rows[0];
            string   filter   = QHS.DoPar(QHS.AppOr(QHS.IsNull("validitystop"), QHS.CmpGe("validitystop", Meta.GetSys("datacontabile"))));
            MetaData Mlistino = MetaData.GetMetaData(this, "listview");

            Mlistino.FilterLocked = true;
            Mlistino.DS           = DS.Clone();

            DataRow Choosen = Mlistino.SelectOne("default", filter, "listview", null);

            if (Choosen == null)
            {
                return;
            }

            Curr["idlist"] = Choosen["idlist"];

            riempiOggetti(Choosen);

            return;
        }
Ejemplo n.º 6
0
        private void btnListino_Click(object sender, EventArgs e)
        {
            Meta = Disp.Get("listview");
            string filter = QHS.DoPar(QHS.AppOr(QHS.IsNull("validitystop"),
                                                QHS.CmpGe("validitystop", Meta.GetSys("datacontabile"))));
            MetaData Mlistino = Disp.Get("listview");

            Mlistino.FilterLocked = true;
            Mlistino.DS           = new DataSet();
            int nFilter = 0;

            //Filtro sulla classificazione merceologica
            if (chkFilterClass.Checked)
            {
                nFilter = 1;
            }

            //Filtro sulla descrizione
            if (chkListDescription.Checked)
            {
                nFilter = nFilter + 2;
            }

            if (nFilter > 0)
            {
                FrmAskDescr  FR = new FrmAskDescr(Meta.Dispatcher, nFilter);
                DialogResult D  = FR.ShowDialog(this);
                if (D != DialogResult.OK)
                {
                    return;
                }
                if (FR.Selected != null)
                {
                    object idlistclass = FR.Selected["idlistclass"];
                    filter = GetData.MergeFilters(filter,
                                                  "(idlistclass =  " + QueryCreator.quotedstrvalue(FR.Selected["idlistclass"], true) + ")");
                }

                filter = GetData.MergeFilters(filter,
                                              "(description like "
                                              + QueryCreator.quotedstrvalue("%" + FR.txtDescrizione.Text + "%", true) + ")");
            }

            DataRow Choosen = Mlistino.SelectOne("default", filter, "listview", null);

            if (Choosen == null)
            {
                return;
            }



            riempiOggetti(Choosen);

            return;
        }
Ejemplo n.º 7
0
        private void btnListino_Click(object sender, EventArgs e)
        {
            string   filter   = QHS.DoPar(QHS.AppOr(QHS.IsNull("validitystop"), QHS.CmpGe("validitystop", Meta.GetSys("datacontabile"))));
            MetaData Mlistino = MetaData.GetMetaData(this, "listview");

            Mlistino.FilterLocked = true;
            Mlistino.DS           = DS.Clone();
            if (chkListDescription.Checked)
            {
                FrmAskDescr  FR = new FrmAskDescr(Meta.Dispatcher);
                DialogResult D  = FR.ShowDialog(this);
                if (D != DialogResult.OK)
                {
                    return;
                }
                if (FR.Selected != null)
                {
                    object idlistclass = FR.Selected["idlistclass"];
                    filter = QHC.AppAnd(filter, QHC.CmpEq("idlistclass", FR.Selected["idlistclass"]));
                }
                if (FR.txtDescrizione.Text != "")
                {
                    string Description = FR.txtDescrizione.Text;
                    if (!Description.EndsWith("%"))
                    {
                        Description += "%";
                    }
                    if (!Description.StartsWith("%"))
                    {
                        Description = "%" + Description;
                    }
                    filter = QHC.AppAnd(filter, QHC.Like("description", Description));
                }
            }
            if (VeroTipoFatturaAV() == "A")
            {
                filter = QHS.AppAnd(filter, QHS.BitSet("flagvisiblekind", 1)); //bit 1: visibile nei c. passivi. BitSet confronta con <> 0
            }
            else
            {
                filter = QHS.AppAnd(filter, QHS.BitSet("flagvisiblekind", 2)); //bit 2: visibile nei c. attivi
            }
            DataRow Choosen = Mlistino.SelectOne("default", filter, "listview", null);

            if (Choosen == null)
            {
                return;
            }
            riempiOggetti(Choosen);

            return;
        }
Ejemplo n.º 8
0
        private void txtListino_Leave(object sender, EventArgs e)
        {
            if (txtListino.Text == "")
            {
                svuotaOggetti();
                return;
            }

            string filter = "";

            if (Meta.InsertMode || Meta.EditMode)
            {
                filter = QHS.DoPar(QHS.AppOr(QHS.IsNull("validitystop"), QHS.CmpGe("validitystop", Meta.GetSys("datacontabile"))));
            }
            string IntCode = txtListino.Text;

            if (!IntCode.EndsWith("%"))
            {
                IntCode += "%";
            }
            filter = GetData.MergeFilters(filter, QHS.Like("intcode", IntCode));

            MetaData Mlistino = MetaData.GetMetaData(this, "listview");

            Mlistino.FilterLocked = true;
            Mlistino.DS           = DS.Clone();

            DataRow Choosen = Mlistino.SelectOne("default", filter, "listview", null);

            if (Choosen == null)
            {
                return;
            }
            riempiOggetti(Choosen);

            if (DS.stock.Rows.Count == 0)
            {
                return;
            }
            if (!Meta.DrawStateIsDone)
            {
                return;
            }

            DataRow Curr = DS.stock.Rows[0];

            Curr["idlist"] = Choosen["idlist"];



            return;
        }
Ejemplo n.º 9
0
        private void btnListino_Click(object sender, EventArgs e)
        {
            if (Meta.IsEmpty)
            {
                return;
            }

            DataRow Curr = DS.showcasedetail.Rows[0];

            string filter = QHS.DoPar(
                QHS.AppOr(
                    QHS.IsNull("validitystop"),
                    QHS.CmpGe("validitystop", Meta.GetSys("datacontabile"))
                    )
                );

            filter = QHS.AppAnd(filter, QHS.BitSet("flagvisiblekind", 0)); //bit 0: visibile nelle prenotazioni di magazzino e nella vetrina. BitSet confronta con <> 0

            if (chkFiltraDescrizioneClassificazione.Checked)
            {
                FrmAskDescr FR = new FrmAskDescr(Meta.Dispatcher);

                if (FR.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                if (FR.Selected != null)
                {
                    object idlistclass = FR.Selected["idlistclass"];
                    filter = QHC.AppAnd(filter, QHC.CmpEq("idlistclass", FR.Selected["idlistclass"]));
                }

                if (FR.txtDescrizione.Text != "")
                {
                    string Description = FR.txtDescrizione.Text;
                    if (!Description.EndsWith("%"))
                    {
                        Description += "%";
                    }
                    if (!Description.StartsWith("%"))
                    {
                        Description = "%" + Description;
                    }
                    filter = QHC.AppAnd(filter, QHC.Like("description", Description));
                }
            }

            Meta.DoMainCommand("choose.listview.default." + filter);
        }
Ejemplo n.º 10
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            QHS  = Meta.Conn.GetQueryHelper();
            string filterCT = QHS.CmpEq("tablename", "mandate");

            GetData.CacheTable(DS.sortingapplicabilityview, filterCT, null, true);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));
            string filterI      = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                           QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive, filterCT)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingapplicabilityview, filterI);
        }
Ejemplo n.º 11
0
        private void calcolaConsolidato()
        {
            DataRow Curr       = DS.finyearview.Rows[0];
            object  idBilancio = Curr["idfin"];
            string  idupb      = Curr["idupb"].ToString();

            string filtro = QHS.DoPar(QHS.AppOr(QHS.CmpEq("idupb", idupb), "(paridupb LIKE '" + idupb + "%')"));

            filtro = QHS.AppAnd(filtro, QHS.CmpEq("idfin", idBilancio));
            string expr = "";

            foreach (string field in new string[] { "prevision", "secondaryprev", "previousprevision", "previoussecondaryprev",
                                                    "currentarrears", "previousarrears", "prevision2", "prevision3", "prevision4", "prevision5" })
            {
                if (expr != "")
                {
                    expr += ",";
                }
                expr += "SUM(" + field + ") as " + field;
            }
            DataTable Tfinyearview = Meta.Conn.SQLRunner("SELECT " + expr + " FROM finyearview WHERE " + filtro, false);


            decimal previsioneCorr    = 0;
            decimal previsioneSecCorr = 0;
            decimal previsionePrec    = 0;
            decimal previsioneSecPrec = 0;
            decimal residuiCorr       = 0;
            decimal residuiPrec       = 0;
            decimal previsioneAnno2   = 0;
            decimal previsioneAnno3   = 0;
            decimal previsioneAnno4   = 0;
            decimal previsioneAnno5   = 0;

            foreach (DataRow rFinYear in Tfinyearview.Select())
            {
                previsioneCorr    += (decimal)isNull(rFinYear["prevision"], 0m);
                previsioneSecCorr += (decimal)isNull(rFinYear["secondaryprev"], 0m);
                previsionePrec    += (decimal)isNull(rFinYear["previousprevision"], 0m);
                previsioneSecPrec += (decimal)isNull(rFinYear["previoussecondaryprev"], 0m);
                residuiCorr       += (decimal)isNull(rFinYear["currentarrears"], 0m);
                residuiPrec       += (decimal)isNull(rFinYear["previousarrears"], 0m);
                previsioneAnno2   += (decimal)isNull(rFinYear["prevision2"], 0m);
                previsioneAnno3   += (decimal)isNull(rFinYear["prevision3"], 0m);
                previsioneAnno4   += (decimal)isNull(rFinYear["prevision4"], 0m);
                previsioneAnno5   += (decimal)isNull(rFinYear["prevision5"], 0m);
            }
            txtPrevisionePrincipaleCorrConsolidato.Text = previsioneCorr.ToString("c");
            txtPrevisioneSecondariaCorrConsolidato.Text = previsioneSecCorr.ToString("c");
            txtPrevisionePrincipalePrecConsolidato.Text = previsionePrec.ToString("c");
            txtPrevisioneSecondariaPrecConsolidato.Text = previsioneSecPrec.ToString("c");
            txtResiduiCorrConsolidato.Text = residuiCorr.ToString("c");
            txtResiduiPrecConsolidato.Text = residuiPrec.ToString("c");
            txtPrevisione2Consolidato.Text = previsioneAnno2.ToString("c");
            txtPrevisione3Consolidato.Text = previsioneAnno3.ToString("c");
            txtPrevisione4Consolidato.Text = previsioneAnno4.ToString("c");
            txtPrevisione5Consolidato.Text = previsioneAnno5.ToString("c");
        }
Ejemplo n.º 12
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            QHC  = new CQueryHelper();
            QHS  = Meta.Conn.GetQueryHelper();
            GetData.SetSorting(DS.registrysortingview, "idreg");
            string filterCT = QHS.CmpEq("tablename", "registry");

            GetData.CacheTable(DS.sortingapplicabilityview, filterCT, null, true);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));
            string filterI      = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                           QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive, filterCT)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingapplicabilityview, filterI);
            //DataAccess.SetTableForReading(DS.cdruolo_alias,"cdruolo");
            //HelpForm.SetDenyNull(DS.cdposruolo.flagattivoColumn,true);
        }
Ejemplo n.º 13
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            Conn = Meta.Conn;
            QHC  = new CQueryHelper();
            QHS  = Conn.GetQueryHelper();
            string filtereserc = QHS.CmpEq("ayear", Meta.GetSys("esercizio"));

            GetData.SetStaticFilter(DS.autoclawbacksorting, filtereserc);
            GetData.SetStaticFilter(DS.autoclawbacksortingview, filtereserc);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));

            string filterI_SK = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                         QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive)), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingkind, filterI_SK);
        }
Ejemplo n.º 14
0
        private void btnSpesa_Click(object sender, EventArgs e)
        {
            string filter    = "";
            string filterreg = QHS.DoPar(QHS.AppOr(QHS.IsNull("idreg"), QHS.CmpEq("idreg", idpettycashreg)));

            int selectedfase = CfgFn.GetNoNullInt32(cmbFaseSpesa.SelectedValue);

            if (selectedfase > 0)
            {
                filter = QHS.AppAnd(filter, filterreg, QHS.CmpEq("nphase", selectedfase));
            }
            else
            {
                filter = QHS.AppAnd(filter, QHS.AppAnd(filterreg,
                                                       QHS.CmpNe("nphase", Conn.GetSys("maxexpensephase")),
                                                       QHS.CmpGe("nphase", Conn.GetSys("expensefinphase"))));
            }
            int     ymov             = CfgFn.GetNoNullInt32(txtEserc.Text.Trim());
            int     nmov             = CfgFn.GetNoNullInt32(txtNum.Text.Trim());
            decimal importoForFilter = CfgFn.GetNoNullDecimal(HelpForm.GetObjectFromString(typeof(Decimal), txtImporto.Text, "x.y.c"));

            if (importoForFilter == 0)
            {
                importoForFilter = importoRimasto;
            }

            if (importoForFilter > 0)
            {
                filter = QHS.AppAnd(filter, QHS.CmpGe("available", importoForFilter));
            }
            if (ymov != 0)
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("ymov", ymov));
            }

            if ((ymov != 0) && (nmov != 0))
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("nmov", nmov));
            }

            MetaData E = Disp.Get("expense");

            E.FilterLocked = true;
            E.DS           = D.Clone();
            DataRow Choosen = E.SelectOne("default", filter, "expense", null);

            if (Choosen == null)
            {
                return;
            }
            idexp         = Choosen["idexp"];
            txtEserc.Text = Choosen["ymov"].ToString();
            txtNum.Text   = Choosen["nmov"].ToString();
            cmbFaseSpesa.SelectedValue = Choosen["nphase"];
        }
Ejemplo n.º 15
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            QHC  = new CQueryHelper();
            QHS  = Meta.Conn.GetQueryHelper();
            Conn = Meta.Conn;
            string  filtereserc = QHS.CmpEq("ayear", Meta.GetSys("esercizio"));
            DataRow ParentRow   = Meta.SourceRow;
            //string filterupb = QHS.CmpEq("idupb", ParentRow["idupb"]);
            //string filter = QHS.AppAnd(QHS.IsNull("idfin"), QHS.IsNull("idman"), QHS.IsNull("idsorreg"), QHS.IsNull("idsorkindreg"));
            //filter = QHS.AppAnd(filter, filtereserc, filterupb);
            //GetData.SetStaticFilter(DS.sortingexpensefilter, filter);
            //GetData.SetStaticFilter(DS.sortingexpensefilterview, filter);

            string filterActive = QHS.DoPar(QHS.AppOr(QHS.NullOrEq("active", 'S'), QHS.CmpEq("active", "")));
            string filterI_SK   = QHS.DoPar(QHS.AppOr(QHS.DoPar(QHS.AppAnd(QHS.NullOrLe("start", Meta.GetSys("esercizio")),
                                                                           QHS.NullOrGe("stop", Meta.GetSys("esercizio")), filterActive,
                                                                           QHS.IsNotNull("nphaseexpense"))), QHS.CmpEq("idsorkind", 0)));

            QueryCreator.SetFilterForInsert(DS.sortingkind, filterI_SK);
        }
Ejemplo n.º 16
0
        private void calcolaConsolidato()
        {
            DataRow Curr      = DS.budgetprevisionview.Rows[0];
            object  idSorting = Curr["idsor"];
            string  idupb     = Curr["idupb"].ToString();

            string filtro = QHS.DoPar(QHS.AppOr(QHS.CmpEq("idupb", idupb), "(paridupb LIKE '" + idupb + "%')"));

            filtro = QHS.AppAnd(filtro, QHS.CmpEq("idsor", idSorting));
            string expr = "";

            foreach (string field in new string[] { "prevision", "previousprevision",
                                                    "prevision2", "prevision3", "prevision4", "prevision5" })
            {
                if (expr != "")
                {
                    expr += ",";
                }
                expr += "SUM(" + field + ") as " + field;
            }
            DataTable Tbudgetprevisionview = Meta.Conn.SQLRunner("SELECT " + expr + " FROM budgetprevisionview WHERE " + filtro, false);


            decimal previsioneCorr = 0;

            decimal previsionePrec = 0;

            decimal previsioneAnno2 = 0;
            decimal previsioneAnno3 = 0;
            decimal previsioneAnno4 = 0;
            decimal previsioneAnno5 = 0;

            foreach (DataRow rbudgetprevision in Tbudgetprevisionview.Select())
            {
                previsioneCorr += (decimal)isNull(rbudgetprevision["prevision"], 0m);

                previsionePrec += (decimal)isNull(rbudgetprevision["previousprevision"], 0m);

                previsioneAnno2 += (decimal)isNull(rbudgetprevision["prevision2"], 0m);
                previsioneAnno3 += (decimal)isNull(rbudgetprevision["prevision3"], 0m);
                previsioneAnno4 += (decimal)isNull(rbudgetprevision["prevision4"], 0m);
                previsioneAnno5 += (decimal)isNull(rbudgetprevision["prevision5"], 0m);
            }
            txtPrevisionePrincipaleCorrConsolidato.Text = previsioneCorr.ToString("c");
            txtPrevisionePrincipalePrecConsolidato.Text = previsionePrec.ToString("c");
            txtPrevisione2Consolidato.Text = previsioneAnno2.ToString("c");
            txtPrevisione3Consolidato.Text = previsioneAnno3.ToString("c");
            txtPrevisione4Consolidato.Text = previsioneAnno4.ToString("c");
            txtPrevisione5Consolidato.Text = previsioneAnno5.ToString("c");
        }
Ejemplo n.º 17
0
        private void calcolaConsolidato()
        {
            DataRow   Curr            = DS.finyearview.Rows[0];
            object    idBilancio      = Curr["idfin"];
            int       esercizio       = (int)Meta.GetSys("esercizio");
            string    filterEsercizio = QHS.CmpEq("ayear", esercizio);
            string    filter          = QHS.AppAnd(QHS.CmpEq("idfin", idBilancio), filterEsercizio);
            DataTable Tfinyearview    = DataAccess.RUN_SELECT(Meta.Conn, "finyearview", "*", "codeupb", filter, null, null, true);

            decimal previsioneCorr    = 0;
            decimal previsioneSecCorr = 0;
            decimal previsionePrec    = 0;
            decimal previsioneSecPrec = 0;
            decimal residuiCorr       = 0;
            decimal residuiPrec       = 0;
            decimal previsioneAnno2   = 0;
            decimal previsioneAnno3   = 0;
            decimal previsioneAnno4   = 0;
            decimal previsioneAnno5   = 0;

            string filtro = QHS.AppOr(QHS.CmpEq("idupb", Curr["idupb"]), "(paridupb LIKE '" + Curr["idupb"] + "%')");

            foreach (DataRow rFinYear in Tfinyearview.Select(filtro))
            {
                previsioneCorr    += (decimal)isNull(rFinYear["prevision"], 0m);
                previsioneSecCorr += (decimal)isNull(rFinYear["secondaryprev"], 0m);
                previsionePrec    += (decimal)isNull(rFinYear["previousprevision"], 0m);
                previsioneSecPrec += (decimal)isNull(rFinYear["previoussecondaryprev"], 0m);
                residuiCorr       += (decimal)isNull(rFinYear["currentarrears"], 0m);
                residuiPrec       += (decimal)isNull(rFinYear["previousarrears"], 0m);
                previsioneAnno2   += (decimal)isNull(rFinYear["prevision2"], 0m);
                previsioneAnno3   += (decimal)isNull(rFinYear["prevision3"], 0m);
                previsioneAnno4   += (decimal)isNull(rFinYear["prevision4"], 0m);
                previsioneAnno5   += (decimal)isNull(rFinYear["prevision5"], 0m);
            }
            txtPrevisionePrincipaleCorrConsolidato.Text = previsioneCorr.ToString("c");
            txtPrevisioneSecondariaCorrConsolidato.Text = previsioneSecCorr.ToString("c");
            txtPrevisionePrincipalePrecConsolidato.Text = previsionePrec.ToString("c");
            txtPrevisioneSecondariaPrecConsolidato.Text = previsioneSecPrec.ToString("c");
            txtResiduiCorrConsolidato.Text = residuiCorr.ToString("c");
            txtResiduiPrecConsolidato.Text = residuiPrec.ToString("c");
            txtPrevisione2Consolidato.Text = previsioneAnno2.ToString("c");
            txtPrevisione3Consolidato.Text = previsioneAnno3.ToString("c");
            txtPrevisione4Consolidato.Text = previsioneAnno4.ToString("c");
            txtPrevisione5Consolidato.Text = previsioneAnno5.ToString("c");
        }
Ejemplo n.º 18
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            QHC  = new CQueryHelper();
            QHS  = Meta.Conn.GetQueryHelper();
            string filtro = "";

            if (DS.banktransaction.ExtendedProperties[MetaData.ExtraParams] != null)
            {
                filtro = DS.banktransaction.ExtendedProperties[MetaData.ExtraParams].ToString();
            }
            DataRow Parent        = Meta.SourceRow;
            string  filterpayment = QHS.MCmp(Parent, "kpay");

            GetData.SetStaticFilter(DS.payment_bankview, filterpayment);

            string filtroSpesa = QHS.AppAnd(filtro, QHS.CmpEq("nphase", Meta.GetSys("maxexpensephase")));

            string filtrostatico = filtroSpesa;

            if (Meta.SourceRow != null)
            {
                DataRow Curr = Meta.SourceRow;
                if (Curr["idexp"] != DBNull.Value)
                {
                    filtrostatico = QHS.DoPar(QHS.AppOr(QHS.DoPar(filtroSpesa), QHS.CmpEq("idexp", Curr["idexp"])));
                }
            }


            GetData.SetStaticFilter(DS.expenseview, filtrostatico);

            object nomeFase = Meta.Conn.DO_READ_VALUE("expensephase", QHS.CmpEq("nphase", Meta.GetSys("maxexpensephase")), "description");
            string fase     = (nomeFase != null) ? nomeFase.ToString() : "";

            grpMovSpesa.Text         = fase;
            btnMovSpesa.Text         = fase;
            standardTagBtnMovSpesa   = HelpForm.GetStandardTag(btnMovSpesa.Tag);
            btnCollegaBankImport.Tag = btnCollegaBankImport.Tag + "." + QHS.DoPar(QHS.CmpEq("ayear", Meta.GetSys("esercizio")));
        }
Ejemplo n.º 19
0
        void riempiGrid()
        {
            var filtercurrency = QHS.CmpEq("idcurrency", _idcurrency);

            filtercurrency = QHS.DoPar(QHS.AppOr(filtercurrency, QHS.IsNull("idcurrency")));
            var filter = QHS.AppAnd(filtercurrency, filterregistry);

            filter = QHS.AppAnd(filter, QHS.CmpNe("toinvoice", "N"), QHS.CmpEq("linktoinvoice", "S"));
            var currency = Conn.DO_READ_VALUE("currency", filtercurrency, "description");

            if (currency != null)
            {
                lblValuta.Text = currency.ToString().ToUpper();
            }
            var estimateDetail =
                Conn.RUN_SELECT("estimatedetailtoinvoice", "*", "idestimkind ASC,yestim DESC,nestim DESC,rownum ASC, idgroup ASC",
                                filter, null, false);

            Conn.DeleteAllUnselectable(estimateDetail);
            if (estimateDetail.Rows.Count != 0)
            {
                estimateDetail.PrimaryKey = new[] { estimateDetail.Columns["idestimkind"],
                                                    estimateDetail.Columns["yestim"],
                                                    estimateDetail.Columns["nestim"],
                                                    estimateDetail.Columns["rownum"] };
                //Ora ha messo in EstimateDetail tutto ciò che da DB risulta 'da fatturare'.

                //Effettua ora una serie di allineamenti sul DataTable per renderlo più coerente con quello
                //che c'è nel DataSet del form padre.

                //Per ogni riga del DataSet in stato di INSERT/UPDATE effettua una sottrazione ed eventualmente
                //un delete su MandateDetail se la riga corrispondente risulta essere esaurita.
                foreach (var r in InvoiceDetail.Select())
                {
                    if (r.RowState != DataRowState.Added)
                    {
                        continue;
                    }
                    if (r["idmankind"] == DBNull.Value)
                    {
                        continue;                                                  //Non è una riga collegata a dettagli ordine
                    }
                    var filterestim = QHC.CmpMulti(r, "idestimkind", "yestim", "nestim");
                    filterestim = QHC.AppAnd(filterestim, QHC.CmpEq("rownum", r["estimrownum"]));
                    var rm = estimateDetail.Select(filterestim);
                    if (rm.Length == 0)
                    {
                        continue;
                    }
                    var     detail      = rm[0];
                    decimal oldnumber   = 0;
                    decimal newnumber   = CfgFn.GetNoNullDecimal(r["number", DataRowVersion.Current]);
                    decimal oldinvoiced = CfgFn.GetNoNullDecimal(detail["invoiced"]);
                    decimal newinvoiced = oldinvoiced + newnumber - oldnumber;
                    detail["invoiced"] = newinvoiced;
                }

                foreach (var r in InvoiceDetail.Select())
                {
                    if (r.RowState != DataRowState.Modified)
                    {
                        continue;
                    }
                    string filterestim = QHC.CmpMulti(r, "idestimkind", "yestim", "nestim");
                    filterestim = QHC.AppAnd(filterestim, QHC.CmpEq("rownum", r["estimrownum"]));
                    var rm = estimateDetail.Select(filterestim);
                    if ((rm.Length == 0))
                    {
                        continue;
                    }
                    DataRow detail = rm[0];
                    decimal oldnumber;
                    if (r["idestimkind", DataRowVersion.Original] == DBNull.Value)
                    {
                        oldnumber = 0;
                    }
                    else
                    {
                        oldnumber = CfgFn.GetNoNullDecimal(r["number", DataRowVersion.Original]);
                    }

                    decimal newnumber;
                    if (r["idestimkind", DataRowVersion.Current] == DBNull.Value)
                    {
                        newnumber = 0;
                    }
                    else
                    {
                        newnumber = CfgFn.GetNoNullDecimal(r["number", DataRowVersion.Current]);
                    }

                    var oldinvoiced = CfgFn.GetNoNullDecimal(detail["invoiced"]);
                    var newinvoiced = oldinvoiced + newnumber - oldnumber;
                    detail["invoiced"] = newinvoiced;
                }

                foreach (DataRow r in InvoiceDetail.Rows)
                {
                    if (r.RowState != DataRowState.Deleted)
                    {
                        continue;
                    }
                    if (r["idestimkind", DataRowVersion.Original] == DBNull.Value)
                    {
                        continue;
                    }

                    string filterestim = QHC.CmpMulti(r, "idestimkind", "yestim", "nestim");
                    filterestim = QHC.AppAnd(filterestim, QHC.CmpEq("rownum", r["estimrownum", DataRowVersion.Original]));

                    var rm = estimateDetail.Select(filterestim);
                    if ((rm.Length == 0))
                    {
                        continue;
                    }
                    var     detail      = rm[0];
                    var     oldnumber   = CfgFn.GetNoNullDecimal(r["number", DataRowVersion.Original]);
                    decimal newnumber   = 0;
                    var     oldinvoiced = CfgFn.GetNoNullDecimal(detail["invoiced"]);
                    var     newinvoiced = oldinvoiced + newnumber - oldnumber;
                    detail["invoiced"] = newinvoiced;
                }

                foreach (var r in estimateDetail.Select())
                {
                    var invoiced = CfgFn.GetNoNullDecimal(r["invoiced"]);
                    var ordered  = CfgFn.GetNoNullDecimal(r["ordered"]);
                    var residual = ordered - invoiced;
                    r["residual"] = residual;
                    if (residual == 0)
                    {
                        r.Delete();
                    }
                }

                estimateDetail.AcceptChanges();
                if (estimateDetail.Select().Length <= 0)
                {
                    return;
                }
                var map = Meta.Dispatcher.Get("estimatedetailtoinvoice");
                map.DescribeColumns(estimateDetail, "default");
                var d = new DataSet();
                d.Tables.Add(estimateDetail);
                HelpForm.SetDataGrid(gridDettagli, estimateDetail);
                gridDettagli.TableStyles.Clear();
                HelpForm.SetGridStyle(gridDettagli, estimateDetail);
                var format = new formatgrids(gridDettagli);
                format.AutosizeColumnWidth();
                HelpForm.SetAllowMultiSelection(estimateDetail, true);
                selezionaTutto();
            }
        }
Ejemplo n.º 20
0
        void riempiGrid()
        {
            if (!HasDDT)
            {
                labDDT.Visible = false;
            }

            string filtercurrency = QHS.CmpEq("idcurrency", idcurrency);

            filtercurrency = QHS.DoPar(QHS.AppOr(filtercurrency, QHS.IsNull("idcurrency")));
            string filter = QHS.AppAnd(filterregistry, filterflagmixed);

            filter = QHS.AppAnd(filter, filtercurrency);
            filter = QHS.AppAnd(filter, QHS.CmpNe("toinvoice", 'N'), QHS.CmpEq("linktoinvoice", 'S'));
            filter = QHS.AppAnd(filter, QHS.CmpEq("idmandatestatus", 5)); // stato approvato

            object currency = Conn.DO_READ_VALUE("currency", filtercurrency, "description");

            if (currency != null)
            {
                lblValuta.Text = currency.ToString().ToUpper();
            }
            DataTable mandateDetail;

            if (HasDDT)
            {
                mandateDetail = Conn.RUN_SELECT("mandatedetailstockedtoinvoice", "*",
                                                "idmankind ASC,yman DESC,nman DESC,rownum ASC, idgroup ASC",
                                                filter, null, false);
            }
            else
            {
                mandateDetail = Conn.RUN_SELECT("mandatedetailnoddttoinvoice", "*",
                                                "idmankind ASC,yman DESC,nman DESC,rownum ASC, idgroup ASC",
                                                filter, null, false);
            }

            Conn.DeleteAllUnselectable(mandateDetail);

            if (mandateDetail.Rows.Count != 0)
            {
                mandateDetail.PrimaryKey = new[] { mandateDetail.Columns["idmankind"],
                                                   mandateDetail.Columns["yman"],
                                                   mandateDetail.Columns["nman"],
                                                   mandateDetail.Columns["rownum"] };
                //Ora ha messo in MandateDetail tutto ciò che da DB risulta 'da fatturare'.

                //Effettua ora una serie di allineamenti sul DataTable per renderlo più coerente con quello
                // che c'è nel DataSet del form padre.

                //Per ogni riga del DataSet in stato di INSERT/UPDATE effettua una sottrazione ed eventualmente
                // un delete su MandateDetail se la riga corrispondente risulta essere esaurita.
                foreach (DataRow R in InvoiceDetail.Select())
                {
                    if (R.RowState != DataRowState.Added)
                    {
                        continue;
                    }
                    if (R["idmankind"] == DBNull.Value)
                    {
                        continue;                                                  //Non è una riga collegata a dettagli ordine
                    }
                    string filtermand = QHC.CmpMulti(R, "idmankind", "yman", "nman");
                    filtermand = QHC.AppAnd(filtermand, QHC.CmpEq("rownum", R["manrownum"]));

                    DataRow [] RM = mandateDetail.Select(filtermand);
                    if ((RM.Length == 0))
                    {
                        continue;
                    }
                    var     detail      = RM[0];
                    decimal oldnumber   = 0;
                    decimal newnumber   = CfgFn.GetNoNullDecimal(R["number", DataRowVersion.Current]);
                    decimal oldresidual = CfgFn.GetNoNullDecimal(detail["residual"]);
                    decimal newresidual = oldresidual - newnumber + oldnumber;
                    detail["residual"] = newresidual;
                }

                foreach (DataRow R in InvoiceDetail.Select())
                {
                    if (R.RowState != DataRowState.Modified)
                    {
                        continue;
                    }
                    string filtermand = QHC.CmpMulti(R, "idmankind", "yman", "nman");
                    filtermand = QHC.AppAnd(filtermand, QHC.CmpEq("rownum", R["manrownum"]));
                    DataRow[] RM = mandateDetail.Select(filtermand);
                    if ((RM.Length == 0))
                    {
                        continue;
                    }
                    DataRow detail = RM[0];
                    decimal oldnumber;
                    if (R["idmankind", DataRowVersion.Original] == DBNull.Value)
                    {
                        oldnumber = 0;
                    }
                    else
                    {
                        oldnumber = CfgFn.GetNoNullDecimal(R["number", DataRowVersion.Original]);
                    }

                    decimal newnumber;
                    if (R["idmankind", DataRowVersion.Current] == DBNull.Value)
                    {
                        newnumber = 0;
                    }
                    else
                    {
                        newnumber = CfgFn.GetNoNullDecimal(R["number", DataRowVersion.Current]);
                    }


                    decimal oldresidual = CfgFn.GetNoNullDecimal(detail["residual"]);
                    decimal newresidual = oldresidual - newnumber + oldnumber;
                    detail["residual"] = newresidual;
                }

                foreach (DataRow r in InvoiceDetail.Rows)
                {
                    if (r.RowState != DataRowState.Deleted)
                    {
                        continue;
                    }
                    if (r["idmankind", DataRowVersion.Original] == DBNull.Value)
                    {
                        continue;
                    }

                    string filtermand = QHC.CmpMulti(r, "idmankind", "yman", "nman");
                    filtermand = QHC.AppAnd(filtermand, QHC.CmpEq("rownum", r["manrownum", DataRowVersion.Original]));

                    DataRow [] RM = mandateDetail.Select(filtermand);
                    if ((RM.Length == 0))
                    {
                        continue;
                    }
                    DataRow Detail      = RM[0];
                    decimal oldnumber   = CfgFn.GetNoNullDecimal(r["number", DataRowVersion.Original]);
                    decimal newnumber   = 0;
                    decimal oldresidual = CfgFn.GetNoNullDecimal(Detail["residual"]);
                    decimal newresidual = oldresidual - newnumber + oldnumber;
                    Detail["residual"] = newresidual;
                }

                foreach (DataRow R in mandateDetail.Select())
                {
                    decimal residual = CfgFn.GetNoNullDecimal(R["residual"]);
                    if (residual == 0)
                    {
                        R.Delete();
                    }
                }

                mandateDetail.AcceptChanges();
                if (mandateDetail.Select().Length > 0)
                {
                    MetaData MAP;
                    if (HasDDT)
                    {
                        MAP = Meta.Dispatcher.Get("mandatedetailstockedtoinvoice");
                    }
                    else
                    {
                        MAP = Meta.Dispatcher.Get("mandatedetailnoddttoinvoice");
                    }
                    MAP.DescribeColumns(mandateDetail, "default");
                    DataSet D = new DataSet();
                    D.Tables.Add(mandateDetail);
                    HelpForm.SetDataGrid(gridDettagli, mandateDetail);
                    gridDettagli.TableStyles.Clear();
                    HelpForm.SetGridStyle(gridDettagli, mandateDetail);
                    formatgrids format = new formatgrids(gridDettagli);
                    format.AutosizeColumnWidth();
                    HelpForm.SetAllowMultiSelection(mandateDetail, true);
                    SelezionaTutto();
                }
            }
        }
Ejemplo n.º 21
0
        private void valorizzaFlagTransmitted()
        {
            StringBuilder SB = new StringBuilder();

            // Update su ASSET
            string q1 =
                "UPDATE asset SET transmitted = 'S' "
                + " WHERE (transmitted = 'N') OR  EXISTS "
                + " (SELECT ac.nassetacquire FROM assetacquire ac "
                + " JOIN inventory i "
                + " ON i.idinventory = ac.idinventory "
                + " WHERE ("
                + " ac.nassetacquire = asset.nassetacquire AND "
                + " (" + QHS.IsNull("asset.transmitted") + " AND "
                + " ((" + QHS.IsNotNull("asset.idassetunload") + " OR " + QHS.DoPar(QHS.AppAnd(QHS.IsNull("asset.idassetunload"), QHS.BitClear("asset.flag", 0))) + ") "
                + " OR ((ac.idassetload IS NOT NULL) OR " + QHS.DoPar(QHS.AppAnd(QHS.IsNull("ac.idassetload"), QHS.BitClear("ac.flag", 0))) + ")))) "
                + " AND i.idinventoryagency = " + QueryCreator.quotedstrvalue(enteScelto, true)
                + ")";

            ArrayList elencoBeni = new ArrayList();

            string filter = "";

            foreach (DataRow rBene in dsEsporta.Tables["assetamortization"].Rows)
            {
                string idasset_piece = rBene["idasset"].ToString() + "," + rBene["idpiece"].ToString();
                if (elencoBeni.Contains(idasset_piece))
                {
                    continue;
                }
                elencoBeni.Add(idasset_piece);

                filter = QHS.AppOr(filter,
                                   QHS.DoPar(
                                       QHS.AppAnd(QHS.CmpEq("idasset", rBene["idasset"]), QHS.CmpEq("idpiece", rBene["idpiece"]))));
            }

            if (filter != "")
            {
                q1 = QHS.AppOr(q1, QHS.DoPar(filter));
            }

            SB.Append(q1);
            SB.Append("\n\rGO\n\r");

            // Update su ASSETACQUIRE
            string q2 =
                "UPDATE assetacquire SET transmitted = 'S' "
                + " WHERE EXISTS "
                + "(SELECT i.idinventory FROM inventory i "
                + " WHERE "
                + " ((assetacquire.transmitted IS NULL) "
                + "	AND ((assetacquire.idassetload IS NOT NULL) "
                + " OR " + QHS.DoPar(QHS.AppAnd(QHS.IsNull("assetacquire.idassetload"), QHS.BitClear("assetacquire.flag", 0))) + "))"
                + " AND i.idinventoryagency = " + QueryCreator.quotedstrvalue(enteScelto, true)
                + " AND assetacquire.idinventory = i.idinventory)"
                + " OR (transmitted = 'N')";

            SB.Append(q2);
            SB.Append("\n\rGO\n\r");

            // Update su ASSETAMORTIZATION
            string q3 =
                "UPDATE assetamortization SET transmitted = 'S' "
                + " WHERE EXISTS "
                + "(SELECT A.idasset FROM asset A "
                + " JOIN assetacquire ac "
                + " ON ac.nassetacquire = A.nassetacquire "
                + " JOIN inventory I "
                + " ON I.idinventory = ac.idinventory "
                + " WHERE ((assetamortization.transmitted IS NULL) "
                + " AND ((assetamortization.idassetunload IS NOT NULL) "
                + " OR " + QHS.DoPar(QHS.AppAnd(QHS.IsNull("assetamortization.idassetunload"), QHS.BitClear("assetamortization.flag", 0))) + "))"
                + " AND I.idinventoryagency = " + QueryCreator.quotedstrvalue(enteScelto, true)
                + " AND assetamortization.idasset = A.idasset AND assetamortization.idpiece = A.idpiece)"
                + " OR (transmitted = 'N')";

            SB.Append(q3);
            SB.Append("\n\rGO\n\r");

            // Update su ASSETLOAD
            string q4 =
                "UPDATE assetload SET transmitted = 'S' "
                + " WHERE EXISTS "
                + " (SELECT TBC.idassetloadkind FROM assetloadkind TBC "
                + " JOIN inventory I ON I.idinventory = TBC.idinventory "
                + " WHERE (ISNULL(assetload.transmitted,'N') = 'N') "
                + " AND (I.idinventoryagency = " + QueryCreator.quotedstrvalue(enteScelto, true)
                + ") AND TBC.idassetloadkind = assetload.idassetloadkind)";

            SB.Append(q4);
            SB.Append("\n\rGO\n\r");
            // Update su ASSETUNLOAD
            string q5 =
                "UPDATE assetunload SET transmitted = 'S' "
                + " WHERE EXISTS "
                + " (SELECT TBC.idassetunloadkind FROM assetunloadkind TBC "
                + " JOIN inventory I ON I.idinventory = TBC.idinventory "
                + " WHERE (ISNULL(assetunload.transmitted,'N') = 'N') "
                + " AND (I.idinventoryagency = " + QueryCreator.quotedstrvalue(enteScelto, true)
                + ") AND TBC.idassetunloadkind = assetunload.idassetunloadkind)";

            SB.Append(q5);
            SB.Append("\n\rGO\n\r");

            if (SB.ToString() != "")
            {
                string error;
                Download.RUN_SCRIPT(Meta.Conn, SB, out error);
            }
        }
Ejemplo n.º 22
0
        private void btnCopertura_Click(object sender, System.EventArgs e)
        {
            if (DS.bill.Rows.Count == 0)
            {
                return;
            }
            DataRow     R      = DS.bill.Rows[0];
            QueryHelper QHS    = Meta.Conn.GetQueryHelper();
            string      filter = QHS.AppAnd(QHS.CmpEq("ayear", R["ybill"]), QHS.CmpEq("ymov", R["ybill"]), QHS.CmpEq("nbill", R["nbill"]));

            string where_multiplo = QHS.AppAnd(QHS.CmpEq("ybill", R["ybill"]), QHS.CmpEq("nbill", R["nbill"]));
            string filtermultiplo = "";



            string table = null;

            if (DS.bill.Rows[0]["billkind"].ToString() == "C")
            {
                table = "income";
                DataTable t = Conn.RUN_SELECT("incomebill", "idinc", null, where_multiplo, null, false);
                if (t != null && t.Rows.Count > 0)
                {
                    filtermultiplo = QHS.AppAnd(QHS.CmpEq("ayear", R["ybill"]), QHS.CmpEq("ymov", R["ybill"]), QHS.FieldIn("idinc", t.Select()));
                    //"  (idinc in (select idinc from incomebill EB where " + where_multiplo + "))";
                }
            }
            else
            {
                table = "expense";
                DataTable t = Conn.RUN_SELECT("expensebill", "idexp", null, where_multiplo, null, false);
                if (t != null && t.Rows.Count > 0)
                {
                    filtermultiplo = QHS.AppAnd(QHS.CmpEq("ayear", R["ybill"]), QHS.CmpEq("ymov", R["ybill"]), QHS.FieldIn("idexp", t.Select()));
                    //filtermultiplo = "  (idexp in (select idexp from expensebill EB where " + where_multiplo + "))";
                }
            }

            filter = QHS.DoPar(QHS.AppOr(filter, filtermultiplo));

            MetaData m = MetaData.GetDispatcher(this).Get(table);
            //m.SelectOne("default",filter,null,null);


            int rowsfound = Meta.Conn.RUN_SELECT_COUNT(table + "view", filter, true);

            if (rowsfound == 0)
            {
                MessageBox.Show("Nessun movimento trovato");
                return;
            }

            m.ContextFilter = filter;
            bool    result = m.Edit(Meta.LinkedForm.ParentForm, "default", false);
            DataRow RR     = m.SelectOne("default", filter, null, null);

            if (RR != null)
            {
                m.SelectRow(RR, "default");
            }
        }
Ejemplo n.º 23
0
        string CalculateFilter(bool pluriennale)
        {
            int    esercizio = Conn.GetEsercizio();
            string MyFilter  = QHS.CmpGt("available", 0);

            if (DS.entrydetailview.Rows.Count > 0)
            {
                //DataRow R = DS.entrydetailview.Rows[0];

                if (parentRow == null)
                {
                    return(MyFilter);
                }
                MyFilter = QHS.AppAnd(MyFilter, QHS.NullOrEq("idepexp", parentRow["idepexp"]));

                if (pluriennale == false)
                {
                    //R["competencystart"] != DBNull.Value || R["competencystop"] == DBNull.Value
                    object inizioCompetenza = parentRow["competencystart"];
                    object fineCompetenza   = parentRow["competencystop"];

                    if (inizioCompetenza != DBNull.Value && fineCompetenza != DBNull.Value)
                    {
                        MyFilter = QHS.AppAnd(MyFilter,
                                              QHS.DoPar(QHS.AppOr(QHS.Between("competencystart", inizioCompetenza, fineCompetenza),
                                                                  QHS.Between("competencystop", inizioCompetenza, fineCompetenza))));
                    }
                }



                if (parentRow["idupb"] != DBNull.Value)
                {
                    MyFilter = QHS.AppAnd(MyFilter, QHS.CmpEq("idupb", parentRow["idupb"]));
                    if (pluriennale)
                    {
                        object idepupbkind = Conn.DO_READ_VALUE("upb", QHS.CmpEq("idupb", parentRow["idupb"]), "idepupbkind");
                        if (idepupbkind != null && idepupbkind != DBNull.Value)
                        {
                            object idacc = Conn.DO_READ_VALUE("epupbkindyear", QHS.AppAnd(
                                                                  QHS.CmpEq("idepupbkind", idepupbkind), QHS.CmpEq("ayear", esercizio)), "idacc_accruals");
                            if (idacc != DBNull.Value && idacc != null)
                            {
                                MyFilter = QHS.AppAnd(MyFilter, QHS.CmpEq("idacc", idacc));
                            }
                        }
                    }
                }

                if (pluriennale == false)
                {
                    foreach (string f in new string[] { "idsor1", "idsor2", "idsor3", "idreg" })
                    {
                        object val = parentRow[f];
                        if (val != DBNull.Value)
                        {
                            MyFilter = QHS.AppAnd(MyFilter, QHS.CmpEq(f, val));
                        }
                    }
                }
                if (pluriennale)
                {
                    MyFilter = QHS.AppAnd(MyFilter, QHS.CmpEq("yentry", esercizio));
                    MyFilter = QHS.AppAnd(MyFilter, QHS.CmpEq("identrykind", 7));
                    MyFilter = QHS.AppAnd(MyFilter, QHS.IsNull("idreg"));
                }
                else
                {
                    MyFilter = QHS.AppAnd(MyFilter, QHS.CmpLt("yentry", esercizio));
                    //string flagAP = "";
                    if (CfgFn.GetNoNullDecimal(parentRow["amount"]) > 0)
                    {
                        //flagAP = "A";
                        MyFilter = QHS.AppAnd(MyFilter, QHS.BitSet("flagaccountusage", 0));//ratei attivi
                    }
                    else
                    {
                        //flagAP = "P";
                        MyFilter = QHS.AppAnd(MyFilter, QHS.BitSet("flagaccountusage", 1));//ratei passivi
                    }
                    //MyFilter = QHS.AppAnd(MyFilter, QHS.CmpEq("flagap", flagAP));
                    MyFilter = QHS.AppAnd(MyFilter, QHS.CmpEq("identrykind", 2));
                }

                DataTable ParentRateo = Meta.SourceRow.Table;
                DataRow[] Added       = ParentRateo.Select(QHC.IsNotNull("ndetaillinked"), null, DataViewRowState.Added);
                // Ciclo per escludere le righe già inserite
                if (Added.Length > 0)
                {
                    foreach (DataRow Row in Added)
                    {
                        // costruisco il filtro sulla chiave per le righe inserite nel form chiamante
                        MyFilter = QHS.AppAnd(MyFilter,
                                              QHS.DoPar(QHS.AppOr(QHS.CmpNe("yentry", Row["yentrylinked"]),
                                                                  QHS.CmpNe("nentry", Row["nentrylinked"]), QHS.CmpNe("ndetail", Row["ndetaillinked"]))));
                    }
                }
            }
            else
            {
                return(MyFilter);
            }

            return(MyFilter);
        }
Ejemplo n.º 24
0
        void RiempiGrid(string Filtro)
        {
            //if (RBooking == null) return;
            //string keyfilter = QHS.CmpEq("idbooking", RBooking["idbooking"]);
            //string lista = "";
            foreach (DataRow rDetail in DS.storeunloaddetail.Rows)
            {
                if ((rDetail.RowState == DataRowState.Deleted) || (rDetail.RowState == DataRowState.Modified))
                {
                    if (rDetail["idbooking", DataRowVersion.Original] != DBNull.Value)
                    {
                        Filtro = QHS.AppOr(QHS.DoPar(Filtro),
                                           QHS.DoPar(QHS.CmpEq("idbooking", rDetail["idbooking", DataRowVersion.Original])));
                    }
                }
            }

            //Details contiene la vista delle righe interessate dalle prenotazioni associate allo scarico
            // ed in più quelle selezionate in base ai filtri
            DataTable Details = Conn.RUN_SELECT("booktotalview", "*", null, Filtro, null, false);

            if (Details.Rows.Count != 0)
            {
                Details.PrimaryKey = new DataColumn[] { Details.Columns["idbooking"], Details.Columns["idlist"], Details.Columns["idstore"] };
                // Ora ha messo in Detail tutto ciò che da DB risulta 'da inserire nello scarico'.

                // Effettua ora una serie di allineamenti sul DataTable per renderlo più coerente con quello
                // che c'è nel DataSet del form padre.

                // Per ogni riga del DataSet in stato di INSERT/UPDATE effettua una sottrazione ed eventualmente
                // un delete su Detail se la riga corrispondente risulta essere esaurita.

                //Esamina le righe cancellate da DS
                foreach (DataRow rDetail in DS.Tables["storeunloaddetail"].Rows)
                {
                    if (rDetail.RowState != DataRowState.Deleted)
                    {
                        continue;
                    }
                    if (rDetail["idbooking", DataRowVersion.Original] == DBNull.Value)
                    {
                        continue;
                    }
                    decimal oldnumber = CfgFn.GetNoNullDecimal(rDetail["number", DataRowVersion.Original]);
                    string  filter    =
                        QHC.AppAnd(
                            QHC.CmpEq("idstore", GetIDStore(rDetail["idstock", DataRowVersion.Original])),
                            QHC.CmpEq("idlist", GetIDList(rDetail["idstock", DataRowVersion.Original])),
                            QHC.CmpEq("idbooking", rDetail["idbooking", DataRowVersion.Original])
                            );
                    DataRow[] RM = Details.Select(filter);
                    if ((RM == null) || (RM.Length == 0))
                    {
                        continue;
                    }
                    DataRow Detail        = RM[0];
                    decimal newnumber     = 0;
                    decimal oldbooknumber = CfgFn.GetNoNullDecimal(Detail["number"]);

                    decimal oldallocated = CfgFn.GetNoNullDecimal(Detail["allocated"]);
                    decimal newallocated = oldallocated - newnumber + oldnumber;

                    decimal newbooknumber = oldbooknumber - newnumber + oldnumber;
                    Detail["number"]    = newbooknumber;
                    Detail["allocated"] = newallocated;
                }

                //Esamina le righe aggiunte al DS
                foreach (DataRow rDetail in DS.Tables["storeunloaddetail"].Select())
                {
                    if (rDetail.RowState != DataRowState.Added)
                    {
                        continue;
                    }
                    if (rDetail["idbooking"] == DBNull.Value)
                    {
                        continue;
                    }

                    //Non è una riga collegata a dettagli ordine
                    string filter =
                        QHC.AppAnd(
                            QHC.CmpEq("idstore", GetIDStore(rDetail["idstock"])),
                            QHC.CmpEq("idlist", GetIDList(rDetail["idstock"])),
                            QHC.CmpEq("idbooking", rDetail["idbooking"])
                            );

                    DataRow[] RM = Details.Select(filter);
                    if ((RM == null) || (RM.Length == 0))
                    {
                        continue;
                    }
                    DataRow Detail        = RM[0];
                    decimal oldnumber     = 0;
                    decimal newnumber     = CfgFn.GetNoNullDecimal(rDetail["number", DataRowVersion.Current]);
                    decimal oldbooknumber = CfgFn.GetNoNullDecimal(Detail["number"]);

                    decimal oldallocated = CfgFn.GetNoNullDecimal(Detail["allocated"]);
                    decimal newallocated = oldallocated - newnumber + oldnumber;

                    decimal newbooknumber = oldbooknumber + newnumber - oldnumber;
                    Detail["number"]    = newbooknumber;
                    Detail["allocated"] = newallocated;
                }

                foreach (DataRow rDetail in DS.Tables["storeunloaddetail"].Select())
                {
                    if (rDetail.RowState != DataRowState.Modified)
                    {
                        continue;
                    }
                    //Non è una riga collegata a dettagli ordine
                    string filter =
                        QHC.AppAnd(
                            QHC.CmpEq("idstore", GetIDStore(rDetail["idstock"])),
                            QHC.CmpEq("idlist", GetIDList(rDetail["idstock"])),
                            QHC.CmpEq("idbooking", rDetail["idbooking"])
                            );

                    DataRow[] RM = Details.Select(filter);
                    if ((RM == null) || (RM.Length == 0))
                    {
                        continue;
                    }
                    DataRow Detail = RM[0];
                    decimal oldnumber;
                    if (rDetail["idbooking", DataRowVersion.Original] == DBNull.Value)
                    {
                        oldnumber = 0;
                    }
                    else
                    {
                        oldnumber = CfgFn.GetNoNullDecimal(rDetail["number", DataRowVersion.Original]);
                    }

                    decimal newnumber;
                    if (rDetail["idbooking", DataRowVersion.Current] == DBNull.Value)
                    {
                        newnumber = 0;
                    }
                    else
                    {
                        newnumber = CfgFn.GetNoNullDecimal(rDetail["number", DataRowVersion.Current]);
                    }

                    decimal oldbooknumber = CfgFn.GetNoNullDecimal(Detail["number"]);
                    decimal newbooknumber = oldbooknumber - newnumber + oldnumber;

                    decimal oldallocated = CfgFn.GetNoNullDecimal(Detail["allocated"]);
                    decimal newallocated = oldallocated - newnumber + oldnumber;

                    Detail["number"]    = newbooknumber;
                    Detail["allocated"] = newallocated;
                }

                foreach (DataRow rDetail in Details.Select())
                {
                    if (CfgFn.GetNoNullDecimal(rDetail["allocated"]) == 0)
                    {
                        rDetail.Delete();
                    }
                }

                Details.AcceptChanges();
                if (Details.Select().Length > 0)
                {
                    MetaData MAP = Meta.Dispatcher.Get("booktotalview");
                    MAP.DescribeColumns(Details, "default");
                    DataSet D = new DataSet();
                    D.Tables.Add(Details);
                    HelpForm.SetDataGrid(gridDettagli, Details);
                    gridDettagli.TableStyles.Clear();
                    HelpForm.SetGridStyle(gridDettagli, Details);
                    formatgrids format = new formatgrids(gridDettagli);
                    format.AutosizeColumnWidth();
                    HelpForm.SetAllowMultiSelection(Details, true);
                    SelezionaTutto();
                }
            }
        }
Ejemplo n.º 25
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);
            QHC  = new CQueryHelper();
            QHS  = Meta.Conn.GetQueryHelper();
            //riga padre (assetacquire)
            DataAccess.SetTableForReading(DS.submanager, "manager");
            entityRow = Meta.SourceRow.GetParentRow("assetacquireasset");
            if (entityRow == null)
            {
                Meta.ErroreIrrecuperabile = true;
                return;
            }

            int  flag         = CfgFn.GetNoNullInt32(entityRow["flag"]);
            bool pieceacquire = ((flag & 4) != 0);

            //riga inventario
            DataRow Rinv = entityRow.GetParentRow("inventoryassetacquire");

            if (Rinv != null)
            {
                txtDescrizione.Text = Rinv["description"].ToString();
            }

            string filter = QHS.CmpEq("idinventory", entityRow["idinventory"]);
            //string filter2="(idpiece='1')AND"+filter;
            string filter2 = QHS.AppAnd(QHS.CmpEq("idpiece", 1), filter);

            if (entityRow["idinv"].ToString() != "")
            {
                object idinv_lev1 = Meta.Conn.DO_READ_VALUE("inventorytreeview", QHS.CmpEq("idinv", entityRow["idinv"]), "idinv_lev1");
                if (idinv_lev1 != null)
                {
                    filter2 = QHS.AppAnd(filter2, QHS.CmpEq("idinv_lev1", idinv_lev1));
                    if (pieceacquire)
                    {
                        DataRow Curr = Meta.SourceRow;
                        filter2 = QHS.AppOr(filter2, QHS.DoPar(QHS.AppAnd(QHS.CmpEq("idasset", Curr["idasset"]), QHS.CmpEq("idpiece", 1))));
                    }
                }
            }



            GetData.SetStaticFilter(DS.assetview, filter2);
            btnSelezBene.Tag += "." + filter;
            if (pieceacquire)  //si tratta di un carico parte
            {
                grpBene.Tag               = "AutoChoose.txtNumInv.default." + filter;
                btnSelezBene.Tag          = "choose.assetview.default";
                txtNumInv.Tag             = "assetview.ninventory?x";
                txtRfid.Tag               = "assetview.rfid?x";
                txtDescrizione.Tag        = "assetview.description";
                gboxResponsabile.Enabled  = false;
                gboxUbicazione.Enabled    = false;
                gboxConsegnatario.Enabled = false;
            }
            else  //si tratta di un carico bene
            {
                btnSelezBene.Enabled      = false;
                txtNumInv.ReadOnly        = false;
                txtNumInv.Tag             = "asset.ninventory";
                txtRfid.Tag               = "asset.rfid";
                grpBene.Text              = "Numero inventario e descrizione";
                gboxResponsabile.Enabled  = true;
                gboxUbicazione.Enabled    = true;
                gboxConsegnatario.Enabled = true;
                if (Meta.InsertMode)
                {
                    txtDescrizione.Tag = null;
                    //txtDescrizione.Text=
                }
            }
            Meta.MarkTableAsNotEntityChild(DS.assetmanager);
            Meta.MarkTableAsNotEntityChild(DS.assetsubmanager);
            Meta.MarkTableAsNotEntityChild(DS.assetlocation);
            GetData.CacheTable(DS.manager, null, null, false);
            GetData.CacheTable(DS.submanager, null, null, false);
            GetData.CacheTable(DS.multifieldkind, null, null, false);
        }
Ejemplo n.º 26
0
        private void btnLinkEpExp_Click(object sender, EventArgs e)
        {
            if (Meta.IsEmpty)
            {
                return;
            }
            DataRow curr = DS.csa_contracttaxepexp.Rows[0];

            MetaData.GetFormData(this, true);
            EP_functions ep     = new EP_functions(Meta.Dispatcher);
            object       nphase = cmbFaseImpBudget.SelectedValue; // Impegno
            string       filter = QHS.CmpEq("ayear", Meta.GetSys("esercizio"));
            int          yepexp = CfgFn.GetNoNullInt32(txtEsercizioImpegno.Text.Trim());

            if (yepexp != 0)
            {
                filter = QHS.CmpEq("yepexp", yepexp);
            }
            else
            {
                filter = QHS.CmpEq("ayear", Meta.GetSys("esercizio"));
            }
            int nepexp = CfgFn.GetNoNullInt32(txtNumImpegno.Text.Trim());

            if (nepexp != 0)
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("nepexp", nepexp));
            }
            string filter_fase = "";

            if (CfgFn.GetNoNullInt32(nphase) == 0)
            {
                filter_fase = QHS.AppOr(QHS.DoPar(QHS.CmpEq("nphase", 1)),
                                        QHS.DoPar(QHS.CmpEq("nphase", 2)));
            }
            if ((CfgFn.GetNoNullInt32(nphase) == 1) || (CfgFn.GetNoNullInt32(nphase) == 2))
            {
                filter_fase = QHS.CmpEq("nphase", nphase);
            }
            filter = QHS.AppAnd(filter, filter_fase);
            String fAmount = QHS.CmpGt("(totcurramount - isnull(totalcost,0))", 0); // condizione sul disponibile

            filter = QHS.AppAnd(filter, fAmount);

            string VistaScelta = "epexpview";

            MetaData mepexp = Meta.Dispatcher.Get(VistaScelta);

            mepexp.FilterLocked = true;
            mepexp.DS           = DS;
            DataRow myDr = mepexp.SelectOne("default", filter, null, null);

            if (myDr != null)
            {
                curr["idepexp"]                = myDr["idepexp"];
                txtEsercizioImpegno.Text       = myDr["yepexp"].ToString();
                txtNumImpegno.Text             = myDr["nepexp"].ToString();
                cmbFaseImpBudget.SelectedValue = myDr["nphase"];
                Meta.FreshForm();
            }
        }