public virtual void reinitEditingForData()
        {
            initChanger();

            //init defaults
            if (userAdapter.getAdapterWorkState() == AdapterWorkState.stateAdd)
            {
                DataSet ds = userAdapter.getDataSet();

                string[][] arrDefaults = getDefaultValues();
                foreach (string[] arrTmp in arrDefaults)
                {
                    string tableName    = arrTmp[0];
                    string tableColName = arrTmp[1];
                    string valueStr     = arrTmp[2];

                    DataTable tableTmp = ds.Tables[tableName];
                    if (tableTmp != null)
                    {
                        DataColumn colTmp = tableTmp.Columns[tableColName];
                        if (colTmp != null)
                        {
                            string val_  = getValue(valueStr);
                            object value = XmlFormating.helper.parse(val_, colTmp.DataType);
                            ToolColumn.setColumnValue(tableTmp, colTmp.ColumnName, value);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public InfoInvoiceSum calcSlipSum(DataSet pDataSet)
        {
            DataTable      pTabSTLINE  = pDataSet.Tables[TableSTLINE.TABLE];
            DataTable      pTabINVOICE = pDataSet.Tables[TableINVOICE.TABLE];
            InfoInvoiceSum infoSum     = new InfoInvoiceSum();

            for (int i = 0; i < pTabSTLINE.Rows.Count; ++i)
            {
                DataRow row = pTabSTLINE.Rows[i];

                if (isUsedRow(row) && !ToolRow.isDeleted(row))
                {
                    if (ToolStockLine.isLineMaterial(row))
                    {
                        double tot    = getLineRealTotal(row);
                        double totNet = getLineNetTotal(row);
                        infoSum.sumOfTotal   += tot;
                        infoSum.sumOfLocDisc += (tot - totNet);
                    }
                    if (ToolStockLine.isLinePromotion(row))
                    {
                        double tot = getLineRealTotal(row);
                        infoSum.sumOfLocPromo += tot;
                    }
                }
            }

            double gDisc = (double)ToolColumn.getColumnLastValue(pTabINVOICE, TableINVOICE.DISCPER, 0.0);

            infoSum.sumOfGlobDisc = (infoSum.sumOfTotal - infoSum.sumOfLocDisc) * (gDisc / 100);
            return(infoSum);
        }
        private object cash(DataRow pRow)
        {
            if (pRow == null)
            {
                return(null);
            }

            EditingTools _editor = environment.getAdapter(ConstAdapterNames.adp_fin_cash_client_input);

            if (_editor == null)
            {
                return(null);
            }

            _editor.adapter.add();
            DataSet   ds  = _editor.adapter.getDataSet();
            DataTable tab = ds.Tables[TableKSLINES.TABLE];

            ToolColumn.setColumnValue(tab, TableKSLINES.AMOUNT, Math.Max((double)pRow[TableCLCARD.BALANCE], 0));
            ToolColumn.setColumnValue(tab, TableKSLINES.CLIENTREF, pRow[TableCLCARD.LOGICALREF]);
            //ToolColumn.setColumnValue(tab, TableKSLINES.CANCELLED, pRow[TableINVOICE.CANCELLED]);
            //ToolColumn.setColumnValue(tab, TableKSLINES.DATE_, pRow[TableINVOICE.DATE_]);

            object invLref_ = pRow[TableINVOICE.LOGICALREF];

            _editor.handlerReferenceInformer = (EditingTools pTool, object pLref) =>
            {
                refresh(invLref_);
            };

            _editor.edit();

            return(invLref_);
        }
        public override DataTable get()
        {
            string stock   = (string)ToolCell.isNull(getBuilder().getParameterValue(TableITEMS.LOGICALREF), string.Empty);
            short  priceid = (short)ToolCell.isNull(getBuilder().getParameterValue(EXTPRICEID), (short)0);


            getBuilder().deleteParameter(EXTPRICEID);


            DataTable prices   = base.get();
            string    priceCol = getPriceCol(priceid);

            prices.Columns.Add(EXTPRICECOL, typeof(double));
            if (priceid > 0 && prices.Columns.Contains(priceCol))
            {
                ToolColumn.copyColumn(prices, priceCol, EXTPRICECOL);
            }
            else
            {
                ToolColumn.setColumnValue(prices, EXTPRICECOL, 0.0);
            }
            //


            //
            return(prices);
        }
 public CellAutomationSimpleScript(string[] pColumns, string[] pExpressions, string[] pVars, DataTable pTable)
     : base(pColumns, null, pVars)
 {
     varsTypes   = ToolColumn.getTypes(pTable, columnsVars);
     expressions = pExpressions;
     evals       = new IEvaluator[pExpressions.Length];
 }
Ejemplo n.º 6
0
        protected override string getId()
        {
            DataTable stslip = cashAdapter.getDataSet().Tables[TableKSLINES.TABLE];
            string    id     = ToolColumn.getColumnLastValue(stslip, TableKSLINES.TRCODE, 0).ToString();

            id = ToolString.shrincDigit(id);
            return(getPrefix() + '_' + id);
        }
Ejemplo n.º 7
0
        public static double getExchange(int curr, DateTime date, IEnvironment env)
        {
            IPagedSource s = new PagedSourceDailyExchangesMagic(env);

            s.getBuilder().addParameterValue(TableDAILYEXCHANGES.CRTYPE, curr);
            s.getBuilder().addParameterValue(TableDAILYEXCHANGES.DATE_, ToolGeneral.date2IntDate(date));
            return((double)ToolColumn.getColumnLastValue(s.getAll(), ToolColumn.getColumnFullName(TableDUMMY.TABLE, TableDUMMY.EXCHANGE), (double)0));
        }
Ejemplo n.º 8
0
        public static void bind(Form control, DataSet dataset, IEnvironment env, bool force)
        {
            if (control != null && dataset != null && env != null)
            {
                control.BindingContext.Clear();

                object[] items = ToolControl.destruct(control);
                foreach (object item in items)
                {
                    IControlBind b = item as IControlBind;
                    if (b != null)
                    {
                        if (!b.isBound() || force)
                        {
                            if (dataset.Tables.Contains(b.DSTable))
                            {
                                DataTable tab    = dataset.Tables[b.DSTable];
                                string    column = string.Empty;
                                if (tab.Columns.Contains(ToolColumn.getColumnFullName(b.DSSubTable, b.DSColumn)))
                                {
                                    column = ToolColumn.getColumnFullName(b.DSSubTable, b.DSColumn);
                                }
                                else
                                if (tab.Columns.Contains(b.DSColumn))
                                {
                                    column = b.DSColumn;
                                }

                                var p = item as View;
                                if (p != null)
                                {
                                    control.BindingContext.Add(new Form.BindingContextSet.BindingItem(p, b.DSProperty, tab, column));
                                    b.bound(env);
                                }
                                //if (column != string.Empty && typeof(IControl).IsAssignableFrom(item.GetType()))
                                //{
                                //    IControl c = (IControl)item;

                                //    if (force)
                                //        for (int i = 0; i < c.DataBindings.Count; ++i)
                                //            if (c.DataBindings[i].PropertyName == b.DSProperty)
                                //            {
                                //                c.DataBindings.RemoveAt(i);
                                //                --i;
                                //            }

                                //    c.DataBindings.Add(b.DSProperty, tab, column); //, true, DataSourceUpdateMode.OnPropertyChanged);

                                //}

                                //  b.bound(env);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public string getName()
        {
            if (isFullName())
            {
                return(ToolColumn.getColumnFullName(table, column));
            }

            return(column);
        }
Ejemplo n.º 10
0
 public ColumnDescriptorExt(string pName)
 {
     if (ToolColumn.isColumnFullName(pName))
     {
         table  = ToolColumn.extractTableName(pName);
         column = ToolColumn.extractColumnName(pName);
     }
     else
     {
         column = pName;
     }
 }
Ejemplo n.º 11
0
 void refreshVal(double pValue, string pCol)
 {
     if (_blockPoint.block())
     {
         try
         {
             ToolColumn.setColumnValue(_tableSchema, pCol, pValue);
         }
         finally
         {
             _blockPoint.unblock();
         }
     }
 }
Ejemplo n.º 12
0
 private void deleteFullColumns(DataSet ds)
 {
     for (int t = 0; t < ds.Tables.Count; ++t)
     {
         DataTable table = ds.Tables[t];
         for (int c = 0; c < table.Columns.Count; ++c)
         {
             if (ToolColumn.isColumnFullName(table.Columns[c].ColumnName))
             {
                 table.Columns.RemoveAt(c);
                 --c;
             }
         }
     }
 }
Ejemplo n.º 13
0
        void cBtnDesc_Click(object sender, EventArgs e)
        {
            if (descList != null && descList.Length > 0)
            {
                ToolMsg.askList(this, descList, delegate(object s, DialogClickEventArgs a)
                {
                    if (a.Which >= 0 && a.Which < descList.Length)
                    {
                        string val_ = descList[a.Which];

                        ToolColumn.setColumnValue(userAdapter.getDataSet().Tables[TableKSLINES.TABLE], TableKSLINES.LINEEXP, val_);
                    }
                });
            }
        }
Ejemplo n.º 14
0
        protected virtual void distributeDocumentBalance(InfoInvoiceSum infoSum, DataTable tab)
        {
            ToolColumn.setColumnValue(tab, TableINVOICE.ADDDISCOUNTS, infoSum.sumOfGlobDisc);
            ToolColumn.setColumnValue(tab, TableINVOICE.TOTALDISCOUNTS, infoSum.sumOfLocDisc + infoSum.sumOfGlobDisc + infoSum.sumOfLocPromo + infoSum.sumOfGlobPromo);
            ToolColumn.setColumnValue(tab, TableINVOICE.TOTALDISCOUNTED, infoSum.sumOfTotal - infoSum.sumOfLocDisc);
            ToolColumn.setColumnValue(tab, TableINVOICE.ADDEXPENSES, infoSum.sumOfGlobSurch);
            ToolColumn.setColumnValue(tab, TableINVOICE.TOTALEXPENSES, infoSum.sumOfLocSurch + infoSum.sumOfGlobSurch);

            ToolColumn.setColumnValue(tab, TableINVOICE.TOTALDEPOZITO, 0);
            ToolColumn.setColumnValue(tab, TableINVOICE.TOTALPROMOTIONS, infoSum.sumOfLocPromo + infoSum.sumOfGlobPromo);

            ToolColumn.setColumnValue(tab, TableINVOICE.TOTALVAT, infoSum.sumOfLocVAT + infoSum.sumOfGlobVAT);
            ToolColumn.setColumnValue(tab, TableINVOICE.GROSSTOTAL, infoSum.sumOfTotal + infoSum.sumOfLocPromo + infoSum.sumOfGlobPromo);
            ToolColumn.setColumnValue(tab, TableINVOICE.NETTOTAL, infoSum.sumOfTotal - (infoSum.sumOfGlobDisc + infoSum.sumOfLocDisc) + (infoSum.sumOfGlobSurch + infoSum.sumOfLocSurch) + (infoSum.sumOfLocVAT + infoSum.sumOfGlobVAT) + (infoSum.sumOfLocTax + infoSum.sumOfGlobTax));
            ToolColumn.setColumnValue(tab, TableINVOICE.TOTALADDTAX, infoSum.sumOfLocTax + infoSum.sumOfGlobTax);
        }
Ejemplo n.º 15
0
        public void addParameterValueTable(string table, string col, object value, SqlTypeRelations relMath, SqlTypeRelations relBool)
        {
            try
            {
                if ((table != null) && (col != null) && (value != null))
                {
                    // Type typeWate = getColumnType(table, col);
                    if (true
                        //isColumnExists(table, col) &&
                        //(value.GetType() == DBNull.Value.GetType() ||
                        // (value = Convert.ChangeType(value, typeWate, null)) != null
                        //)
                        )
                    {
                        object[] arr = new object[] { tableWhereRecodrType.common, table, col, value, relMath, relBool, getPatternWhere() };

                        int indx = tableWhere.Rows.Count - 1;
                        for (; indx >= 0; --indx)
                        {
                            DataRow lastRow = tableWhere.Rows[indx];
                            if (isLineCommon(lastRow) && (getLinePatern(lastRow) == getPatternWhere()))
                            {
                                string targetCol = ToolColumn.getColumnFullName(table, col);
                                string curCol    = ToolColumn.getColumnFullName((string)lastRow[TableDUMMY.PARENTNAME], (string)lastRow[TableDUMMY.CHILDNAME]);
                                if (string.Compare(targetCol, curCol) < 0)
                                {
                                    continue;
                                }
                            }

                            ++indx;
                            break;
                        }

                        ToolTable.insertRowAt(tableWhere, indx, arr);
                        return;
                    }
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
            throw new MyException.MyExceptionInner(MessageCollection.T_MSG_ERROR_INNER);
        }
Ejemplo n.º 16
0
 void distribute(DataRow row, string[] cols)
 {
     if (needUpdate(row, cols))
     {
         //getData
         source.getBuilder().reset();
         for (int i = 0; i < cols.Length; ++i)
         {
             string col = ToolColumn.extractColumnName(getColMapBind(cols[i]));
             string tab = ToolColumn.extractTableName(getColMapBind(cols[i]));
             object val = row[cols[i]];
             if ((tab != string.Empty) && (col != string.Empty))
             {
                 source.getBuilder().addParameterValueTable(tab, col, val);
             }
             else
             if (col != string.Empty)
             {
                 source.getBuilder().addParameterValue(col, val);
             }
             else
             if (col == string.Empty)
             {
                 source.getBuilder().addFreeParameterValue(val);
             }
         }
         emptyDest();
         DataTable tabData = source.getAll();
         //
         if (tabData != null)
         { //Has data
             foreach (DataRow rowData in tabData.Rows)
             {
                 DataRow nRow = tableDest.NewRow();
                 ToolRow.initTableNewRow(nRow);
                 tableDest.Rows.Add(nRow);
                 for (int i = 0; i < updateChildCol.Length; ++i)
                 {
                     ToolCell.set(nRow, getColMapData(updateChildCol[i]), rowData[updateChildCol[i]]);
                 }
             }
         }
     }
 }
Ejemplo n.º 17
0
        public int getColumnSize(string pTableName, string pColName, int pDef)
        {
            if (ToolColumn.isColumnFullName(pColName))
            {
                pTableName = ToolColumn.extractTableName(pColName);
                pColName   = ToolColumn.extractColumnName(pColName);
            }
            ITableDescriptor tds = getTable(pTableName);

            if (tds != null)
            {
                ColumnDescriptor cds = tds.getColumn(pColName);
                if (cds != null)
                {
                    return(cds.size);
                }
            }
            return(pDef);
        }
Ejemplo n.º 18
0
        public static DataTable getMatUnitPrices(int unit, DateTime date, IEnvironment env, DataTable tablePrices, DataTable tableMatUnits)
        {
            DataTable resPrices = tablePrices.Clone();

            ToolColumn.add(resPrices, TablePRCLIST.E_DUMMY__PRICE, typeof(double));
            for (int i = 0; i < tablePrices.Rows.Count; ++i)
            {
                DataRow row         = tablePrices.Rows[i];
                short   convertable = (short)row[TablePRCLIST.UNITCONVERT];
                int     curUnit     = (int)row[TablePRCLIST.UOMREF];

                if ((convertable == (short)ConstBool.yes) || (curUnit == unit))
                {
                    if (ToolDateTime.isBetween(date, (DateTime)row[TablePRCLIST.BEGDATE], (DateTime)row[TablePRCLIST.ENDDATE]))
                    {
                        DataRow curRow = ToolRow.copyRowToTable(row, resPrices);
                        double  cf     = getMatUnitCF(curUnit, tableMatUnits);
                        double  cf_    = getMatUnitCF(unit, tableMatUnits);
                        double  price  = (double)curRow[TablePRCLIST.PRICE];
                        price = (price / cf) * cf_;
                        curRow[TablePRCLIST.PRICE] = price;
                        double exchange = ToolGeneral.getExchange((short)curRow[TablePRCLIST.CURRENCY], date, env);
                        curRow[TablePRCLIST.CURRENCY] = env.getInfoApplication().periodCurrencyNativeId;
                        if (exchange > ConstValues.minPositive)
                        {
                            price /= exchange;
                        }
                        else
                        {
                            price = 0;
                        }
                        curRow[TablePRCLIST.E_DUMMY__PRICE] = price;
                        curRow[TablePRCLIST.UOMREF]         = unit;
                    }
                }
            }
            return(resPrices);
        }
Ejemplo n.º 19
0
        private string getPriceCol()
        {
            short   indx = 0;
            DataSet ds   = environment.getCurDoc();


            if (ds == null)
            {
                return(TableDUMMY.PRICE + environment.getSysSettings().getString(SettingsSysMob.MOB_SYS_DEF_PLIST, "1"));
            }

            if (ds.Tables.Contains(TableINVOICE.TABLE))
            {
                indx = (short)ToolColumn.getColumnLastValue(ds.Tables[TableINVOICE.TABLE], TableINVOICE.PRCLIST, (short)0);
            }

            if (indx > 0) // 1 2 3 4
            {
                return(TableDUMMY.PRICE + ToolString.shrincDigit(indx.ToString()));
            }

            return(string.Empty);
        }
        public override DataTable get()
        {
            DataTable exch;
            int       date;
            short     curr = (short)ToolCell.isNull(getBuilder().getParameterValue(TableDAILYEXCHANGES.CRTYPE), (short)0);

            object dt = getBuilder().getParameterValue(E_DATE_);

            if (dt != null)
            {
                date = ToolGeneral.date2IntDate((DateTime)dt);
                getBuilder().deleteParameter(E_DATE_);
                getBuilder().addParameterValue(TableDAILYEXCHANGES.DATE_, date);
            }
            else
            {
                date = (int)ToolCell.isNull(getBuilder().getParameterValue(TableDAILYEXCHANGES.DATE_), (int)0);
            }

            if ((curr == 0) || (curr == environment.getInfoApplication().periodCurrencyNativeId))
            {
                exch = getTableInstance();
                exch.Rows.Add(ToolRow.initTableNewRow(exch.NewRow()));
                ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.CRTYPE, curr);
                ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.DATE_, date);
                ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES1, 1);
                ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES2, 1);
                ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES3, 1);
                ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES4, 1);
            }
            else
            {
                exch = base.get();
            }
            exch.Columns.Add(ToolColumn.getColumnFullName(TableDUMMY.TABLE, TableDUMMY.EXCHANGE), typeof(double), TableDAILYEXCHANGES.RATES1);
            return(exch);
        }
Ejemplo n.º 21
0
 public object get()
 {
     return(ToolColumn.getColumnLastValue(tab, col, def));
 }
Ejemplo n.º 22
0
 public override void setHeaderClient(object pClienRef)
 {
     ToolColumn.setColumnValue(getTable(TableKSLINES.TABLE), TableKSLINES.CLIENTREF, pClienRef);
 }
Ejemplo n.º 23
0
        protected virtual void dataResivedForINVOICE(DataSet pDataSet)
        {
            IPagedSource pagedSource;
            DataTable    tab = pDataSet.Tables[TableINVOICE.TABLE];

            cellBindingHeader = new ImplCellReltions(tab);



            tab.ColumnChanged += new DataColumnChangeEventHandler(tableINVOICEColumnChanged);



            /////CURRENCY///////////////////////////////////////////////////////////////////////


            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__RATE, typeof(double));
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__CUR, typeof(short));
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__CURCODE, typeof(string));

            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__REPRATE, typeof(double));



            //string _extp = "IIF({1} <> 0,{0}/{1},0)";

            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__TOTSURCHARGE, typeof(double));
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__TOTDISCOUNT, typeof(double));
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__TOT, typeof(double));
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__TOTNET, typeof(double));

            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__REPTOTSURCHARGE, typeof(double));
            //new RowColumnsBindingInnerExpr(tab, new string[] { TableINVOICE.E_DUMMY__TOTSURCHARGE, TableINVOICE.E_DUMMY__REPRATE }, TableINVOICE.E_DUMMY__REPTOTSURCHARGE, _extp, null);
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__REPTOTDISCOUNT, typeof(double));
            //new RowColumnsBindingInnerExpr(tab, new string[] { TableINVOICE.E_DUMMY__TOTDISCOUNT, TableINVOICE.E_DUMMY__REPRATE }, TableINVOICE.E_DUMMY__REPTOTDISCOUNT, _extp, null);
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__REPTOT, typeof(double));
            //new RowColumnsBindingInnerExpr(tab, new string[] { TableINVOICE.E_DUMMY__TOT, TableINVOICE.E_DUMMY__REPRATE }, TableINVOICE.E_DUMMY__REPTOT, _extp, null);
            //ToolColumn.add(tab, TableINVOICE.E_DUMMY__REPTOTNET, typeof(double));
            //new RowColumnsBindingInnerExpr(tab, new string[] { TableINVOICE.E_DUMMY__TOTNET, TableINVOICE.E_DUMMY__REPRATE }, TableINVOICE.E_DUMMY__REPTOTNET, _extp, null);


            ////////////////////////////////////////////////////////////////////////////////////


            /////////////////////////////////////////////////////////////////
            ToolColumn.add(tab, TableINVOICE.E_DUMMY__SOURCEWHNAME, typeof(string));
            pagedSource = new PagedSourceWarehouse(environment);
            new RowColumnsBindingDBRelations(tab, pagedSource,
                                             new string[] { TableINVOICE.SOURCEINDEX },
                                             new string[] { TableWHOUSE.NR },
                                             new string[] { TableINVOICE.E_DUMMY__SOURCEWHNAME },
                                             new string[] { TableWHOUSE.NAME },
                                             UpdateTypeFlags.activeOnRelColumn | UpdateTypeFlags.disableEditCancel | UpdateTypeFlags.setTypeDefaultToDrivedChild,
                                             null);

            //new RowColumnsBindingDBRelations(tab, new PagedSourceClient(environment),
            //  new string[] { TableINVOICE.CLIENTREF },
            //  new string[] { TableCLCARD.LOGICALREF },
            //  new string[] { string.Empty, string.Empty, TableINVOICE.DISCPER, TableINVOICE.PRCLIST },
            //  new string[] { TableCLCARD.CODE, TableCLCARD.DEFINITION_, TableCLCARD.DISCPER, TableCLCARD.PRCLIST },
            //  UpdateTypeFlags.activateIgnorLast2DrivedChilCols | UpdateTypeFlags.setTypeDefaultToDrivedChild | UpdateTypeFlags.resetIfAllCurrentRelColsAreDefaultOrNull,
            //  null);

            new RowColumnsBindingDBRelations(tab, new PagedSourceClient(environment),
                                             new string[] { TableINVOICE.CLIENTREF },
                                             new string[] { TableCLCARD.LOGICALREF },
                                             new string[] { },
                                             new string[] { TableCLCARD.CODE, TableCLCARD.DEFINITION_, TableCLCARD.BARCODE },
                                             UpdateTypeFlags.setTypeDefaultToDrivedChild | UpdateTypeFlags.resetIfAllCurrentRelColsAreDefaultOrNull,
                                             null);

            /////////////////////////////////////////////////////////
        }
