示例#1
0
        public static void search(Habitacion room, DataGridView dgvRoom)
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = "PUNTO_ZIP.sp_habitacion_search";

            command.Parameters.Add(new SqlParameter("@p_habitacion_id", SqlDbType.Int));
            if (room.id == 0)
            {
                command.Parameters["@p_habitacion_id"].Value = null;
            }
            else
            {
                command.Parameters["@p_habitacion_id"].Value = room.id;
            }

            command.Parameters.Add(new SqlParameter("@p_habitacion_hotel_id", SqlDbType.Int));
            if (room.hotel == 0)
            {
                command.Parameters["@p_habitacion_hotel_id"].Value = null;
            }
            else
            {
                command.Parameters["@p_habitacion_hotel_id"].Value = room.hotel;
            }

            command.Parameters.Add(new SqlParameter("@p_habitacion_floor", SqlDbType.Int));
            if (room.floor == 0)
            {
                command.Parameters["@p_habitacion_floor"].Value = null;
            }
            else
            {
                command.Parameters["@p_habitacion_floor"].Value = room.floor;
            }

            command.Parameters.Add(new SqlParameter("@p_habitacion_type", SqlDbType.Int));
            if (room.type == 0)
            {
                command.Parameters["@p_habitacion_type"].Value = null;
            }
            else
            {
                command.Parameters["@p_habitacion_type"].Value = room.type;
            }

            command.Parameters.Add(new SqlParameter("@p_habitacion_front", SqlDbType.Int));
            if (room.front == 0)
            {
                command.Parameters["@p_habitacion_front"].Value = null;
            }
            else
            {
                command.Parameters["@p_habitacion_front"].Value = room.front;
            }

            command.Parameters.Add(new SqlParameter("@p_habitacion_comodity", SqlDbType.VarChar, 255));
            if (room.comodity == String.Empty)
            {
                command.Parameters["@p_habitacion_comodity"].Value = null;
            }
            else
            {
                command.Parameters["@p_habitacion_comodity"].Value = room.comodity;
            }

            command.Parameters.Add(new SqlParameter("@p_user_name", SqlDbType.VarChar, 20));
            command.Parameters["@p_user_name"].Value = VarGlobal.usuario.id;

            DataGridViewHelper.fill(command, dgvRoom);
        }
        private Habitacion getDataToSearch()
        {
            Habitacion room = new Habitacion();

            if (comboBoxHotel.SelectedValue.ToString() != String.Empty)
            {
                room.hotel = Convert.ToInt32(comboBoxHotel.SelectedValue.ToString());
            }
            else
            {
                room.hotel = 0;
            }

            if (textBoxRoom.Text != String.Empty)
            {
                Boolean isValid;
                isValid = Validaciones.validAndRequiredInt32MoreThan0(textBoxRoom.Text, "El numeo de habitacion debe ser numerico");
                if (isValid)
                {
                    room.id = Convert.ToInt32(textBoxRoom.Text);
                }
                else
                {
                    room.id = 0;
                }
            }
            else
            {
                room.id = 0;
            }

            if (textBoxFloor.Text != String.Empty)
            {
                Boolean isValid;
                isValid = Validaciones.validAndRequiredInt32MoreThan0(textBoxFloor.Text, "El numeo de piso debe ser numerico");
                if (isValid)
                {
                    room.floor = Convert.ToInt32(textBoxFloor.Text);
                }
                else
                {
                    room.floor = 0;
                }
            }
            else
            {
                room.floor = 0;
            }

            if (comboBoxFront.SelectedValue.ToString() != String.Empty)
            {
                room.front = Convert.ToInt32(comboBoxFront.SelectedValue.ToString());
            }
            else
            {
                room.front = 0;
            }

            if (comboBoxType.SelectedValue.ToString() != String.Empty)
            {
                room.type = Convert.ToInt32(comboBoxType.SelectedValue.ToString());
            }
            else
            {
                room.type = 0;
            }

            room.comodity = textBoxDescription.Text;

            return(room);
        }
示例#3
0
        private Habitacion getDataFromForm()
        {
            Habitacion room = new Habitacion();

            Boolean isValid;

            isValid = Validaciones.validAndRequiredInt32MoreThanEqual0(textBoxFloor.Text, "El piso debe ser numerico mayor o igual a 0");
            if (isValid)
            {
                room.floor = Convert.ToInt32(textBoxFloor.Text);
            }
            else
            {
                return(null);
            }

            isValid = Validaciones.validAndRequiredInt32MoreThanEqual0(textBoxRoom.Text, "El nro de habitacion debe ser numerico mayor o igual a 0");
            if (isValid)
            {
                room.id = Convert.ToInt32(textBoxRoom.Text);
            }
            else
            {
                return(null);
            }

            isValid = Validaciones.requiredString(comboBoxHotel.SelectedValue.ToString(), "Debe seleccionar un hotel");
            if (isValid)
            {
                room.hotel     = Convert.ToInt32(comboBoxHotel.SelectedValue.ToString());
                room.hotelName = comboBoxHotel.SelectedText;
            }
            else
            {
                return(null);
            }

            isValid = Validaciones.requiredString(comboBoxType.SelectedValue.ToString(), "Debe seleccionar un tipo de habitacion");
            if (isValid)
            {
                room.type            = Convert.ToInt32(comboBoxType.SelectedValue.ToString());
                room.typeDescription = comboBoxType.SelectedText;
            }
            else
            {
                return(null);
            }

            isValid = Validaciones.requiredString(comboBoxFront.SelectedValue.ToString(), "Debe seleccionar el frente");
            if (isValid)
            {
                room.front            = Convert.ToInt32(comboBoxFront.SelectedValue.ToString());
                room.frontDescription = comboBoxFront.SelectedText;
            }
            else
            {
                return(null);
            }

            isValid = Validaciones.requiredString(textBoxComodity.Text, "Debe agregar comodidades a la habitacion");
            if (isValid)
            {
                room.comodity = textBoxComodity.Text;
            }
            else
            {
                return(null);
            }

            return(room);
        }
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            Habitacion room = this.getDataToSearch();

            HabitacionHelper.search(room, dgvRoom);
        }