Ejemplo n.º 1
0
        public Endereco BuscarPorID(int _idEndereco)
        {
            Endereco p = null;

            try
            {
                String SQL = String.Format("SELECT * FROM endereco WHERE id = {0};", _idEndereco);

                DataTableReader data = BD.ExecutarSelect(SQL);

                if (data.Read())
                {
                    p = new Endereco();

                    p.ID         = data.GetInt32(0);
                    p.TipoEnd    = data.GetInt32(1);
                    p.Logradouro = data.GetString(2);
                    p.Cidade     = data.GetInt32(3);
                    p.Estado     = data.GetInt32(4);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("BUSCAR POR ID / " + ex.Message);
            }

            return(p);
        }
        public CreateProject()
        {
            InitializeComponent();

            try
            {
                DataTable kunde = SqlConnection.SelectStatement("SELECT kuId ,kuFirma, kuAnsprechpartner FROM tkunde");

                DataTableReader reader = kunde.CreateDataReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        if (reader["kuFirma"].ToString() == "")
                        {
                            kunde_box.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(2)));
                        }
                        else
                        {
                            kunde_box.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(1)));
                        }
                    }
                }

                kunde_box.SelectedIndex = 0;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Es kam zu einem Problem mit der Datenbank." + Environment.NewLine +
                                "Fehlernummer: " + ex.Number + Environment.NewLine +
                                "Fehlerbeschreibung: " + ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        public override MenuItem LoadFromReader(DataTableReader reader)
        {
            var temp = new MenuItem();

            if (reader != null && !reader.IsClosed)
            {
                temp.MenuItemId = reader.GetInt32(0);
                if (!reader.IsDBNull(1))
                {
                    temp.MenuItemName = reader.GetString(1);
                }

                temp.Price          = reader.GetDecimal(2);
                temp.MenuItemCode   = reader.GetString(3);
                temp.MenuCategoryId = reader.GetInt32(4);
                if (!reader.IsDBNull(5))
                {
                    temp.MenuCategoryName = reader.GetString(5);
                }
                if (!reader.IsDBNull(6))
                {
                    temp.Description = reader.GetString(6);
                }
                if (!reader.IsDBNull(7))
                {
                    temp.FoodOrBeverage = reader.GetString(7);
                }
            }

            return(temp);
        }
		/// <summary>Initializes an instance of RemainderSplitter.</summary>
		/// <param name="conn">The database connection to retreive the rule details from.</param>
		/// <param name="splitRuleID">The database ID of the rule this Splitter represents.</param>
		/// <param name="procedureCode">The ADA procedure code this splitter operates on.</param>
		/// <param name="carrier">The insurance carrier this splitter is for.</param>
        public RemainderSplitter(int splitRuleID, string procedureCode, string carrier)
            : base(procedureCode, carrier)
        {
            C_DentalClaimTracker.splitter_rule_details srd = new C_DentalClaimTracker.splitter_rule_details();

            DataTable details = srd.Search("SELECT rd.PROCEDURE_CODE, " +
                                            "       rd.PRIORITY, " +
                                            "       rd.DESCRIPTION, " +
                                            "       rd.RULE_VALUE " +
                                            "FROM SPLITTER_RULE_DETAILS rd " +                             
                                            "WHERE (SPLIT_RULE = " + splitRuleID.ToString() + ") " +
                                            "ORDER BY rd.PRIORITY DESC");

            // "       ISNULL(code.DESCRIPTION, ' ') AS DESCRIPTION, " +
            // "     LEFT OUTER JOIN DDB_PROC_CODE_BASE code ON (rd.PROCEDURE_CODE = code.ADACODE) " +
            DataTableReader reader = details.CreateDataReader();

            SplitRuleDetail d;
            while (reader.Read())
            {
                d = new SplitRuleDetail();
                d.ProcedureCode = reader.GetString(reader.GetOrdinal("PROCEDURE_CODE"));
                d.Description = reader.GetString(reader.GetOrdinal("DESCRIPTION"));
                d.Value = reader.GetInt32(reader.GetOrdinal("RULE_VALUE"));
                d.Priority = (Int16) reader.GetInt32(reader.GetOrdinal("PRIORITY"));
                ruleDetails.Add(d);
            }
            reader.Close();

            // Didn't get any details -- this is worthless.
            if (ruleDetails.Count < 1)
            {
                throw new Exception("No details were found for rule " + splitRuleID.ToString() + ".");
            }
        }
Ejemplo n.º 5
0
 public override ComboBoxItem inflate(DataTableReader reader)
 {
     descr = reader.GetString(3);
     zona  = reader.GetString(1);
     piso  = reader.GetInt32(0);
     inst  = reader.GetInt32(2);
     return(this);
 }
