示例#1
0
        public ImplPagedGridExtender(MobDataGrid pGrid, IPagedSource pSource, string pGlobalId)
        {
            globalId = pGlobalId;
            //
            grid   = pGrid;
            source = pSource;
            //
            source.getBuilder().reset();
            int indx = -1;

            try
            {
                indx = source.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableDUMMY.ID, ToolLRef.dummyLRef));
                DataTable tab_ = source.getAll();
                initTable(tab_);
                grid.DataSource = tab_;
                tab_.DefaultView.ListChanged += DefaultView_ListChanged;
            }
            finally
            {
                if (indx > 0)
                {
                    source.getBuilder().deletePreparer(indx);
                }
            }

            //grid.KeyPress += new KeyPressEventHandler(grid_KeyPress_Search);
            //grid.KeyDown += new KeyEventHandler(grid_KeyDown_Search);
        }
        public ImplAdapterTableExt(IEnvironment pEnv, IPagedSource pSource, string[] pCol, String pSqlNewIdTable, ISqlBuilderPreparer[] preps)
        {
            environment = pEnv;
            source      = pSource;
            columns     = pCol;
            newIdTable  = pSqlNewIdTable;
            //
            if (preps != null)
            {
                for (int i = 0; i < preps.Length; ++i)
                {
                    source.getBuilder().addPereparer(preps[i]);
                }
            }
            //
            //adapter = new SqliteDataAdapter();
            //adapter.AcceptChangesDuringUpdate = false;


            //source.getBuilder().reset();
            //source.getBuilder().setCountMin();
            //for (int i = 0; i < columns.Length; ++i)
            //    source.getBuilder().addParameterValue(columns[i], DBNull.Value);
            //adapter.SelectCommand = source.getBuilder().get();


            //builder = new SqliteCommandBuilder(adapter);

            // builder.ConflictOption = ConflictOption.CompareAllSearchableValues;
            // builder.SetAllValues = true;
            //
            // adapter.RowUpdating += new SqliteRowUpdatingEventHandler(adapter_RowUpdating);
        }
示例#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]]);
                 }
             }
         }
     }
 }
示例#4
0
 public void refreshSource()
 {
     if (_sourceDs != null)
     {
         _data = _sourceDs;
     }
     else
     if (_sourcePs != null)
     {
         _sourcePs.getBuilder().reset();
         DataTable table = _sourcePs.getAll();
         ToolTable.fillNull(table);
         _data = new DataSet();
         _data.Tables.Add(table);
     }
 }
示例#5
0
        public DataTable refresh()
        {
            if (getTable() == null)
            {
                return(null);
            }

            source.getBuilder().reset();

            if (startigDataLoad != null)
            {
                startigDataLoad.Invoke(this, EventArgs.Empty);
            }

            DataTable tab_ = source.getAll();

            ToolTable.fillNull(tab_);

            loadData(tab_);

            return(tab_);
        }
示例#6
0
        protected override void returnData(DataRow pRow)
        {
            reset();
            if (pRow != null)
            {
                string barcode = pRow[TableDUMMY.VALUE].ToString().Trim();
                if (barcode != string.Empty)
                {
                    var p = new PARSER(barcode, CurrentVersion.ENV.getEnvString("WEIGHTBARCODE", ""));

                    barcode = p.CODE1;


                    IPagedSource ps = reference.getPagedSource();
                    ps.getBuilder().reset();
                    ps.getBuilder().beginWhereGroup();
                    ps.getBuilder().addParameterValue(TableITEMS.BARCODE1, barcode, SqlTypeRelations.equal, SqlTypeRelations.boolOr);
                    if (CurrentVersion.ENV.getEnvBool("BARCODEMULTI", false))
                    {
                        ps.getBuilder().addParameterValue(TableITEMS.BARCODE2, barcode, SqlTypeRelations.equal, SqlTypeRelations.boolOr);
                        ps.getBuilder().addParameterValue(TableITEMS.BARCODE3, barcode, SqlTypeRelations.equal, SqlTypeRelations.boolOr);
                    }
                    ps.getBuilder().endWhereGroup();
                    DataTable matTab = ps.getAll();
                    if (matTab != null && matTab.Rows.Count > 0)
                    {
                        DataRow matRow    = matTab.Rows[0];
                        DataRow matRowExt = selectUnit(matRow, barcode, p.WEIGHT);

                        base.returnData(matRowExt);
                    }
                    else
                    {
                        ToolMobile.playAlarmAndVibrate();


                        ToolMsg.show(this, MessageCollection.T_MSG_INVALID_BARCODE, null);
                    }
                }
            }
        }
示例#7
0
 protected override void setSource(IPagedSource pSource)
 {
     base.setSource(pSource);
     pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableINVOICE.GRPCODE, ConstDocGroupCode.sales));
     pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableINVOICE.TRCODE, ConstDocTypeMaterial.wholeSaleReturn));
 }