Ejemplo n.º 24
0
        protected virtual void dataResivedForSTLINE(DataSet pDataSet)
        {
            //IPagedSource pagedSource;
            DataTable tab = pDataSet.Tables[TableSTLINE.TABLE];

            cellBindingLines = new ImplCellReltions(tab);



            tab.ColumnChanged += new DataColumnChangeEventHandler(tableSTLINEColumnChanged);
            tab.RowChanged    += new DataRowChangeEventHandler(tableSTLINERowChanged);
            tab.RowDeleted    += new DataRowChangeEventHandler(tableSTLINERowDeleted);
            /////CURRENCY///////////////////////////////////////////////////////////////////////
            ToolColumn.add(tab, TableSTLINE.E_DUMMY__TOTAL, typeof(double));
            ToolColumn.add(tab, TableSTLINE.E_DUMMY__PRICE, typeof(double));
            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__RATE, typeof(double));

            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__REPTOTAL, typeof(double));
            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__REPPRICE, typeof(double));
            //ToolColumn.add(tab, TableSTLINE.E_DUMMY__REPRATE, typeof(double));

            ////////////BIND AND INHERIT/////////////////////////////////////////

            new TablesColumnsBinding(
                pDataSet.Tables[TableINVOICE.TABLE],
                pDataSet.Tables[TableSTLINE.TABLE],
                new string[] {
                TableINVOICE.CANCELLED,
                TableINVOICE.CLIENTREF,
                TableINVOICE.DATE_,
                TableINVOICE.SOURCEINDEX,
                //TableINVOICE.E_DUMMY__REPRATE,
                TableINVOICE.PRCLIST
            }
                , new string[] {
                TableSTLINE.CANCELLED,
                TableSTLINE.CLIENTREF,
                TableSTLINE.DATE_,
                TableSTLINE.SOURCEINDEX,
                //TableSTLINE.E_DUMMY__REPRATE,
                TableSTLINE.PRCLIST
            }, true);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //MAIN//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (int i = 0; i < count; ++i) //Now 1
            {
                CellAutomationSimpleExp cellExpes = new CellAutomationSimpleExp(
                    new string[] { TableSTLINE.AMOUNT, arrPriceCols[i], arrTotalCols[i] },
                    new IEvaluator[] { new CalcDoubleDiv(2, 1), new CalcDoubleDiv(2, 0), new CalcDoubleMult(0, 1) },
                    // new string[] { "IIF({1}<>0,{2}/{1},0)", "IIF({0}<>0,{2}/{0},0)", "{0}*{1}" },
                    new string[] { TableSTLINE.AMOUNT, arrPriceCols[i], arrTotalCols[i] });
                cellBindingLines.addRelation(new string[] { TableSTLINE.AMOUNT, arrPriceCols[i], arrTotalCols[i] }, cellExpes, bpArrMain[i] = new BlockPoint(), new ImplValidRowStockPriced());
            }
            //PRICE FROM LOC//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (int i = 1; i < count; ++i)
            {
                CellAutomationSimpleExp cellExpes = new CellAutomationSimpleExp(
                    new string[] { arrPriceCols[i] },
                    new IEvaluator[] { new CalcDoubleMult(0, 1) },
                    // new string[] { "{0}*{1}" },
                    new string[] { TableSTLINE.PRICE, arrRateCols[i] });
                cellBindingLines.addRelation(new string[] { TableSTLINE.PRICE, arrRateCols[i] }, cellExpes, bpArrPriceXFromLoc[i] = new BlockPoint(), null);
            }
            //TOTAL FROM LOC//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            for (int i = 1; i < count; ++i)
            {
                CellAutomationSimpleExp cellExpes = new CellAutomationSimpleExp(
                    new string[] { arrTotalCols[i] },
                    new IEvaluator[] { new CalcDoubleMult(0, 1) },
                    // new string[] { "{0}*{1}" },
                    new string[] { TableSTLINE.TOTAL, arrRateCols[i] });
                cellBindingLines.addRelation(new string[] { TableSTLINE.TOTAL, arrRateCols[i] }, cellExpes, bpArrTotalXFromLoc[i] = new BlockPoint(), null);
            }
            ////////////////////////////////////////////////////////////////////////////////////
            setUsedCurrency(ConstUsedCur.national);


            ////////////////////////////////////////////////////////////////////////////////////
            CellAutomationDB dbAutomation;

            dbAutomation = new CellAutomationDB(tab, new PagedSourceMaterial(environment),
                                                new string[] { TableSTLINE.STOCKREF },
                                                new string[] { TableITEMS.LOGICALREF },
                                                new string[] { },
                                                new string[] { TableITEMS.CODE, TableITEMS.NAME },
                                                UpdateTypeFlags.resetIfAllCurrentRelColsAreDefaultOrNull,
                                                validatorLineMatOrPromo);

            cellBindingLines.addRelation(dbAutomation.getTriggerColumns(), dbAutomation, validatorLineMatOrPromo);
            dbAutomation = new CellAutomationDB(tab, new PagedSourceMaterial(environment),
                                                new string[] { TableSTLINE.STOCKREF },
                                                new string[] { TableITEMS.LOGICALREF },
                                                new string[] { /* TableSTLINE.DISCPER, */ TableSTLINE.UINFO1, TableSTLINE.UINFO2, TableSTLINE.UNIT, TableSTLINE.UNITREF },
                                                new string[] { /* TableITEMS.DISCPER,*/ TableITEMS.UNITCF1, TableITEMS.UNITCF1, TableITEMS.UNIT1, TableITEMS.UNITREF1 },
                                                UpdateTypeFlags.activeOnRelColumn | UpdateTypeFlags.disableEditCancel | UpdateTypeFlags.setTypeDefaultToDrivedChild,
                                                validatorLineMatOrPromo);

            cellBindingLines.addRelation(dbAutomation.getTriggerColumns(), dbAutomation, validatorLineMatOrPromo);



            //
            //



            new RowDeleteWatcher(tab, null, new string[] { TableSTLINE.TOTAL }, new object[] { 0.0 });



            bindForLineType(tab);
            bindForDistributeSums(tab);
            bindForPromo(tab);
        }