Ejemplo n.º 6
0
        public Dictionary <Int64, Pessoa> BuscarListaFiltrada(String _filtro)
        {
            Dictionary <Int64, Pessoa> mapaPessoas = new Dictionary <Int64, Pessoa>();

            try
            {
                String SQL = "SELECT * FROM pessoa WHERE ";

                Int64 saida;
                if (Int64.TryParse(_filtro, out saida))
                {
                    SQL += String.Format("cpf = {0}", _filtro);
                }
                else
                {
                    SQL += String.Format("nome LIKE '%{0}%'", _filtro);
                }

                SQL += " ORDER BY cpf;";

                DataTableReader data = BD.ExecutarSelect(SQL);

                while (data.Read())
                {
                    Pessoa p = new Pessoa();

                    p.CPF         = data.GetInt64(0);
                    p.Nome        = data.GetString(1);
                    p.Idade       = data.GetInt32(2);
                    p.Cel         = data.GetString(3);
                    p.Email       = data.GetString(4);
                    p.EstadoCivil = data.GetInt32(5);
                    p.Animais     = data.GetBoolean(6);
                    p.Filhos      = data.GetBoolean(7);
                    p.Fumante     = data.GetBoolean(8);

                    EnderecoDAO daoEnd = new EnderecoDAO();
                    p.EnderecoPadrao = daoEnd.BuscarPorID(data.GetInt32(9));

                    FotoDAO daoFoto = new FotoDAO();
                    p.Foto = daoFoto.BuscarPorID(p.CPF);

                    mapaPessoas.Add(p.CPF, p);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("BUSCAR TODOS / " + ex.Message);
            }

            return(mapaPessoas);
        }
Ejemplo n.º 7
0
    /// <summary>
    /// overloaded function that used DataTableReader instead of SqlDataReader
    /// </summary>
    /// <param name="reader"></param>
    /// <param name="index"></param>
    /// <param name="counter"></param>
    /// <returns></returns>
    private TableRow GenerateTableRow(DataTableReader reader, int index, ref int counter)
    {
        TableRow row = new TableRow();

        row.CssClass = "table-row";
        TableCell cell;

        for (int i = 0; i < reader.FieldCount; i++)
        {
            cell = new TableCell();
            switch (reader.GetFieldType(i).ToString())
            {
            case "System.Int32":
                cell.Controls.Add(GenerateTextBox(reader.GetInt32(i).ToString(), counter++, true));
                cell.Controls.Add(GenerateTextBoxValidator((TextBox)cell.Controls[0]));
                cell.ToolTip = reader.GetInt32(i).ToString();
                break;

            case "System.String":
                cell.Controls.Add(GenerateTextBox(reader.GetString(i), counter++, true));
                cell.Controls.Add(GenerateTextBoxValidator((TextBox)cell.Controls[0]));
                cell.ToolTip = reader.GetString(i).ToString();
                break;

            case "System.DateTime":
                cell.Controls.Add(GenerateTextBox(reader.GetDateTime(i).ToString(), counter++, true));
                cell.Controls.Add(GenerateTextBoxValidator((TextBox)cell.Controls[0]));
                cell.ToolTip = reader.GetDateTime(i).ToString();
                break;

            case "System.Boolean":
                cell.Controls.Add(GenerateCheckBox(reader.GetBoolean(i), true));
                break;
            }
            cell.CssClass = "table-cell";
            cell.ID       = "row" + index + "cell" + i;
            row.Controls.Add(cell);
        }
        TableCell actionCell = new TableCell();

        actionCell.CssClass = "table-cell";
        actionCell.Controls.Add(GenerateImgButton("/Resources/Icons/delete-icon.png", new ImageClickEventHandler(delete_btn_Click), "delete-btn" + index));
        actionCell.Controls.Add(GenerateImage("/Resources/Icons/changed-icon.png", "changed" + index));
        actionCell.ID = "row" + index + "cell-action";
        row.Controls.Add(actionCell);
        row.ID = "row" + index;
        return(row);
    }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialisiert alle Mitarbeiter und holt alle verfügbaren Mitarbeiter und Rollen in die Liste.
        /// </summary>
        private void mitarbeiterInitialisieren()
        {
            try
            {
                //Mitarbeiterliste säubern
                userNameBox.Items.Clear();

                string test = "SELECT miID ,miUsername, roBezeichnung FROM tMitarbeiter WHERE miID != " + Session.GetSession().UserId + " JOIN trolle USING(roID)";

                DataTable allema = SqlConnection.SelectStatement("SELECT miID ,miUsername, roBezeichnung FROM tMitarbeiter JOIN trolle USING(roID) WHERE miID != " + Session.GetSession().UserId);

                DataTableReader reader = allema.CreateDataReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        userNameBox.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(1) + ", " + reader.GetString(2)));
                    }
                }

                //Rollen säubern
                roleBox.Items.Clear();

                //Mitarbeiter einfügen
                DataTable alleRollen = SqlConnection.SelectStatement("SELECT roID ,roBezeichnung FROM tRolle");

                reader = alleRollen.CreateDataReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        roleBox.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(1)));
                    }
                }

                roleBox.SelectedIndex = 0;

                userNameBox.SelectedIndex = 0;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Es kam zu einem Problem mit der Datenbank." + Environment.NewLine +
                                "Fehlernummer: " + ex.Number + Environment.NewLine +
                                "Fehlerbeschreibung: " + ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 9
