Example #1
0
        void RiempiGrid()
        {
            string filterstock = QHS.IsNull("idinvkind");

            string sqlCmd = " SELECT * " +
                            " FROM ddt_inview " +
                            " WHERE " + filter +
                            " AND EXISTS (SELECT * FROM stock WHERE " +
                            " ddt_inview.idddt_in = stock.idddt_in AND " + filterstock + " ) " +
                            " ORDER BY ddt_inview.idddt_in asc ";

            DataTable ddt_in = Meta.Conn.SQLRunner(sqlCmd);

            if (ddt_in.Rows.Count != 0)
            {
                ddt_in.PrimaryKey = new DataColumn[] { ddt_in.Columns["idddt_in"] };
                //Ora ha messo in ddt_in tutto ciò che da DB risulta 'da fatturare'.
                if (ddt_in.Select().Length > 0)
                {
                    MetaData MAP;
                    MAP = Meta.Dispatcher.Get("ddt_inview");
                    MAP.DescribeColumns(ddt_in, "default");
                    DataSet D = new DataSet();
                    D.Tables.Add(ddt_in);
                    HelpForm.SetDataGrid(gridDettagli, ddt_in);
                    gridDettagli.TableStyles.Clear();
                    HelpForm.SetGridStyle(gridDettagli, ddt_in);
                    formatgrids format = new formatgrids(gridDettagli);
                    format.AutosizeColumnWidth();
                    HelpForm.SetAllowMultiSelection(ddt_in, true);
                    SelezionaTutto();
                }
            }
        }
Example #2
0
 public void MetaData_AfterLink()
 {
     meta = MetaData.GetMetaData(this);
     QHC  = new CQueryHelper();
     QHS  = meta.Conn.GetQueryHelper();
     HelpForm.SetAllowMultiSelection(DS.proceedsview, true);
     GetData.SetSorting(DS.proceedsview, "npro");
     MetaData.SetDefault(DS.banktransaction, "kind", "C");
     MetaData.SetDefault(DS.banktransaction, "yban", meta.GetSys("esercizio"));
 }
Example #3
0
 public void MetaData_AfterLink()
 {
     meta      = MetaData.GetMetaData(this);
     QHC       = new CQueryHelper();
     QHS       = meta.Conn.GetQueryHelper();
     esercizio = (int)meta.GetSys("esercizio");
     HelpForm.SetAllowMultiSelection(DS.expenseview, true);
     GetData.SetSorting(DS.expenseview, "ymov, nmov");
     MetaData.SetDefault(DS.banktransaction, "kind", "D");
     MetaData.SetDefault(DS.banktransaction, "yban", esercizio);
 }
Example #4
0
 public void MetaData_AfterLink()
 {
     Meta = MetaData.GetMetaData(this);
     QHC  = new CQueryHelper();
     QHS  = Meta.Conn.GetQueryHelper();
     GetData.SetSorting(DS.payrollview, "idcon, fiscalyear, npayroll");
     GetData.SetStaticFilter(DS.payrollview, QHS.AppAnd(QHS.CmpEq("flagcomputed", 'N'),
                                                        QHS.CmpEq("fiscalyear", Meta.GetSys("esercizio")), QHS.CmpLe("start", Meta.GetSys("datacontabile")),
                                                        QHS.CmpEq("year(stop)", Meta.GetSys("esercizio")),
                                                        QHS.CmpEq("flagbalance", 'N')));
     HelpForm.SetAllowMultiSelection(DS.payrollview, true);
 }
Example #5
0
        public void MetaData_AfterLink()
        {
            Meta      = MetaData.GetMetaData(this);
            QHC       = new CQueryHelper();
            QHS       = Meta.Conn.GetQueryHelper();
            esercizio = CfgFn.GetNoNullInt32(Meta.GetSys("esercizio"));
            string filterEsercizio = QHS.CmpEq("ayear", esercizio);

            GetData.CacheTable(DS.config, filterEsercizio, null, false);
            GetData.CacheTable(DS.accountkind);
            HelpForm.SetAllowMultiSelection(DS.proceeds, true);
            btnIstitutoCassiere.Enabled = false;
            cmbCodiceIstituto.Enabled   = false;
            HelpForm.SetDenyNull(DS.proceedstransmission.Columns["transmissionkind"], true);
            EPM = new EP_Manager(Meta, null, null, null, null, null, null, null, null, "proceedstransmission");
        }
