예제 #1
0
        public List <ListDataRow> sub(string table, Dictionary <string, string> pk)
        {
            SubTableSchema     subSchema = DataSourceComm.getSubTableSchema(table, _schema);
            List <ListDataRow> rows      = getSubTableRows(pk, subSchema);

            return(rows);
        }
예제 #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);
                    }
                }
            }
        }