Example #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);
        }
Example #2
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);
     }
 }
Example #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]]);
                 }
             }
         }
     }
 }
Example #4
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);
                    }
                }
            }
        }
Example #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_);
        }
Example #6
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();
                }
            }
        }
Example #7
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));
                     }
                 }
             }
         }
     }
 }