Пример #1
0
        /// <summary>
        /// Metodo che consente la selezione del movimento finanziario
        /// </summary>
        /// <param name="E_S"></param>
        private void selezionaMovimento(string E_S)
        {
            if (Meta.IsEmpty)
            {
                return;
            }
            Meta.GetFormData(true);

            string filterPhase = (E_S == "E")
                ? QHC.CmpEq("nphase", Meta.GetSys("maxincomephase"))
                : QHC.CmpEq("nphase", Meta.GetSys("maxexpensephase"));

            DataRow Curr    = DS.expensetaxcorrige.Rows[0];
            decimal importo = (E_S == "E")
                ? -(CfgFn.GetNoNullDecimal(Curr["employamount"]) +
                    CfgFn.GetNoNullDecimal(Curr["adminamount"]))
                : CfgFn.GetNoNullDecimal(Curr["employamount"])
                              + CfgFn.GetNoNullDecimal(Curr["adminamount"]);

            //DataTable tUpb = DataAccess.RUN_SELECT(Meta.Conn, "upb", "*", null, QHS.CmpEq("idupb", "0001"),
            //    null, null, true);

            //string flag = (E_S == "E") ? QHS.BitClear("flag", 0) : QHS.BitSet("flag", 0);
            //DataTable tFinView = DataAccess.RUN_SELECT(Meta.Conn, "finview", "*", null,
            //    QHS.AppAnd(QHS.CmpEq("idupb", "0001"), QHS.CmpEq("ayear", Meta.GetSys("esercizio")), flag),
            //    null, null, true);

            //FrmAskFase F = new FrmAskFase(E_S, importo, tUpb, tFinView, Meta.Dispatcher, Meta.Conn);
            //if (F.ShowDialog() != DialogResult.OK) return;
            FrmAskInfo fInfo = new FrmAskInfo(Meta, E_S, true)
                               .EnableManagerSelection(true)
                               .AllowNoManagerSelection(true)
                               .EnableFinSelection(true)
                               .EnableUPBSelection(true)
                               .AllowNoUpbSelection(true)
                               .AllowNoFinSelection(true)
                               .AllowNoManagerSelection(true)
                               .EnableFilterAvailable(importo);

            fInfo.Text                = "Impostazione filtro per ricerca movimento";
            fInfo.gboxUPB.Text        = "Selezionare l'UPB  (opzionale)";
            fInfo.gboxBilAnnuale.Text = "Selezionare la voce di bilancio (opzionale)";
            if (fInfo.ShowDialog() != DialogResult.OK)
            {
                return;
            }



            int selectedfase = (E_S == "E")
                ? CfgFn.GetNoNullInt32(Meta.GetSys("maxincomephase"))
                : CfgFn.GetNoNullInt32(Meta.GetSys("maxexpensephase"));

            string filter    = "";
            string filterUpb = QHS.CmpEq("idupb", "0001");
            string filterFin = "";
            string filterMan = "";

            if (selectedfase > 0)
            {
                filter = GetData.MergeFilters(filter, QHS.CmpEq("nphase", selectedfase));
            }
            if (fInfo.GetUPB() != DBNull.Value)
            {
                filterUpb = QHS.CmpEq("idupb", fInfo.GetUPB());
            }
            if (fInfo.GetFin() != DBNull.Value)
            {
                filterFin = QHS.CmpEq("idfin", fInfo.GetFin());
            }

            if (fInfo.GetManager() != DBNull.Value)
            {
                filterMan = QHS.CmpEq("idman", fInfo.GetManager());
            }

            filter = GetData.MergeFilters(filter, filterUpb);
            if (filterFin != "")
            {
                filter = GetData.MergeFilters(filter, filterFin);
            }
            if (filterMan != "")
            {
                filter = GetData.MergeFilters(filter, filterMan);
            }
            if (importo > 0)
            {
                filter = GetData.MergeFilters(filter, QHS.CmpGe("curramount", importo));
            }
            else
            {
                filter = GetData.MergeFilters(filter, QHS.CmpGt("curramount", 0));
            }

            string   tName = (E_S == "E") ? "income" : "expense";
            MetaData E     = Meta.Dispatcher.Get(tName);

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

            if (Choosen == null)
            {
                return;
            }
            string Linkedfield = (E_S == "E") ? "linkedidinc" : "linkedidexp";
            string SourceField = (E_S == "E") ? "idinc" : "idexp";

            Curr[Linkedfield] = Choosen[SourceField];
            string vName = (E_S == "E") ? "incomeview" : "expenseview";

            DS.Tables[vName].Clear();
            Meta.Conn.RUN_SELECT_INTO_TABLE(DS.Tables[vName], null,
                                            QHS.AppAnd(QHS.CmpEq(SourceField, Curr[Linkedfield]), QHS.CmpEq("ayear", Meta.GetSys("esercizio"))),
                                            null, true);
            Meta.FreshForm(false);
        }