Ejemplo n.º 25
0
 void distribute(DataRow row, string[] cols)
 {
     if (needUpdate(row, cols))
     {
         bool drivedUpdateMode = flags.isFlagEnabled(UpdateTypeFlags.__spe__updateIfDrived);
         if (drivedUpdateMode)
         {
             bool hasFull = false;
             for (int i = 0; i < allChildCol.Length; ++i)
             {
                 if (ToolColumn.isColumnFullName(allChildCol[i]))
                 {
                     hasFull = true;
                 }
             }
             if (!hasFull)
             {
                 return;
             }
         }
         //getData
         source.getBuilder().reset();
         for (int i = 0; i < cols.Length; ++i)
         {
             string col = ToolColumn.extractColumnName(getColMap(cols[i]));
             string tab = ToolColumn.extractTableName(getColMap(cols[i]));
             object val = row[cols[i]];
             if ((tab != string.Empty) && (col != string.Empty))
             {
                 source.getBuilder().addParameterValueTable(tab, col, val);
             }
             else
             if (col != string.Empty)
             {
                 source.getBuilder().addParameterValue(col, val);
             }
             else
             if (col == string.Empty)
             {
                 source.getBuilder().addFreeParameterValue(val);
             }
         }
         IDictionary dicData = ToolRow.convertFirstToDictionary(source.getAll());
         //
         if (dicData != null)
         { //Has data
             string[] tmpChildCol = (drivedUpdateMode ? ToolColumn.selectFullNameCols(updateChildCol) : updateChildCol);
             for (int i = 0; i < tmpChildCol.Length; ++i)
             {
                 ToolCell.set(row, tmpChildCol[i], dicData[getColMap(tmpChildCol[i])]);
             }
         }
         else
         { //No data
             if (!flags.isFlagEnabled(UpdateTypeFlags.disableEditCancel))
             {
                 row.CancelEdit();
             }
             else
             {
                 if (flags.isFlagEnabled(UpdateTypeFlags.setTypeDefaultToDrivedChild))
                 {
                     ToolRow.initTableNewRow(row, (drivedUpdateMode ? ToolColumn.selectFullNameCols(childCol) : childCol));
                 }
                 if (flags.isFlagEnabled(UpdateTypeFlags.setTypeDefaultToRelChild))
                 {
                     ToolRow.initTableNewRow(row, (drivedUpdateMode ? ToolColumn.selectFullNameCols(bindChildCol) : bindChildCol));
                 }
             }
         }
     }
 }
