コード例 #1
0
        static double getStockDocLineAmount(DataRow docLine)
        {
            double        amount      = 0;
            ConstBool     isCancelled = (ConstBool)(short)ToolCell.isNull(docLine[TableSTLINE.CANCELLED], (short)ConstBool.yes);
            ConstLineType lineType    = (ConstLineType)(short)ToolCell.isNull(docLine[TableSTLINE.LINETYPE], (short)ConstLineType.undef);


            if (isCancelled == ConstBool.not && (lineType == ConstLineType.material || lineType == ConstLineType.promotion))
            {
                amount = (double)ToolCell.isNull(docLine[TableSTLINE.AMOUNT], 0.0);
                ConstIOCode ioCode = (ConstIOCode)(short)ToolCell.isNull(docLine[TableSTLINE.IOCODE], (short)0);
                switch (ioCode)
                {
                case ConstIOCode.input:
                case ConstIOCode.inputFromWarehouse:
                    amount = +amount;
                    break;

                case ConstIOCode.output:
                case ConstIOCode.outputFromWarehouse:
                    amount = -amount;
                    break;

                default:
                    amount = 0;
                    break;
                }
            }
            return(amount);
        }
コード例 #2
0
        protected bool startSave()
        {
            try
            {
                FinishDataEditing();

                if (_checkLevel)
                {
                    DataRow row    = ToolRow.getFirstRealRow(_tableSchema);
                    double  amount = (double)ToolCell.isNull(row[TableDUMMY.AMOUNT], 0.0);
                    double  onhand = (double)ToolCell.isNull(_curMatRecord[TableDUMMY.ONHAND], 0.0);
                    if ((amount - onhand) > ConstValues.minPositive)
                    {
                        ToolMsg.show(this, MessageCollection.T_MSG_INVALID_QUANTITY, null);
                        return(false);
                    }
                }



                DataRow _rowActiveUnit = this.BindingContext.getBindingItemRecord(cUnit);

                //
                if (_rowActiveUnit != null)
                {
                    switch (handler.converCol(handler.column))
                    {
                    case TableDUMMY.AMOUNT:
                        ToolCell.set(handler.row, TableSTLINE.AMOUNT, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.AMOUNT]);
                        //
                        if (_rowActiveUnit != null)
                        {
                            ToolCell.set(handler.row, TableSTLINE.UNIT, _rowActiveUnit[TableDUMMY.UNIT]);
                            ToolCell.set(handler.row, TableSTLINE.UNITREF, _rowActiveUnit[TableDUMMY.UNITREF]);
                            ToolCell.set(handler.row, TableSTLINE.UINFO1, _rowActiveUnit[TableDUMMY.UNITCF01]);
                            ToolCell.set(handler.row, TableSTLINE.UINFO2, _rowActiveUnit[TableDUMMY.UNITCF02]);
                        }
                        //
                        return(true);

                    case TableDUMMY.PRICE:
                        ToolCell.set(handler.row, TableSTLINE.PRICE, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.PRICE]);
                        return(true);

                    case TableDUMMY.DISCPER:
                        ToolCell.set(handler.row, TableSTLINE.DISCPER, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.DISCPER]);
                        return(true);

                    case TableDUMMY.TOTAL:
                        ToolCell.set(handler.row, TableSTLINE.TOTAL, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.TOTAL]);
                        return(true);
                    }
                }
            }
            catch (Exception exc)
            {
                ToolMobile.setException(exc);
            }
            return(false);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        double getLineNetTotal(DataRow row)
        {
            double tot  = getLineRealTotal(row);
            double perc = (double)ToolCell.isNull(row[TableSTLINE.DISCPER], (double)0.0);

            return(tot * (100 - perc) / 100);
        }
