예제 #1
0
        bool needUpdate(DataRow row, string[] cols)
        {
            if (row == null)
            {
                return(false);
            }



            bool flagResetOnAllNullOrDef = flags.isFlagEnabled(UpdateTypeFlags.resetIfAllCurrentRelColsAreDefaultOrNull);
            bool flagStopIfOneNullOrDef  = !flags.isFlagEnabled(UpdateTypeFlags.continueIfOneOfCurrentRelColsDefaultOrNull);


            if (ToolCell.isDefaultOrNullAll(row, cols))
            {
                if (flagResetOnAllNullOrDef)
                {
                    ToolRow.initTableNewRow(row, allChildCol);
                    return(false);
                }
                if (flagStopIfOneNullOrDef)
                {
                    return(false);
                }
            }
            if (ToolCell.hasDefaultOrNull(row, cols))
            {
                if (flagStopIfOneNullOrDef)
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #2
0
        public DataRow insertRowIntoTable(DataTable table, int pos)
        {
            DataRow row = table.NewRow();

            ToolRow.initTableNewRow(null);
            table.Rows.InsertAt(row, pos);
            return(row);
        }
예제 #3
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]]);
                 }
             }
         }
     }
 }
        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);
        }
예제 #5
0
        public static void syncWithClTran(DataTable tabPayTrans, DataTable tabClTrans)
        {
            DataRow rowTran = ToolRow.getFirstRealRow(tabClTrans);

            if (rowTran != null)
            {
                DataRow rowPay = ToolRow.getFirstRealRow(tabPayTrans);
                if (rowPay == null)
                {
                    tabPayTrans.Rows.Add(rowPay = ToolRow.initTableNewRow(tabPayTrans.NewRow()));
                }

                ToolCell.set(rowPay, TablePAYTRANS.PAYNO, 1);
                ToolCell.set(rowPay, TablePAYTRANS.PROCDATE, rowTran[TableCLFLINE.DATE_]);
                ToolCell.set(rowPay, TablePAYTRANS.DISCDUEDATE, rowTran[TableCLFLINE.DATE_]);
                ToolCell.set(rowPay, TablePAYTRANS.DATE_, rowTran[TableCLFLINE.DATE_]);
                ToolCell.set(rowPay, TablePAYTRANS.TOTAL, rowTran[TableCLFLINE.AMOUNT]);
                ToolCell.set(rowPay, TablePAYTRANS.REPORTRATE, rowTran[TableCLFLINE.REPORTRATE]);
                ToolCell.set(rowPay, TablePAYTRANS.CARDREF, rowTran[TableCLFLINE.CLIENTREF]);
                ToolCell.set(rowPay, TablePAYTRANS.DISCDUEDATE, rowTran[TableCLFLINE.DATE_]);
                ToolCell.set(rowPay, TablePAYTRANS.TRCURR, rowTran[TableCLFLINE.TRCURR]);
                ToolCell.set(rowPay, TablePAYTRANS.TRNET, rowTran[TableCLFLINE.TRNET]);
            }
        }
예제 #6
0
 void ImplAdapterUser_TableNewRow(object sender, DataTableNewRowEventArgs e)
 {
     ToolRow.initTableNewRow(e.Row);
 }
