/// <summary>
        /// Creates a new instance of the ViewAuditoriaListaVerificacionDetalleCross class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAuditoriaListaVerificacionDetalleCrossInfo MakeViewAuditoriaListaVerificacionDetalleCross(SqlDataReader dataReader)
        {
            ViewAuditoriaListaVerificacionDetalleCrossInfo viewAuditoriaListaVerificacionDetalleCross = new ViewAuditoriaListaVerificacionDetalleCrossInfo();

            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleCargoId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionDetalleCargoId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleCargoId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionDetalleId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionId) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaListaVerificacionId = dataReader.GetInt32(AuditoriaListaVerificacionId);
            if (dataReader.IsDBNull(CargoId) == false)
                viewAuditoriaListaVerificacionDetalleCross.CargoId = dataReader.GetInt32(CargoId);
            if (dataReader.IsDBNull(Cargo) == false)
                viewAuditoriaListaVerificacionDetalleCross.Cargo = dataReader.GetString(Cargo);
            if (dataReader.IsDBNull(Activo) == false)
                viewAuditoriaListaVerificacionDetalleCross.Activo = dataReader.GetBoolean(Activo);
            if (dataReader.IsDBNull(AuditoriaPunto) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaPunto = dataReader.GetString(AuditoriaPunto);
            if (dataReader.IsDBNull(AuditoriaControl) == false)
                viewAuditoriaListaVerificacionDetalleCross.AuditoriaControl = dataReader.GetString(AuditoriaControl);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewAuditoriaListaVerificacionDetalleCross.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(Empresa) == false)
                viewAuditoriaListaVerificacionDetalleCross.Empresa = dataReader.GetString(Empresa);
            if (dataReader.IsDBNull(Orden) == false)
                viewAuditoriaListaVerificacionDetalleCross.Orden = dataReader.GetByte(Orden);

            return viewAuditoriaListaVerificacionDetalleCross;
        }
Example #2
0
        /// <summary>
        /// 数据转用户实体
        /// </summary>
        public static UserInfo DataToModel(SqlDataReader rdr)
        {
            UserInfo user = new UserInfo();
            if (!rdr.IsDBNull(0)) user.UserID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) user.UserName = rdr.GetString(1);
            if (!rdr.IsDBNull(2)) user.UserPassword = rdr.GetString(2);
            if (!rdr.IsDBNull(3)) user.UserNickName = rdr.GetString(3);
            if (!rdr.IsDBNull(4)) user.UserImage = rdr.GetString(4);
            if (!rdr.IsDBNull(5)) user.UserPhone = rdr.GetString(5);
            if (!rdr.IsDBNull(6)) user.UserEmail = rdr.GetString(6);
            if (!rdr.IsDBNull(7)) user.UserTheme = rdr.GetString(7);
            if (!rdr.IsDBNull(8)) user.UserLevel = rdr.GetByte(8);
            if (!rdr.IsDBNull(9)) user.UserFrom = rdr.GetString(9);
            if (!rdr.IsDBNull(10)) user.ModifyDate = rdr.GetDateTime(10);
            if (!rdr.IsDBNull(11)) user.CreateDate = rdr.GetDateTime(11);
            if (!rdr.IsDBNull(12)) user.UserCity = rdr.GetString(12);
            if (!rdr.IsDBNull(13)) user.UserMoney = rdr.GetDecimal(13);
            if (!rdr.IsDBNull(14)) user.UserWorkDay = rdr.GetString(14);
            if (!rdr.IsDBNull(15)) user.UserFunction = rdr.GetString(15);
            if (!rdr.IsDBNull(16)) user.CategoryRate = rdr.GetInt32(16);
            if (!rdr.IsDBNull(17)) user.Synchronize = rdr.GetByte(17);
            if (!rdr.IsDBNull(18)) user.MoneyStart = rdr.GetDecimal(18);
            if (!rdr.IsDBNull(19)) user.IsUpdate = rdr.GetByte(19);

            return user;
        }