コード例 #5
0
        public void fillTree(object[][] arrGroups)
        {
            //object[]{object[]{1,2,3},object[]{5,6},object[]{6,9}}

            this.RootNode.Clear();

            foreach (object[] arr in arrGroups)
            {
                Node curNode = this.RootNode;
                for (int i = 0; i < Math.Min(2, arr.Length); ++i)
                {
                    string item = ToolCell.isNull(arr[i], string.Empty).ToString();

                    Node res_ = curNode.Search(item); // Find(curCollect, item.ToString(), false);
                    if (res_ != null)
                    {
                        curNode = res_;
                    }
                    else
                    {
                        curNode     = curNode.Add(new Node(item, item));
                        curNode.Tag = arr[i];
                    }
                }
            }
        }
コード例 #6
0
ファイル: Form.cs プロジェクト: rualb/ava-agent-xamarin
                object convertToType(object pVal, Type pType)
                {
                    if (ToolCell.isNull(pVal))
                    {
                        pVal = ToolType.getTypeDefaulValue(pType);
                    }

                    return(Convert.ChangeType(pVal, pType));
                }
コード例 #7
0
        //user need save
        public object save(Form pForm)
        {
            object res = null;
            bool   ok  = false;

            try
            {
                environment.beginBatch();
                res = adapter.update();
                environment.commitBatch();
                ok = true;
            }
            catch (Exception exc)
            {
                environment.rollbackBatch();
                environment.getExceptionHandler().setException(exc);
            }



            if (ok)
            {
                environment.docEnd();

                if (pForm != null)
                {
                    pForm.Close();
                }

                if (handlerReferenceInformer != null)
                {
                    handlerReferenceInformer.Invoke(this, res);
                }


                //     onSaved();
            }


            if (ok)
            {
                var ds   = adapter.getDataSet();
                var code = (ds != null && ds.Tables.Count > 0 ? ds.Tables[0].TableName : "DUMMY");
                if (ds != null)
                {
                    ToolMobile.logRuntime(string.Format(
                                              "Doc commited by [{0}] with id [{1}] and worked as [{2}]",
                                              code,
                                              ToolCell.isNull(res, "null").ToString(),
                                              adapter.getAdapterWorkState().ToString()
                                              ));
                }
            }

            return(res);
        }
コード例 #8
0
        String getBoolRelToStr(DataRow row)
        {
            string res = SqlTypeRelationsString.convert((SqlTypeRelations)ToolCell.isNull((SqlTypeRelations)row[TableDUMMY.RELATIONBOOL], SqlTypeRelations.undef));

            if (res != string.Empty)
            {
                res = _space + res + _newLine;
            }
            return(res);
        }
コード例 #9
0
 public virtual void initForColumnChanged(DataRow pRow)
 {
     for (int i = 0; i < columnsCalc.Length; ++i)
     {
         if (ToolCell.isNull(pRow[columnsCalc[i]]))
         {
             calcColumn(pRow, columnsCalc[i]);
         }
     }
 }
コード例 #10
0
 public bool check(DataRow row)
 {
     if (eval == null)
     {
         eval = new ImplRowEvaluator(row.Table);
         eval.addExpression(exp, typeof(bool));
     }
     eval.setVar(row);
     return((bool)ToolCell.isNull(eval.getResult(), false));
 }
コード例 #11
0
        protected virtual bool needUpdate()
        {
            Object res = SqlExecute.executeScalar(environment, SqlExecute.translate(getReplaceList(), environment.prepareSqlText(SQLTextCollection.NeedUpdate)));

            if (ToolCell.isNull(res, string.Empty).ToString() == "1")
            {
                return(true);
            }
            return(false);
        }
コード例 #12
0
        public static DataTable getMaterialUnitsBase(int stock, IEnvironment env, DataTable matUnits)
        {
            IPagedSource s = new PagedSourceUnits(env);

            for (int i = 0; i < matUnits.Rows.Count; ++i)
            {
                s.getBuilder().addParameterValue(TableUNITSETL.LOGICALREF, ToolCell.isNull(matUnits.Rows[i][TableITMUNITA.UNITLINEREF], LRef.undef), SqlTypeRelations.equal, SqlTypeRelations.boolOr);
            }
            return(s.getAll());
        }
