Example #1
0
        public void update(List <ListDataRow> insertRows, List <ListDataRow> updateRows, List <ListDataRow> deleteRows)
        {
            DsAdapterCustomer dsa = new DsAdapterCustomer(_schema);

            dsa.update(updateRows, getQueryParams(_schema.UpdateCommand));
            dsa.insert(insertRows, getQueryParams(_schema.InsertCommand));
            dsa.delete(deleteRows, getQueryParams(_schema.DeleteCommand));
        }
        private static void BuildFields(DataSourceSchema schema)
        {
            DsAdapterCustomer dsa      = new DsAdapterCustomer(schema);
            DataSet           ds       = dsa.getDataSet();
            DataTable         netTable = ds.Tables[0];


            //  schema.Fields.Clear();
            SchemaList <FieldSchema> tmpFieldSchema = new SchemaList <FieldSchema>();

            //da.FillSchema(netTable, SchemaType.Source);
            //     schema.PrimaryKeys = new List<string>();
            //     foreach (DataColumn col in netTable.PrimaryKey)
            //     {
            //         schema.PrimaryKeys.Add(col.ColumnName);
            //     }
            foreach (DataColumn col in netTable.Columns)
            {
                FieldSchema field = new FieldSchema();
                field.Id    = col.ColumnName;
                field.Title = col.Caption;
                if (col.ExtendedProperties.ContainsKey(DataSourceConst.ExProDescription))
                {
                    if (col.ExtendedProperties[DataSourceConst.ExProDescription] != null)
                    {
                        field.Description = col.ExtendedProperties[DataSourceConst.ExProDescription].ToString();
                    }
                }
                field.ReadOnly = col.ReadOnly;
                field.ReadOnly = col.AutoIncrement;

                if (netTable.PrimaryKey.Contains(col))
                {
                    field.IsKey = true;
                }

                if (col.ExtendedProperties.ContainsKey(DataSourceConst.ExProDbType))
                {
                    field.DataType = (DbType)col.ExtendedProperties[DataSourceConst.ExProDbType];
                }
                else
                {
                    field.DataType = DatabaseAdmin.getInstance().getDbType(col.DataType);
                }

                //                    schema.Fields.Add(field);
                if (schema.Fields.FindItem(field.Id) == null)
                {
                    schema.Fields.Add(field);
                }

                if (tmpFieldSchema.FindItem(field.Id) == null)
                {
                    tmpFieldSchema.Add(field);
                }
            }
        }
Example #3
0
        public DataSet getDataSet()
        {
            if (_ds != null)
            {
                return(_ds);
            }
            string where = getWhere();
            string            orderBy = getOrderBy();
            string            groupBy = null;
            DsAdapterCustomer dsa     = new DsAdapterCustomer(_schema);

            return(dsa.getDataSet(getQueryParams(_schema.SelectCommand), where, orderBy, groupBy, _pagination));
        }
Example #4
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 #5
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);
                    }
                }
            }
        }
Example #6
0
        public ListDataRow row(Dictionary <string, string> pk)
        {
            if (pk == null || pk.Count < 1)
            {
                throw new Exception(Lang.UpdateNoKey);
            }

            StringBuilder sb = new StringBuilder();

            foreach (string field in pk.Keys)
            {
                sb.Append(" and ");
                sb.Append(field);
                sb.Append("='");
                sb.Append(pk[field]);
                sb.Append("' ");
            }

            sb.Remove(0, 5);
            PaginationInfo pagin = new PaginationInfo();

            DsAdapterCustomer dsa = new DsAdapterCustomer(_schema);
            DataSet           ds  = dsa.getDataSet(getQueryParams(_schema.SelectCommand), sb.ToString(), null, null, pagin);

            if (ds.Tables.Count < 1)
            {
                return(null);
            }
            DataTable tb = ds.Tables[0];

            DataRow[] rows = tb.Select(sb.ToString());
            if (tb.Rows.Count < 1)
            {
                return(null);
            }
            ListDataRow ret = DataSourceComm.readRow(tb, _schema, rows[0]);

            return(ret);
        }
Example #7
0
        public void insert(ListDataRow row)
        {
            DsAdapterCustomer dbsa = new DsAdapterCustomer(_schema);

            dbsa.insert(row, getQueryParams(_schema.InsertCommand));
        }
Example #8
0
        public void delete(List <ListDataRow> rows)
        {
            DsAdapterCustomer dsa = new DsAdapterCustomer(_schema);

            dsa.delete(rows, getQueryParams(_schema.DeleteCommand));
        }
Example #9
0
        public void delete()
        {
            DsAdapterCustomer dsa = new DsAdapterCustomer(_schema);

            dsa.delete(getQueryParams(_schema.DeleteCommand));
        }