Example #6
0
        void SetDataGrid(DataGrid G, string table, string listtype)
        {
            MetaData M = Dispatcher.Get(table);

            if (listtype == null)
            {
                listtype = M.DefaultListType;
            }
            if (listtype == null)
            {
                listtype = "default";
            }
            M.DescribeColumns(DS.Tables[table], listtype);
            HelpForm.SetAllowMultiSelection(DS.Tables[table], true);
            HelpForm.SetDataGrid(G, DS.Tables[table]);
        }
Example #7
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);

            QHC       = new CQueryHelper();
            QHS       = Meta.Conn.GetQueryHelper();
            esercizio = Convert.ToInt32(Meta.GetSys("esercizio"));
            DataAccess.RUN_SELECT_INTO_TABLE(Meta.Conn, DS.incomephase, null, null, null, true);
            codicefase = CfgFn.GetNoNullInt32(Meta.GetSys("maxincomephase"));
            GetData.LockRead(DS.incomeview);
            GetData.DenyClear(DS.incomeview);
            GetData.LockRead(DS.proceedspart);
            FillEntrataView();
            QueryCreator.SetTableForPosting(DS.incomeview, "income");
            HelpForm.SetAllowMultiSelection(DS.incomeview, true);
            Meta.CanCancel     = false;
            Meta.CanInsert     = false;
            Meta.CanInsertCopy = false;
            Meta.CanSave       = false;
            Meta.SearchEnabled = false;
        }
Example #8
0
        public void MetaData_AfterLink()
        {
            Meta = MetaData.GetMetaData(this);

            QHC = new CQueryHelper();
            QHS = Meta.Conn.GetQueryHelper();

            esercizio  = Convert.ToInt32(Meta.GetSys("esercizio"));
            codicefase = Convert.ToInt32(Meta.GetSys("incomefinphase"));
            GetData.LockRead(DS.incomeview);
            GetData.DenyClear(DS.incomeview);
            GetData.LockRead(DS.creditpart);
            FillEntrataView();
            QueryCreator.SetTableForPosting(DS.incomeview, "income");
            HelpForm.SetAllowMultiSelection(DS.incomeview, true);
            Meta.CanCancel     = false;
            Meta.CanInsert     = false;
            Meta.CanInsertCopy = false;
            Meta.CanSave       = false;
            Meta.SearchEnabled = false;
        }
Example #9
0
        public void MetaData_AfterLink()
        {
            HelpForm.SetAllowMultiSelection(DS.assetpieceview, true);
            Meta = MetaData.GetMetaData(this);
            Conn = Meta.Conn;
            QHS  = Conn.GetQueryHelper();
            QHC  = new CQueryHelper();
            string filter = QHS.CmpEq("ayear", Conn.GetSys("esercizio"));

            GetData.CacheTable(DS.config, filter, null, false);
            GetData.CacheTable(DS.incomephase, null, "nphase", true);
            Mentrataview = MetaData.GetMetaData(this, "incomeview");

            //Tooltip
            Tip.SetToolTip(btnInizia, "Cliccare qui per far partire la generazione automatica");
            Tip.SetToolTip(grpIncludi, "Selezionare una delle voci per filtrare la generazione completa");
            Tip.SetToolTip(rdoAll, "Selezionare questa voce se si vogliono tutti i tipi di scarico");
            Tip.SetToolTip(rdoBene, "Selezionare questa voce se si vuole scaricare solo i cespiti");
            Tip.SetToolTip(rdoParte, "Selezionare questa voce se si vuole scaricare solo gli aumenti di valore");
            Tip.SetToolTip(btnGeneraTutto, "Cliccare qui per avviare in qualsiasi momento la generazione automatica");
            //Tip.SetToolTip(btnAddAll,"Cliccare qui per collegare al buono sia gli scarichi cespiti che gli scarichi parti");
            Tip.SetToolTip(btnAddBene, "Cliccare qui per scaricare i cespiti e gli eumenti di valore selezionati");
            Tip.SetToolTip(btnSuccessivo, "Cliccare qui per passare al buono successivo");
        }