Ejemplo n.º 26
0
        void init(DataTable pTable, IPagedSource pSource, string[] pBindChildCol, string[] pBindParentCol, string[] pChildCol, string[] pParentCol, UpdateTypeFlags pFlags, IRowValidator pValidator, string[] pTriggerCols)
        {
            validator   = (pValidator == null) ? new RowValidatorTrue() : pValidator;
            tableSource = pTable;
            flags.flagEnable(pFlags);
            source = pSource;
            for (int i = pChildCol.Length; i < pParentCol.Length; ++i)
            {
                pChildCol = ToolArray.resize <string>(pChildCol, pChildCol.Length + 1);

                pChildCol[pChildCol.Length - 1] = string.Empty;
            }
            for (int i = 0; i < pParentCol.Length; ++i)
            {
                if ((pChildCol[i] == string.Empty) || (pChildCol[i] == null))
                {
                    pChildCol[i] = ToolColumn.getColumnFullName(source.getBuilder().getName(), pParentCol[i]);
                }
            }
            triggerCols   = pTriggerCols;
            bindChildCol  = pBindChildCol;
            bindParentCol = pBindParentCol;
            childCol      = pChildCol;
            parentCol     = pParentCol;
            allChildCol   = new string[bindChildCol.Length + childCol.Length];
            bindChildCol.CopyTo(allChildCol, 0);
            childCol.CopyTo(allChildCol, bindChildCol.Length);
            allParentCol = new string[bindParentCol.Length + parentCol.Length];
            bindParentCol.CopyTo(allParentCol, 0);
            parentCol.CopyTo(allParentCol, bindParentCol.Length);
            //

            for (int i = 0; i < bindChildCol.Length; ++i)
            {
                addColForMap(bindChildCol[i], bindParentCol[i]);
            }
            for (int i = 0; i < childCol.Length; ++i)
            {
                addColForMap(childCol[i], parentCol[i]);
            }

            //

            if (flags.isFlagEnabled(UpdateTypeFlags.activeOnRelColumn))
            {
                columns = bindChildCol;
            }
            else
            {
                int len = allChildCol.Length;
                if (flags.isFlagEnabled(UpdateTypeFlags.activateIgnorLast1DrivedChilCols))
                {
                    len -= 1;
                }
                else
                if (flags.isFlagEnabled(UpdateTypeFlags.activateIgnorLast2DrivedChilCols))
                {
                    len -= 2;
                }
                else
                if (flags.isFlagEnabled(UpdateTypeFlags.activateIgnorLast3DrivedChilCols))
                {
                    len -= 3;
                }
                columns = new string[len];
                Array.Copy(allChildCol, columns, len);
            }
            columns = ToolArray.merge <string>(columns, triggerCols);
            //
            if (flags.isFlagEnabled(UpdateTypeFlags.updateIgnoreRelColumn))
            {
                updateChildCol = childCol;
            }
            else
            {
                updateChildCol = allChildCol;
            }
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!

            //

            for (int i = 0; i < allChildCol.Length; ++i)
            {
                if (allParentCol[i] != string.Empty && !tableSource.Columns.Contains(allChildCol[i]))
                {
                    tableSource.Columns.Add(allChildCol[i], ToolTypeSet.helper.tObject);//check//source.getBuilder().getColumnType(allParentCol[i]));
                }
            }

            //

            //try
            //{
            //    flags.flagEnable(UpdateTypeFlags.__spe__updateIfDrived);
            //    for (int i = 0; i < tableSource.Rows.Count; ++i)
            //        refresh(tableSource.Rows[i]);
            //}
            //finally
            //{
            //    flags.flagDisable(UpdateTypeFlags.__spe__updateIfDrived);
            //}
            ////
        }
Ejemplo n.º 27
0
 public virtual void setHeader(String pColName, Object pVal)
 {
     ToolColumn.setColumnValue(getHeaderTable(), pColName, pVal);
 }
Ejemplo n.º 28
0
 public virtual object getHeader(String pColName, Object pValDef)
 {
     return(ToolColumn.getColumnLastValue(getHeaderTable(), pColName, pValDef));
 }