コード例 #13
0
 public void setVar(string name, object val)
 {
     try
     {
         ToolCell.set(evalData, name, ToolCell.isNull(val, DBNull.Value));
     }
     catch (Exception exc)
     {
         throw new MyException.MyExceptionError(MessageCollection.T_MSG_ERROR_DYNAMIC_EXPRESSION, exc);
     }
 }
コード例 #14
0
        protected virtual bool hasValidId(DataRow row, string col)
        {
            object defVal = ToolCell.getCellTypeDefaulValue(row.Table.Columns[col].DataType);
            object curId  = row[col];

            if (ToolCell.isNull(curId) || ToolType.isEqual(defVal, curId))
            {
                return(false);
            }
            return(true);
        }
コード例 #15
0
        public override DataTable get()
        {
            short curr = (short)ToolCell.isNull(getBuilder().getParameterValue(TableCURRENCYLIST.CURTYPE), (short)-100);

            if (curr == 0)
            {
                getBuilder().deleteParameter(TableCURRENCYLIST.CURTYPE);
                getBuilder().addParameterValue(TableCURRENCYLIST.CURTYPE, environment.getInfoApplication().periodCurrencyNativeId);
            }

            return(base.get());
        }
コード例 #16
0
        void fillRemain(DataRow pRow)
        {
            string SPE_REMAIN = "SPE_REMAIN";

            DataTable tabList = getTable();

            if (tabList != null && tabList.DefaultView.Count > 0 && tabList.Columns.Contains(SPE_REMAIN))
            {
                bool isOrder = ToolSlip.isDsOrder(environment.getCurDoc());
                bool isSlip  = ToolSlip.isDsSlip(environment.getCurDoc());

                int indxMatLOGICALREF = tabList.Columns.IndexOf(TableITEMS.LOGICALREF);
                int indxMatONHAND     = tabList.Columns.IndexOf(TableITEMS.ONHAND);
                int indxMatONHANDIO   = tabList.Columns.IndexOf(TableITEMS.ONHANDIO);
                int indxMatONMAIN     = tabList.Columns.IndexOf(TableITEMS.ONMAIN);
                int indxMatSPE_REMAIN = tabList.Columns.IndexOf(SPE_REMAIN);



                foreach (DataRowView v in tabList.DefaultView)
                {
                    if (pRow == null || object.ReferenceEquals(v.Row, pRow))
                    {
                        double remain = 0;
                        if (isOrder)
                        {
                            remain = (double)v[indxMatONMAIN];
                        }
                        else
                        // if (   isSlip)
                        {
                            object lref_ = v[indxMatLOGICALREF];

                            remain = (double)v[indxMatONHAND];
                            if (indxMatONHANDIO < 0)
                            {
                                remain += environment.getMatIOAmount(lref_);
                            }
                            else
                            {
                                remain += Convert.ToDouble(ToolCell.isNull(v[indxMatONHANDIO], 0));
                                remain += environment.getMatIOAmountDoc(lref_);
                            }
                        }


                        v.Row[indxMatSPE_REMAIN] = remain;
                    }
                }
            }
        }
コード例 #17
0
        //
        protected virtual void tableINVOICEColumnChanged(object sender, DataColumnChangeEventArgs e)
        {
            DataTable tab     = (DataTable)sender;
            DataSet   dataSet = tab.DataSet;

            if (!ToolCell.isNull(e.ProposedValue))
            {
                switch (e.Column.ColumnName)
                {
                case TableINVOICE.DATE_:
                    break;
                }
            }
        }
コード例 #18
0
 public double getMatDBIO(object id)
 {
     //if (_tableIO == null)
     //    refreshIOTable();
     //DataRow rowIO = _tableIO.Rows.Find(id);
     //if (rowIO != null && !rowIO.IsNull(indxIOAmount))
     //    return (double)rowIO[indxIOAmount];
     //return 0;
     if (!ToolCell.isNull(id))
     {
         return(Convert.ToDouble(ToolCell.isNull(SqlExecute.executeScalar(environment, "SELECT ONHANDIO FROM LG_$FIRM$_ITEMS WHERE LOGICALREF = @P1", new object[] { id }), 0)));
     }
     return(0);
 }