Example #10
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();
                }
            }
        }
Example #11
0
        void RiempiGrid()
        {
            DataTable MandateDetail =
                Conn.RUN_SELECT("mandatedetail_tostock", "*", "idmankind ASC,yman DESC,nman DESC, idgroup ASC",
                                filtersql, null, false);

            Conn.DeleteAllUnselectable(MandateDetail);

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

                //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 rStock in DS.Tables["stock"].Select())
                {
                    if (rStock.RowState != DataRowState.Added)
                    {
                        continue;
                    }
                    if (rStock["idmankind"] == DBNull.Value)
                    {
                        continue;                                      //Non è una riga collegata a dettagli ordine
                    }
                    string filtermand = QHC.CmpMulti(rStock, "idmankind", "yman", "nman");
                    filtermand = QHC.AppAnd(filtermand, QHC.CmpEq("idgroup", rStock["man_idgroup"]));

                    DataRow[] RM = MandateDetail.Select(filtermand);
                    if ((RM == null) || (RM.Length == 0))
                    {
                        continue;
                    }
                    DataRow Detail     = RM[0];
                    decimal oldnumber  = 0;
                    decimal newnumber  = CfgFn.GetNoNullDecimal(rStock["number", DataRowVersion.Current]);
                    decimal oldstocked = CfgFn.GetNoNullDecimal(Detail["stocked"]);
                    decimal newstocked = oldstocked + newnumber - oldnumber;
                    Detail["stocked"] = newstocked;
                }

                foreach (DataRow rStock in DS.Tables["stock"].Select())
                {
                    if (rStock.RowState != DataRowState.Modified)
                    {
                        continue;
                    }
                    string filtermand = QHC.CmpMulti(rStock, "idmankind", "yman", "nman");
                    filtermand = QHC.AppAnd(filtermand, QHC.CmpEq("idgroup", rStock["man_idgroup"]));
                    DataRow[] RM = MandateDetail.Select(filtermand);
                    if ((RM == null) || (RM.Length == 0))
                    {
                        continue;
                    }
                    DataRow Detail = RM[0];
                    decimal oldnumber;
                    if (rStock["idmankind", DataRowVersion.Original] == DBNull.Value)
                    {
                        oldnumber = 0;
                    }
                    else
                    {
                        oldnumber = CfgFn.GetNoNullDecimal(rStock["number", DataRowVersion.Original]);
                    }

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


                    decimal oldstocked = CfgFn.GetNoNullDecimal(Detail["stocked"]);
                    decimal newstocked = oldstocked + newnumber - oldnumber;
                    Detail["stocked"] = newstocked;
                }

                //foreach (DataRow rStock in DS.Tables["stock"].Rows){
                //    if (rStock.RowState != DataRowState.Deleted) continue;
                //    if (rStock["idmankind", DataRowVersion.Original] == DBNull.Value) continue;

                //    string filtermand = QHC.CmpMulti(rStock, "idmankind", "yman", "nman");
                //    filtermand = QHC.AppAnd(filtermand, QHC.CmpEq("idgroup", rStock["man_idgroup", DataRowVersion.Original]));

                //    DataRow[] RM = MandateDetail.Select(filtermand);
                //    if ((RM == null) || (RM.Length == 0)) continue;
                //    DataRow Detail = RM[0];
                //    decimal oldnumber = CfgFn.GetNoNullDecimal(rStock["number", DataRowVersion.Original]);
                //    decimal newnumber = 0;
                //    decimal oldstocked = CfgFn.GetNoNullDecimal(Detail["stocked"]);
                //    decimal newstocked = oldstocked + newnumber - oldnumber;
                //    Detail["stocked"] = newstocked;
                //}

                foreach (DataRow rMandatedetail in MandateDetail.Select())
                {
                    decimal stocked  = CfgFn.GetNoNullDecimal(rMandatedetail["stocked"]);
                    decimal ordered  = CfgFn.GetNoNullDecimal(rMandatedetail["ordered"]);
                    decimal ntostock = ordered - stocked;
                    rMandatedetail["ntostock"] = ntostock;
                    if (ntostock == 0)
                    {
                        rMandatedetail.Delete();
                    }
                }

                MandateDetail.AcceptChanges();
                if (MandateDetail.Select().Length > 0)
                {
                    MetaData MAP = Meta.Dispatcher.Get("mandatedetail_tostock");
                    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();
                }
            }
        }