0
        private void tätigkeitenInitialisieren()
        {
            DataTable tätigkeiten = SqlConnection.SelectStatement("SELECT taID, taBeschreibung " +
                                                                  "FROM ttaetigkeitenvorlage " +
                                                                  "WHERE taID IN (" +
                                                                  "SELECT taID FROM tproj_taet " +
                                                                  "WHERE prID = " + Session.GetSession().ProId + ")");

            DataTableReader reader = tätigkeiten.CreateDataReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    tätigkeits_Box.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(1)));
                }
                tätigkeits_Box.SelectedIndex = 0;
            }

            else
            {
                bu_Custom_CheckBox.Checked   = true;
                bu_Custom_CheckBox.AutoCheck = false;
            }
        }
        public AddTaetigkeit(int prID_temp)
        {
            InitializeComponent();

            this.prID = prID_temp;

            try
            {
                DataTable AllTaetig = SqlConnection.SelectStatement("SELECT taID, taBeschreibung " +
                                                                    "FROM ttaetigkeitenvorlage " +
                                                                    "WHERE taID NOT IN (" +
                                                                    "SELECT taID " +
                                                                    "FROM tproj_taet " +
                                                                    "WHERE prID = " + prID + ")");

                DataTableReader reader = AllTaetig.CreateDataReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        tätigkeitListe.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(1)));
                    }
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Es kam zu einem Problem mit der Datenbank." + Environment.NewLine +
                                "Fehlernummer: " + ex.Number + Environment.NewLine +
                                "Fehlerbeschreibung: " + ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 11
