Example #1
0
        public void update(ListDataRow row)
        {
            //if (_isSourceTable)
            //    updateSourceTableRow(row);
            DsAdapterCustomer dbsa = new DsAdapterCustomer(_schema);

            if (DataSourceComm.isNewRow(row))
            {
                dbsa.insert(row, this.getQueryParams(_schema.InsertCommand));
            }
            else
            {
                dbsa.update(row, this.getQueryParams(_schema.UpdateCommand));
            }
        }
Example #2
0
        private void updateSubTables(ListDataRow row, List <SubTable> subTables)
        {
            if (subTables == null || subTables.Count < 1)
            {
                return;
            }
            for (int c = 0; c < subTables.Count; c++)
            {
                string           subTable = subTables[c].Name;
                DataSourceSchema ds       = DataSourceSchemaContainer.Instance().GetItem(subTable);
                if (ds.SelectCommand.CommandType != CommandType.TableDirect)
                {
                    throw new XException(string.Format(Lang.SubTableSelCommandTypeOnlyIsTable, subTable));
                }

                SubTableSchema sds = DataSourceComm.getSubTableSchema(subTable, _schema);
                Dictionary <string, string> parametes = new Dictionary <string, string>();


                for (int i = 0; i < sds.Fks.Count; i++)
                {
                    string fk = sds.Fks[i];
                    parametes.Add("@" + fk, row[_schema.PrimaryKeys[i]]);
                }


                DsAdapter dsa = new DsAdapterCustomer(ds);

                List <ListDataRow> subRows = subTables[c].Rows;
                for (int i = 0; i < subRows.Count; i++)
                {
                    ListDataRow subRow = subRows[i];
                    if (DataSourceComm.isNewRow(subRow))
                    {
                        dsa.insert(subRow, parametes);
                    }
                    else
                    {
                        dsa.update(subRow, parametes);
                    }
                }
            }
        }