Example #12
0
        bool GetFiltro()
        {
            string Filtro = "";

            if (txtIDUbicazione.Text != "")
            {
                Filtro = QHS.CmpEq("idcurrlocation", txtIDUbicazione.Text);
            }
            if (cboResponsabile.SelectedIndex > 0)
            {
                Filtro = QHS.AppAnd(Filtro, QHS.CmpEq("idcurrman", cboResponsabile.SelectedValue));
            }

            if (txt_idbene_da.Text.Trim() != "")
            {
                int N1 = CfgFn.GetNoNullInt32(HelpForm.GetObjectFromString(typeof(int), txt_idbene_da.Text, "x.y"));
                if (N1 > 0)
                {
                    Filtro = QHS.AppAnd(Filtro, QHS.CmpGe("idasset", N1));
                }
            }
            if (txt_idbene_a.Text.Trim() != "")
            {
                int N2 = CfgFn.GetNoNullInt32(HelpForm.GetObjectFromString(typeof(int), txt_idbene_a.Text, "x.y"));
                if (N2 > 0)
                {
                    Filtro = QHS.AppAnd(Filtro, QHS.CmpLe("idasset", N2));
                }
            }
            if (txt_numcarico_da.Text.Trim() != "")
            {
                int N3 = CfgFn.GetNoNullInt32(HelpForm.GetObjectFromString(typeof(int), txt_numcarico_da.Text, "x.y"));
                if (N3 > 0)
                {
                    Filtro = QHS.AppAnd(Filtro, QHS.CmpGe("nassetacquire", N3));
                }
            }
            if (txt_numcarico_a.Text.Trim() != "")
            {
                int N4 = CfgFn.GetNoNullInt32(HelpForm.GetObjectFromString(typeof(int), txt_numcarico_a.Text, "x.y"));
                if (N4 > 0)
                {
                    Filtro = QHS.AppAnd(Filtro, QHS.CmpLe("nassetacquire", N4));
                }
            }

            if (txt_numinv_da.Text.Trim() != "")
            {
                int N5 = CfgFn.GetNoNullInt32(HelpForm.GetObjectFromString(typeof(int), txt_numinv_da.Text, "x.y"));
                if (N5 > 0)
                {
                    Filtro = QHS.AppAnd(Filtro, QHS.CmpGe("ninventory", N5));
                }
            }
            if (txt_numinv_a.Text.Trim() != "")
            {
                int N6 = CfgFn.GetNoNullInt32(HelpForm.GetObjectFromString(typeof(int), txt_numinv_a.Text, "x.y"));
                if (N6 > 0)
                {
                    Filtro = QHS.AppAnd(Filtro, QHS.CmpLe("ninventory", N6));
                }
            }
            if (cmbInventario.SelectedIndex > 0)
            {
                Filtro = QHS.AppAnd(Filtro,
                                    "(namortization in (SELECT namortization from assetamortization " +
                                    " WHERE " + GetInventoryFilter(QHS, cmbInventario.SelectedValue) +
                                    //QHS.CmpEq("idinventory", cmbInventario.SelectedValue) +
                                    "))");
            }
            if (txtDescrizione.Text.Trim() != "")
            {
                string descr = txtDescrizione.Text.Trim();
                if (!descr.StartsWith("%"))
                {
                    descr = "%" + descr;
                }
                if (!descr.EndsWith("%"))
                {
                    descr = descr + "%";
                }
                Filtro = QHS.AppAnd(Filtro, QHS.Like("description", descr + "%"));
            }
            if (Filtro == "")
            {
                if (MessageBox.Show("Non è stato selezionato alcun filtro. Conferma?",
                                    "Conferma", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return(false);
                }
            }
            if (!chkIncludiAsset.Checked && chkIncludiAumenti.Checked)
            {
                Filtro = QHS.AppAnd(Filtro, QHS.CmpGt("idpiece", 1));
            }
            if (chkIncludiAsset.Checked && !chkIncludiAumenti.Checked)
            {
                Filtro = QHS.AppAnd(Filtro, QHS.CmpEq("idpiece", 1));
            }
            Filtro = QHS.AppAnd(Filtro, QHS.IsNull("idassetload"),
                                QHS.IsNull("idassetunload"),
                                QHS.CmpEq("flagunload", 'S'),
                                QHS.CmpGt("amortizationquota", 0)
                                );

            AssetAmortization = Conn.RUN_SELECT("assetamortizationunloadview", "*", "idinventory asc,ninventory asc",
                                                Filtro, null, false);

            MetaData MAP = Meta.Dispatcher.Get("assetamortizationunloadview");

            MAP.DescribeColumns(AssetAmortization, "default");
            DataSet D = new DataSet();

            D.Tables.Add(AssetAmortization);
            gridBeni.DataSource = null;
            HelpForm.SetDataGrid(gridBeni, AssetAmortization);
            HelpForm.SetAllowMultiSelection(AssetAmortization, true);
            SelezionaTuttiICespiti();
            return(true);
        }
Example #13
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();
            }
        }