コード例 #19
0
        public override DataTable get()
        {
            int      stock = (int)ToolCell.isNull(getBuilder().getParameterValue(TablePRCLIST.CARDREF), (int)0);
            int      unit  = (int)ToolCell.isNull(getBuilder().getParameterValue(TablePRCLIST.UOMREF), (int)0);
            DateTime date  = (DateTime)ToolCell.isNull(getBuilder().getParameterValue(TablePRCLIST.BEGDATE), DateTime.Now);

            getBuilder().deleteParameter(TablePRCLIST.TABLE, TablePRCLIST.UOMREF);
            getBuilder().deleteParameter(TablePRCLIST.TABLE, TablePRCLIST.BEGDATE);
            DataTable    prices = base.get();
            IPagedSource source = new PagedSourceMaterialUnits(environment);

            source.getBuilder().addParameterValue(TableITMUNITA.ITEMREF, stock);
            return(ToolMaterial.getMatUnitPrices(unit, date, environment, prices, source.get()));
        }
コード例 #20
0
        String getParameterName(DataRow row)
        {
            string tab = (string)ToolCell.isNull(row[TableDUMMY.PARENTNAME], string.Empty);
            string col = (string)ToolCell.isNull(row[TableDUMMY.CHILDNAME], string.Empty);

            if ((tab != string.Empty) && (col != string.Empty))
            {
                return(tab + '.' + col);
            }
            if ((tab == string.Empty) && (col != string.Empty))
            {
                return(col);
            }
            return(string.Empty);
        }
コード例 #21
0
        void checkDoc(DataTable trans)
        {
            bool isCancelled = false;

            foreach (DataRow rowCurent in trans.Rows)
            {
                if (rowCurent.RowState != DataRowState.Deleted)
                {
                    isCancelled = ((short)ToolCell.isNull(rowCurent[TableKSLINES.CANCELLED], (short)ConstBool.yes) == (short)ConstBool.yes);
                }
            }

            foreach (DataRow rowCurent in trans.Rows)
            {
                if (rowCurent.RowState != DataRowState.Deleted)
                {
                    string[] arrReqCols = ToolString.explodeList(environment.getSysSettings().getString("MOB_REQCOLS_" + getId()));
                    foreach (string col in arrReqCols)
                    {
                        if (col != string.Empty && rowCurent.Table.Columns.Contains(col))
                        {
                            string val = ToolCell.isNull(rowCurent, col, string.Empty).ToString().Trim();
                            if (val == string.Empty)
                            {
                                throw new MyBaseException(MessageCollection.T_MSG_SET_REQFIELDS);
                            }
                        }
                    }

                    if (!isCancelled)
                    {
                        if (!CurrentVersion.ENV.isZeroDocAllowed())
                        {
                            double amount = (double)rowCurent[TableKSLINES.AMOUNT];
                            if (amount < ConstValues.minPositive)
                            {
                                throw new MyBaseException(MessageCollection.T_MSG_EMPTY_DOC);
                            }
                        }
                    }

                    if ((string)ToolCell.isNull(rowCurent[TableKSLINES.CLIENTREF], string.Empty) == string.Empty)
                    {
                        throw new MyBaseException(MessageCollection.T_MSG_SET_CLIENT);
                    }
                }
            }
        }
コード例 #22
0
        public static string getFromTag(Android.Views.View obj, string arg)
        {
            if (obj == null)
            {
                throw new ArgumentNullException();
            }

            string tag_ = ToolCell.isNull(obj.Tag, string.Empty).ToString();
            string val_ = string.Empty;

            if (tag_ != null)
            {
                val_ = ToolObjectName.getArgValue(tag_, arg);
            }

            return(val_);
        }
