コード例 #1
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);
        }
コード例 #2
0
        private void btnSpesa_Click(object sender, EventArgs e)
        {
            if (_controller.IsEmpty)
            {
                return;
            }
            if (_controller.ErroreIrrecuperabile)
            {
                return;
            }
            _controller.GetFormData(true);

            var curr         = DS.csa_contract_partition.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));
            }
            else
            {
                filter = QHS.AppAnd(filter, QHS.CmpNe("nphase", _security.GetSys("maxexpensephase")),
                                    QHS.CmpGe("nphase", _security.GetSys("expensefinphase")),
                                    QHS.CmpLt("nphase", _security.GetSys("expenseregphase")));
            }

            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
            {
                object selectedUPB = curr["idupb"];
                object selectedFin = curr["idfin"];
                if (ymov != 0)
                {
                    filter = QHS.AppAnd(filter, QHS.CmpEq("ymov", ymov));
                }

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

                if (selectedUPB != DBNull.Value)
                {
                    filter = QHS.AppAnd(filter, QHS.CmpEq("idupb", selectedUPB));
                }

                if (selectedFin != DBNull.Value)
                {
                    filter = QHS.AppAnd(filter, QHS.CmpEq("idfin", selectedFin));
                }
            }

            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"];
            curr["idfin"] = choosen["idfin"];
            curr["idupb"] = choosen["idupb"];
            _conn.RUN_SELECT_INTO_TABLE(DS.fin, null, QHS.CmpEq("idfin", curr["idfin"]), null, true);
            _conn.RUN_SELECT_INTO_TABLE(DS.upb, null, QHS.CmpEq("idupb", curr["idupb"]), null, true);
            _controller.FreshForm(false, false);
        }