Example #14
0
        void RiempiGrid()
        {
            string filter = "";

            filter = QHS.AppAnd(QHS.IsNull("iduniqueformcode"), QHS.IsNull("idflussocrediti"));
            if (cmbTipocontrattoattivo.SelectedValue != null)
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("idestimkind", cmbTipocontrattoattivo.SelectedValue));
            }
            if (txtAnagrafica.Text != "")
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("registry", txtAnagrafica.Text.ToString()));
            }
            if (txtDataStart.Text != "")
            {
                object datainizio = HelpForm.GetObjectFromString(typeof(DateTime), txtDataStart.Text,
                                                                 txtDataStart.Tag.ToString());
                filter = QHS.AppAnd(filter, QHS.CmpGe("adate", datainizio));
            }
            if (txtDataStop.Text != "")
            {
                object datafine = HelpForm.GetObjectFromString(typeof(DateTime), txtDataStop.Text,
                                                               txtDataStop.Tag.ToString());
                filter = QHS.AppAnd(filter, QHS.CmpLe("adate", datafine));
            }
            DataTable EstimateDetail =
                Conn.RUN_SELECT("estimatedetailview", "*",
                                "idestimkind ASC,yestim DESC,nestim DESC,rownum ASC, idgroup ASC",
                                filter, null, false);

            Conn.DeleteAllUnselectable(EstimateDetail);
            if (EstimateDetail.Rows.Count != 0)
            {
                EstimateDetail.PrimaryKey = new DataColumn[] {
                    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.

                foreach (DataRow R in Flussocreditidetail.Select())
                {
                    if (R.RowState != DataRowState.Added)
                    {
                        continue;
                    }
                    if (R["idestimkind"] == DBNull.Value)
                    {
                        continue; //Non è una riga collegata a dettagli contratto attivo
                    }
                    string filterestim = QHC.CmpMulti(R, "idestimkind", "yestim", "nestim", "rownum");
                    foreach (DataRow Re in EstimateDetail.Select(filterestim))
                    {
                        Re.Delete();
                    }
                }

                EstimateDetail.AcceptChanges();
                if (EstimateDetail.Select().Length > 0)
                {
                    MetaData MAP = Meta.Dispatcher.Get("estimatedetailview");
                    MAP.DescribeColumns(EstimateDetail, "flussocrediti");
                    DataSet D = new DataSet();
                    D.Tables.Add(EstimateDetail);
                    HelpForm.SetDataGrid(gridDettagli, EstimateDetail);
                    gridDettagli.TableStyles.Clear();
                    HelpForm.SetGridStyle(gridDettagli, EstimateDetail);
                    formatgrids format = new formatgrids(gridDettagli);
                    format.AutosizeColumnWidth();
                    HelpForm.SetAllowMultiSelection(EstimateDetail, true);
                    SelezionaTutto();
                }
            }
        }
Example #15
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();
                }
            }
        }