コード例 #23
0
        void fillDataForRequest(ISettings pSettings)
        {
            DataTable tab_ = getUnSyncedDocs();

            foreach (DataRow row_ in tab_.Rows)
            {
                pSettings.add();
                pSettings.setEnumer(ConstCmdLine.cmd, "IMPHIS");
                pSettings.setEnumer(ConstCmdLine.type, ToolCell.isNull(row_[TableDUMMY.TYPE], string.Empty));
                pSettings.setEnumer(ConstCmdLine.lref, ToolCell.isNull(row_[TableDUMMY.LOGICALREF], string.Empty));
            }

            {
                pSettings.add();
                pSettings.setEnumer(ConstCmdLine.cmd, "GUID");
                pSettings.setEnumer(ConstCmdLine.value, environment.getSysSettings().getString(SettingsSysMob.MOB_USR_DATA_ID, string.Empty));
            }
        }
コード例 #24
0
        private void initCommands(DbDataAdapter pAdp, DataTable pData, ITableDescriptor pTabDesc)
        {
            if (CurrentVersion.ENV.isDebugMode())
            {
                ToolMobile.setRuntimeMsg("ImplAdapterTableExt:initCommands:beg");
            }

            DataColumn colV_ = pData.Columns[TableDUMMY.RECVERS];

            foreach (DataRow row in pData.Rows)
            {
                switch (row.RowState)
                {
                case DataRowState.Added:
                    if (pAdp.InsertCommand == null)
                    {
                        initCommandInsert(pAdp, pTabDesc);
                    }
                    break;

                case DataRowState.Deleted:
                    if (pAdp.DeleteCommand == null)
                    {
                        initCommandDelete(pAdp, pTabDesc);
                    }
                    break;

                case DataRowState.Modified:
                    if (colV_ != null)
                    {
                        short rv_ = Convert.ToInt16(ToolCell.isNull(row[colV_, DataRowVersion.Original], 0));
                        ++rv_;
                        ToolCell.set(row, colV_, rv_);
                    }
                    if (pAdp.UpdateCommand == null)
                    {
                        initCommandUpdate(pAdp, pTabDesc);
                    }
                    break;
                }
            }
        }
コード例 #25
0
        double getFix(object lref, DataRow lRow, DataRowVersion vers)
        {
            double fix = 0;

            if ((string)lref == (string)lRow[TableSTLINE.STOCKREF, vers])
            {
                ConstBool isCancelled = (ConstBool)(short)ToolCell.isNull(lRow[TableSTLINE.CANCELLED, vers], (short)ConstBool.yes);
                if (isCancelled == ConstBool.not)
                {
                    ConstLineType lineType = (ConstLineType)(short)ToolCell.isNull(lRow[TableSTLINE.LINETYPE, vers], (short)ConstLineType.undef);
                    double        amount   = (double)ToolCell.isNull(lRow[TableSTLINE.AMOUNT, vers], (double)0.0);
                    ConstIOCode   ioCode   = (ConstIOCode)(short)ToolCell.isNull(lRow[TableSTLINE.IOCODE, vers], (short)0);
                    if (lineType == ConstLineType.material || lineType == ConstLineType.promotion)
                    {
                        fix += (amount * getIOSign(ioCode));
                    }
                }
            }
            return(fix);
        }
コード例 #26
0
 void validated(object sender, EventArgs e)
 {
     foreach (Binding b in DataBindings)
     {
         if (typeof(DataTable).IsAssignableFrom(b.DataSource.GetType()) && b.IsBinding)
         {
             if (b.BindingManagerBase.Current != null && b.PropertyName == DSProperty)
             {
                 object dsVal   = ((DataRowView)b.BindingManagerBase.Current)[b.BindingMemberInfo.BindingField];
                 object thisVal = this.GetType().GetProperty(DSProperty).GetValue(this, null);
                 if (!ToolCell.isNull(thisVal))
                 {
                     if (!ToolType.isEqual(dsVal, thisVal))
                     {
                         b.WriteValue();
                         b.ReadValue();
                     }
                 }
                 b.BindingManagerBase.EndCurrentEdit();
             }
         }
     }
 }