예제 #7
0
        private void fillSchema(DataRow rowDocLine)
        {
            _curMatRecord = ToolStockLine.getItemData(environment, rowDocLine[TableSTLINE.STOCKREF]);

            //

            //if (_checkLevel)
            {
                //object docLRef = rowDocHeader[TableINVOICE.LOGICALREF];
                object lref   = rowDocLine[TableSTLINE.STOCKREF];
                double onhand = (double)ToolCell.isNull(_curMatRecord[TableITEMS.ONHAND], 0.0);
                onhand += environment.getMatIOAmount(lref);
                //onhand += ToolStockLine.itemAmountInDoc(lref, rowDocLine.Table);
                //onhand += ToolStockLine.itemAmountInDB(environment, lref, docLRef);
                ToolCell.set(_curMatRecord, TableITEMS.ONHAND, onhand);
            }


            //
            if (handler.report != null)
            {
                handler.report.setDataSource(_curMatRecord.Table);
                handler.report.refreshSource();
            }
            //
            _tableSchema.Clear();



            string unit   = string.Empty;
            double amount = (double)ToolCell.isNull(rowDocLine[TableSTLINE.AMOUNT], 0.0);

            if (ToolDouble.isZero(amount) && CurrentVersion.ENV.getEnvBool("STOCKAMOUNTONE", false))
            {
                amount = 1.0;
            }

            double  price   = (double)ToolCell.isNull(rowDocLine[TableSTLINE.PRICE], 0.0);
            double  total   = (double)ToolCell.isNull(rowDocLine[TableSTLINE.TOTAL], 0.0);
            double  disperc = (double)ToolCell.isNull(rowDocLine[TableSTLINE.DISCPER], 0.0);
            double  uinfo1  = 0.0;
            double  uinfo2  = 0.0;
            DataRow newRow;

            //
            newRow = ToolRow.initTableNewRow(_tableSchema.NewRow());
            newRow[TableDUMMY.UNIT]     = unit = (string)ToolCell.isNull(_curMatRecord[TableITEMS.UNIT1], string.Empty);
            newRow[TableDUMMY.UNITREF]  = (string)ToolCell.isNull(_curMatRecord[TableITEMS.UNITREF1], string.Empty);
            newRow[TableDUMMY.UNITCF01] = uinfo1 = (double)ToolCell.isNull(_curMatRecord[TableITEMS.UNITCF1], 0.0);
            newRow[TableDUMMY.UNITCF02] = uinfo2 = (double)ToolCell.isNull(_curMatRecord[TableITEMS.UNITCF1], 0.0);
            newRow[TableDUMMY.CONVFACT] = (uinfo1 > ConstValues.minPositive ? uinfo2 / uinfo1 : 1.0);

            newRow[TableDUMMY.AMOUNT]  = amount;
            newRow[TableDUMMY.PRICE]   = price;
            newRow[TableDUMMY.TOTAL]   = total;
            newRow[TableDUMMY.DISCPER] = disperc;

            _tableSchema.Rows.Add(newRow);
            //
            newRow = ToolRow.initTableNewRow(_tableSchema.NewRow());
            newRow[TableDUMMY.UNIT]     = unit = (string)ToolCell.isNull(_curMatRecord[TableITEMS.UNIT2], string.Empty);
            newRow[TableDUMMY.UNITREF]  = (string)ToolCell.isNull(_curMatRecord[TableITEMS.UNITREF2], string.Empty);
            newRow[TableDUMMY.UNITCF01] = uinfo1 = (double)ToolCell.isNull(_curMatRecord[TableITEMS.UNITCF1], 0.0);
            newRow[TableDUMMY.UNITCF02] = uinfo2 = (double)ToolCell.isNull(_curMatRecord[TableITEMS.UNITCF2], 0.0);
            newRow[TableDUMMY.CONVFACT] = (uinfo1 > ConstValues.minPositive ? uinfo2 / uinfo1 : 1.0);
            if ((unit != string.Empty))
            {
                _tableSchema.Rows.Add(newRow);
            }

            //
            newRow = ToolRow.initTableNewRow(_tableSchema.NewRow());
            newRow[TableDUMMY.UNIT]     = unit = (string)ToolCell.isNull(_curMatRecord[TableITEMS.UNIT3], string.Empty);
            newRow[TableDUMMY.UNITREF]  = (string)ToolCell.isNull(_curMatRecord[TableITEMS.UNITREF3], string.Empty);
            newRow[TableDUMMY.UNITCF01] = uinfo1 = (double)ToolCell.isNull(_curMatRecord[TableITEMS.UNITCF1], 0.0);
            newRow[TableDUMMY.UNITCF02] = uinfo2 = (double)ToolCell.isNull(_curMatRecord[TableITEMS.UNITCF3], 0.0);
            newRow[TableDUMMY.CONVFACT] = (uinfo1 > ConstValues.minPositive ? uinfo2 / uinfo1 : 1.0);
            if ((unit != string.Empty))
            {
                _tableSchema.Rows.Add(newRow);
            }
            //
            refreshVal();
            //
            //check
            //string userUnitRef = (string)ToolCell.isNull(rowDocLine[TableSTLINE.UNITREF], string.Empty);
            //for (int i = 0; i < _tableSchema.Rows.Count; ++i)
            //{
            //    DataRow row = _tableSchema.Rows[i];
            //    string unitRef = (string)row[TableDUMMY.UNITREF];
            //    if (userUnitRef == unitRef)
            //        cBoxUnits.SelectedIndex = i;
            //}
        }
예제 #8
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));
                 }
             }
         }
     }
 }
 public void columnChange(DataColumnChangeEventArgs e)
 {
     ToolRow.initTableNewRow(e.Row, cols);
 }