public Recordset ToRecordSet()
        {
            var recordSet = new Recordset();

            foreach (var field in _metaData.Fields)
            {
                recordSet.Fields.Append(field.Name, field.AdodbDataType, field.DefinedSize, field.Attribute, null);
            }

            recordSet.Open(Missing.Value, Missing.Value, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockUnspecified, 0);

            for (var i = 0; i < _records.Count; i++)
            {
                recordSet.AddNew(Missing.Value, Missing.Value);

                for (var j = 0; j < _metaData.Fields.Length; j++)
                {
                    recordSet.Fields[j].Value = _records[i][j];
                }

                if (i == _records.Count - 1)
                    recordSet.MoveFirst();
                else
                    recordSet.MoveNext();
            }

            return recordSet;
        }
        /// <summary>
        /// Preenche um ComboBox com os dados de um Recordset.
        /// </summary>
        /// <param name="comboBox">O ComboBox a ser preenchido.</param>
        /// <param name="recordset">O Recordset com os dados.</param>
        /// <param name="fieldValue">O nome do Field que contém o valor para ComboBox.</param>
        /// <param name="fieldDescription">O nome do Field que contém a descrição para o ComboBox.</param>
        public static Recordset AddValuesFromRecordset(this ComboBox comboBox, Recordset recordset, string fieldValue = null,
                                                string fieldDescription = null)
        {
            if (comboBox == null) throw new ArgumentNullException("comboBox");
            if (recordset == null) throw new ArgumentNullException("recordset");

            recordset.MoveFirst();

            if (fieldDescription == null)
            {
                if (fieldValue == null)
                {
                    var fields = recordset.Fields;

                    if (fields.Count > 1)
                    {
                        fieldValue = fields.Item(0).Name;
                        fieldDescription = fields.Item(1).Name;
                    }
                    else
                    {
                        fieldValue = fieldDescription = fields.Item(0).Name;
                    }
                }
                else
                {
                    var fields = recordset.Fields;

                    if (fields.Count > 1)
                    {
                        fieldDescription = fields.Item(0).Name == fieldValue ? fields.Item(1).Name : fields.Item(0).Name;
                    }
                    else
                    {
                        fieldDescription = fieldValue;
                    }
                }
            }

            var validValues = comboBox.ValidValues;

            while (!recordset.EoF)
            {
                var value = recordset.Fields.Item(fieldValue);
                var description = recordset.Fields.Item(fieldDescription);

                validValues.Add(value.Value.ToString(), description.Value.ToString());

                recordset.MoveNext();
            }

            return recordset;
        }
示例#3
0
        /// <summary>
        /// Performs buffer query with a given reference point, distance and FNO.
        /// FNO is the target feature FNO for which feature class instances are to be searched inside the buffer zone.
        /// </summary>
        /// <returns>Key Value pair of feature class instance and distance from reference point</returns>
        public Dictionary <int, double> PerformBufferQuery()
        {
            Recordset   resultRecordSet = null;
            IGTGeometry gTGeometry      = null;

            try
            {
                IGTOrientedPointGeometry gTOrientedPointGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>();
                gTOrientedPointGeometry.Origin = m_referencePoint;

                IGTZoneService gTZoneService = GTClassFactory.Create <IGTZoneService>();
                gTZoneService.ZoneWidth       = m_distance;
                gTZoneService.InputGeometries = gTOrientedPointGeometry;
                IGTGeometry outPutGeometry = gTZoneService.OutputGeometries;

                IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>();
                spatialService.DataContext    = m_iGtDataContext;
                spatialService.Operator       = GTSpatialOperatorConstants.gtsoEntirelyContains;
                spatialService.FilterGeometry = outPutGeometry;

                resultRecordSet = spatialService.GetResultsByFNO(new short[] { this.m_targetFno });
                if (resultRecordSet != null && resultRecordSet.RecordCount > 0)
                {
                    resultRecordSet.MoveFirst();
                    m_fidDistancePair = new Dictionary <int, double>();
                    short primaryGraphicCno = GetPrimaryGraphicCno(m_targetFno);
                    while (!resultRecordSet.EOF)
                    {
                        int fid = Convert.ToInt32(resultRecordSet.Fields["G3E_FID"].Value);
                        gTGeometry = m_iGtDataContext.OpenFeature(m_targetFno, fid).Components.GetComponent(primaryGraphicCno).Geometry;
                        if (gTGeometry != null)
                        {
                            m_fidDistancePair.Add(fid, CalculateDistanceFromReferencePoint(gTGeometry.FirstPoint));
                        }
                        resultRecordSet.MoveNext();
                    }
                }
                return(m_fidDistancePair);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (resultRecordSet != null)
                {
                    resultRecordSet.Close();
                    resultRecordSet = null;
                }
            }
        }