コード例 #27
0
        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);
        }
コード例 #28
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;
            //}
        }
コード例 #29
0
        void fillColumnsInfo()
        {
            string firmId   = environment.prepareSqlText("$FIRM$");
            string periodId = environment.prepareSqlText("$PERIOD$");
            //

            DataTable tabs_ = new ImplPagedSource(environment, new ImplSqlBuilder(environment, "SELECT name FROM sqlite_master  where type= 'table'", string.Empty)).getAll();

            foreach (DataRow row1 in tabs_.Rows)
            {
                //  string type1_ = ToolCell.isNull(row1["type"], "").ToString().ToLowerInvariant();
                string name1_ = ToolCell.isNull(row1["name"], "").ToString();
                // if (type1_ == "table")
                {
                    string tableNameShort = name1_;
                    string tableNameFull  = name1_;


                    if (tableNameFull.StartsWith("L_CAPI"))
                    {
                        tableNameShort = tableNameFull.Remove(0, 6);
                    }
                    else if (tableNameFull.StartsWith("L_"))
                    {
                        tableNameShort = tableNameFull.Remove(0, 2);
                    }
                    else
                    if (tableNameFull.StartsWith("LG_" + firmId + "_" + periodId + "_"))
                    {
                        tableNameShort = tableNameFull.Remove(0, 10);
                    }
                    else
                    if (tableNameFull.StartsWith("LG_" + firmId + "_"))
                    {
                        tableNameShort = tableNameFull.Remove(0, 7);
                    }



                    List <string> listCols = new List <string>();
                    List <int>    listSize = new List <int>();
                    List <Type>   listType = new List <Type>();

                    DataTable cols_ = new ImplPagedSource(environment, new ImplSqlBuilder(environment, "pragma table_info(" + name1_ + ")", string.Empty)).getAll();
                    foreach (DataRow row2 in cols_.Rows)
                    {
                        string type2_ = ToolCell.isNull(row2["type"], "").ToString().ToLowerInvariant();
                        string name2_ = ToolCell.isNull(row2["name"], "").ToString();
                        //store len as nvarchar(20)

                        StringBuilder sbName = new StringBuilder();
                        StringBuilder sbLen  = new StringBuilder();

                        foreach (char c in type2_.ToCharArray())
                        {
                            if (char.IsLetter(c))
                            {
                                sbName.Append(c);
                            }
                            else
                            if (char.IsDigit(c) || c == '.')
                            {
                                sbLen.Append(c);
                            }
                        }

                        if (sbLen.Length == 0)
                        {
                            sbLen.Append('0');
                        }


                        Type   type3_ = ToolTypeSet.helper.tObject;
                        double len3_  = XmlFormating.helper.parseDouble(sbLen.ToString());


                        switch (sbName.ToString())
                        {
                        case "nvarchar":
                        case "varchar":
                            type3_ = ToolTypeSet.helper.tString;
                            break;

                        case "float":
                            type3_ = ToolTypeSet.helper.tDouble;
                            break;

                        case "datetime":
                            type3_ = ToolTypeSet.helper.tDateTime;
                            break;

                        case "smallint":
                            type3_ = ToolTypeSet.helper.tShort;
                            break;

                        case "int":
                            type3_ = ToolTypeSet.helper.tInt;
                            break;
                        }

                        {
                            string name = name2_;
                            int    len  = (int)len3_;
                            Type   type = type3_;

                            listCols.Add(name);
                            listSize.Add(len);
                            listType.Add(type);
                        }
                    }

                    dic[tableNameShort] = new ImplTableDescriptor(tableNameShort, tableNameFull, listCols.ToArray(), listSize.ToArray(), listType.ToArray());
                }
            }
        }
コード例 #30
0
        public static bool isEmptyLRef(object val)
        {
            string i = Convert.ToString(ToolCell.isNull(val, ToolLRef.dummyLRef));

            return(i == "" || i == "0" || i == dummyLRef.ToString());
        }