0
        public AddWorkerToProject(int proj_id_temp)
        {
            InitializeComponent();

            try
            {
                this.prID = proj_id_temp;

                DataTable AllWorkers = SqlConnection.SelectStatement("SELECT miID, miName, miVorname " +
                                                                     "FROM tmitarbeiter " +
                                                                     "WHERE miID NOT IN (" +
                                                                     "SELECT miID " +
                                                                     "FROM tmita_proj " +
                                                                     "WHERE prID = " + prID + " AND mpAktiv = 1) ORDER BY miName");

                DataTableReader reader = AllWorkers.CreateDataReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        arbeiterListe.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(1) + ", " + reader.GetString(2)));
                    }
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Es kam zu einem Problem mit der Datenbank." + Environment.NewLine +
                                "Fehlernummer: " + ex.Number + Environment.NewLine +
                                "Fehlerbeschreibung: " + ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void GetTest()
        {
            dt.Columns.Add("nullint", typeof(int));
            dt.Rows [0] ["nullint"] = 333;

            DataTableReader reader = new DataTableReader(dt);

            try
            {
                reader.Read();

                int ordinal = reader.GetOrdinal("nullint");
                // Get by name
                Assert.AreEqual(1, (int)reader ["id"], "#1 should be able to get by name");
                Assert.AreEqual(333, reader.GetInt32(ordinal), "#2 should get int32");
                Assert.AreEqual("System.Int32", reader.GetDataTypeName(ordinal), "#3 data type should match");
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Ejemplo n.º 13
0
        public List <Estado> BuscarTodos()
        {
            List <Estado> listaEstados = new List <Estado>();

            try
            {
                String SQL = "SELECT * FROM estado ORDER BY descricao;";

                DataTableReader data = BD.ExecutarSelect(SQL);

                while (data.Read())
                {
                    Estado e = new Estado();

                    e.ID        = data.GetInt32(0);
                    e.Descricao = data.GetString(1);

                    CidadeDAO daoCid = new CidadeDAO();
                    e.Cidades = daoCid.BuscarTodasPorEstadoID(e.ID);

                    listaEstados.Add(e);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("BUSCAR TODOS / " + ex.Message);
            }

            return(listaEstados);
        }
Ejemplo n.º 14
0
        public void GetTest()
        {
            _dt.Columns.Add("nullint", typeof(int));
            _dt.Rows[0]["nullint"] = 333;

            DataTableReader reader = new DataTableReader(_dt);

            try
            {
                reader.Read();

                int ordinal = reader.GetOrdinal("nullint");
                // Get by name
                Assert.Equal(1, (int)reader["id"]);
                Assert.Equal(333, reader.GetInt32(ordinal));
                Assert.Equal("Int32", reader.GetDataTypeName(ordinal));
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
        /// <summary>Initializes an instance of PercentageSplitter.</summary>
        /// <param name="conn">The database connection to retreive the rule details from.</param>
        /// <param name="splitRuleID">The database ID of the rule this Splitter represents.</param>
        /// <param name="procedureCode">The ADA procedure code this splitter operates on.</param>
        /// <param name="carrier">The insurance carrier this splitter is for.</param>
        public PercentageSplitter(int splitRuleID, string procedureCode, string carrier)
            : base(procedureCode, carrier)
        {
            C_DentalClaimTracker.splitter_rule_details srd = new C_DentalClaimTracker.splitter_rule_details();

            DataTable details = srd.Search("SELECT rd.PROCEDURE_CODE, " +
                                           "       rd.Description AS DESCRIPTION, " +
                                           "       rd.RULE_VALUE " +
                                           "FROM SPLITTER_RULE_DETAILS rd " +
                                           "WHERE (SPLIT_RULE = " + splitRuleID.ToString() + ")");
            DataTableReader reader = details.CreateDataReader();

            SplitRuleDetail d;

            while (reader.Read())
            {
                d = new SplitRuleDetail();
                d.ProcedureCode = reader.GetString(reader.GetOrdinal("PROCEDURE_CODE"));
                d.Description   = reader.GetString(reader.GetOrdinal("DESCRIPTION"));
                d.Value         = reader.GetInt32(reader.GetOrdinal("RULE_VALUE"));
                ruleDetails.Add(d);
            }
            reader.Close();

            // Didn't get any details -- this is worthless.
            if (ruleDetails.Count < 1)
            {
                throw new Exception("No details were found for rule " + splitRuleID.ToString() + ".");
            }
        }
Ejemplo n.º 16
0
        public void DontSeeTheEarlierRowsTest()
        {
            DataTableReader reader = new DataTableReader(_dt);

            try
            {
                reader.Read(); // first row
                reader.Read(); // second row

                // insert a row at position 0
                DataRow r = _dt.NewRow();
                r[0] = 0;
                r[1] = "adhi bagavan";
                _dt.Rows.InsertAt(r, 0);

                Assert.Equal(2, reader.GetInt32(0));
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Ejemplo n.º 17
0
        public List <Cidade> BuscarTodasPorEstadoID(Int32 _idEstado)
        {
            List <Cidade> listaCidades = new List <Cidade>();

            try
            {
                String SQL = "SELECT * FROM cidade WHERE estado_id = " + _idEstado + " ORDER BY descricao;";

                DataTableReader data = BD.ExecutarSelect(SQL);

                while (data.Read())
                {
                    Cidade c = new Cidade();

                    c.ID        = data.GetInt32(0);
                    c.Descricao = data.GetString(1);

                    listaCidades.Add(c);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("BUSCAR TODOS / " + ex.Message);
            }

            return(listaCidades);
        }
        //Aktualisiert die Liste aller möglichen Projekte
        private void projekteInitialisieren()
        {
            selectBoxProjekt.Items.Clear();

            try
            {
                DataTable projekte = SqlConnection.SelectStatement("SELECT prId ,prName FROM tprojekt ORDER BY prname");

                DataTableReader reader = projekte.CreateDataReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        selectBoxProjekt.Items.Add(new ListItem(reader.GetInt32(0), reader.GetString(1)));
                    }
                }

                selectBoxProjekt.SelectedIndex = 0;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Es kam zu einem Problem mit der Datenbank." + Environment.NewLine +
                                "Fehlernummer: " + ex.Number + Environment.NewLine +
                                "Fehlerbeschreibung: " + ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public override BillDetails LoadFromReader(DataTableReader reader)
        {
            var temp = new BillDetails();

            if (reader != null && !reader.IsClosed)
            {
                temp.BillDetailId = reader.GetInt32(0);
                if (!reader.IsDBNull(1))
                {
                    temp.BillId = reader.GetInt32(1);
                }
                if (!reader.IsDBNull(2))
                {
                    temp.MenuItemId = reader.GetInt32(2);
                }
                if (!reader.IsDBNull(3))
                {
                    temp.Quantity = reader.GetInt32(3);
                }
                if (!reader.IsDBNull(4))
                {
                    temp.UnitPrice = reader.GetDecimal(4);
                }
                if (!reader.IsDBNull(5))
                {
                    temp.IsDiscountAvailable = reader.GetBoolean(5);
                }
                if (!reader.IsDBNull(6))
                {
                    temp.TotalPrice = reader.GetDecimal(6);
                }
                if (!reader.IsDBNull(7))
                {
                    temp.ReceivedBy = reader.GetInt32(7);
                }
                if (!reader.IsDBNull(8))
                {
                    temp.IsDeleted = reader.GetBoolean(8);
                }
                if (!reader.IsDBNull(9))
                {
                    temp.MenuItemName = reader.GetString(9);
                }
            }

            return(temp);
        }
Ejemplo n.º 20
0
        public RR_TerminosCondiciones ObtenerDatosTerminosCondiciones(RR_TerminosCondiciones Datos)
        {
            try
            {
                RR_TerminosCondiciones datos = new RR_TerminosCondiciones();
                DataSet ds = SqlHelper.ExecuteDataset(Datos.Conexion, "RR_spCSLDB_get_TerminosCondicioesDatosGeneralesWeb");
                if (ds != null)
                {
                    if (ds.Tables.Count == 3)
                    {
                        DataTableReader dr = ds.Tables[0].CreateDataReader();
                        List<CH_Textos> listaTextos = new List<CH_Textos>();
                        CH_Textos itemTexto;
                        while (dr.Read())
                        {
                            itemTexto = new CH_Textos();
                            itemTexto.Texto = dr.GetString(dr.GetOrdinal("texto"));
                            itemTexto.NumPosition = dr.GetInt32(dr.GetOrdinal("numPosition"));
                            listaTextos.Add(itemTexto);
                        }
                        datos.ListaTextos = listaTextos;

                        DataTableReader drImg = ds.Tables[1].CreateDataReader();
                        List<CH_Imagen> listaImagenes = new List<CH_Imagen>();
                        CH_Imagen itemImagen;
                        while (drImg.Read())
                        {
                            itemImagen = new CH_Imagen();
                            itemImagen.Alt = drImg.GetString(drImg.GetOrdinal("TextoAlternativo"));
                            itemImagen.Title = drImg.GetString(drImg.GetOrdinal("TituloImagen"));
                            itemImagen.UrlImagen = drImg.GetString(drImg.GetOrdinal("UrlImagen"));
                            itemImagen.NumPosition = drImg.GetInt32(drImg.GetOrdinal("Posicion"));
                            listaImagenes.Add(itemImagen);
                        }
                        datos.ListaImagenes = listaImagenes;

                        DataTableReader drAviso = ds.Tables[2].CreateDataReader();
                        List<CH_SeccionB> listaAviso = new List<CH_SeccionB>();
                        CH_SeccionB itemAviso;

                        while (drAviso.Read())
                        {
                            itemAviso = new CH_SeccionB();
                            itemAviso.Titulo = drAviso.GetString(drAviso.GetOrdinal("titulo"));
                            itemAviso.Texto = drAviso.GetString(drAviso.GetOrdinal("texto"));
                            listaAviso.Add(itemAviso);
                        }
                        datos.ListaTerminos = listaAviso;
                        datos.Completado = true;
                    }
                }
                return datos;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void ObtenerReporteNominaSaldos(NominaModels Datos)
        {
            try
            {
                object[] Parametros = { Datos.IDNomina, Datos.IDSucursal };
                DataSet  Ds         = SqlHelper.ExecuteDataset(Datos.Conexion, "spCSLDB_Nomina_get_RptNominaSaldos", Parametros);
                if (Ds != null)
                {
                    if (Ds.Tables.Count == 3)
                    {
                        DataTableReader Dr = Ds.Tables[0].CreateDataReader();
                        while (Dr.Read())
                        {
                            Datos.ClaveNomina   = Dr.GetString(Dr.GetOrdinal("ClaveNomina"));
                            Datos.FechaInicio   = Dr.GetDateTime(Dr.GetOrdinal("FechaInicio"));
                            Datos.FechaFin      = Dr.GetDateTime(Dr.GetOrdinal("FechaFin"));
                            Datos.DiasPeriodo   = Dr.GetInt32(Dr.GetOrdinal("DiasPeriodo"));
                            Datos.PeriodoFechas = "DEL " + Datos.FechaInicio.ToShortDateString() + " AL " + Datos.FechaFin.ToShortDateString();
                        }

                        DataTableReader            Dr2   = Ds.Tables[1].CreateDataReader();
                        List <NominaDetalleModels> Lista = new List <NominaDetalleModels>();
                        NominaDetalleModels        Item;
                        while (Dr2.Read())
                        {
                            Item = new NominaDetalleModels();
                            Item.NombreEmpleado = Dr2.GetString(Dr2.GetOrdinal("Empleado"));
                            Item.Percepciones   = Dr2.GetDecimal(Dr2.GetOrdinal("Percepciones"));
                            Item.Deducciones    = Dr2.GetDecimal(Dr2.GetOrdinal("Deducciones"));
                            Item.Total          = Dr2.GetDecimal(Dr2.GetOrdinal("Total"));
                            Item.Puesto         = Dr2.GetString(Dr2.GetOrdinal("Puesto"));
                            Item.Sueldo         = Dr2.GetDecimal(Dr2.GetOrdinal("Sueldo"));
                            Item.DiasLaborados  = Dr2.GetInt16(Dr2.GetOrdinal("DiasLaborados"));
                            Lista.Add(Item);
                        }
                        Datos.ListaNominaDetalle = Lista;

                        DataTableReader Dr3 = Ds.Tables[2].CreateDataReader();
                        List <NominaConceptosFijosModels> Lista02 = new List <NominaConceptosFijosModels>();
                        List <CatEmpleadoModels>          ListaEm = new List <CatEmpleadoModels>();
                        CatEmpleadoModels Item003;

                        NominaConceptosFijosModels Item02;
                        while (Dr3.Read())
                        {
                            Item003            = new CatEmpleadoModels();
                            Item003.IDEmpleado = Dr3.GetString(Dr3.GetOrdinal("IDEmpleado"));
            bmpFromString = Datos.DatosEmpresa.LogoEmpresa.Base64StringToBitmap();
                    Datos.DatosEmpresa.ImagenContruida = bmpFromString.ToBase64ImageReport(ImageFormat.Png);
                }
                return(Datos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 22
0
        private void EditWardSelected(object sender, EventArgs e)
        {
            // show ward config edit controls
            ConfigureDefaultsBox.Visible = true;
            ConfigureDefaultsBox.Enabled = true;
            SelectBayBox.Visible         = true;
            SelectBayBox.Enabled         = true;
            // get ward data
            DataSet         wardData = SqlQueryExecutor.SelectAllFromTable("Ward_Settings", "Id=" + EditSelectWardDropdown.SelectedIndex);
            DataTableReader reader   = wardData.CreateDataReader();

            reader.Read();
            // update UI
            EditDefaultNumberOfBaysSelect.Value   = reader.GetInt32(2);
            EditDefaultBedsPerBaySelect.Value     = reader.GetInt32(3);
            EditDefaultMonitorsPerBedSelect.Value = reader.GetInt32(4);
            ResetBaysList(reader.GetInt32(2));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Retorna datos para dibujado de la página de preguntas frecuentes
        /// </summary>
        /// <param name="_datos">Objeto con datos de conexión y parámetros </param>
        public CH_FAQ ObtenerDatosPagFaqs(CH_FAQ _datos)
        {
            try
            {
                CH_FAQ  datos = new CH_FAQ();
                DataSet ds    = SqlHelper.ExecuteDataset(_datos.Conexion, "CH_spCSLDB_get_DatosFaqs");
                if (ds != null)
                {
                    if (ds.Tables.Count == 3)
                    {
                        DataTableReader  dr          = ds.Tables[0].CreateDataReader();
                        List <CH_Textos> listaTextos = new List <CH_Textos>();
                        CH_Textos        itemTexto;
                        while (dr.Read())
                        {
                            itemTexto             = new CH_Textos();
                            itemTexto.Texto       = dr.GetString(dr.GetOrdinal("Texto"));
                            itemTexto.NumPosition = dr.GetInt32(dr.GetOrdinal("NumPosition"));
                            listaTextos.Add(itemTexto);
                        }
                        datos.ListaTextos = listaTextos;

                        DataTableReader  drImg         = ds.Tables[1].CreateDataReader();
                        List <CH_Imagen> listaImagenes = new List <CH_Imagen>();
                        CH_Imagen        itemImagen;
                        while (drImg.Read())
                        {
                            itemImagen             = new CH_Imagen();
                            itemImagen.Alt         = drImg.GetString(drImg.GetOrdinal("TextoAlternativo"));
                            itemImagen.Title       = drImg.GetString(drImg.GetOrdinal("TituloImagen"));
                            itemImagen.UrlImagen   = drImg.GetString(drImg.GetOrdinal("UrlImagen"));
                            itemImagen.NumPosition = drImg.GetInt32(drImg.GetOrdinal("NumPosition"));
                            listaImagenes.Add(itemImagen);
                        }
                        datos.ListaImagenes = listaImagenes;

                        DataTableReader    drFaqs    = ds.Tables[2].CreateDataReader();
                        List <CH_SeccionB> listaFaqs = new List <CH_SeccionB>();
                        CH_SeccionB        itemFaq;
                        while (drFaqs.Read())
                        {
                            itemFaq        = new CH_SeccionB();
                            itemFaq.Titulo = drFaqs.GetString(drFaqs.GetOrdinal("Pregunta"));
                            itemFaq.Texto  = drFaqs.GetString(drFaqs.GetOrdinal("Respuesta"));
                            listaFaqs.Add(itemFaq);
                        }
                        datos.ListaFaqs  = listaFaqs;
                        datos.Completado = true;
                    }
                }
                return(datos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    public void CalculateAndStoreAverage(int UserScore, string BookId, string UserId)
    {
        //Used to store the current average rating of the book
        int AverageRating = 0;
        int NumberOfRates = 0;
        int NewRating     = 0;

        //Connect to the database
        UseDataBase usedb = new UseDataBase();

        usedb.ConnectDataBase();

        //Retreive the number of people who have rated the book
        NumberOfRates = usedb.RecordNumber("SELECT * FROM [RatingInformation] WHERE [BookId] = '" + BookId.ToString() + "'") + 1;

        //Retrive the users ratings
        DataSet RatingsRead = usedb.ExecuteQuery("SELECT [Rating] FROM [RatingInformation] WHERE BookId = '" + BookId.ToString() + "'");

        //Convert the dataSet to a DataReader
        DataTableReader sqlReader = RatingsRead.CreateDataReader();

        if (sqlReader.HasRows)
        {
            //This variable is used to increment the loop
            int increment = 0;
            while (sqlReader.Read())
            {
                //Store the average rating
                AverageRating = AverageRating + sqlReader.GetInt32(increment);
                increment     = increment++;
            }
        }

        //Close the DataReader
        sqlReader.Close();

        //Calculate the new average using the old average plus the new user average devided by the number of people who have scored this book
        AverageRating = AverageRating + UserScore;
        NewRating     = AverageRating / NumberOfRates;

        //Store the new average in the BookInformation table
        usedb.ExecuteCommand("UPDATE [BookInformation] SET [BookAverageRating] = '" + NewRating + "' WHERE [BookId] = " + BookId.ToString());

        //Close the database
        usedb.Close();

        //Open a new connection
        UseDataBase storeRating = new UseDataBase();

        storeRating.ConnectDataBase();

        //Store the UsersScore in the RatingInformation table
        storeRating.ExecuteCommand("INSERT INTO [RatingInformation] ([BookId],[UserId],[Rating]) VALUES ('" + BookId.ToString() + "','" + UserId.ToString() + "','" + UserScore.ToString() + "');");

        //Close the connection
        storeRating.Close();
    }
Ejemplo n.º 25
0
        private int[] GetMonitorConfigurationFromDatabase()
        {
            string  AND         = ") AND ";
            DataSet monitorData = SqlQueryExecutor.SelectColumnsFromTable(new string[2] {
                "Monitor_Number", "Monitor_Type"
            }, "Monitors_In_Beds", "(Ward=" + wardRef.Id + AND + "(Bay=" + BayID + AND + "(Bed=" + bedNumber + AND + "(Monitor_Number<" + monitors.Length + ")");
            DataTableReader reader = monitorData.CreateDataReader();

            int[] types = new int[monitors.Length];
            for (int monitor = 0; monitor < types.Length; monitor++)
            {
                types[monitor] = -1;
            }
            while (reader.Read())
            {
                types[reader.GetInt32(0)] = reader.GetInt32(1);
            }
            return(types);
        }
Ejemplo n.º 26
0
        public void ObtenerDetalleCapturaXID(CH_Conteo Datos)
        {
            try
            {
                DataSet Ds = SqlHelper.ExecuteDataset(Datos.Conexion, "ER_spCSLDB_get_CapturaPREPDetalleV2", Datos.IDCaptura);
                if (Ds != null)
                {
                    if (Ds.Tables.Count == 2)
                    {
                        DataTableReader Dr = Ds.Tables[0].CreateDataReader();
                        while (Dr.Read())
                        {
                            Datos.Casilla     = Dr.GetString(Dr.GetOrdinal("Casilla"));
                            Datos.UrlImagen   = Dr.GetString(Dr.GetOrdinal("UrlImagen"));
                            Datos.Colaborador = Dr.GetString(Dr.GetOrdinal("Colaborador"));
                            Datos.Comentarios = Dr.GetString(Dr.GetOrdinal("Comentarios"));
                            Datos.Completado  = true;
                            break;
                        }
                        List <CH_PartidoPolitico> Lista = new List <CH_PartidoPolitico>();
                        CH_PartidoPolitico        Item;
                        DataTableReader           Dr2 = Ds.Tables[1].CreateDataReader();
                        while (Dr2.Read())
                        {
                            Item           = new CH_PartidoPolitico();
                            Item.IDPartido = Dr2.GetInt32(Dr2.GetOrdinal("IDPartido"));
                            Item.Nombre    = Dr2.GetString(Dr2.GetOrdinal("Partido"));
                            Item.Siglas    = Dr2.GetString(Dr2.GetOrdinal("Siglas"));
                            Item.UrlLogo   = Dr2.GetString(Dr2.GetOrdinal("LogoPartido"));
                            Item.Votos     = Dr2.GetInt32(Dr2.GetOrdinal("Votos"));

                            Lista.Add(Item);
                        }
                        Datos.ListaPartidos = Lista;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 27
0
 public void ObtenerDatosGraficaConteoPrep(CH_Conteo Datos)
 {
     try
     {
         DataSet Ds = SqlHelper.ExecuteDataset(Datos.Conexion, "EM_Estadisticos_spCSLDB_get_ConteoPrep");
         if (Ds != null)
         {
             if (Ds.Tables.Count == 4)
             {
                 DataTableReader Dr = Ds.Tables[0].CreateDataReader();
                 while (Dr.Read())
                 {
                     Datos.CasillaGanada = Dr.GetInt32(Dr.GetOrdinal("CasillaGanada"));
                     Datos.Completado    = true;
                     break;
                 }
                 DataTableReader Drp = Ds.Tables[1].CreateDataReader();
                 while (Drp.Read())
                 {
                     Datos.CasillaPerdida = Drp.GetInt32(Drp.GetOrdinal("CasillaPerdida"));
                     Datos.Completado     = true;
                     break;
                 }
                 DataTableReader Drt = Ds.Tables[2].CreateDataReader();
                 while (Drt.Read())
                 {
                     Datos.TotalCasilla = Drt.GetInt32(Drt.GetOrdinal("TotalCasilla"));
                     Datos.Completado   = true;
                     break;
                 }
                 List <CH_Conteo> Lista = new List <CH_Conteo>();
                 CH_Conteo        Item;
                 DataTableReader  Dr2 = Ds.Tables[3].CreateDataReader();
                 while (Dr2.Read())
                 {
                     Item = new CH_Conteo();
                     Item.CantidadVoto  = Dr2.GetInt32(Dr2.GetOrdinal("CantidadVoto"));
                     Item.SiglasPartido = Dr2.GetString(Dr2.GetOrdinal("siglas"));
                     Lista.Add(Item);
                 }
                 Datos.ListaConteo     = Lista;
                 Datos.CasillaEmpatada = Datos.TotalCasilla - (Datos.CasillaGanada + Datos.CasillaPerdida);
                 if (Datos.CasillaEmpatada < 0)
                 {
                     Datos.CasillaEmpatada *= -1;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 28
0
        private void buttonArtikel_Click(object sender, EventArgs e)
        {
            adapterArtikel.FillSchema(ds, SchemaType.Source, "Artikel");
            ds.Tables["Artikel"].Columns[0].AutoIncrement = true;
            adapterArtikel.Fill(ds, "Artikel");
            DataTableReader reader = ds.Tables["Artikel"].CreateDataReader();

            while (reader.Read())
            {
                DisplayArtikel da = new DisplayArtikel();
                da.ArtikelOid   = reader.GetInt32(0);
                da.ArtNr        = reader.GetString(1);
                da.ArtGruppe    = GetArtGruppe(reader.GetInt32(2));
                da.Bezeichnung  = reader.GetString(3);
                da.Bestand      = reader.GetByte(4);
                da.Meldebestand = reader.GetInt16(5);
                lsArtikel.Add(da);
            }
            reader.Close();
            dataGridViewAusgabe.DataSource = lsArtikel;


            //dataGridViewAusgabe.DataSource = ds;
            //dataGridViewAusgabe.DataMember = "Artikel";
            //adapterGruppe = new OleDbDataAdapter("Select * from tArtGruppe", con);
            //adapterGruppe.Fill(ds, "ArtGruppe");



            //DataTableReader reader = ds.Tables["Artikel"].CreateDataReader();
            //while(reader.Read())
            //{
            //    DisplayArtikel da = new DisplayArtikel();
            //    da.ArtNr = reader.GetString(1);
            //    da.Bezeichnung = reader.GetString(3);
            //    da.ArtGruppe = GetArtGruppe(reader.GetInt32(2));
            //    lsArtikel.Add(da);

            //}
            //dataGridViewAusgabe.DataSource = lsArtikel;
        }
Ejemplo n.º 29
0
 public RR_MiCuenta ObtenerDatosCuenta(RR_MiCuenta Datos)
 {
     try
     {
         object[]    Parametros  = { Datos.Cliente.IdCliente };
         RR_MiCuenta DatosCuenta = new RR_MiCuenta();
         DataSet     ds          = SqlHelper.ExecuteDataset(Datos.Conexion, "RR_spCSLDB_getDatosCliente", Parametros);
         if (ds != null)
         {
             if (ds.Tables.Count == 1)
             {
                 DataTableReader   dr          = ds.Tables[0].CreateDataReader();
                 List <CH_Cliente> listaCuenta = new List <CH_Cliente>();
                 CH_Cliente        itemCuenta;
                 while (dr.Read())
                 {
                     itemCuenta             = new CH_Cliente();
                     itemCuenta.IdCliente   = dr.GetString(dr.GetOrdinal("id_cliente"));
                     itemCuenta.Nombre      = dr.GetString(dr.GetOrdinal("nombre"));
                     itemCuenta.ApPat       = dr.GetString(dr.GetOrdinal("apePat"));
                     itemCuenta.ApMat       = dr.GetString(dr.GetOrdinal("apeMat"));
                     itemCuenta.Correo      = dr.GetString(dr.GetOrdinal("correoElectronico"));
                     itemCuenta.IdPais      = dr.GetInt32(dr.GetOrdinal("id_pais"));
                     itemCuenta.IdEstado    = dr.GetInt32(dr.GetOrdinal("id_estado"));
                     itemCuenta.IdMunicipio = dr.GetInt32(dr.GetOrdinal("id_municipio"));
                     itemCuenta.Colonia     = dr.GetString(dr.GetOrdinal("colonia"));
                     itemCuenta.Telefono    = dr.GetString(dr.GetOrdinal("telefono"));
                     itemCuenta.Password    = dr.GetString(dr.GetOrdinal("password"));
                     itemCuenta.Direccion   = dr.GetString(dr.GetOrdinal("direccion"));
                     listaCuenta.Add(itemCuenta);
                 }
                 DatosCuenta.ListaCliente = listaCuenta;
             }
         }
         return(DatosCuenta);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 30
0
        // Build the splitter table.
        private void LoadSplitters()
        {
            ArrayList temp = new ArrayList();

            // Instance of DB object splitter rules here with the following SQL statement
            C_DentalClaimTracker.splitter_rules sr = new C_DentalClaimTracker.splitter_rules();

            DataTable allSplits = sr.Search("SELECT sc.PROCEDURE_CODE, " +
                                            "       sc.CARRIER, " +
                                            "       sc.SPLIT_RULE, " +
                                            "       sr.RULE_TYPE " +
                                            "FROM SPLITTER_CODES sc " +
                                            "     INNER JOIN SPLITTER_RULES sr ON (sc.SPLIT_RULE = sr.SPLIT_RULE) " +
                                            "ORDER BY sc.PROCEDURE_CODE ASC, " +
                                            "         sc.PRIORITY DESC");

            // Get the splitter list.

            DataTableReader reader = allSplits.CreateDataReader();

            while (reader.Read())
            {
                try
                {
                    temp.Add(new string[4] {
                        reader.GetString(reader.GetOrdinal("PROCEDURE_CODE")),
                        reader.GetString(reader.GetOrdinal("CARRIER")),
                        reader.GetInt32(reader.GetOrdinal("SPLIT_RULE")).ToString(),
                        reader.GetString(reader.GetOrdinal("RULE_TYPE"))
                    });
                }
                catch (Exception ex)
                {
                    throw new Exception("There was an error reading a splitter rule from the database.", ex);
                }
            }
            reader.Close();


            // Catalog the splitters.
            Splitter s;

            foreach (string[] t in temp)
            {
                s = SplitterFactory.GetSplitter(int.Parse(t[2]), t[3], t[0], t[1]);
                if (!Splitters.ContainsKey(s.ProcedureCode))
                {
                    Splitters.Add(s.ProcedureCode, new ArrayList());
                }

                ((ArrayList)Splitters[s.ProcedureCode]).Add(s);
            }
        }
Ejemplo n.º 31
0
        public void GetTest()
        {
            _dt.Columns.Add("nullint", typeof(int));
            _dt.Rows[0]["nullint"] = 333;

            DataTableReader reader = new DataTableReader(_dt);
            try
            {
                reader.Read();

                int ordinal = reader.GetOrdinal("nullint");
                // Get by name
                Assert.Equal(1, (int)reader["id"]);
                Assert.Equal(333, reader.GetInt32(ordinal));
                Assert.Equal("Int32", reader.GetDataTypeName(ordinal));
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }
        }
Ejemplo n.º 32
0
        public void DontSeeTheEarlierRowsTest()
        {
            DataTableReader reader = new DataTableReader(_dt);
            try
            {
                reader.Read(); // first row
                reader.Read(); // second row

                // insert a row at position 0
                DataRow r = _dt.NewRow();
                r[0] = 0;
                r[1] = "adhi bagavan";
                _dt.Rows.InsertAt(r, 0);

                Assert.Equal(2, reader.GetInt32(0));
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }
        }