示例#4
0
        //metodo que coleta os dados baseado em uma SQL recebida como argumento de entrada
        private void coletaDados(String SQL)
        {
            Recordset dados = new Recordset();

            dados.Open(SQL, new Conexao().getDb4(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
            dadosCombo.Clear();
            while (!(dados.EOF || dados.BOF))
            {
                dadosCombo.Add(new String[] { Convert.ToString(dados.Fields["cod_cliente"].Value), Convert.ToString(dados.Fields["Nome"].Value) });
                dados.MoveNext();
            }
            dados.Close();
        }
示例#5
0
        private static void criaListaUsuarios()
        {
            String item;

            dados.MoveFirst();
            while (!(dados.BOF || dados.EOF))
            {
                item = Convert.ToString(dados.Fields["Matricula"].Value);
                String[] itens = { item.ToUpper(), Convert.ToString(dados.Fields["cod"].Value) };
                listUsuarios.Add(itens);
                dados.MoveNext();
            }
        }
示例#6
0
        public List <string> GetInvoices()
        {
            List <string> invoices = new List <string>();
            Recordset     rs       = DB.OpenRecordset("select Name from Invoices");

            while (!rs.EOF)
            {
                invoices.Add(rs.Fields["Name"].Value);
                Console.WriteLine(rs.Fields["Name"].Value);
                rs.MoveNext();
            }
            return(invoices);
        }
示例#7
0
 private void montaLista()
 {
     RsDados = new Recordset();
     RsDados.Open(SQL, new Conexao().getContas(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
     listaAtendimento.Clear();
     //Atendimento por padrão deve ser Balcão
     while (!(RsDados.EOF || RsDados.BOF))
     {
         listaAtendimento.Add(new String[] { Convert.ToString(RsDados.Fields["cod"].Value), Convert.ToString(RsDados.Fields["Atendimento"].Value), Convert.ToString(RsDados.Fields["ncobrar"].Value) });
         RsDados.MoveNext();
     }
     RsDados.Close();
 }
        public string CheckForRestrictedAndPendingEditsValidate()
        {
            try
            {
                if (m_Components["STREETLIGHT_N"].Recordset.EOF)
                {
                    m_Components["STREETLIGHT_N"].Recordset.MoveFirst();
                }

                //check for street light with pending edits and is a restricted account
                bool      hasPendingEdits      = false;       //default to false
                string    restricted           = "";
                string    streetLightAccountID = m_Components["STREETLIGHT_N"].Recordset.Fields["ACCOUNT_ID"].Value.ToString();
                string    SQL = "select RESTRICTED from stlt_account where ESI_LOCATION = ?";
                Recordset RS  = m_DataContext.OpenRecordset(SQL, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, streetLightAccountID);

                if (null != RS && RS.RecordCount > 0)
                {
                    restricted = RS.Fields["RESTRICTED"].Value.ToString();
                }
                string    streetLightFNO = m_Components["STREETLIGHT_N"].Recordset.Fields["G3E_FNO"].Value.ToString().ToUpper().Trim();
                string    streetLightFID = m_Components["STREETLIGHT_N"].Recordset.Fields["G3E_FID"].Value.ToString().ToUpper().Trim();
                Recordset pendingEdits   = jobService.FindPendingEdits();

                if (null != pendingEdits && pendingEdits.RecordCount > 0)
                {
                    pendingEdits.MoveFirst();

                    do
                    {
                        if (pendingEdits.Fields["G3E_FNO"].Value.ToString().ToUpper().Trim() == streetLightFNO && pendingEdits.Fields["G3E_FID"].Value.ToString().ToUpper().Trim() == streetLightFID)
                        {
                            hasPendingEdits = true;
                            break;
                        }
                        pendingEdits.MoveNext();
                    } while(!pendingEdits.EOF);
                }

                if (jobManager.ActiveJob != null && restricted.ToUpper().Trim() == "Y" && hasPendingEdits)
                {
                    return("ACCOUNT # CONFLICT: Street Lights with Restricted Accounts may only be edited by a Street Light Administrator.");
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                throw new Exception(exMsg);
            }
        }
示例#9
0
        /// <summary>
        /// Método que faz a coleta das informações no banco de dados.
        /// </summary>
        private void coletaDados()
        {
            abreConexao();

            while (!(dados.EOF || dados.BOF))
            {
                double          totalAnterior = especie + cheque + vale + cartao, atual = 0;
                String[]        informacoes = new string[6];
                List <String[]> infoVenda   = new List <string[]>();
                // Linha para somar o valor total pago.
                atual = Convert.ToDouble(dados.Fields["especie"].Value) + Convert.ToDouble(dados.Fields["cheque"].Value) + Convert.ToDouble(dados.Fields["cartao"].Value) + Convert.ToDouble(dados.Fields["vale"].Value);

                if (atual > 0)
                {
                    informacoes[1] = Convert.ToString(dados.Fields["especie"].Value);
                    especie       += Convert.ToDouble(dados.Fields["especie"].Value);
                    informacoes[2] = Convert.ToString(dados.Fields["cheque"].Value);
                    cheque        += Convert.ToDouble(dados.Fields["cheque"].Value);
                    informacoes[3] = Convert.ToString(dados.Fields["cartao"].Value);
                    cartao        += Convert.ToDouble(dados.Fields["cartao"].Value);
                    informacoes[4] = Convert.ToString(dados.Fields["vale"].Value);
                    vale          += Convert.ToDouble(dados.Fields["vale"].Value);
                    informacoes[0] = Convert.ToString(dados.Fields["nome"].Value);
                    informacoes[5] = informacoes[1] + informacoes[2] + informacoes[3] + informacoes[4];


                    //Agrupondo as somas por datas usando as mesmas como chaves
                    if (dadosVenda.ContainsKey(Convert.ToDateTime(dados.Fields["data"].Value, culture)) == false)
                    {
                        infoVenda.Add(informacoes);
                        dadosVenda.Add(Convert.ToDateTime(dados.Fields["data"].Value, culture), infoVenda);
                        resumoData.Add((Convert.ToDateTime(dados.Fields["data"].Value, culture)), atual);
                    }
                    else
                    {
                        infoVenda = dadosVenda[Convert.ToDateTime(dados.Fields["data"].Value, culture)];
                        infoVenda.Add(informacoes);
                        dadosVenda[Convert.ToDateTime(dados.Fields["data"].Value, culture)]  = infoVenda;
                        resumoData[Convert.ToDateTime(dados.Fields["data"].Value, culture)] += atual;
                    }

                    //Incluido a venda na lista de vendas
                    listaVendas.Add(dados.Fields["cod_sai"].Value.ToString());
                }



                dados.MoveNext();
            }
            fechaConexao();
        }
示例#10
0
        /// <summary>
        /// Method to set the activity attribute of the CU and ACU components
        /// </summary>
        /// <param name="selectedObject">Selected feature on map window</param>
        private void SetActivity(IGTDDCKeyObject selectedObject)
        {
            Recordset           cuComponentRs        = null;
            Recordset           acuComponentRs       = null;
            WorkPointOperations oWorkPointOperations = null;
            IGTComponents       gTComponents         = GTClassFactory.Create <IGTComponents>();

            try
            {
                IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(selectedObject.FNO, selectedObject.FID);
                // Set Activity in CU attributes
                cuComponentRs = feature.Components.GetComponent(21).Recordset;
                if (cuComponentRs != null && cuComponentRs.RecordCount > 0)
                {
                    gTComponents.Add(feature.Components.GetComponent(21));
                    cuComponentRs.MoveFirst();
                    while (!cuComponentRs.EOF)
                    {
                        cuComponentRs.Fields["ACTIVITY_C"].Value = "A";
                        cuComponentRs.MoveNext();
                    }
                }
                // Set Activity in Ancillary CU attributes
                if (feature.Components.GetComponent(22) != null)
                {
                    acuComponentRs = feature.Components.GetComponent(22).Recordset;
                    if (acuComponentRs != null && acuComponentRs.RecordCount > 0)
                    {
                        gTComponents.Add(feature.Components.GetComponent(22));
                        acuComponentRs.MoveFirst();
                        while (!acuComponentRs.EOF)
                        {
                            string retiremenType = Convert.ToString(acuComponentRs.Fields["RETIREMENT_C"].Value);
                            if (retiremenType == "1" || retiremenType == "2")
                            {
                                acuComponentRs.Fields["ACTIVITY_C"].Value = "R";
                            }
                            acuComponentRs.MoveNext();
                        }
                    }
                }

                //// Synchronize the workpoint
                //oWorkPointOperations = new WorkPointOperations(gTComponents, feature, m_DataContext);
                //oWorkPointOperations.DoWorkpointOperations();
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#11
0
        private void cmb_DeviceType2_SelectedIndexChanged(object sender, EventArgs e)
        {
            Recordset objRt = null;

            try
            {
                if (cmb_DeviceType2.SelectedItem == null)
                {
                    return;
                }
                ResourceTypeData data = cmb_DeviceType2.SelectedItem as ResourceTypeData;
                if (!m_Application.Workspace.Datasources["Resource"].Datasets.Contains(data.DatasetName))
                {
                    return;
                }
                dgv_Data.Rows.Clear();
                objRt = (m_Application.Workspace.Datasources["Resource"].Datasets[data.DatasetName] as DatasetVector).GetRecordset(false, CursorType.Static);
                objRt.MoveFirst();
                while (!objRt.IsEOF)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.Cells.Add(new DataGridViewCheckBoxCell());
                    DataGridViewTextBoxCell cell1 = new DataGridViewTextBoxCell
                    {
                        Value = Convert.ToString(objRt.GetFieldValue(data.FieldID))
                    };
                    row.Cells.Add(cell1);
                    DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell
                    {
                        Value = Convert.ToString(objRt.GetFieldValue(data.FieldName))
                    };
                    row.Cells.Add(cell2);
                    row.Tag = objRt.GetID();
                    dgv_Data.Rows.Add(row);

                    objRt.MoveNext();
                }
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
            finally
            {
                if (objRt != null)
                {
                    objRt.Close();
                    objRt.Dispose();
                }
            }
        }
示例#12
0
        /// <summary>
        /// Obtiene una lista de los CAEs activos
        /// </summary>
        /// <returns></returns>
        public List <ValidacionCAE> ObtenerListaCAEs()
        {
            List <ValidacionCAE> CAEs     = new List <ValidacionCAE>();
            Recordset            registro = null;
            string consulta = "SELECT U_TipoDoc, U_NumFin, U_NumAct, U_ValDesde, U_ValHasta FROM [@TFERANGO] WHERE U_Activo = 'Y'";
            int    i        = 0;

            try
            {
                //Obtener objeto estadar de record set
                registro = Conexion.ProcConexion.Comp.GetBusinessObject(BoObjectTypes.BoRecordset);

                //Ejecutar consulta
                registro.DoQuery(consulta);

                //Validar que se hayan obtenido resultado
                if (registro.RecordCount > 0)
                {
                    //Se obtiene la informacion de la base de datos
                    while (i < registro.RecordCount)
                    {
                        ValidacionCAE validacionCAE = new ValidacionCAE();

                        validacionCAE.TipoDocumento = registro.Fields.Item("U_TipoDoc").Value + "";
                        validacionCAE.NumeroFinal   = int.Parse(registro.Fields.Item("U_NumFin").Value + "");
                        validacionCAE.NumeroActual  = int.Parse(registro.Fields.Item("U_NumAct").Value + "");
                        validacionCAE.ValidoDesde   = registro.Fields.Item("U_ValDesde").Value + "";
                        validacionCAE.ValidoHasta   = registro.Fields.Item("U_ValHasta").Value + "";

                        CAEs.Add(validacionCAE);

                        registro.MoveNext();
                        i++;
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (registro != null)
                {
                    //Libera de memoria el objeto registro
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(registro);
                    GC.Collect();
                }
            }

            return(CAEs);
        }
        /// <summary>
        /// Method to ensure whether WorkSheet contains additional column name matches to a column name for any Street Light attribute and is duplicate with other components.
        /// </summary>
        /// <param name="p_workSheetColumnNames">List of worksheet column headers </param>
        /// <returns></returns>
        private bool CheckAdditionalUniqueColumn(List <string> p_workSheetColumnNames)
        {
            Recordset     oRS = null;
            List <string> alreadyExistsList = new List <string>();
            bool          alreadyExists     = false;
            string        errrorMessage     = null;
            bool          checkUniqColmn    = true;

            try
            {
                DataAccess dataAccess = new DataAccess(m_oGTDataContext);
                oRS        = dataAccess.GetMetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE");
                oRS.Filter = "g3e_cno = " + 1 + " or g3e_cno = " + 2 + " or g3e_cno = " + 11 + " or g3e_cno = " + 21 + " or g3e_cno = " + 5601;
                if (oRS != null)
                {
                    oRS.MoveFirst();
                    while (!oRS.EOF)
                    {
                        if (p_workSheetColumnNames.Any(i => i.ToUpper() == oRS.Fields["G3E_USERNAME"].Value.ToString().ToUpper()))
                        {
                            if (alreadyExistsList.Contains(oRS.Fields["G3E_USERNAME"].Value.ToString()))
                            {
                                alreadyExists = true;
                                break;
                            }
                            else
                            {
                                alreadyExistsList.Add(oRS.Fields["G3E_USERNAME"].Value.ToString());
                            }
                        }
                        oRS.MoveNext();
                    }
                    if (alreadyExists)
                    {
                        errrorMessage = "Spreadsheet cannot contain column name " + oRS.Fields["G3E_USERNAME"].Value.ToString() + " as it is not unique across all components of the Street Light feature.";
                        DisplayErrorMessage(errrorMessage);
                        checkUniqColmn = false;
                    }
                }
            }
            catch
            {
                checkUniqColmn = false;
                throw;
            }
            finally
            {
                oRS = null;
            }
            return(checkUniqColmn);
        }
示例#14
0
/// <summary>
/// Gets the command parameters from the SYS_GENERALPARAMETER table for this command.
/// </summary>
/// <returns></returns>
        internal static Boolean gGetSysGenPrams()
        {
            Recordset tmpRS     = null;
            string    tmpQry    = string.Empty;
            Boolean   tmpRetVal = false;

            try
            {
                tmpQry = "select param_name, param_value from gis_onc.SYS_GENERALPARAMETER " +
                         "where SUBSYSTEM_NAME = 'AttachFeatureDocumentCC'";
                tmpRS = gDatacont.OpenRecordset(tmpQry, CursorTypeEnum.adOpenStatic,
                                                LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText);
                if (!(tmpRS.BOF && tmpRS.EOF))
                {
                    tmpRS.MoveFirst();

                    for (int i = 0; i < tmpRS.RecordCount; ++i)
                    {
                        switch (tmpRS.Fields[0].Value.ToString())
                        {
                        case "SPRelPath":
                            gSPDocBaseRelPath = tmpRS.Fields[1].Value.ToString();
                            break;

                        case "FILE_TYPES":
                            gSPFileTypeLst = tmpRS.Fields[1].Value.ToString();
                            break;

                        case "FILE_EXTENSIONS":
                            gOpenFileFilterLst = tmpRS.Fields[1].Value.ToString();
                            break;

                        case "FEATURE_FILE_LOC":
                            gSPDocFeatureDocLoc = tmpRS.Fields[1].Value.ToString();
                            break;
                        }
                        tmpRS.MoveNext();
                    }
                }

                tmpRetVal = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in gGetSPFileTypeList: " + ex.Message,
                                "Attach Feature Hyperlink Document - csGlobals",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                tmpRetVal = false;
            }
            return(tmpRetVal);
        }
示例#15
0
 private void montaLista()
 {
     RsDados = new Recordset();
     RsDados.Open(SQL, new Conexao().getContas(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
     listaTipos.Clear();
     //Para o caso não seleionado
     listaTipos.Add(new String[] { "0", "NÃO SELECIONADO" });
     while (!(RsDados.EOF || RsDados.BOF))
     {
         listaTipos.Add(new String[] { Convert.ToString(RsDados.Fields["Cod"].Value), Convert.ToString(RsDados.Fields["Aparelho"].Value) });
         RsDados.MoveNext();
     }
     RsDados.Close();
 }
        public void Execute()
        {
            int   fId = 0;
            short fNo = 0;
            short treeTrimmingGraphicCno = 19002;
            short workPointFno           = 191;
            short treeTrimmingFno        = 190;
            short workPointGcNo          = 19102;
            IGTOrientedPointGeometry workPointGeometry   = null;;
            IGTKeyObject             treeTrimmingFeature = null;
            IGTKeyObject             workPointFeature    = null;
            IGTComponent             mainComponent       = null;
            short cid = 0;

            try
            {
                IGTSpatialService spatialService = GTClassFactory.Create <IGTSpatialService>();
                spatialService.DataContext    = m_DataContext;
                spatialService.Operator       = GTSpatialOperatorConstants.gtsoEntirelyContains;
                spatialService.FilterGeometry = Components.GetComponent(treeTrimmingGraphicCno).Geometry;
                Recordset rs = spatialService.GetResultsByFNO(new short[] { workPointFno });
                if (rs != null)
                {
                    IGTComponent tTVGraphic = Components.GetComponent(treeTrimmingGraphicCno);
                    int          tTVFid     = Convert.ToInt32(tTVGraphic.Recordset.Fields["G3E_FID"].Value);
                    treeTrimmingFeature = DataContext.OpenFeature(treeTrimmingFno, tTVFid);
                    DeleteWorkLabelGeometry(treeTrimmingFeature);

                    if (rs.RecordCount > 0)
                    {
                        rs.MoveFirst();
                        while (!rs.EOF)
                        {
                            fId = Convert.ToInt32(rs.Fields["G3E_FID"].Value.ToString());
                            workPointFeature = DataContext.OpenFeature(workPointFno, fId);
                            mainComponent    = workPointFeature.Components.GetComponent(workPointGcNo);
                            mainComponent.Recordset.MoveFirst();
                            workPointGeometry = (IGTOrientedPointGeometry)mainComponent.Geometry;
                            cid = (short)(cid + 1);
                            CreateWorkLabelGeometry(workPointGeometry, treeTrimmingFeature, cid);
                            rs.MoveNext();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error during Tree Trimming Labels execution." + ex.Message, "G/Technology");
            }
        }
示例#17
0
        /// <summary>
        /// Obtiene el listado cfe utilizados por fecha
        /// </summary>
        /// <param name="comp"></param>
        /// <returns></returns>
        public List <CFE> ObtenerCertificadosUtilizados()
        {
            Recordset  recSet            = null;
            string     consulta          = "";
            List <CFE> listaCertificados = new List <CFE>();
            CFE        cfe;

            try
            {
                //Obtener objeto estandar de record set
                recSet = ProcConexion.Comp.GetBusinessObject(BoObjectTypes.BoRecordset);

                //Establecer consulta
                consulta = "SELECT T1.U_DocSap, T1.U_TipoDoc, T1.U_Serie, T1.U_NumCFE, T1.U_Sucursal FROM [@TFECFE] AS T1  WHERE CONVERT(DATE, T1.CreateDate, 103) = CONVERT(DATE, GETDATE(), 103)  ORDER BY U_DocSap, U_Sucursal";

                //Ejecutar consulta
                recSet.DoQuery(consulta);

                recSet.MoveFirst();

                for (int i = 0; i < recSet.RecordCount; i++)
                {
                    cfe = new CFE();

                    cfe.DocumentoSAP              = recSet.Fields.Item("U_DocSap").Value + "";
                    cfe.TipoCFEInt                = int.Parse(recSet.Fields.Item("U_TipoDoc").Value + "");
                    cfe.SerieComprobante          = recSet.Fields.Item("U_Serie").Value + "";
                    cfe.NumeroComprobante         = int.Parse(recSet.Fields.Item("U_NumCFE").Value + "");
                    cfe.CodigoCasaPrincipalEmisor = int.Parse(recSet.Fields.Item("U_Sucursal").Value + "");

                    listaCertificados.Add(cfe);

                    recSet.MoveNext();
                }
            }
            catch (Exception)
            {
                listaCertificados = null;
            }
            finally
            {
                if (recSet != null)
                {
                    //Liberar memoria utilizada por el objeto record set
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(recSet);
                    System.GC.Collect();
                }
            }
            return(listaCertificados);
        }
示例#18
0
文件: Ticket.cs 项目: git786hub/DLL
        /// <summary>
        /// Gets the list of member codes
        /// </summary>
        /// <returns></returns>
        private List <string> GetMemberCodes()
        {
            try
            {
                List <string> codesList   = new List <string>();
                IGTKeyObject  gTKeyObject = DataContext.OpenFeature(110, POLE_FID);
                Recordset     rs          = gTKeyObject.Components.GetComponent(1).Recordset;

                IGTGeometry geometry = gTKeyObject.Components.GetComponent(11002).Geometry;
                IGTPoint    point    = GTClassFactory.Create <IGTPoint>();
                point.X = geometry.FirstPoint.X;
                point.Y = geometry.FirstPoint.Y;
                point.Z = geometry.FirstPoint.Z;
                customBoundaryQuery boundaryQuery = new customBoundaryQuery(point, 235);// County boundary  FNO 235
                Recordset           resultRs1     = boundaryQuery.PerformPointInPolygon();

                if (resultRs1 != null && resultRs1.RecordCount > 0)
                {
                    IGTKeyObject countyFeature        = DataContext.OpenFeature(Convert.ToInt16(resultRs1.Fields["G3E_FNO"].Value), Convert.ToInt32(resultRs1.Fields["G3E_FID"].Value));
                    Recordset    boundaryAttributesRs = countyFeature.Components.GetComponent(23501).Recordset; // // County Boundary Attributes
                    if (boundaryAttributesRs != null && boundaryAttributesRs.RecordCount > 0)
                    {
                        boundaryAttributesRs.MoveFirst();
                        if (!string.IsNullOrEmpty(Convert.ToString(boundaryAttributesRs.Fields["ID"].Value)))
                        {
                            string    countyBoundaryId = Convert.ToString(boundaryAttributesRs.Fields["ID"].Value).Replace("TX", string.Empty).Trim();
                            Recordset memberCodeRS     = GetRecordSet(string.Format(@"SELECT NJUNS_MEMBER FROM NJUNS_MEMBER A , NJUNS_CONTACTS B WHERE A.NJUNS_MEMBER_ID = B.NJUNS_MEMBER_ID AND
                                                                        B.COUNTY_N_ID = {0} ", countyBoundaryId));

                            if (memberCodeRS != null && memberCodeRS.RecordCount > 0)
                            {
                                memberCodeRS.MoveFirst();
                                while (!memberCodeRS.EOF)
                                {
                                    codesList.Add(Convert.ToString(memberCodeRS.Fields["NJUNS_MEMBER"].Value));
                                    memberCodeRS.MoveNext();
                                }
                                memberCodeRS.Close();
                                memberCodeRS = null;
                            }
                        }
                    }
                }
                return(codesList);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#19
0
文件: lojas.cs 项目: Laerton2016/SIME
        private void coletaDados(string SQL)
        {
            Recordset dados = new Recordset();

            dados.Open(SQL, new Conexao().getContas(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
            dadosCombo.Clear();
            dadosCombo.Add(new String[] { "0", "NÃO SELECIONADO" });
            while (!(dados.EOF || dados.BOF))
            {
                dadosCombo.Add(new String[] { Convert.ToString(dados.Fields["ID"].Value), Convert.ToString(dados.Fields["Razão"].Value) });
                dados.MoveNext();
            }
            dados.Close();
        }
示例#20
0
        public void MontaListaFornecedores(DropDownList combFornecedores)
        {
            combFornecedores.Items.Clear();
            Recordset  rsDados = new Recordset();
            Connection conex   = new Conexao().getContas();
            String     SQL     = "SELECT Fornecedores.* FROM Fornecedores ORDER BY Fornecedores.Fornecedor;";

            rsDados.Open(SQL, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
            while (!(rsDados.BOF || rsDados.EOF))
            {
                combFornecedores.Items.Add(new ListItem(rsDados.Fields["Fornecedor"].Value.ToString().ToUpper(), rsDados.Fields["cod"].Value.ToString()));
                rsDados.MoveNext();
            }
        }
        public void Query()
        {
            try
            {
                mDataVec = mData as DatasetVector;
                Recordset rec = mDataVec.GetRecordset(false, CursorType.Dynamic);
                this.dataGridView1.Columns.Clear();
                this.dataGridView1.Rows.Clear();

                for (int i = 0; i < rec.FieldCount; i++)
                {
                    //定义并获得字段名称
                    String fieldName = rec.GetFieldInfos()[i].Name;
                    //将得到的字段名称添加到dataGridView列中
                    this.dataGridView1.Columns.Add(fieldName, fieldName);
                }

                //初始化row
                DataGridViewRow row = null;

                //根据选中记录的个数,将选中对象的信息添加到dataGridView中显示
                while (!rec.IsEOF)
                {
                    row = new DataGridViewRow();
                    for (int i = 0; i < rec.FieldCount; i++)
                    {
                        //定义并获得字段值
                        Object fieldValue = rec.GetFieldValue(i);

                        //将字段值添加到dataGridView中对应的位置
                        DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
                        if (fieldValue != null)
                        {
                            cell.ValueType = fieldValue.GetType();
                            cell.Value     = fieldValue;
                        }
                        row.Cells.Add(cell);
                    }

                    this.dataGridView1.Rows.Add(row);
                    rec.MoveNext();
                }
                this.dataGridView1.Update();
                rec.Dispose();
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
示例#22
0
        public void montaComboEmpresas(DropDownList combEmpresas)
        {
            combEmpresas.Items.Clear();
            Recordset  rsDados = new Recordset();
            Connection conex   = new Conexao().getContas();
            String     sql     = "SELECT DESTINO.* FROM DESTINO ORDER BY DESTINO.Descrição; ";

            rsDados.Open(sql, conex, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
            while (!(rsDados.BOF || rsDados.EOF))
            {
                combEmpresas.Items.Add(new ListItem(rsDados.Fields["Descrição"].Value.ToString().ToUpper(), rsDados.Fields["cod"].Value.ToString()));
                rsDados.MoveNext();
            }
        }
示例#23
0
 private void montaLista()
 {
     RsDados = new Recordset();
     RsDados.Open(SQL, new Conexao().getDb4(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
     listaSeguradora.Clear();
     //CASO DE SEM SEGURO
     listaSeguradora.Add(new String[] { "0", "SEM SEGURO" });
     while (!(RsDados.EOF || RsDados.BOF))
     {
         listaSeguradora.Add(new String[] { Convert.ToString(RsDados.Fields["ID"].Value), Convert.ToString(RsDados.Fields["Asseguradora"].Value) });
         RsDados.MoveNext();
     }
     RsDados.Close();
 }
示例#24
0
 public bool MoveNext()
 {
     if (HasRows())
     {
         if (_isEdit)
         {
             _isEdit = false;
             Recordset.Update();
         }
         Recordset.MoveNext();
         _isMove = true;
     }
     return(EOF);
 }
示例#25
0
        public static void AddSheet(ExcelPackage pck, string sheetName, Recordset recordset, string htmlColor = "#D3D3D3")
        {
            //recordset.DoQuery(url);

            var sheet = pck.Workbook.Worksheets.Add(sheetName);

            //Add Columns
            int col = 1;

            for (int i = 0; i < recordset.Fields.Count; i++)
            {
                var recordCol = recordset.Fields.Item(i).Description;
                sheet.Cells[1, col].Value = recordCol;
                col++;
            }

            //Add Style
            Color headercolor = ColorTranslator.FromHtml(htmlColor);

            sheet.Cells[1, 1, 1, recordset.Fields.Count].Style.Font.Bold        = true;
            sheet.Cells[1, 1, 1, recordset.Fields.Count].Style.Font.Bold        = true;
            sheet.Cells[1, 1, 1, recordset.Fields.Count].Style.Fill.PatternType = ExcelFillStyle.Solid;
            sheet.Cells[1, 1, 1, recordset.Fields.Count].Style.Fill.BackgroundColor.SetColor(headercolor);
            sheet.Cells.AutoFitColumns();
            sheet.DefaultColWidth  = 18;
            sheet.DefaultRowHeight = 18;


            //Fill cells
            if (recordset.Fields.Count > 0)
            {
                int currentCol = 1;
                int currentRow = 2;
                for (int i = 0; i < recordset.RecordCount; i++)
                {
                    for (int j = 0; j < recordset.Fields.Count; j++)
                    {
                        var recordCol = recordset.Fields.Item(j).Description;
                        sheet.Cells[currentRow, currentCol].Value = recordset.Fields.Item(recordCol).Value.ToString();
                        currentCol++;
                        if (currentCol > recordset.Fields.Count)
                        {
                            currentCol = 1;
                        }
                    }
                    currentRow++;
                    recordset.MoveNext();
                }
            }
        }
示例#26
0
        private void MontaLista()
        {
            RsDados = new Recordset();
            RsDados.Open(SQL, new Conexao().getContas(), CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
            listaEstoque.Clear();


            while (!(RsDados.EOF || RsDados.BOF))
            {
                listaEstoque.Add(new String[] { Convert.ToString(RsDados.Fields["Cod"].Value), Convert.ToString(RsDados.Fields["Estoque"].Value) });
                RsDados.MoveNext();
            }
            RsDados.Close();
        }
示例#27
0
        public List <T> ExecuteSqlForList <T>(string sql)
        {
            var       retValue = new List <T>();
            Type      type     = typeof(T);
            Recordset rs       = (Recordset)company.GetBusinessObject(BoObjectTypes.BoRecordset);

            Logger.Debug(DebugString.Format(Messages.ExecuteForListCommand, sql));

            try
            {
                rs.DoQuery(sql);
                int fieldsSize = rs.Fields.Count;
                while (!rs.EoF)
                {
                    T obj;
                    if (IsNotCoreType(type))
                    {
                        obj = PrepareObject <T>(rs);
                    }
                    else
                    {
                        if (rs.Fields.Item(0).Value.GetType() != type)
                        {
                            String errMsg = String.Format(
                                Messages.ExecuteForObjectArgument,
                                rs.Fields.Item(0).Value.GetType(), type);
                            Logger.Error(errMsg);
                            throw new Exception(errMsg);
                        }
                        obj = (T)rs.Fields.Item(0).Value;
                    }
                    Logger.Debug(DebugString.Format(Messages.ExecuteForListReturn, obj));
                    retValue.Add(obj);
                    rs.MoveNext();
                }
                return(retValue);
            }
            catch (Exception e)
            {
                Logger.Error(String.Format(Messages.ExecuteForObjectError, e.Message), e);
                throw e;
            }
            finally
            {
                if (rs != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rs);
                }
            }
        }
示例#28
0
        /// <summary>
        /// Method to build the Work Point features Account Recordset.
        /// </summary>
        /// <param name="p_workPointRS">Workpoint Recordsets Contained by placed TreeTrimming feature</param>
        /// <returns></returns>
        public Recordset GetWorkPtAccountRecordset(Recordset p_workPointRS)
        {
            Recordset accountsRS = null;
            int wpFid = 0;
            try
            {
                p_workPointRS.MoveFirst();

                accountsRS = new Recordset();
                accountsRS.Fields.Append("Prime Account", DataTypeEnum.adInteger, 4, FieldAttributeEnum.adFldIsNullable);
                accountsRS.Fields.Append("Sub Account", DataTypeEnum.adInteger, 4, FieldAttributeEnum.adFldIsNullable);
                accountsRS.Open(System.Reflection.Missing.Value, System.Reflection.Missing.Value, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, -1);

                while (!p_workPointRS.EOF)
                {
                    wpFid = Convert.ToInt32(p_workPointRS.Fields["G3E_FID"].Value.ToString());

                    Recordset workpointAttributeRS = m_oGTApp.DataContext.OpenRecordset(String.Format("SELECT DISTINCT PRIME_ACCT_ID,SUB_ACCT FROM WORKPOINT_CU_N CU,WORKPOINT_N WP,REFWMIS_FERC_ACCOUNT REF WHERE CU.G3E_FID=WP.G3E_FID AND WP.WR_NBR='{0}' AND REF.PRIME_ACCT=CU.PRIME_ACCT_ID AND REF.ACTIVITY_C=CU.ACTIVITY_C AND WP.G3E_FID={1}", m_oGTApp.DataContext.ActiveJob, wpFid), CursorTypeEnum.adOpenStatic,
                               LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText);

                    if (workpointAttributeRS != null && workpointAttributeRS.RecordCount > 0)
                    {
                        workpointAttributeRS.MoveFirst();

                        while (!workpointAttributeRS.EOF)
                        {

                            if (workpointAttributeRS.Fields["PRIME_ACCT_ID"].Value != DBNull.Value || workpointAttributeRS.Fields["SUB_ACCT"].Value != DBNull.Value)
                            {
                                accountsRS.AddNew();

                                accountsRS.Fields["Prime Account"].Value = workpointAttributeRS.Fields["PRIME_ACCT_ID"].Value;
                                accountsRS.Fields["Sub Account"].Value = workpointAttributeRS.Fields["SUB_ACCT"].Value;

                                accountsRS.Update(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                            }

                            workpointAttributeRS.MoveNext();
                        }
                    }
                    p_workPointRS.MoveNext();
                }          
            }
            catch
            {
                throw;
            }
            return accountsRS;
        }
示例#29
0
        private IGTKeyObject CheckforVirtualpoint(short isoPtNumber)
        {
            IGTKeyObject feature = null;
            bool         exist   = false;

            try
            {
                String sql = "select G3E_FID,G3E_FNO from VIRTUALPT_N where ASSOCIATED_FID = ?";

                Recordset virtualRS = m_dataContext.OpenRecordset(sql, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText,
                                                                  m_IsolationScenarioFeature.GtKeyObject.FID);
                if (virtualRS != null && virtualRS.RecordCount > 0)
                {
                    virtualRS.MoveFirst();

                    while (!virtualRS.EOF)
                    {
                        feature = m_dataContext.OpenFeature(Convert.ToInt16(virtualRS.Fields["G3E_FNO"].Value), Convert.ToInt32(virtualRS.Fields["G3E_FID"].Value));

                        if (isoPtNumber == 1)
                        {
                            if (feature.FNO == 41 || feature.FNO == 81)
                            {
                                exist = true;
                                break;
                            }
                        }
                        else
                        {
                            if (feature.FID != m_IsolationScenarioFeature.IsolationPoint1.FID && (feature.FNO == 41 || feature.FNO == 81))
                            {
                                exist = true;
                                break;
                            }
                        }
                        if (exist)
                        {
                            break;
                        }
                        virtualRS.MoveNext();
                    }
                }
            }
            catch
            {
                throw;
            }
            return(feature);
        }
示例#30
0
        private void DeviceTypeManagerControl_Load(object sender, EventArgs e)
        {
            Recordset objRt = null;

            try
            {
                if (m_Application.MainForm.FormManager.ActiveForm is IFormScene formScene)
                {
                    m_SceneControl = formScene.SceneControl;
                }
                if (m_lstType == null)
                {
                    m_lstType = new List <ResourceTypeData>();
                }
                if (m_lstTypeData == null)
                {
                    m_lstTypeData = new List <Label>();
                }
                objRt = (m_Application.Workspace.Datasources["Resource"].Datasets["ResourceTable"] as DatasetVector).GetRecordset(false, CursorType.Static);
                objRt.MoveFirst();
                while (!objRt.IsEOF)
                {
                    ResourceTypeData data = new ResourceTypeData
                    {
                        Caption     = Convert.ToString(objRt.GetFieldValue("SourceName")),
                        Name        = Convert.ToString(objRt.GetFieldValue("SourceID")),
                        FieldID     = Convert.ToString(objRt.GetFieldValue("TableField"))?.Split(',')[0],
                        FieldName   = Convert.ToString(objRt.GetFieldValue("TableField"))?.Split(',')[1],
                        DatasetName = Convert.ToString(objRt.GetFieldValue("TableName")),
                    };
                    m_lstType.Add(data);

                    objRt.MoveNext();
                }
                GetData();
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
            finally
            {
                if (objRt != null)
                {
                    objRt.Close();
                    objRt.Dispose();
                }
            }
        }
示例#31
0
        //设置区划中心点和边界
        private void SetRegionInfo(csGovRegion csGR)
        {
            try
            {
                //获取GIS信息
                Recordset recdst2 = GetRecordsetByCode(csGR.RegionCode);

                if (recdst2 != null && recdst2.RecordCount > 0)
                {
                    csGR.RegionCenter = new csCenter();
                    csGR.RegionBounds = new csBounds();
                    GeoLine geoLine1 = recdst2.GetGeometry() as GeoLine;
                    csGR.RegionCenter.center = GetCenterPoint(csGR.RegionCode);
                    double dKey = 10714896 / 111000 / 0.08;
                    while (!recdst2.IsEOF)
                    {
                        try
                        {
                            GeoLine geoLine2 = recdst2.GetGeometry() as GeoLine;

                            for (int i = 0; i < geoLine2.PartCount; i++)
                            {
                                GeoLine geoL    = new GeoLine(geoLine2[i]);
                                GeoLine geoLine = null;
                                if (geoL[0].Count < 400)
                                {
                                    geoLine = geoL;
                                }
                                else
                                {
                                    double dTolerance = geoL.Length / dKey;
                                    {
                                        //dTolerance = GetTolerance(csGR.RegionCode);
                                    }
                                    geoLine = Geometrist.Resample(geoL, ResampleType.RTGeneral, dTolerance) as GeoLine;
                                }
                                csGR.RegionBounds.bounds.Add(geoLine[0].Clone());
                            }
                        }
                        catch (SystemException sysEx)
                        {
                            string strErr = sysEx.Message;
                        }
                        recdst2.MoveNext();
                    }
                }
            }
            catch {}
        }
示例#32
0
        public List <TravelExpensesDTO> GetPaymentsByRiseId(int pIntRiseId, string pStrObjType)
        {
            List <TravelExpensesDTO> lLstTravelExpensesDTO = new List <TravelExpensesDTO>();
            Recordset lObjRecordset = null;

            try
            {
                lObjRecordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);

                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("RiseId", pIntRiseId.ToString());
                lLstStrParameters.Add("ObjType", pStrObjType);

                string lStrQuery = this.GetSQL("GetPaymentsByRiseId").Inject(lLstStrParameters);

                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    for (int i = 0; i < lObjRecordset.RecordCount; i++)
                    {
                        TravelExpensesDTO lObjTravelExpensesDTO = new TravelExpensesDTO
                        {
                            Code     = lObjRecordset.Fields.Item("Code").Value.ToString(),
                            DocDate  = DateTime.Parse(lObjRecordset.Fields.Item("DocDate").Value.ToString()),
                            DocEntry = int.Parse(lObjRecordset.Fields.Item("DocEntry").Value.ToString()),
                            DocNum   = int.Parse(lObjRecordset.Fields.Item("DocNum").Value.ToString()),
                            Folio    = lObjRecordset.Fields.Item("U_GLO_CodeMov").Value.ToString(),
                            Total    = double.Parse(lObjRecordset.Fields.Item("Total").Value.ToString()),
                            IdRise   = int.Parse(lObjRecordset.Fields.Item("RiseId").Value.ToString()),
                            Status   = int.Parse(lObjRecordset.Fields.Item("Status").Value.ToString()),
                        };

                        lLstTravelExpensesDTO.Add(lObjTravelExpensesDTO);
                        lObjRecordset.MoveNext();
                    }
                }
            }
            catch (Exception lObjException)
            {
                LogService.WriteError(string.Format("[GetCurrentFolio - GetPaymentsByRiseId: {0}]", lObjException.Message));
                throw new DAOException(lObjException.Message, lObjException);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }
            return(lLstTravelExpensesDTO);
        }
示例#33
0
文件: GISUtility.cs 项目: zfc317/mscd
        public static DataTable RecordsetToDataTable(Recordset rs,LayerInfo layerInfo)
        {
            var dt = CreateDataTableByLayerInfo(layerInfo);
            if (rs.IsEmpty) return dt;

            while (!rs.IsEOF)
            {
                var row = dt.NewRow();
                foreach (var fieldInfo in layerInfo.FieldInfos)
                {
                    var value = rs.GetFieldValue(fieldInfo.FieldName);
                    row[fieldInfo.FieldName] = value;
                }
                dt.Rows.Add(row);
                rs.MoveNext();
            }
            return dt;
        }
 public ArrayList listOfCatalogs(out string errorMessage)
 {
     try
     {
         listCatalogs.Clear();
         rsSchema = dbConn.OpenSchema(ADODB.SchemaEnum.adSchemaCatalogs, Missing.Value, Missing.Value);
         while (!rsSchema.EOF)
         {
             listCatalogs.Add(rsSchema.Fields[0].Value);
             rsSchema.MoveNext();
         }
         errorMessage = "";
     }
     catch (Exception e)
     {
         errorMessage = e.Source + " " + e.Message;
         MessageBox.Show(e.Source + " " + e.Message);
     }
     return listCatalogs;
 }
    protected void ExportToPDF(Recordset Recordset, bool LandScape, string StationID)
    {
        try { 

        DataTable MasterCouponTable = new DataTable("MasterCoupon");
        MasterCouponTable.Columns.Add("日期 / 時間", typeof(String));
        MasterCouponTable.Columns.Add("更期", typeof(String));
        MasterCouponTable.Columns.Add("禮券編號", typeof(String));
        MasterCouponTable.Columns.Add("類型", typeof(String));
        MasterCouponTable.Columns.Add("產品", typeof(String));
        MasterCouponTable.Columns.Add("升數", typeof(String));
        MasterCouponTable.Columns.Add("銀碼", typeof(String));
        MasterCouponTable.Columns.Add("車牌", typeof(String));
        while (!(Recordset.Eof))
        {

            //MasterCouponTable.Rows.Add(Recordset.Fields["Present_Date"].Value);
            //MasterCouponTable.Rows.Add(Recordset.Fields["Period"].Value);
            DataRow trow = MasterCouponTable.NewRow();
            trow[0] = Recordset.Fields["Present_Date"].Value;
          //  trow[1] = Recordset.Fields["Period"].Value;
            if (Convert.ToInt32(Recordset.Fields["Period"].Value) == 11)
            {
               // Response.Write("早");
                trow[1] = "早";
            }
            else if (Convert.ToInt32(Recordset.Fields["Period"].Value) == 12)
            {
               // Response.Write("中");
                trow[1] = "中";
            }
            else if (Convert.ToInt32(Recordset.Fields["Period"].Value) == 13)
            {
                //Response.Write("晚");
                trow[1] = "晚";
            }

            trow[2] = Recordset.Fields["Coupon_Number"].Value;
            trow[3] = Recordset.Fields["Coupon_type"].Value;
            trow[4] = Recordset.Fields["Product_Type"].Value;
            trow[5] = String.Format("{0:0.00}", Recordset.Fields["SaleLitre"].Value);
            trow[6] = Recordset.Fields["SaleAmount"].Value;
            trow[7] = Recordset.Fields["Car_ID"].Value;
           

            MasterCouponTable.Rows.Add(trow);
            Recordset.MoveNext();
        }

        GridView gvReport = new GridView();

        gvReport.DataSource = MasterCouponTable;
        gvReport.DataBind();
      

        int noOfColumns = 0, noOfRows = 0;
        DataTable tbl = new DataTable();



        
        tbl = gvReport.DataSource as DataTable;
        noOfColumns = tbl.Columns.Count;
        noOfRows = gvReport.Rows.Count;
        

        float HeaderTextSize = 8;
        float ReportNameSize = 10;
        float ReportTextSize = 8;
        float ApplicationNameSize = 7;

        // Creates a PDF document
        Document document = null;
        FontSelector selector = new FontSelector();
        selector.AddFont(FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12));
        selector.AddFont(FontFactory.GetFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED));

        string fontpath =
        System.Web.HttpContext.Current.Request.PhysicalApplicationPath +
        "include\\fonts\\SimSun.ttf";
        //"simsun.ttf" file was downloaded from web and placed in the folder
        BaseFont bf = BaseFont.CreateFont(fontpath,
                         BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

        //create new font based on BaseFont
        Font fontContent = new Font(bf, 11);
        Font fontHeader = new Font(bf, 12);


        Font simsunBold = new Font(bf, 14, Font.BOLD, Color.BLACK);
        Font simsunNormal = new Font(bf, 11, Font.NORMAL, Color.BLACK);
      
        if (LandScape == true)
        {
            // Sets the document to A4 size and rotates it so that the orientation of the page is Landscape.
            document = new Document(PageSize.A4.Rotate(), 0, 0, 15, 5);
        }
        else
        {
            document = new Document(PageSize.A4, 0, 0, 15, 5);
        }

        // Creates a PdfPTable with column count of the table equal to no of columns of the gridview or gridview datasource.
        iTextSharp.text.pdf.PdfPTable mainTable = new iTextSharp.text.pdf.PdfPTable(noOfColumns);

        // Sets the first 4 rows of the table as the header rows which will be repeated in all the pages.
        mainTable.HeaderRows = 4;

        // Creates a PdfPTable with 2 columns to hold the header in the exported PDF.
        iTextSharp.text.pdf.PdfPTable headerTable = new iTextSharp.text.pdf.PdfPTable(2);

        // Creates a phrase to hold the application name at the left hand side of the header.
        Phrase phApplicationName =  new Phrase(DateTime.Now.Date.ToString("dd/MM/yyyy"), FontFactory.GetFont("Arial", ApplicationNameSize, iTextSharp.text.Font.NORMAL)); 

        // Creates a PdfPCell which accepts a phrase as a parameter.
        PdfPCell clApplicationName = new PdfPCell(phApplicationName);
        // Sets the border of the cell to zero.
        clApplicationName.Border = PdfPCell.NO_BORDER;
        // Sets the Horizontal Alignment of the PdfPCell to left.
        clApplicationName.HorizontalAlignment = Element.ALIGN_LEFT;

        // Creates a phrase to show the current date at the right hand side of the header.
        Phrase phDate = new Phrase("油站 : " + StationID, simsunNormal);

        // Creates a PdfPCell which accepts the date phrase as a parameter.
        PdfPCell clDate = new PdfPCell(phDate);
        // Sets the Horizontal Alignment of the PdfPCell to right.
        clDate.HorizontalAlignment = Element.ALIGN_RIGHT;
        // Sets the border of the cell to zero.
        clDate.Border = PdfPCell.NO_BORDER;

        // Adds the cell which holds the application name to the headerTable.
        headerTable.AddCell(clApplicationName);
        // Adds the cell which holds the date to the headerTable.
        headerTable.AddCell(clDate);
        // Sets the border of the headerTable to zero.
        headerTable.DefaultCell.Border = PdfPCell.NO_BORDER;

        // Creates a PdfPCell that accepts the headerTable as a parameter and then adds that cell to the main PdfPTable.
        PdfPCell cellHeader = new PdfPCell(headerTable);
        cellHeader.Border = PdfPCell.NO_BORDER;
        // Sets the column span of the header cell to noOfColumns.
        cellHeader.Colspan = noOfColumns;
        // Adds the above header cell to the table.
        mainTable.AddCell(cellHeader);

        // Creates a phrase which holds the file name.
        Phrase phHeader = new Phrase("禮券驗證系統",simsunNormal);
        PdfPCell clHeader = new PdfPCell(phHeader);
        clHeader.Colspan = noOfColumns;
        clHeader.Border = PdfPCell.NO_BORDER;
        clHeader.HorizontalAlignment = Element.ALIGN_CENTER;
        mainTable.AddCell(clHeader);

        // Creates a phrase for a new line.
        Phrase phSpace = new Phrase("\n");
        PdfPCell clSpace = new PdfPCell(phSpace);
        clSpace.Border = PdfPCell.NO_BORDER;
        clSpace.Colspan = noOfColumns;
        mainTable.AddCell(clSpace);
        PdfPCell hc;
        PdfPCell fc;

        // Sets the gridview column names as table headers.
        for (int i = 0; i < noOfColumns; i++)
        {
            Phrase ph = null;
            

            if (gvReport.AutoGenerateColumns)
            {
                ph = new Phrase(tbl.Columns[i].ColumnName, simsunNormal);
            }
            else
            {
                ph = new Phrase(gvReport.Columns[i].HeaderText, simsunNormal);
                  
            }

            hc = new PdfPCell(new Phrase(ph));
            hc.Top = 5f;
          
            hc.FixedHeight = 20f;
            hc.HorizontalAlignment =1 ;
            hc.BackgroundColor = iTextSharp.text.Color.LIGHT_GRAY;// new BaseColor(221,221,221,1);  

           // BaseColor objBaseColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#008000"));
            
            


            mainTable.AddCell(hc);
        }

        // Reads the gridview rows and adds them to the mainTable
        for (int rowNo = 0; rowNo < noOfRows; rowNo++)
        {
            for (int columnNo = 0; columnNo < noOfColumns; columnNo++)
            {
                if (gvReport.AutoGenerateColumns)
                {
                    string s = gvReport.Rows[rowNo].Cells[columnNo].Text.Trim();
                    Phrase ph = new Phrase(s, simsunNormal);
                    hc = new PdfPCell(new Phrase(ph));
                    hc.Left =2f;
                    mainTable.AddCell(hc);
                }
                else
                {
                    if (gvReport.Columns[columnNo] is TemplateField)
                    {
                        DataBoundLiteralControl lc = gvReport.Rows[rowNo].Cells[columnNo].Controls[0] as DataBoundLiteralControl;
                        string s = lc.Text.Trim();
                        Phrase ph = new Phrase(s, simsunNormal);
                        hc = new PdfPCell(new Phrase(ph));
                        hc.Top = 0f;
                        hc.FixedHeight = 7f;
                        hc.HorizontalAlignment = 1;
                        hc.BackgroundColor = iTextSharp.text.Color.LIGHT_GRAY;
                        ((Chunk)(hc.Phrase[0])).Font = new iTextSharp.text.Font(((Chunk)(hc.Phrase[0])).Font.Family, 5f);
                        mainTable.AddCell(hc); 
                       
                    }
                    else
                    {
                        string s = gvReport.Rows[rowNo].Cells[columnNo].Text.Trim();
                        Phrase ph = new Phrase(s, simsunNormal);
                        hc = new PdfPCell(new Phrase(ph));
                        hc.Left = 2f;
                        mainTable.AddCell(hc);
                    }
                }
            }

            // Tells the mainTable to complete the row even if any cell is left incomplete.
            mainTable.CompleteRow();
        }

        // Gets the instance of the document created and writes it to the output stream of the Response object.
        PdfWriter.GetInstance(document, Response.OutputStream);

        // Creates a footer for the PDF document.
        HeaderFooter pdfFooter = new HeaderFooter(new Phrase(), true);
        pdfFooter.Alignment = Element.ALIGN_CENTER;
        pdfFooter.Border = iTextSharp.text.Rectangle.NO_BORDER;

        // Sets the document footer to pdfFooter.
        document.Footer = pdfFooter;
        // Opens the document.
        document.Open();
        // Adds the mainTable to the document.
        document.Add(mainTable);
        // Closes the document.
        document.Close();

         
       
            }
        catch(Exception ex)
        { 
            
        }

    }
示例#36
0
 public void Write_CSV_From_Recordset(Recordset RS)
 {
     Regex RX = null;
     object i = null;
     object Field = null;
     string Separator = "";
     if (RS.Eof)
     {
     //
     //There is no data to be written
     //
     return ;
     }
     //RX = new System.Text.RegularExpressions.Regex();
     //RX.Pattern = "\\r|\\n|,|\"";
     //
     //Writing the header row (header row contains field names)
     //
     Separator = ",";
     Response.Write("Present Date and Time");
     Response.Write(Separator);
     Response.Write("Period");
     Response.Write(Separator);
     Response.Write("Number");
     Response.Write(Separator);
     Response.Write("Type");
     Response.Write(Separator);
     Response.Write("Product");
     Response.Write(Separator);
     Response.Write("Litre");
     Response.Write(Separator);
     Response.Write("Amount");
     Response.Write(Separator);
     Response.Write("Car");
     Response.Write("\r\n");
     //
     //Writing the data rows
     //
     while(!(RS.Eof))
     {
     Response.Write(RS.Fields["Present_Date"].Value);
     Response.Write(Separator);
     Response.Write(RS.Fields["Period"].Value);
     Response.Write(Separator);
     Response.Write(RS.Fields["Coupon_Number"].Value);
     Response.Write(Separator);
     Response.Write(RS.Fields["Coupon_Type"].Value);
     Response.Write(Separator);
     Response.Write(RS.Fields["Product_Type"].Value);
     Response.Write(Separator);
     Response.Write(RS.Fields["SaleLitre"].Value);
     Response.Write(Separator);
     Response.Write(RS.Fields["SaleAmount"].Value);
     Response.Write(Separator);
     Response.Write(RS.Fields["Car_ID"].Value);
     Response.Write("\r\n");
     RS.MoveNext();
     }
 }
 private IEnumerable<ImportEntity> MapMasterDataList(Recordset rs)
 {
     rs.MoveFirst();
     while (!(rs.EoF))
     {
         var imports = new ImportEntity();
         var list = new List<string>();
         for (int i = 0; i < rs.Fields.Count; i++)
         {
             string field = rs.Fields.Item(i).Value.ToString();
             list.Add(field);
         }
         imports.Fields = list.ToArray();
         imports.MasterDataCollective = masterdataEntity;
         MasterDataList.Add(imports);
         rs.MoveNext();
     }
     return MasterDataList;
 }