Пример #2
0
        private void btnEntrata_Click(object sender, EventArgs e)
        {
            if (Meta.IsEmpty)
            {
                return;
            }
            Meta.GetFormData(true);
            DataTable Fasi2 = DS.incomephase.Copy();

            string filterPhase = QHC.AppOr(QHC.CmpEq("nphase", Meta.GetSys("maxincomephase")),
                                           QHC.CmpLt("nphase", Meta.GetSys("incomefinphase")));

            foreach (DataRow ToDel in Fasi2.Select(filterPhase))
            {
                ToDel.Delete();
            }
            Fasi2.AcceptChanges();

            DataRow Curr    = DS.admpay_assessment.Rows[0];
            decimal importo = CfgFn.GetNoNullDecimal(Curr["amount"]);
            var     f       = new FrmAskInfo(Meta, "E", true).SetUPB("0001").EnableManagerSelection(false);

            if (importo > 0)
            {
                f.EnableFilterAvailable(importo);
            }

            f.allowSelectPhase("Seleziona la fase del movimento a cui collegare il pagamento degli stipendi");
            if (f.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            var    selectedfase = Convert.ToInt32(f.GetFaseMovimento());
            string filter       = "";
            string filterUpb    = QHS.CmpEq("idupb", "0001");
            string filterFin    = "";

            if (selectedfase > 0)
            {
                filter = GetData.MergeFilters(filter, QHS.CmpEq("nphase", selectedfase));
            }
            // Aggiunta filtro dell'UPB e del Bilancio
            if (f.GetUPB() != DBNull.Value)
            {
                filterUpb = QHS.CmpEq("idupb", f.GetUPB());

                if (f.GetFin() != DBNull.Value)
                {
                    filterFin = QHS.CmpEq("idfin", f.GetFin());
                }
            }
            filter = GetData.MergeFilters(filter, filterUpb);
            if (filterFin != "")
            {
                filter = GetData.MergeFilters(filter, filterFin);
            }

            filter = GetData.MergeFilters(filter, importo > 0 ? QHS.CmpGe("available", importo) : QHS.CmpGt("available", 0));

            int faseScelta   = CfgFn.GetNoNullInt32(f.GetFaseMovimento());
            int faseRegistry = CfgFn.GetNoNullInt32(Meta.GetSys("expenseregphase"));

            if (faseScelta >= faseRegistry)
            {
                filter = QHS.AppAnd(filter, filterOnReg);
            }

            MetaData E = Meta.Dispatcher.Get("income");

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

            if (Choosen == null)
            {
                lastIdInc = DBNull.Value;
                return;
            }
            Curr["idinc"] = Choosen["idinc"];
            if (!lastIdInc.Equals(Choosen["idinc"]))
            {
                ricalcolaImporto(Choosen["available"]);
            }
            lastIdInc = Choosen["idinc"];
            DS.incomeview.Clear();
            Meta.Conn.RUN_SELECT_INTO_TABLE(DS.incomeview, null,
                                            QHS.AppAnd(QHS.CmpEq("idinc", Curr["idinc"]), QHS.CmpEq("ayear", Meta.GetSys("esercizio"))),
                                            null, true);
            Meta.FreshForm(false);
        }
Пример #3
0
        private void btnSpesa_Click(object sender, EventArgs e)
        {
            if (Meta.IsEmpty)
            {
                return;
            }
            Meta.GetFormData(true);

            DataRow Curr      = DS.csa_contracttaxexpense.Rows[0];
            string  filter    = "";
            object  idregauto = Get_Registry_Auto();

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

            if (selectedfase > 0)
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("nphase", selectedfase)); //,
                //QHS.DoPar(QHS.NullOrEq("idreg", idregauto)));
            }
            else
            {
                filter = QHS.AppAnd(filter, QHS.CmpNe("nphase", Meta.GetSys("maxexpensephase")),
                                    QHS.CmpGe("nphase", Meta.GetSys("expensefinphase"))); //,
                //QHS.DoPar(QHS.NullOrEq("idreg", idregauto)));
            }

            int ymov = CfgFn.GetNoNullInt32(txtEserc.Text.Trim());
            int nmov = CfgFn.GetNoNullInt32(txtNum.Text.Trim());

            if ((ymov != 0) && (nmov != 0))
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("ymov", ymov), QHS.CmpEq("nmov", nmov));
            }
            else
            {
                var f = new FrmAskInfo(Meta, "S", true);
                if (f.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

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

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

                var filterUpb = QHC.CmpEq("idupb", "0001");
                var filterFin = "";
                // Aggiunta filtro dell'UPB e del Bilancio
                if (f.GetUPB() != DBNull.Value)
                {
                    filterUpb = QHS.CmpEq("idupb", f.GetUPB());
                    if (f.GetFin() != DBNull.Value)
                    {
                        filterFin = QHS.CmpEq("idfin", f.GetFin());
                    }
                }

                filter = QHS.AppAnd(filter, filterUpb);
                if (filterFin != "")
                {
                    filter = QHS.AppAnd(filter, filterFin);
                }
            }

            MetaData E = Meta.Dispatcher.Get("expense");

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

            if (Choosen == null)
            {
                return;
            }
            int oldIdExp = CfgFn.GetNoNullInt32(Curr["idexp"]);
            int newIdExp = CfgFn.GetNoNullInt32(Choosen["idexp"]);

            Curr["idexp"] = Choosen["idexp"];

            DS.expenseview.Clear();
            Meta.Conn.RUN_SELECT_INTO_TABLE(DS.expenseview, null,
                                            QHS.AppAnd(QHS.CmpEq("idexp", Curr["idexp"]), QHS.CmpEq("ayear", Meta.GetSys("esercizio"))),
                                            null, true);
            txtEserc.Text = Choosen["ymov"].ToString();
            txtNum.Text   = Choosen["nmov"].ToString();
            cmbFaseSpesa.SelectedValue = Choosen["nphase"];
            Meta.FreshForm(false);
        }