Example #3
0
        public List <Product> SearchProductListByName(string searchvalue)
        {
            List <Product> ProductList  = new List <Product>();
            Dao            dao          = new Dao();
            string         sqlStatement = "SELECT ProductID, ProductName, Price, Quantity, Image, Description, CategoryID FROM Product where ProductName Like N'%" + searchvalue + "%'";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader == null)
            {
                return(null);
            }
            while (reader.Read())
            {
                try
                {
                    int    id          = reader.GetInt32(0);
                    string name        = reader.GetString(1);
                    double price       = (double)reader.GetDecimal(2);
                    int    quantity    = reader.GetInt32(3);
                    string image       = reader.GetString(4);
                    string description = "sss";
                    int    categoryID  = reader.GetInt32(6);

                    ProductList.Add(new Product(id, name, price, quantity, image, description, categoryID));
                }
                catch (Exception)
                {
                }
            }
            dao.Con.Close();
            return(ProductList);
        }
        /// <summary>
        /// Creates a new instance of the ViewAuditoriaListaVerificacionDetalle class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewAuditoriaListaVerificacionDetalleInfo MakeViewAuditoriaListaVerificacionDetalle(SqlDataReader dataReader)
        {
            ViewAuditoriaListaVerificacionDetalleInfo viewAuditoriaListaVerificacionDetalle = new ViewAuditoriaListaVerificacionDetalleInfo();

            if (dataReader.IsDBNull(AuditoriaListaVerificacionDetalleId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaListaVerificacionDetalleId = dataReader.GetInt32(AuditoriaListaVerificacionDetalleId);
            if (dataReader.IsDBNull(AuditoriaListaVerificacionId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaListaVerificacionId = dataReader.GetInt32(AuditoriaListaVerificacionId);
            if (dataReader.IsDBNull(AuditoriaPuntoId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaPuntoId = dataReader.GetInt32(AuditoriaPuntoId);
            if (dataReader.IsDBNull(AuditoriaControlId) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaControlId = dataReader.GetInt32(AuditoriaControlId);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewAuditoriaListaVerificacionDetalle.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(AuditoriaPunto) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaPunto = dataReader.GetString(AuditoriaPunto);
            if (dataReader.IsDBNull(AuditoriaControl) == false)
                viewAuditoriaListaVerificacionDetalle.AuditoriaControl = dataReader.GetString(AuditoriaControl);
            if (dataReader.IsDBNull(Orden) == false)
                viewAuditoriaListaVerificacionDetalle.Orden = dataReader.GetByte(Orden);
            if (dataReader.IsDBNull(Activo) == false)
                viewAuditoriaListaVerificacionDetalle.Activo = dataReader.GetBoolean(Activo);

            return viewAuditoriaListaVerificacionDetalle;
        }
 private void button2_Click(object sender, EventArgs e)
 {
     if (tablaReg.Rows.Count == 0)
     {
         MessageBox.Show("Debe seleccionar por lo menos 1 Consumible");
         return;
     }
     foreach (DataRow fila in tablaReg.Rows)
     {
         resultado = Home.BD.comando("EXEC GESTION_DE_GATOS.RegistrarConsXEstadiaXHab "+ textBox1.Text +","+ fila["Id"].ToString() + "," +textBox2.Text);
         if (resultado.Read())
         {
             if (resultado.GetDecimal(0) == 0)
             {
                 MessageBox.Show("Error. El consumible ya estaba agregado");
             }
         }
         else
         {
             MessageBox.Show("Error. El consumible ya estaba agregado");
         }
         resultado.Close();
     }
     MessageBox.Show("El proceso de carga de consumibles finalizo correctamente");
     this.Close();
 }
Example #6
0
        public TList_Empreendimento Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco         = false;
            TList_Empreendimento lista = new TList_Empreendimento();

            if (Banco_Dados == null)
            {
                this.CriarBanco_Dados(false);
                podeFecharBco = true;
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Empreendimento reg = new TRegistro_Empreendimento();
                    if (!(reader.IsDBNull(reader.GetOrdinal("ID_Empreendimento"))))
                    {
                        reg.Id_empreendimento = reader.GetDecimal(reader.GetOrdinal("ID_Empreendimento"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("CD_Empresa"))))
                    {
                        reg.Cd_empresa = reader.GetString(reader.GetOrdinal("CD_Empresa"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("NM_Empresa"))))
                    {
                        reg.Nm_empresa = reader.GetString(reader.GetOrdinal("NM_Empresa"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Empreendimento")))
                    {
                        reg.Ds_empreendimento = reader.GetString(reader.GetOrdinal("DS_Empreendimento"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Observacao")))
                    {
                        reg.Ds_observacao = reader.GetString(reader.GetOrdinal("DS_Observacao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DT_IniEmpreendimento")))
                    {
                        reg.Dt_iniempreendimento = reader.GetDateTime(reader.GetOrdinal("DT_IniEmpreendimento"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("ST_Registro"))))
                    {
                        reg.St_registro = reader.GetString(reader.GetOrdinal("ST_Registro"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
 public ClientesEstadia(string nroRes,string nroEst)
 {
     InitializeComponent();
     nroReserva = nroRes;
     nroEstadia = nroEst;
     tabla = new DataTable();
     tabla.Columns.Add("Id");
     DataColumn column = tabla.Columns["Id"];
     column.Unique = true;
     tabla.Columns.Add("Nombre");
     tabla.Columns.Add("Apellido");
     bSource2 = new BindingSource();
     bSource2.DataSource = tabla;
     //set the DataGridView DataSource
     dataGridView1.DataSource = bSource2;
     consulta = "select sum(T.cantPersonas) from GESTION_DE_GATOS.ReservaXHabitacion RH,GESTION_DE_GATOS.Habitacion H,GESTION_DE_GATOS.TipoHabitacion T where RH.habitacion = H.idHabitacion and T.codigo=H.tipo and RH.reserva = " + nroReserva;
     resultado = Home.BD.comando(consulta);
     if (resultado.Read())
     {
         textBox2.Text = resultado.GetDecimal(0).ToString();
         totalPers = resultado.GetDecimal(0);
         resultado.Close();
     }
     else
     {
         resultado.Close();
         MessageBox.Show("La reserva no tiene habitaciones");
         this.Close();
     }
     consulta = "select C.idCli,C.nombre,C.apellido from GESTION_DE_GATOS.Reserva R,GESTION_DE_GATOS.Cliente C where R.cliente = C.idCli and R.idReserva = " + nroReserva;
     resultado = Home.BD.comando(consulta);
     resultado.Read();
     textBox3.Text = resultado.GetString(1) + " " + resultado.GetString(2);
     persDisp = totalPers - 1;
     textBox4.Text = (persDisp).ToString();
     idCli = resultado.GetDecimal(0);
     nombre = resultado.GetString(1);
     apellido = resultado.GetString(2);
     DataRow row = tabla.NewRow();
     row["Id"] = idCli;
     row["Nombre"] = nombre;
     row["Apellido"] = apellido;
     tabla.Rows.Add(row);
     textBox1.Text = nroReserva;
     resultado.Close();
 }
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     consulta= "select H.numero,H.piso,T.descripcion,T.cantPersonas from GESTION_DE_GATOS.Habitacion H, GESTION_DE_GATOS.TipoHabitacion T where H.tipo = T.codigo and H.idHabitacion = "+comboBox1.Text;
     resultado = Home.BD.comando(consulta);
     if( resultado.Read())
     {
         textBox1.Text = resultado.GetDecimal(0).ToString();
         textBox2.Text = resultado.GetDecimal(1).ToString();
         textBox4.Text = resultado.GetDecimal(3).ToString();
         textBox3.Text = resultado.GetString(2);
     }
     else
     {
         MessageBox.Show("Error la habitacion no existe");
     }
     resultado.Close();
 }
Example #9
0
        /// <summary>
        /// 数据转类别实体
        /// </summary>
        public static UserCategoryInfo DataToModel(SqlDataReader rdr)
        {
            UserCategoryInfo category = new UserCategoryInfo();
            if (!rdr.IsDBNull(0)) category.CategoryTypeID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) category.CategoryTypeName = rdr.GetString(1);
            if (!rdr.IsDBNull(2)) category.CategoryTypePrice = rdr.GetDecimal(2);

            return category;
        }
Example #10
0
        /// <summary>
        /// 数据转钱包实体
        /// </summary>
        public static CardInfo DataToModel(SqlDataReader rdr)
        {
            CardInfo card = new CardInfo();
            if (!rdr.IsDBNull(0)) card.CardID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) card.CardName = rdr.GetString(1);
            if (!rdr.IsDBNull(2)) card.CardNumber = rdr.GetString(2);
            if (!rdr.IsDBNull(3)) card.CardImage = rdr.GetString(3);
            if (!rdr.IsDBNull(4)) card.CardMoney = rdr.GetDecimal(4);
            if (!rdr.IsDBNull(5)) card.CardLive = rdr.GetByte(5);
            if (!rdr.IsDBNull(6)) card.Synchronize = rdr.GetByte(6);
            if (!rdr.IsDBNull(7)) card.ModifyDate = rdr.GetDateTime(7);
            if (!rdr.IsDBNull(8)) card.CDID = rdr.GetInt32(8);
            if (!rdr.IsDBNull(9)) card.UserID = rdr.GetInt32(9);
            if (!rdr.IsDBNull(10)) card.MoneyStart = rdr.GetDecimal(10);
            if (!rdr.IsDBNull(11)) card.CardShow = rdr.GetByte(11);

            return card;
        }
        public Modificacion_Direccion(decimal direccion)
        {
            InitializeComponent();
            string consulta = "select nombre from GESTION_DE_GATOS.Pais";
            resultado = Home.BD.comando(consulta);
            while (resultado.Read() == true)
            {
                comboBox1.Items.Add(resultado.GetSqlString(0));
            }
            resultado.Close();
            idDir = direccion;
            consulta = "select D.calle,D.numero,D.piso,D.depto,D.ciudad,P.nombre from GESTION_DE_GATOS.Direccion D,GESTION_DE_GATOS.Pais P where D.pais = P.idPais and D.idDir = " + direccion.ToString();
            resultado = Home.BD.comando(consulta);
            if (resultado.Read())
            {
                textBox1.Text = resultado.GetString(0);
                textBox2.Text = resultado.GetDecimal(1).ToString();
                if(string.IsNullOrEmpty(resultado.GetValue(2).ToString()))
                {
                }
                else
                {
                    textBox3.Text= resultado.GetDecimal(2).ToString();
                }
                if (string.IsNullOrEmpty(resultado.GetValue(3).ToString()))
                {
                }
                else
                {
                    textBox4.Text = resultado.GetString(3);
                }
                if (string.IsNullOrEmpty(resultado.GetValue(3).ToString()))
                {
                }
                else
                {
                    textBox5.Text = resultado.GetString(4);
                }

                comboBox1.Text = resultado.GetString(5);
            }
            resultado.Close();
            textBox1.Focus();
        }
        public Receipt GetReceiptByReceiptID(int id)
        {
            Receipt Receipt      = null;
            Dao     dao          = new Dao();
            string  sqlStatement = "SELECT EmployeeID, TableNumber, PrintDate, Total, AdditionalFee FROM Receipt WHERE ReceiptID='" + id + "'";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader.Read())
            {
                int      emID        = reader.GetInt32(0);
                int      tablenumber = reader.GetInt32(1);
                DateTime date        = reader.GetDateTime(2);
                double   total       = (double)reader.GetDecimal(3);
                double   addFee      = (double)reader.GetDecimal(4);
                Receipt = new Receipt(id, emID, tablenumber, date, total, addFee);
            }
            dao.Con.Close();
            return(Receipt);
        }
Example #13
0
        public TList_LanServico_X_Duplicata Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco = false;
            TList_LanServico_X_Duplicata lista = new TList_LanServico_X_Duplicata();

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_LanServico_X_Duplicata reg = new TRegistro_LanServico_X_Duplicata();
                    if (!reader.IsDBNull(reader.GetOrdinal("id_os")))
                    {
                        reg.Id_os = reader.GetDecimal(reader.GetOrdinal("id_os"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa")))
                    {
                        reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("nr_lancto")))
                    {
                        reg.Nr_lancto = reader.GetDecimal(reader.GetOrdinal("nr_lancto"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     string consulta="exec GESTION_DE_GATOS.BuscarHotelDeUser '"+comboBox1.SelectedItem+"' , "+Login.HomeLogin.idUsuario.ToString()+";";
     resultado = Home.BD.comando(consulta);
     comboBox2.Items.Clear();
     while (resultado.Read() == true)
     {
         comboBox2.Items.Add(resultado.GetDecimal(0));
     }
     resultado.Close();
 }
Example #15
0
        public TList_Empreendimento_X_LanCCusto Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            bool podeFecharBco = false;
            TList_Empreendimento_X_LanCCusto lista = new TList_Empreendimento_X_LanCCusto();

            if (Banco_Dados == null)
            {
                this.CriarBanco_Dados(false);
                podeFecharBco = true;
            }
            System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, vTop, vNM_Campo));
            try
            {
                while (reader.Read())
                {
                    TRegistro_Empreendimento_X_lanCCusto reg = new TRegistro_Empreendimento_X_lanCCusto();
                    if (!(reader.IsDBNull(reader.GetOrdinal("ID_Empreendimento"))))
                    {
                        reg.Id_empreendimento = reader.GetDecimal(reader.GetOrdinal("ID_Empreendimento"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("ID_CCustoLan"))))
                    {
                        reg.Id_ccustolan = reader.GetDecimal(reader.GetOrdinal("ID_CCustoLan"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Example #16
0
        public decimal GetDecimal(SqlDataReader row, string field)
        {
            try
            {
                var i = GetField(row, field);
                if (row.IsDBNull(i)) return 0m;
                return row.GetDecimal(i);

            }
            catch (Exception ex)
            {
                throw new Exception("BindingError: " + field, ex);
            }
        }
 public Distribucion_Clientes(DataTable tablaP,string nroReserva, string nroEstadia)
 {
     InitializeComponent();
     tabla = tablaP;
     estadia = nroEstadia;
     dataGridView1.DataSource = tabla;
     consulta= "select habitacion from GESTION_DE_GATOS.ReservaXHabitacion where reserva = "+nroReserva;
     resultado = Home.BD.comando(consulta);
     while( resultado.Read())
     {
         comboBox1.Items.Add(resultado.GetDecimal(0));
     }
     resultado.Close();
 }
        private void IntermediaUsuarioConRol_Load(object sender, EventArgs e)
        {
            string consulta = "select H.idHotel from GESTION_DE_GATOS.UserXRolXHotel U,GESTION_DE_GATOS.Hotel H where U.hotel=H.idHotel and U.usuario = " + Login.HomeLogin.idUsuario.ToString() + " order by H.idHotel";
            resultado = Home.BD.comando(consulta);
            while (resultado.Read() == true)
            {
                comboBox1.Items.Add(resultado.GetDecimal(0));
            }
            resultado.Close();
            consulta = "select H.idHotel Id, H.nombre Nombre from GESTION_DE_GATOS.UserXRolXHotel U,GESTION_DE_GATOS.Hotel H where U.hotel=H.idHotel and U.usuario = " + Login.HomeLogin.idUsuario.ToString() + " order by H.idHotel";

            DataTable result = Home.BD.consulta(consulta);
            dataGridView1.DataSource = result;
        }
Example #19
0
 public void Property(string key, SqlDataReader reader, int idx)
 {
     jsonWriter.WritePropertyName(key);
     string typeName = reader.GetDataTypeName(idx);
     if (reader.IsDBNull(idx))
         jsonWriter.WriteNull();
     else if (typeName == "decimal")
         jsonWriter.WriteValue(reader.GetDecimal(idx));
     else if (typeName == "datetime")
         jsonWriter.WriteValue(reader.GetDateTime(idx));
     else if (typeName == "varchar" || typeName == "nvarchar")
         jsonWriter.WriteValue(reader.GetString(idx));
     else
         throw new Exception("Unknown data type " + typeName);
 }
        public List <Receipt> GetReceiptList()
        {
            List <Receipt> ReceiptList  = new List <Receipt>();
            Dao            dao          = new Dao();
            string         sqlStatement = "SELECT ReceiptID, EmployeeID, TableNumber, PrintDate, Total, AdditionalFee FROM Receipt";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader == null)
            {
                return(null);
            }
            while (reader.Read())
            {
                int      reID        = reader.GetInt32(0);
                int      emID        = reader.GetInt32(1);
                int      tablenumber = reader.GetInt32(2);
                DateTime date        = reader.GetDateTime(3);
                double   total       = (double)reader.GetDecimal(4);
                double   addFee      = (double)reader.GetDecimal(5);
                ReceiptList.Add(new Receipt(reID, emID, tablenumber, date, total, addFee));
            }
            dao.Con.Close();
            return(ReceiptList);
        }
        public static long GetLong(SqlDataReader myReader, int myColumnNo)
        {
            Decimal myDecimal = new Decimal();
            long myData = 0;

            try
            {
                myDecimal = myReader.GetDecimal(myColumnNo);
                myData = Convert.ToInt64(myDecimal);
            }
            catch (Exception)
            {
                myData = 0;
            }
            return myData;
        }
Example #22
0
        public List <ReceiptDetail> GetReceiptDetailByReceiptId(int receiptId)
        {
            List <ReceiptDetail> receiptDetailList = new List <ReceiptDetail>();
            Dao    dao          = new Dao();
            string sqlStatement = "SELECT ProductID, Quantity, Total FROM ReceiptDetails WHERE ReceiptID='" + receiptId + "'";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            while (reader.Read())
            {
                int     productID = reader.GetInt32(0);
                int     quantity  = reader.GetInt32(1);
                decimal total     = reader.GetDecimal(2);
                receiptDetailList.Add(new ReceiptDetail(productID, quantity, Decimal.ToDouble(total)));
            }
            dao.Con.Close();
            return(receiptDetailList);
        }
Example #23
0
        public Checkin()
        {
            InitializeComponent();
            textBox1.Clear();
            textBox1.Focus();

            resok = 0;
            resultado = Home.BD.comando("Select idEstado from GESTION_DE_GATOS.Estado where descripcion = 'RESERVA CORRECTA'");
            resultado.Read();
            resok = resultado.GetDecimal(0);
            resultado.Close();
            resmodif = 0;
            resultado = Home.BD.comando("Select idEstado from GESTION_DE_GATOS.Estado where descripcion = 'RESERVA MODIFICADA'");
            resultado.Read();
            resmodif = resultado.GetDecimal(0);
            resultado.Close();
        }
Example #24
0
        /// <summary>
        /// 数据转转账实体
        /// </summary>
        public static ZhuanZhangInfo DataToModel(SqlDataReader rdr)
        {
            ZhuanZhangInfo zhang = new ZhuanZhangInfo();
            if (!rdr.IsDBNull(0)) zhang.ZhuanZhangID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) zhang.ZhuanZhangFrom = rdr.GetInt32(1);
            if (!rdr.IsDBNull(2)) zhang.ZhuanZhangTo = rdr.GetInt32(2);
            if (!rdr.IsDBNull(3)) zhang.ZhuanZhangDate = rdr.GetDateTime(3);
            if (!rdr.IsDBNull(4)) zhang.ZhuanZhangMoney = rdr.GetDecimal(4);
            if (!rdr.IsDBNull(5)) zhang.ZhuanZhangLive = rdr.GetByte(5);
            if (!rdr.IsDBNull(7)) zhang.Synchronize = rdr.GetByte(6);
            if (!rdr.IsDBNull(6)) zhang.ModifyDate = rdr.GetDateTime(7);
            if (!rdr.IsDBNull(7)) zhang.UserID = rdr.GetInt32(8);
            if (!rdr.IsDBNull(7)) zhang.ZhuanZhangNote = rdr.GetString(9);
            if (!rdr.IsDBNull(7)) zhang.ZZID = rdr.GetInt32(10);

            return zhang;
        }
Example #25
0
        public String[] getDBAlarm()
        {
            comm.Connection = conn;
            comm.Connection.Open();

            comm.CommandText = "SELECT TOP 1 [ALARMOBJDN],[ALARMOBJTYPE],[ALARMLEVEL],CONVERT(DateTime,[BEGINTIME]) FROM [SunCoreDB].[dbo].[ALM_ALARMINFO]";
            dr = comm.ExecuteReader();
            dr.Read();
            String[] alarm = new String[4];

            alarm[0] = dr.GetString(0);
            alarm[1] = dr.GetString(1);
            alarm[2] = dr.GetDecimal(2).ToString();
            alarm[3] = dr.GetDateTime(3).ToString();

            comm.Connection.Close();
            return alarm;
        }
        public Payment GetPaymentByEmpID(int employeeID)
        {
            Payment payment      = null;
            Dao     dao          = new Dao();
            string  sqlStatement = "SELECT PaymentID, EmployeeID, PayDate, TotalFee, Detail FROM Payment WHERE EmployeeID='" + employeeID + "'";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader.Read())
            {
                int      pID = reader.GetInt32(0);
                int      eID = reader.GetInt32(1);
                DateTime pD  = reader.GetDateTime(2);
                decimal  tF  = reader.GetDecimal(3);
                string   de  = reader.GetString(4);
                payment = new Payment(pID, eID, pD, Decimal.ToDouble(tF), de);
            }
            dao.Con.Close();
            return(payment);
        }
Example #27
0
        public Product GetProductByName(string Name)
        {
            Product Product      = null;
            Dao     dao          = new Dao();
            string  sqlStatement = "SELECT ProductID, Price, Quantity, Image, Description, CategoryID FROM Product WHERE ProductName='" + Name + "'";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader.Read())
            {
                int    id          = reader.GetInt32(0);
                double price       = (double)reader.GetDecimal(1);
                int    quantity    = reader.GetInt32(2);
                string image       = reader.GetString(3);
                string description = reader.GetString(4);
                int    categoryID  = reader.GetInt32(5);
                Product = new Product(id, Name, price, quantity, image, description, categoryID);
            }
            dao.Con.Close();
            return(Product);
        }
 public Cancelacion()
 {
     InitializeComponent();
     textBox1.Clear();
     textBox1.Focus();
     noshow = 0;
     resultado = Home.BD.comando("Select idEstado from GESTION_DE_GATOS.Estado where descripcion = 'RESERVA CANCELADA POR NO-SHOW'");
     resultado.Read();
     noshow = resultado.GetDecimal(0);
     resultado.Close();
     canceUser = 0;
     resultado = Home.BD.comando("Select idEstado from GESTION_DE_GATOS.Estado where descripcion = 'RESERVA CANCELADA POR RECEPCION'");
     resultado.Read();
     canceUser = resultado.GetDecimal(0);
     resultado.Close();
     cancelCli = 0;
     resultado = Home.BD.comando("Select idEstado from GESTION_DE_GATOS.Estado where descripcion = 'RESERVA CANCELADA POR CLIENTE'");
     resultado.Read();
     cancelCli = resultado.GetDecimal(0);
     resultado.Close();
 }
Example #29
0
        public List <ReceiptDetail> GetReceiptDetailList()
        {
            List <ReceiptDetail> receiptDetailList = new List <ReceiptDetail>();
            Dao    dao          = new Dao();
            string sqlStatement = "SELECT ReceiptID, ProductID, Quantity, Total FROM ReceiptDetails";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader == null)
            {
                return(null);
            }
            while (reader.Read())
            {
                int     rID = reader.GetInt32(0);
                int     pID = reader.GetInt32(1);
                int     q   = reader.GetInt32(2);
                decimal t   = reader.GetDecimal(3);
                receiptDetailList.Add(new ReceiptDetail(rID, pID, q, Decimal.ToDouble(t)));
            }
            dao.Con.Close();
            return(receiptDetailList);
        }
        public double GetByMonth(string month)
        {
            double         all         = 0;
            List <Receipt> ReceiptList = new List <Receipt>();
            Dao            dao         = new Dao();

            try
            {
                string sqlStatement = "SELECT SUM(Total) FROM Receipt where FORMAT(PrintDate,'MM')= '" + month + "'";
                System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
                if (reader.Read())
                {
                    all = (double)reader.GetDecimal(0);
                }
            }
            catch (Exception e)
            {
                return(0);
            }

            dao.Con.Close();
            return(all);
        }
        public List <Payment> GetPaymentList()
        {
            List <Payment> paymentList  = new List <Payment>();
            Dao            dao          = new Dao();
            string         sqlStatement = "SELECT PaymentID, EmployeeID, PayDate, TotalFee, Detail FROM Payment";

            System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
            if (reader == null)
            {
                return(null);
            }
            while (reader.Read())
            {
                int      pID = reader.GetInt32(0);
                int      eID = reader.GetInt32(1);
                DateTime pD  = reader.GetDateTime(2);
                decimal  tF  = reader.GetDecimal(3);
                string   de  = reader.GetString(4);
                paymentList.Add(new Payment(pID, eID, pD, Decimal.ToDouble(tF), de));
            }
            dao.Con.Close();
            return(paymentList);
        }
        public double GetByYear(int year)
        {
            double         all         = 0;
            List <Receipt> ReceiptList = new List <Receipt>();
            Dao            dao         = new Dao();

            try
            {
                string sqlStatement = "SELECT SUM(TotalFee) FROM Payment where FORMAT(PayDate,'yyyy')= '" + year + "'";
                System.Data.SqlClient.SqlDataReader reader = dao.Get(sqlStatement);
                if (reader.Read())
                {
                    all = (double)reader.GetDecimal(0);
                }
            }
            catch (Exception e)
            {
                return(0);
            }

            dao.Con.Close();
            return(all);
        }
Example #33
0
        public static void ReportBuilder(SqlDataReader dr, int cropYear, DateTime letterDate, DateTime deadlineDate, string logoUrl, System.IO.FileStream fs)
        {
            const string METHOD_NAME = "ReportBuilder";
            const float primaryLeading = 13.5F;
            const float primaryLeftIndent = 20F;
            string strLetterDate = letterDate.ToString("MMMM dd, yyyy");
            string strDeadlineDate = deadlineDate.ToString("MMMM dd, yyyy");
            string LdoBusinessName = "";
            string tmpStr = "";
            string tmpStr2 = "";

            Document document = null;
            PdfWriter writer = null;
            LandownerLetterEvent pgEvent = null;
            ColumnText ct = null;
            iTextSharp.text.Image imgLogo = null;

            try {

                while (dr.Read()) {

                    LdoBusinessName = dr["LdoBusinessName"].ToString();
                    string LdoAddressLine1 = dr["LdoAddressLine1"].ToString();
                    string LdoAddressLine2 = dr["LdoAddressLine2"].ToString();
                    string LdoCityStateZip = dr["LdoCityStateZip"].ToString();

                    if (document == null) {

                        // IF YOU CHANGE MARGINS, CHANGE YOUR TABLE LAYOUTS !!!
                        //  ***  US LETTER: 612 X 792  ***
                        document = new Document(PortraitPageSize.PgPageSize, PortraitPageSize.PgLeftMargin,
                            PortraitPageSize.PgRightMargin, PortraitPageSize.PgTopMargin, PortraitPageSize.PgBottomMargin);

                        imgLogo = PdfReports.GetImage(logoUrl, 127, 50, iTextSharp.text.Element.ALIGN_CENTER);

                        // we create a writer that listens to the document
                        // and directs a PDF-stream to a file
                        writer = PdfWriter.GetInstance(document, fs);

                        // Attach my override event handler(s)
                        pgEvent = new LandownerLetterEvent();
                        pgEvent.FillEvent(imgLogo, strLetterDate, LdoBusinessName, LdoAddressLine1, LdoAddressLine2, LdoCityStateZip);
                        writer.PageEvent = pgEvent;

                        // Open the document
                        document.Open();

                    } else {
                        pgEvent.FillEvent(imgLogo, strLetterDate, LdoBusinessName, LdoAddressLine1, LdoAddressLine2, LdoCityStateZip);
                        document.NewPage();
                    }

                    ct = pgEvent.GetColumnObject();

                    Paragraph p = new Paragraph(primaryLeading, "Your tenant, " + dr["GroBusinessName"].ToString() +
                    ", has indicated that the proceeds for sugar beets grown on your land in\n" +
                    cropYear.ToString() + " are to be split and you will be receiving " + dr.GetDecimal(dr.GetOrdinal("LdoSplitPercent")).ToString("##.0##") +
                    "% of the proceeds. Since Western Sugar Cooperative no\n" +
                    "longer requires signatures for the second payees, this letter has been sent for your verification.\n\n", _normalFont);

                    ct.AddElement(p);

                    p = new Paragraph(new Phrase(primaryLeading, "Your check will be made payable as follows:", _normalFont));
                    ct.AddElement(p);
                    p = new Paragraph(primaryLeading, dr["ldoPayeeDescription"].ToString(), _normalFont);
                    p.IndentationLeft = primaryLeftIndent;
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "If you have a lien on the beets, the lien holder’s name should be included above.\n\n" +
                    "In addition, the following options were selected by your tenant.", _normalFont);
                    ct.AddElement(p);

                    decimal ldoChemPct = dr.GetDecimal(dr.GetOrdinal("LdoChemicalSplitPct"));
                    if (dr.GetBoolean(dr.GetOrdinal("IsSplitChemical")) && ldoChemPct != 0) {
                        tmpStr = ldoChemPct.ToString("##.0##") + "%";
                    } else {
                        tmpStr = "No";
                    }

                    decimal ldoRetainPct = dr.GetDecimal(dr.GetOrdinal("LdoSplitPercent"));
                    if (dr.GetBoolean(dr.GetOrdinal("IsSplitRetain")) && ldoRetainPct != 0) {
                        tmpStr2 = ldoRetainPct.ToString("##.0##") + "% of the";
                    } else {
                        tmpStr2 = "No";
                    }

                    p = new Paragraph(primaryLeading, tmpStr2 + " Unit Retains on this contract will be deducted from your proceeds.\n" +
                    tmpStr + " seed & chemical receivables charged to this contract will be deducted from your proceeds.", _normalFont);
                    p.IndentationLeft = primaryLeftIndent;
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "If the above information is correct, no response is needed.\n\n", _normalFont);
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "If any of the above information is not correct, please contact your tenant’s agriculturist, " +
                    dr["AgriculturistName"].ToString() +
                    " at\n" + WSCIEMP.Common.CodeLib.FormatPhoneNumber2Display(dr["AgriculturistPhone"].ToString()) +
                    " by " + strDeadlineDate + ", or mail the corrections to:\n\n", _normalFont);
                    ct.AddElement(p);

                    p = new Paragraph(12F, "Western Sugar Cooperative\n" +
                    "Attn: Marty Smith\n" +
                    "1221 8th Avenue Unit E\n" +
                    "Greeley, CO  80631\n\n", _normalFont);
                    p.IndentationLeft = primaryLeftIndent;
                    ct.AddElement(p);

                    p = new Paragraph(primaryLeading, "Sincerely,\n\n" +
                    "Marty Smith\n" +
                    "Beet Accounting Manager\n\n" +
                    "Ref: " + dr["ContractNo"].ToString(), _normalFont);
                    ct.AddElement(p);

                    ct.Go(false);

                }
                // ======================================================
                // Close document
                // ======================================================
                if (document != null) {

                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                    document = null;
                }
                if (writer == null || String.IsNullOrEmpty(LdoBusinessName)) {
                    // Warn that we have no data.
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                    throw (warn);
                }
            }
            catch (Exception ex) {
                string errMsg = "document is null: " + (document == null).ToString() + "; " +
                    "writer is null: " + (writer == null).ToString();
                WSCIEMP.Common.CException wscex = new WSCIEMP.Common.CException(MOD_NAME + METHOD_NAME + errMsg, ex);
                throw (wscex);
            }
            finally {

                if (document != null) {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                }
                if (writer != null) {
                    writer.Close();
                }
            }
        }
Example #34
0
        protected static void PopulateEntity(SqlDataReader reader, ServerEntity entity, Dictionary<string, PropertyInfo> propMap)
        {
            for (int i = 0; i < reader.FieldCount; i++)
            {
                String columnName = reader.GetName(i);

                // Special case for when we select a range of values with an EntityBroker, just ignore
                if (columnName.Equals("RowNum"))
                    continue;

                if (columnName.Equals("GUID"))
                {
                    Guid uid = reader.GetGuid(i);
                    entity.SetKey(new ServerEntityKey(entity.Name, uid));
                    continue;
                }

                if (columnName.Equals(entity.Name) && columnName.Contains("Enum"))
                    columnName = "Enum";

                PropertyInfo prop;
				
                if (!propMap.TryGetValue(columnName, out prop))
                    throw new EntityNotFoundException("Unable to match column to property: " + columnName, null);

                if (columnName.Contains("GUID"))
                    columnName = columnName.Replace("GUID", "Key");

                if (reader.IsDBNull(i))
                {
                    prop.SetValue(entity, null, null);
                    continue;
                }

                Type propType = prop.PropertyType;
                if (propType == typeof(String))
                    prop.SetValue(entity, reader.GetString(i), null);
                else if (propType == typeof(ServerEntityKey))
                {
                    Guid uid = reader.GetGuid(i);
                    prop.SetValue(entity, new ServerEntityKey(columnName.Replace("Key", String.Empty), uid), null);
                }
                else if (propType == typeof(DateTime))
                    prop.SetValue(entity, reader.GetDateTime(i), null);
                else if (propType == typeof(DateTime?))
                {
                    if (reader.IsDBNull(i))
                    {
                        prop.SetValue(entity, null, null);
                    }
                    else
                    {
                        prop.SetValue(entity, reader.GetDateTime(i), null);
                    }
                    
                }
                else if (propType == typeof(bool))
                    prop.SetValue(entity, reader.GetBoolean(i), null);
                else if (propType == typeof(Int32))
                    prop.SetValue(entity, reader.GetInt32(i), null);
                else if (propType == typeof(Int16))
                    prop.SetValue(entity, reader.GetInt16(i), null);
                else if (propType == typeof(double))
                    prop.SetValue(entity, reader.GetDouble(i), null);
                else if (propType == typeof(Decimal))
                    prop.SetValue(entity, reader.GetDecimal(i), null);
                else if (propType == typeof(float))
                    prop.SetValue(entity, reader.GetFloat(i), null);
                else if (propType == typeof(XmlDocument))
                {
                    SqlXml xml = reader.GetSqlXml(i);
                    if (xml!=null && !xml.IsNull)
                    {
                        XmlReader xmlReader = xml.CreateReader();
                        if (xmlReader != null)
                        {
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.Load(xmlReader);
                            prop.SetValue(entity, xmlDoc, null);
                        }
                        else
                            prop.SetValue(entity, null, null);
                    }
                    else
                    {
                        prop.SetValue(entity, null, null);
                    }
                }
                else if (typeof(ServerEnum).IsAssignableFrom(propType))
                {
                    short enumVal = reader.GetInt16(i);
                    ConstructorInfo construct = prop.PropertyType.GetConstructor(new Type[0]);
                    ServerEnum val = (ServerEnum)construct.Invoke(null);
                    val.SetEnum(enumVal);
                    prop.SetValue(entity, val, null);
                }
                else
                    throw new EntityNotFoundException("Unsupported property type: " + propType, null);
            }
        }
        /// <summary>
        /// Creates a new instance of the ViewResultadoAuditoriaTipo class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static ViewResultadoAuditoriaTipoInfo MakeViewResultadoAuditoriaTipo(SqlDataReader dataReader)
        {
            ViewResultadoAuditoriaTipoInfo viewResultadoAuditoriaTipo = new ViewResultadoAuditoriaTipoInfo();

            if (dataReader.IsDBNull(AuditoriaId) == false)
                viewResultadoAuditoriaTipo.AuditoriaId = dataReader.GetInt32(AuditoriaId);
            if (dataReader.IsDBNull(AuditoriaTipoId) == false)
                viewResultadoAuditoriaTipo.AuditoriaTipoId = dataReader.GetInt32(AuditoriaTipoId);
            if (dataReader.IsDBNull(AuditoriaTipo) == false)
                viewResultadoAuditoriaTipo.AuditoriaTipo = dataReader.GetString(AuditoriaTipo);
            if (dataReader.IsDBNull(Periodo) == false)
                viewResultadoAuditoriaTipo.Periodo = dataReader.GetString(Periodo);
            if (dataReader.IsDBNull(Territorio) == false)
                viewResultadoAuditoriaTipo.Territorio = dataReader.GetString(Territorio);
            if (dataReader.IsDBNull(Grupo) == false)
                viewResultadoAuditoriaTipo.Grupo = dataReader.GetString(Grupo);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                viewResultadoAuditoriaTipo.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(PuntajeObtenido) == false)
                viewResultadoAuditoriaTipo.PuntajeObtenido = dataReader.GetDecimal(PuntajeObtenido);
            if (dataReader.IsDBNull(Cargo) == false)
                viewResultadoAuditoriaTipo.Cargo = dataReader.GetString(Cargo);
            if (dataReader.IsDBNull(ResultadoCargo) == false)
                viewResultadoAuditoriaTipo.ResultadoCargo = dataReader.GetDecimal(ResultadoCargo);
            if (dataReader.IsDBNull(Orden) == false)
                viewResultadoAuditoriaTipo.Orden = dataReader.GetByte(Orden);

            return viewResultadoAuditoriaTipo;
        }
        private static Registration MakeRegistration(SqlDataReader dataReader)
        {
            Registration registration = new Registration();

            if (dataReader.IsDBNull(0) == false) {
                registration.StudentID = dataReader.GetInt32(0);
            }
            if (dataReader.IsDBNull(1) == false) {
                registration.Name = dataReader.GetString(1);
            }
            if (dataReader.IsDBNull(2) == false) {
                registration.DateOfBirth = dataReader.GetDateTime(2);
            }
            if (dataReader.IsDBNull(3) == false) {
                registration.GradePointAvg = dataReader.GetDecimal(3);
            }
            if (dataReader.IsDBNull(4) == false) {
                registration.Active = dataReader.GetBoolean(4);
            }

            return registration;
        }
Example #37
0
 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
 {
     consulta = "select cantPersonas from GESTION_DE_GATOS.TipoHabitacion where descripcion = '" + comboBox2.SelectedItem + "'";
     resultado = Home.BD.comando(consulta);
     if (resultado.Read())
     {
         textBox1.Text = resultado.GetDecimal(0).ToString();
     }
     resultado.Close();
 }
Example #38
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (habitaciones == "" || cant == 0)
            {
                MessageBox.Show("Debe seleccionar por lo menos una habitacion");
                return;
            }
            if (string.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("Debe seleccionar 1 cliente");
                return;
            }
            bool estado = false;
            resultado = Home.BD.comando("select habilitado from GESTION_DE_GATOS.Cliente where idCli =" + textBox2.Text);
            if (resultado.Read())
            {
                estado = resultado.GetBoolean(0);
            }
            resultado.Close();
            if (estado == false)
            {
                MessageBox.Show("Cliente Inhabilitado para realizar reservas");
                return;
            }
            //AHORA LOS INSERTS
            string insert = "EXEC GESTION_DE_GATOS.InsertarReserva ";
            insert = insert + "'" + dateTimePicker1.Value.Date.ToString("yyyyMMdd HH:mm:ss") + "',";
            insert = insert + "'" + comboBox3.Text + "',";
            insert = insert + "'" + dateTimePicker2.Value.Date.ToString("yyyyMMdd HH:mm:ss") + "',";
            insert = insert + "'" + Home.fecha.Date.ToString("yyyyMMdd HH:mm:ss") + "',";
            insert = insert + Login.HomeLogin.idUsuario + ",";
            insert = insert + textBox2.Text + ",";
            double ab = (dateTimePicker2.Value.Date - dateTimePicker1.Value.Date).TotalDays;
            insert = insert + ab.ToString() + ",";
            insert = insert + Convert.ToInt32(total).ToString();

            decimal id = 0;
            resultado = Home.BD.comando(insert);
            if (resultado.Read() == true)
            {
                id = resultado.GetDecimal(0);
            }
            resultado.Close();
            if (id == 0)
            {

                MessageBox.Show("No se pudo generar la reserva");
                button1_Click(null, null);
                return;
            }

            string comand = "EXEC GESTION_DE_GATOS.InsertarReservaXHabitacion " + id.ToString() + ",";

            string[] strArr = null;
            int count = 0;
            char[] splitchar = { ',' };
            comand = "EXEC GESTION_DE_GATOS.InsertarReservaXHabitacion " + id.ToString() + ",";

            if (cant > 1)
            {
                strArr = null;
                count = 0;
                strArr = habitaciones.Split(splitchar);

                for (count = 0; count <= strArr.Length - 1; count++)
                {
                    resultado = Home.BD.comando(comand + strArr[count]);

                    if (!resultado.Read())
                    {

                        MessageBox.Show("No se pudo insertar la habitacion a la reserva,error en el read");
                        resultado.Close();
                        return;
                    }
                    decimal a = resultado.GetDecimal(0);
                    if (a == 0)
                    {
                        MessageBox.Show("No se pudo insertar la habitacion a la reserva, no cumplio el unique");
                        resultado.Close();
                        return;
                    }
                    resultado.Close();
                }
            }
            else
            {
                resultado = Home.BD.comando(comand + habitaciones);
                if (!resultado.Read())
                {

                    MessageBox.Show("No se pudo insertar la habitacion a la reserva,error en el read");
                    resultado.Close();
                    return;
                }
                decimal b = resultado.GetDecimal(0);
                if (b == 0)
                {
                    MessageBox.Show("No se pudo insertar la habitacion a la reserva, no cumplio el unique");
                    resultado.Close();
                    return;
                }
                resultado.Close();

            }
            MessageBox.Show("Reserva generada correctamente, su numero de reserva es: "+id.ToString());
            this.Close();
        }
Example #39
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {

                string numero = dataGridView1.CurrentRow.Cells[1].Value.ToString();
                string piso = dataGridView1.CurrentRow.Cells[2].Value.ToString();
                string tipo = dataGridView1.CurrentRow.Cells[4].Value.ToString();
                string estado = dataGridView1.CurrentRow.Cells[6].Value.ToString();
                if (estado == "False")
                {
                    MessageBox.Show("No se puede eliminar porque ya esta en estado inactivo");
                    return;
                }

                if (MessageBox.Show("Estas seguro que desea eliminar?", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    decimal id = 0;
                    decimal tipoT = 0;
                    consulta = "select codigo from GESTION_DE_GATOS.TipoHabitacion where descripcion = '" + tipo + "'";
                    resultado = Home.BD.comando(consulta);
                    if (resultado.Read())
                    {
                        tipoT = resultado.GetDecimal(0);
                    }
                    resultado.Close();
                    consulta = "select idHabitacion from GESTION_DE_GATOS.Habitacion where numero = " + numero + " and piso = " + piso + " and hotel = " + Login.HomeLogin.hotel + " and tipo = " + tipoT;
                    resultado = Home.BD.comando(consulta);
                    if (resultado.Read())
                    {
                        id = resultado.GetDecimal(0);
                    }
                    resultado.Close();

                    consulta = "update GESTION_DE_GATOS.Habitacion set estado=0 where idHabitacion = " + id;

                    resultado = Home.BD.comando(consulta);
                    if (resultado.Read() == true)
                    {
                    }
                    resultado.Close();
                }
                Baja_Load(null, null);

            }
        }
Example #40
0
        public TList_Plantio Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo)
        {
            TList_Plantio lista = new TList_Plantio();

            System.Data.SqlClient.SqlDataReader reader = null;
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            try
            {
                reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo));
                while (reader.Read())
                {
                    TRegistro_Plantio reg = new TRegistro_Plantio();

                    if (!reader.IsDBNull(reader.GetOrdinal("Id_Plantio")))
                    {
                        reg.Id_plantio = reader.GetDecimal(reader.GetOrdinal("Id_Plantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("id_cultura")))
                    {
                        reg.Id_cultura = reader.GetDecimal(reader.GetOrdinal("id_cultura"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ds_cultura")))
                    {
                        reg.Ds_cultura = reader.GetString(reader.GetOrdinal("ds_cultura"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("sigla_unidade")))
                    {
                        reg.Sigla_unidade = reader.GetString(reader.GetOrdinal("sigla_unidade"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("cd_produto")))
                    {
                        reg.Cd_produto = reader.GetString(reader.GetOrdinal("cd_produto"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ds_produto")))
                    {
                        reg.Ds_produto = reader.GetString(reader.GetOrdinal("ds_produto"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Observacao")))
                    {
                        reg.Ds_observacao = reader.GetString(reader.GetOrdinal("DS_Observacao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("AnoSafra")))
                    {
                        reg.Anosafra = reader.GetString(reader.GetOrdinal("AnoSafra"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Safra")))
                    {
                        reg.Ds_safra = reader.GetString(reader.GetOrdinal("DS_Safra"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DT_IniPlantio")))
                    {
                        reg.Dt_iniplantio = reader.GetDateTime(reader.GetOrdinal("DT_IniPlantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DT_FinPlantio")))
                    {
                        reg.Dt_finplantio = reader.GetDateTime(reader.GetOrdinal("DT_FinPlantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("QT_SementesPorMetro")))
                    {
                        reg.Qt_sementespormetro = reader.GetDecimal(reader.GetOrdinal("QT_SementesPorMetro"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("EspacoSemente")))
                    {
                        reg.Espacosemente = reader.GetDecimal(reader.GetOrdinal("EspacoSemente"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Example #41
0
        /// <summary>
        /// Creates a new instance of the AuditoriaResultado class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static AuditoriaResultadoInfo MakeAuditoriaResultado(SqlDataReader dataReader)
        {
            AuditoriaResultadoInfo auditoriaResultado = new AuditoriaResultadoInfo();

            if (dataReader.IsDBNull(AuditoriaResultadoId) == false)
                auditoriaResultado.AuditoriaResultadoId = dataReader.GetInt32(AuditoriaResultadoId);
            if (dataReader.IsDBNull(AuditoriaId) == false)
                auditoriaResultado.AuditoriaId = dataReader.GetInt32(AuditoriaId);
            if (dataReader.IsDBNull(AuditoriaPuntoId) == false)
                auditoriaResultado.AuditoriaPuntoId = dataReader.GetInt32(AuditoriaPuntoId);
            if (dataReader.IsDBNull(AuditoriaControlId) == false)
                auditoriaResultado.AuditoriaControlId = dataReader.GetInt32(AuditoriaControlId);
            if (dataReader.IsDBNull(PuntajeRequerido) == false)
                auditoriaResultado.PuntajeRequerido = dataReader.GetDecimal(PuntajeRequerido);
            if (dataReader.IsDBNull(PuntajeObtenido) == false)
                auditoriaResultado.PuntajeObtenido = dataReader.GetDecimal(PuntajeObtenido);
            if (dataReader.IsDBNull(ResultadoPunto) == false)
                auditoriaResultado.ResultadoPunto = dataReader.GetDecimal(ResultadoPunto);
            if (dataReader.IsDBNull(EsNoConformidad) == false)
                auditoriaResultado.EsNoConformidad = dataReader.GetBoolean(EsNoConformidad);
            if (dataReader.IsDBNull(AuditoriaCausaRaizId) == false)
                auditoriaResultado.AuditoriaCausaRaizId = dataReader.GetInt32(AuditoriaCausaRaizId);
            if (dataReader.IsDBNull(Observacion) == false)
                auditoriaResultado.Observacion = dataReader.GetString(Observacion);

            return auditoriaResultado;
        }
Example #42
0
        public TList_Plantio_X_Talhoes Select(Utils.TpBusca[] vBusca, Int32 vTop, string vNm_Campo)
        {
            TList_Plantio_X_Talhoes lista = new TList_Plantio_X_Talhoes();

            System.Data.SqlClient.SqlDataReader reader = null;
            bool podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = this.CriarBanco_Dados(false);
            }
            try
            {
                reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo));
                while (reader.Read())
                {
                    TRegistro_Plantio_X_Talhoes reg = new TRegistro_Plantio_X_Talhoes();

                    if (!reader.IsDBNull(reader.GetOrdinal("Id_Plantio")))
                    {
                        reg.Id_plantio = reader.GetDecimal(reader.GetOrdinal("Id_Plantio"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ID_Talhao")))
                    {
                        reg.Id_talhao = reader.GetDecimal(reader.GetOrdinal("ID_Talhao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Talhao")))
                    {
                        reg.Ds_talhao = reader.GetString(reader.GetOrdinal("DS_Talhao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("area_talhao")))
                    {
                        reg.Area_talhao = reader.GetDecimal(reader.GetOrdinal("area_talhao"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ID_Area")))
                    {
                        reg.Id_area = reader.GetDecimal(reader.GetOrdinal("ID_Area"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("DS_Area")))
                    {
                        reg.Ds_area = reader.GetString(reader.GetOrdinal("DS_Area"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("CD_Fazenda")))
                    {
                        reg.Cd_fazenda = reader.GetString(reader.GetOrdinal("CD_Fazenda"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("NM_Fazenda")))
                    {
                        reg.Nm_fazenda = reader.GetString(reader.GetOrdinal("NM_Fazenda"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("sigla_unidade")))
                    {
                        reg.Sigla_unidade = reader.GetString(reader.GetOrdinal("sigla_unidade"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("Area_Plantada")))
                    {
                        reg.Area_plantada = reader.GetDecimal(reader.GetOrdinal("Area_Plantada"));
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("producao_prevista")))
                    {
                        reg.Producao_prevista = reader.GetDecimal(reader.GetOrdinal("producao_prevista"));
                    }

                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    this.deletarBanco_Dados();
                }
            }
            return(lista);
        }
Example #43
0
        private bool IsValidateVIP()
        {
            bool vip = false;

            string sql = @"
SELECT  Salute,FullName,WorkTel,HomeTel,ISNULL(PagerTel,''),Email,Birthday,[Profile],Remarks,
        DateOfRegister,ExpiryDate,VipNumber,CodeNumber,LoyaltyNum,
        SUM(TxCount) AS AccumulativeTranscations, SUM(TxAmount) AS AccumulativeSpending,
        CONVERT(VARCHAR(10),TxDate,126) AS TxDate
FROM (SELECT Salute,FullName,WorkTel,HomeTel,PagerTel,Email,CAST(Birthday AS DateTime) AS Birthday,[Profile],Remarks,
            CAST(DateOfRegister AS DateTime) AS DateOfRegister,ExpiryDate,HKID,VipNumber,CodeNumber,LoyaltyNum,
            MemberNumber, TxDate,TxNumber, TxType, 1 AS TxCount, SUM((CASE TxType WHEN 'CAS' THEN 1 ELSE -1 END) * Amount) AS TxAmount 
      FROM dbo.vwVIPSalesAnalysis
      GROUP BY Salute,FullName,WorkTel,HomeTel,PagerTel,Email,Birthday,[Profile],Remarks,
             DateOfRegister,ExpiryDate,HKID,VipNumber,CodeNumber,LoyaltyNum,MemberNumber,TxDate,TxNumber,TxType) lst ";

            string whereCaluse = string.Empty;

            if (this.txtNumber.Text.Trim().Length > 0)
            {
                whereCaluse = " lst.MemberNumber ='" + this.txtNumber.Text.Trim() + "'";
            }

            if (this.txtHKID.Text.Trim().Length > 0)
            {
                whereCaluse += (whereCaluse.Length > 0 ? " OR " : "") + " lst.HKID ='" + this.txtHKID.Text.Trim() + "'";
            }

            if (this.txtLoyalty.Text.Trim().Length > 0)
            {
                whereCaluse += (whereCaluse.Length > 0 ? " OR " : "") + " lst.LoyaltyNum ='" + this.txtLoyalty.Text.Trim() + "'";
            }

            if (this.txtCode.Text.Trim().Length > 0)
            {
                whereCaluse += (whereCaluse.Length > 0 ? " OR " : "") + " lst.CodeNumber ='" + this.txtCode.Text.Trim() + "'";
            }

            whereCaluse += " AND (CONVERT(NVARCHAR(10),TxDate,126) BETWEEN '" + this.dtDateFrom.Value.ToString("yyyy-MM-dd")
                           + "' AND '" + this.dtDateTo.Value.ToString("yyyy-MM-dd") + "')";

            whereCaluse += "GROUP BY CONVERT(VARCHAR(10),TxDate,126),Salute,FullName,WorkTel,HomeTel,PagerTel,Email,Birthday,[Profile],Remarks,DateOfRegister,ExpiryDate,VipNumber,CodeNumber,LoyaltyNum";

            sql = sql + string.Format(" WHERE {0}", whereCaluse);

            SqlCommand cmd = new SqlCommand();

            cmd.CommandText    = sql;
            cmd.CommandTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["CommandTimedOut"]);
            cmd.CommandType    = CommandType.Text;

            using (System.Data.SqlClient.SqlDataReader reader = SqlHelper.Default.ExecuteReader(cmd))
            {
                decimal spending = 0;
                int     trnNo    = 0;
                while (reader.Read())
                {
                    vip = true;

                    txtSalute.Text         = ": " + reader.GetString(0);
                    txtVipName.Text        = ": " + reader.GetString(1);
                    txtContactNumber.Text  = ": " + reader.GetString(2) + "\t";
                    txtContactNumber.Text += "/" + reader.GetString(3) + "\t";
                    txtContactNumber.Text += "/" + reader.GetString(4);
                    txtEmail.Text          = ": " + reader.GetString(5);
                    txtBirthday.Text       = ": " + reader.GetDateTime(6).ToString("dd/MM/yyyy").Replace("01/01/1900", "");
                    txtProfile.Text        = ": " + reader.GetString(7);
                    txtRemarks.Text        = ": " + reader.GetString(8);
                    txtRegDate.Text        = ": " + reader.GetDateTime(9).ToString("dd/MM/yyyy").Replace("01/01/1900", "");
                    txtExpiryDate.Text     = ": " + reader.GetDateTime(10).ToString("dd/MM/yyyy").Replace("01/01/1900", "");
                    txtTypeAndNumber.Text  = ": " + "EXVIP \t" + reader.GetString(11) + "\t";
                    txtTypeAndNumber.Text += "/" + reader.GetString(12) + "\t";
                    txtTypeAndNumber.Text += "/" + reader.GetString(13);

                    spending += reader.GetDecimal(15);
                    txtAccumulativeSpending.Text = ": " + spending.ToString("C");

                    trnNo += reader.GetInt32(14);
                    txtAccumulativeTransactionNumber.Text = ": " + trnNo.ToString("n0");
                }
            }

            return(vip);
        }
Example #44
0
 /// <summary>
 /// Gets the user from data reader.
 /// </summary>
 /// <param name="user_list">The user_list.</param>
 /// <returns>User from database</returns>
 private static User GetUserFromDataReader( SqlDataReader user_list )
 {
     return new User(
         user_list.GetString( 0 ),
         user_list.GetString( 1 ),
         user_list.GetInt32( 2 ),
         user_list.GetInt32( 3 ),
         user_list.GetString( 4 ),
         user_list.GetBoolean( 5 ),
         user_list.GetDateTime( 6 ),
         user_list.GetString( 7 ),
         user_list.GetBoolean( 8 ),
         user_list.GetBoolean( 9 ),
         user_list.GetDateTime( 10 ),
         user_list.GetGuid( 11 ),
         user_list.GetBoolean( 12 ),
         user_list.GetBoolean( 13 ),
         user_list.GetInt32( 14 ),
         user_list.GetDecimal( 15 ),
         user_list.GetBoolean( 16 ),
         user_list.GetString( 17 ),
         user_list.GetDecimal( 18 ),
         user_list.GetString( 19 ),
         user_list.GetString( 20 ),
         user_list.GetString( 21 ),
         user_list.GetString( 22 ),
         user_list.GetString( 23 ),
         user_list.GetString( 24 ),
         user_list.GetString( 25 ),
         user_list.GetString( 26 ),
         user_list.GetString( 27 ),
         user_list.GetString( 28 ),
         user_list.GetString( 39 ),
         user_list.GetString( 30 ),
         user_list.GetString( 31 ),
         user_list.GetInt32( 32 ),
         user_list.GetBoolean( 33 ),
         user_list.GetInt32( 34 ),
         user_list.GetString( 35 ),
         user_list.GetBoolean( 36 ),
         user_list.GetBoolean( 37 ),
         user_list.GetString( 38 ),
         user_list.GetString( 39 ),
         user_list.GetString( 40 ),
         user_list.GetString( 41 ),
         user_list.GetString( 42 ),
         user_list.GetInt32( 43 ),
         user_list.GetString( 44 ),
         user_list.GetBoolean( 45 ),
         user_list.GetBoolean( 46 ),
         user_list.GetInt32( 47 ),
         user_list.GetInt32( 48 ),
         user_list.GetString( 49 ),
         user_list.GetInt32( 50 ),
         user_list.GetString( 51 )
     );
 }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                if(Convert.ToInt32(comboBox1.SelectedIndex) == -1)
                {
                    MessageBox.Show("Debe seleccionar una habitacion");
                    return;

                }
                int index = dataGridView1.CurrentRow.Index;
                consulta = "select count(*) from GESTION_DE_GATOS.ClienteXEstadia where estadia = "+estadia +" and habitacion = "+comboBox1.Text;
                resultado = Home.BD.comando(consulta);
                resultado.Read();
                int aux = resultado.GetInt32(0);
                resultado.Close();
                if(aux < Convert.ToInt32(textBox4.Text))
                {
                    consulta = "EXEC GESTION_DE_GATOS.ModificarClienteXEstadia "+comboBox1.Text+ ","+dataGridView1.CurrentRow.Cells[1].Value.ToString()+","+estadia;
                    resultado = Home.BD.comando(consulta);
                    resultado.Read();
                    if(resultado.GetDecimal(0)==1)
                    {
                        MessageBox.Show("El cliente se agrego correctamente");
                        tabla.Rows.RemoveAt(index);
                        dataGridView1.DataSource = tabla;
                        resultado.Close();
                    }
                    else
                    {
                        resultado.Close();
                        MessageBox.Show("El cliente ya estaba agregado a esa estadia");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Esa habitacion ya esta llena");
                }
            }
        }
Example #46
0
        Patient getNextPatient(SqlDataReader reader)
        {
            Patient p = new Patient();
            p.LocalSiteId = (reader.GetInt16(reader.GetOrdinal("sitecode"))).ToString();

            Decimal d = Convert.ToDecimal(reader.GetDecimal(reader.GetOrdinal("localPid")));
            if ((d - Math.Floor(d)) > 0)
            {
                p.LocalPid = (d).ToString();
            }
            else
            {
                p.LocalPid = (Convert.ToInt64(d)).ToString();
            }
            p.Name = new PersonName(reader.GetString(reader.GetOrdinal("name")));
            p.SSN = new SocSecNum(reader.GetString(reader.GetOrdinal("ssn")));

            if (!reader.IsDBNull(reader.GetOrdinal("gender")))
            {
                p.Gender = reader.GetBoolean(reader.GetOrdinal("gender")) ? "M" : "F"; // 1 or true == male, 0 or false == female
            }
            else
            {
                p.Gender = "";
            }
            if (!reader.IsDBNull(reader.GetOrdinal("vistaDOB")))
            {
                p.DOB = reader.GetString(reader.GetOrdinal("vistaDOB"));
            }
            p.MpiPid = (reader.GetInt32(reader.GetOrdinal("icn"))).ToString();
            p.MpiChecksum = (reader.GetInt32(reader.GetOrdinal("icnx"))).ToString();

            p.Demographics = new Dictionary<string, DemographicSet>();
            DemographicSet demogs = new DemographicSet();
            demogs.PhoneNumbers = new List<PhoneNum>();
            demogs.EmailAddresses = new List<EmailAddress>();
            demogs.StreetAddresses = new List<Address>();

            if (!reader.IsDBNull(reader.GetOrdinal("homePhone")))
            {
                demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("homePhone"))));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("workPhone")))
            {
                demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("workPhone"))));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("cellPhone")))
            {
                demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("cellPhone"))));
            }

            if (!reader.IsDBNull(reader.GetOrdinal("emailAddress")))
            {
                demogs.EmailAddresses.Add(new EmailAddress(reader.GetString(reader.GetOrdinal("emailAddress"))));
            }

            Address address = new Address();
            if (!reader.IsDBNull(reader.GetOrdinal("addressLine1")))
            {
                address.Street1 = reader.GetString(reader.GetOrdinal("addressLine1"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("addressLine2")))
            {
                address.Street2 = reader.GetString(reader.GetOrdinal("addressLine2"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("addressLine3")))
            {
                address.Street3 = reader.GetString(reader.GetOrdinal("addressLine3"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("city")))
            {
                address.City = reader.GetString(reader.GetOrdinal("city"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("county")))
            {
                address.County = reader.GetString(reader.GetOrdinal("county"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("state")))
            {
                address.State = reader.GetString(reader.GetOrdinal("state"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("zipcode")))
            {
                address.Zipcode = reader.GetString(reader.GetOrdinal("zipcode"));
            }
            demogs.StreetAddresses.Add(address);

            p.Demographics.Add(p.LocalSiteId, demogs);

            return p;
        }
Example #47
0
    protected void scholarshipTable_Load(object sender, EventArgs e)
    {
        int    countTotalScholarships = 0;
        String connectionString       = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;

        System.Data.SqlClient.SqlConnection sc = new System.Data.SqlClient.SqlConnection(connectionString);
        sc.Open();

        System.Data.SqlClient.SqlCommand countScholarships = new System.Data.SqlClient.SqlCommand();
        countScholarships.CommandText = "SELECT count(SchoolApproval.OpportunityEntityID) FROM OpportunityEntity INNER JOIN SchoolApproval ON OpportunityEntity.OpportunityEntityID = SchoolApproval.OpportunityEntityID where OpportunityEntity.OpportunityType = 'SCHOL' and schoolApproval.approvedflag = 'Y' and SchoolApproval.SchoolEntityID = " + Session["schoolID"];
        countScholarships.Connection  = sc;

        System.Data.SqlClient.SqlDataReader reader = countScholarships.ExecuteReader();

        while (reader.Read())
        {
            countTotalScholarships = reader.GetInt32(0);
        }

        sc.Close();



        sc.Open();
        System.Data.SqlClient.SqlCommand pullScholarshipInfo = new System.Data.SqlClient.SqlCommand();
        pullScholarshipInfo.CommandText = "SELECT Organization.OrganizationName, Scholarship.ScholarshipName, Scholarship.ScholarshipDescription, Organization.Image, Organization.ExternalLink, Scholarship.ScholarshipMin, Scholarship.ScholarshipMax, Scholarship.ScholarshipDueDate, Scholarship.ScholarshipID FROM SchoolApproval INNER JOIN OpportunityEntity ON SchoolApproval.OpportunityEntityID = OpportunityEntity.OpportunityEntityID INNER JOIN Scholarship" +
                                          " ON OpportunityEntity.OpportunityEntityID = Scholarship.ScholarshipID INNER JOIN Organization ON Scholarship.OrganizationID = Organization.OrganizationEntityID " +
                                          "where SchoolApproval.ApprovedFlag = 'Y' and OpportunityEntity.OpportunityType = 'SCHOL' and SchoolApproval.SchoolEntityID = " + Session["schoolID"];
        pullScholarshipInfo.Connection = sc;



        reader = pullScholarshipInfo.ExecuteReader();

        {
            List <Scholarship> scholarships = new List <Scholarship>();

            String   orgName;
            String   scholarshipName;
            String   scholarshipDescription;
            String   image;
            String   link;
            decimal  scholarshipMin;
            decimal  scholarshipMax;
            DateTime deadline;
            int      scholarshipID;

            int x = 0;
            while (reader.Read())
            {
                orgName                = reader.GetString(0);
                scholarshipName        = reader.GetString(1);
                scholarshipDescription = reader.GetString(2);
                image          = reader.GetString(3);
                link           = reader.GetString(4);
                scholarshipMin = reader.GetDecimal(5);
                scholarshipMax = reader.GetDecimal(6);
                deadline       = reader.GetDateTime(7);
                scholarshipID  = reader.GetInt32(8);

                x++;

                Scholarship scholarship = new Scholarship(scholarshipID, scholarshipName, scholarshipDescription,
                                                          scholarshipMin, scholarshipMax, image, link, deadline, orgName);

                scholarships.Add(scholarship);
            }
            sc.Close();
            double doubleRows = countTotalScholarships / 3.0;
            int    numrows    = (int)(Math.Ceiling(doubleRows));
            int    numcells   = 3;
            int    count      = 0;
            for (int j = 0; j < numrows; j++)
            {
                TableRow r = new TableRow();


                for (int i = 0; i < numcells; i++)
                {
                    if (count == countTotalScholarships)
                    {
                        break;
                    }
                    TableCell  c            = new TableCell();
                    LinkButton referralLink = new LinkButton();
                    referralLink.ID = "referralLink" + count;

                    referralLink.CssClass = "far fa-paper-plane";

                    referralLink.CommandArgument += scholarships[count].getScholarshipID();
                    referralLink.Command         += new CommandEventHandler(this.referralButton_Click);

                    c.Controls.Add(new LiteralControl("<div class='image-flip' ontouchstart='this.classList.toggle('hover');'>"));
                    c.Controls.Add(new LiteralControl("<div class='mainflip'>"));
                    c.Controls.Add(new LiteralControl("<div class='frontside'>"));
                    c.Controls.Add(new LiteralControl("<div class='card'>"));
                    c.Controls.Add(new LiteralControl("<div class='card-body text-center'>"));
                    c.Controls.Add(new LiteralControl("<p><img class='img-fluid' src='" + scholarships[count].getImage() + "' alt='card image'></p>"));
                    c.Controls.Add(new LiteralControl("<h4 class='card-title'>" + scholarships[count].getScholarshipName() + "</h4>"));
                    c.Controls.Add(new LiteralControl("<p class='card-text'>" + scholarships[count].getOrgName() + "</p>"));
                    c.Controls.Add(new LiteralControl("<a href='#' class='btn btn-primary btn-sm'><i class='fa fa-plus'></i></a>"));
                    c.Controls.Add(new LiteralControl("</div>"));
                    c.Controls.Add(new LiteralControl("</div>"));
                    c.Controls.Add(new LiteralControl("</div>"));

                    c.Controls.Add(new LiteralControl("<div class='backside'>"));
                    c.Controls.Add(new LiteralControl("<div class='card'>"));
                    c.Controls.Add(new LiteralControl("<div class='card-body text-center'>"));
                    c.Controls.Add(new LiteralControl("<h4 class='card-title'>" + scholarships[count].getScholarshipName() + "</h4>"));
                    c.Controls.Add(new LiteralControl("<p class='card-text'>" + scholarships[count].getScholarshipName() + "</p>"));
                    c.Controls.Add(new LiteralControl("<p class='card-text'>" + scholarships[count].getScholarshipDescription() + "</p>"));
                    c.Controls.Add(new LiteralControl("<p class='card-text'> Minimum: " + scholarships[count].getScholarshipMin().ToString() + "</p>"));
                    c.Controls.Add(new LiteralControl("<p class='card-text'> Maximum: " + scholarships[count].getScholarshipMax().ToString() + "</p>"));
                    c.Controls.Add(new LiteralControl("<p class='card-text'> Deadline: " + scholarships[count].getScholarshipDueDate().ToString() + "</p>"));
                    c.Controls.Add(new LiteralControl("<ul class='list-inline'>"));
                    c.Controls.Add(new LiteralControl("<li class='list-inline-item'>"));
                    c.Controls.Add(new LiteralControl("<a class='social-icon text-xs-center' target='_blank' href='" + scholarships[count].getLink() + "'>"));
                    c.Controls.Add(new LiteralControl("<i class='fas fa-external-link-alt'></i>&nbsp;&nbsp;&nbsp;"));
                    c.Controls.Add(referralLink);
                    c.Controls.Add(new LiteralControl("</a>"));
                    c.Controls.Add(new LiteralControl("</li>"));
                    c.Controls.Add(new LiteralControl("</ul>"));
                    c.Controls.Add(new LiteralControl("</div>"));
                    c.Controls.Add(new LiteralControl("</div>"));
                    c.Controls.Add(new LiteralControl("</div>"));
                    c.Controls.Add(new LiteralControl("</div>"));
                    c.Controls.Add(new LiteralControl("</div>"));
                    c.Style.Add("width", "33%");
                    r.Cells.Add(c);
                    count++;
                }
                scholarshipTable.Rows.Add(r);
            }
        }
    }