示例#1
0
        private List <Gidy> listaWybranychGid(string nazwaListy, Procedures procId)
        {
            List <Gidy> listaGID = new List <Gidy>();

            int        listaId   = GetWindow().AllChildren[nazwaListy].Id;
            _Recordset recordset = Runtime.WindowController.GetQueueMarked((int)procId, listaId, GetCallbackThread());

            try
            {
                //jesli nie jest nic zaznaczone to recordset == null
                if (recordset != null && recordset.RecordCount > 0)
                {
                    string fieldName;
                    recordset.MoveFirst();
                    while (recordset.EOF == false)
                    {
                        ADODB.Fields fields = recordset.Fields;
                        Gidy         g      = new Gidy();

                        for (int i = 0; i < fields.Count; i++)
                        {
                            fieldName = fields[i].Name;
                            if (fieldName == "TYP")
                            {
                                g.GIDTyp = fields[i].Value.ToString();
                            }

                            if (fieldName == "FIRMA")
                            {
                                g.GIDFirma = fields[i].Value.ToString();
                            }

                            if (fieldName == "NUMER")
                            {
                                g.GIDNumer = fields[i].Value.ToString();
                            }

                            if (fieldName == "LP")
                            {
                                g.GIDLp = fields[i].Value.ToString();
                            }
                        }

                        listaGID.Add(g);
                        recordset.MoveNext();
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(listaGID);
        }
        private void UpdateADODBRecordset_from_ADODataTable(DataTable inTable, ref ADODB.Recordset adoRs)
        {
            ADODB.Fields adoFields = adoRs.Fields;
            System.Data.DataColumnCollection inColumns = inTable.Columns;
            //Delete
            if (adoRs.RecordCount > 0)
            {
                adoRs.MoveFirst();
            }
            while (!adoRs.EOF)
            {
                adoRs.Delete();
                adoRs.MoveNext();
            }
            //Add
            foreach (DataRow dr in inTable.Rows)
            {
                // Proceso las que no estan borradas
                if (dr.RowState != DataRowState.Deleted)
                {
                    adoRs.AddNew(System.Reflection.Missing.Value,
                                 System.Reflection.Missing.Value);

                    for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
                    {
                        ADODB.Field field = adoFields[columnIndex];
                        try
                        {
                            adoFields[columnIndex].Value = dr[columnIndex];
                        }
                        catch (Exception ex)
                        {
                            string message = string.Format("Error al actualizar la columna {0}.{1}: {2}", inTable.TableName, field.Name, ex.Message);
                            throw new XTangoException(message);
                        }
                    }
                }
            }
        }
示例#3
0
        public static ADODB.Recordset ConvertToRecordset(DataTable dt)
        {
            ADODB.Recordset rs = new ADODB.Recordset();
            rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient;

            ADODB.Fields RsFld = rs.Fields;
            System.Data.DataColumnCollection DtCols = dt.Columns;

            foreach (DataColumn DtCol in DtCols)
            {
                RsFld.Append(DtCol.ColumnName
                             , CAdo.ConvertDotNetTypeToAdoType(DtCol.DataType)
                             , DtCol.MaxLength
                             , DtCol.AllowDBNull ? ADODB.FieldAttributeEnum.adFldIsNullable :
                             ADODB.FieldAttributeEnum.adFldUnspecified
                             , null);
            }

            rs.Open(System.Reflection.Missing.Value
                    , System.Reflection.Missing.Value
                    , ADODB.CursorTypeEnum.adOpenStatic
                    , ADODB.LockTypeEnum.adLockOptimistic, 0);

            foreach (DataRow dr in dt.Rows)
            {
                rs.AddNew(System.Reflection.Missing.Value,
                          System.Reflection.Missing.Value);

                for (int cl = 0; cl < DtCols.Count; cl++)
                {
                    RsFld[cl].Value = dr[cl];
                }
            }

            return(rs);
        }