Пример #4
0
        private void btnSpesa_Click(object sender, EventArgs e)
        {
            if (_controller.IsEmpty)
            {
                return;
            }
            _controller.GetFormData(true);

            var curr         = DS.csa_contractexpense.Rows[0];
            var filter       = "";
            var selectedfase = CfgFn.GetNoNullInt32(cmbFaseSpesa.SelectedValue);
            var idregcsa     = Get_Registry_Csa();

            if (selectedfase > 0)
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("nphase", selectedfase),
                                    QHS.DoPar(QHS.NullOrEq("idreg", idregcsa)));
            }
            else
            {
                filter = QHS.AppAnd(filter, QHS.CmpNe("nphase", _security.GetSys("maxexpensephase")),
                                    QHS.CmpGe("nphase", _security.GetSys("expensefinphase")),
                                    QHS.DoPar(QHS.NullOrEq("idreg", idregcsa)));
            }

            var ymov = CfgFn.GetNoNullInt32(txtEserc.Text.Trim());
            var nmov = CfgFn.GetNoNullInt32(txtNum.Text.Trim());

            if ((ymov != 0) && (nmov != 0))
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("ymov", ymov), QHS.CmpEq("nmov", nmov));
            }
            else
            {
                var ff = new FrmAskInfo(_meta as MetaData, "S", true).EnableManagerSelection(false);
                if (ff.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                //var f = new FrmAskFase("S", _dispatcher as EntityDispatcher, _conn as DataAccess);
                //if (f.ShowDialog() != DialogResult.OK) return;

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

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

                var filterUpb = QHC.CmpEq("idupb", "0001");
                var filterFin = "";
                // Aggiunta filtro dell'UPB e del Bilancio
                if (ff.GetUPB() != DBNull.Value)
                {
                    filterUpb = QHS.CmpEq("idupb", ff.GetUPB());
                    if (ff.GetFin() != DBNull.Value)
                    {
                        filterFin = QHS.CmpEq("idfin", ff.GetFin());
                    }
                }

                filter = QHS.AppAnd(filter, filterUpb);
                if (filterFin != "")
                {
                    filter = QHS.AppAnd(filter, filterFin);
                }
            }

            var expense = _dispatcher.Get("expense");

            expense.FilterLocked = true;
            expense.DS           = DS.Clone();
            var choosen = expense.SelectOne("default", filter, "expense", null);

            if (choosen == null)
            {
                return;
            }

            curr["idexp"] = choosen["idexp"];

            DS.expenseview.Clear();
            _conn.RUN_SELECT_INTO_TABLE(DS.expenseview, null,
                                        QHS.AppAnd(QHS.CmpEq("idexp", curr["idexp"]), QHS.CmpEq("ayear", _security.GetEsercizio())),
                                        null, true);
            txtEserc.Text = choosen["ymov"].ToString();
            txtNum.Text   = choosen["nmov"].ToString();
            cmbFaseSpesa.SelectedValue = choosen["nphase"];

            _controller.FreshForm(false, false);
        }