示例#8
0
        void doneAsync()
        {
            lock (environment)
            {
                bool ok = false;
                try
                {
                    //

                    log.set(MessageCollection.T_MSG_OPERATION_STARTING);
                    //
                    makeDbReadonly();

                    //
                    string fileWorkDir = ToolMobile.getFullPath("data");
                    ToolMobile.createDir(fileWorkDir);
                    string fileOutputZip = Path.Combine(fileWorkDir, "toava.zip");
                    string fileOutputXml = Path.Combine(fileWorkDir, "toava.xml");
                    // bool res = false;

                    //Source
                    //if (environment.getAppSettings().getBool(AvaExt.Settings.SettingsAvaAgent.MOB_USE_LOCAL_EXPIMP_B))
                    //{
                    //    //SaveFileDialog sfd = new SaveFileDialog();
                    //    //if (sfd.ShowDialog() == DialogResult.OK)
                    //    //    fileOutputXml = sfd.FileName;
                    //    //else
                    //    //    throw new Exception(string.Empty);
                    //}

                    //
                    log.set(MessageCollection.T_MSG_DATA_READING);
                    //
                    XmlDocument doc = new XmlDocument();

                    string docID = "LOGICALREF";

                    AdapterUserDocument[] adapters = new AdapterUserDocument[]
                    {
                        new AdapterUserWholesaleSlip(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetWholesaleSlip(environment))),
                        new AdapterUserWholesaleOrder(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetWholesaleOrder(environment))),
                        new AdapterUserCashClient(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetCashClient(environment)))
                    };
                    IPagedSource[] sources = new IPagedSource[]
                    {
                        new PagedSourceSlip(environment),
                        new PagedSourceOrder(environment),
                        new PagedSourceCashTrans(environment)
                    };
                    string[] arrDesc = new string[]
                    {
                        environment.translate(WordCollection.T_DOC_STOCK_TRANS),
                        environment.translate(WordCollection.T_DOC_STOCK_ORDERS),
                        environment.translate(WordCollection.T_DOC_FINANCE)
                    };
                    bool hasData = false;
                    for (int i = 0; i < sources.Length; ++i)
                    {
                        IPagedSource source = sources[i];
                        source.getBuilder().addParameterValue(TableDUMMY.CANCELLED, ConstBool.not);
                        AdapterUserDocument adapter = adapters[i];
                        log.set(MessageCollection.T_MSG_DATA_READING, new object[] { arrDesc[i] });
                        DataTable table = source.getAll();
                        log.set(MessageCollection.T_MSG_DATA_EXPORT, new object[] { arrDesc[i] });
                        foreach (DataRow row in table.Rows)
                        {
                            hasData = true;
                            adapter.edit(row[docID]);
                            adapter.export(doc);
                        }
                    }

                    if (!hasData)
                    {
                        throw new Exception(MessageCollection.T_MSG_ERROR_NO_DATA);
                    }
                    //
                    string[] expSettings = environment.getSysSettings().getAllSettings();
                    foreach (string settingsName in expSettings)
                    {
                        if (settingsName.StartsWith("MOB_SYS_"))
                        {
                            XmlAttribute attr = doc.CreateAttribute(settingsName);
                            attr.Value = environment.getSysSettings().getString(settingsName);
                            doc.DocumentElement.Attributes.Append(attr);
                        }
                    }


                    //
                    log.set(MessageCollection.T_MSG_DATA_WRITING);
                    //
                    doc.Save(fileOutputXml);
                    ToolZip.compress(fileOutputZip, fileOutputXml);
                    // if (!environment.getAppSettings().getBool(AvaExt.Settings.SettingsAvaAgent.MOB_USE_LOCAL_EXPIMP_B))
                    //  {
                    if (ToolMobile.existsFile(fileOutputZip))
                    {
                        //
                        log.set(MessageCollection.T_MSG_DATA_SENDING);
                        //
                        AgentData ad = new AgentData(environment);
                        ad.chackOperationResult(ad.sendData(ToolMobile.readFileData(fileOutputZip)));
                    }
                    // }
                    ok = true;
                }
                catch (Exception exc)
                {
                    log.error(ToolException.unwrap(exc));
                    environment.getExceptionHandler().setException(exc);
                }
                finally
                {
                    log.set(MessageCollection.T_MSG_OPERATION_FINISHING);

                    Thread.Sleep(1000);
                    log.hide();
                }
            }
        }
示例#9
0
 protected override void setSource(IPagedSource pSource)
 {
     base.setSource(pSource);
     pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableINVOICE.GRPCODE, ConstDocGroupCode.materialManagement));
     pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableINVOICE.TRCODE, ConstDocTypeMaterial.marerialDefinedInput15));
 }
        protected override void setSource(IPagedSource pSource)
        {
            base.setSource(pSource);

            pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableKSLINES.TRCODE, ConstCashDocType.clientToCash));
        }
示例#11
0
        void init(DataTable pTable, IPagedSource pSource, string[] pBindChildCol, string[] pBindParentCol, string[] pChildCol, string[] pParentCol, UpdateTypeFlags pFlags, IRowValidator pValidator, string[] pTriggerCols)
        {
            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 (!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);
            }
            //
            tableSource.ColumnChanged += new DataColumnChangeEventHandler(table_ColumnChanged);
        }
示例#12
0
 void distribute(DataRow row, string[] cols)
 {
     if (validator.check(row))
     {
         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));
                     }
                 }
             }
         }
     }
 }
 protected override void setSource(IPagedSource pSource)
 {
     base.setSource(pSource);
     pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableINVOICE.GRPCODE, ConstDocGroupCode.purchasing));
     pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableINVOICE.TRCODE, ConstDocTypeMaterial.materialPurchase));
 }
 public virtual string getName()
 {
     return(source.getBuilder().getName());
 }
 protected override void setSource(IPagedSource pSource)
 {
     base.setSource(pSource);
     pSource.getBuilder().addPereparer(new SqlBuilderPreparerFixedCondition(TableSTFICHE.GRPCODE, ConstDocGroupCode.materialManagement));
 }