Exemplo n.º 1
0
        private void btComprar_Click(object sender, EventArgs e)
        {
            if (dgv_cabina.Rows.Count > 0)
            {
                DataRow         row     = this.cabinasCompradas.NewRow();
                DataGridViewRow dataRow = dgv_cabina.Rows[(dgv_cabina.CurrentRow.Index)];
                int             idViaje = ABMCabina.ObtenerIDViaje(Convert.ToInt32(txt_reserva.Text.Trim()));
                int             idTipo  = ABMCabina.ObtenerIDTipo(dataRow.Cells["TipoCabina"].Value.ToString());

                row["cab_via_id"]   = idViaje;
                row["cab_precio"]   = dataRow.Cells["Precio"].Value.ToString();
                row["cab_nro"]      = dataRow.Cells["Numero"].Value.ToString();
                row["cab_piso"]     = dataRow.Cells["Piso"].Value.ToString();
                row["cab_tcab_id"]  = idTipo;
                row["pue_id_hasta"] = ABMCabina.ObtenerIDPuerto(dataRow.Cells["PuertoHasta"].Value.ToString());
                this.cabinasCompradas.Rows.Add(row);

                dgv_cabina.Enabled        = false;
                btCabDisponibles.Enabled  = false;
                btComprarReservar.Enabled = false;

                //Medio de pago
                lb_mp.Visible    = true;
                lb_selec.Visible = true;
                bt_mp.Visible    = true;
                cmb_mp.Visible   = true;
            }
            else
            {
                MessageBox.Show("Ingrese una reserva valida");
            }
        }
Exemplo n.º 2
0
        private void btCabDisponibles_Click(object sender, EventArgs e)
        {
            //Validar Tipo
            if (string.IsNullOrEmpty(cmb_tipo.Text))
            {
                MessageBox.Show("Elija tipo de cabina");
            }
            else
            {
                dgv_cabina.Refresh();
                dgv_cabina.Rows.Clear();


                Int32 idViaje = this.idViaje;
                Int32 idTipo  = ABMCabina.ObtenerIDTipo(cmb_tipo.Text.Trim());

                DataTable cabinas = ABMCabina.ObtenerCabinasSinCompra(idViaje, idTipo);
                //Si hay ubicaciones
                if (cabinas.Rows.Count > 0)
                {
                    //cab_tcab_id,cab_piso,cab_nro,cab_via_id

                    dgv_cabina.AllowUserToAddRows = true;
                    int cantCabinas = cabinas.Rows.Count;
                    //Se agragan las filas necesarias
                    for (Int32 j = 0; j < cabinas.Rows.Count; j++)
                    {
                        DataGridViewRow rowCab = (DataGridViewRow)dgv_cabina.Rows[0].Clone();
                        dgv_cabina.Rows.Add(rowCab);
                    }

                    //Se agregan los datos en las filas
                    for (Int32 i = 0; i < cabinas.Rows.Count; i++)
                    {
                        dgv_cabina.Rows[i].Cells[0].Value = cabinas.Rows[i]["cab_tcab_id"].ToString();;
                        dgv_cabina.Rows[i].Cells[1].Value = cabinas.Rows[i]["cab_piso"].ToString();
                        dgv_cabina.Rows[i].Cells[2].Value = cabinas.Rows[i]["cab_nro"].ToString();  //.Replace(",", ".").Replace(".", ".");
                        //Precio = (Suma precio de tramos * Porc)/100 + Suma precio de tramos
                        dgv_cabina.Rows[i].Cells[3].Value = Math.Round((ABMCabina.ObtenerPorc(Convert.ToInt32(cabinas.Rows[i]["cab_tcab_id"])) * ABMCabina.ObtenerPrecioRecorrido(this.idRecorrido, this.puertoDesde, this.puertoHasta) / 100) + ABMCabina.ObtenerPrecioRecorrido(this.idRecorrido, this.puertoDesde, this.puertoHasta), 2);
                        dgv_cabina.Rows[i].Cells[4].Value = cabinas.Rows[i]["cab_via_id"].ToString();
                    }

                    //Marcar las filas que ya fueron seleccionadas para comprar
                    if (this.cabinasCompradas.Rows.Count > 0)
                    {
                        for (Int32 j = 0; j < this.cabinasCompradas.Rows.Count; j++)
                        {
                            for (Int32 j2 = 0; j2 < this.dgv_cabina.Rows.Count - 1; j2++)
                            {
                                if (string.Compare(dgv_cabina.Rows[j2].Cells[0].Value.ToString(), this.cabinasCompradas.Rows[j]["cab_tcab_id"].ToString()) == 0 &&
                                    string.Compare(dgv_cabina.Rows[j2].Cells[1].Value.ToString(), this.cabinasCompradas.Rows[j]["cab_piso"].ToString()) == 0 &&
                                    string.Compare(dgv_cabina.Rows[j2].Cells[2].Value.ToString(), this.cabinasCompradas.Rows[j]["cab_nro"].ToString()) == 0 &&
                                    string.Compare(dgv_cabina.Rows[j2].Cells[4].Value.ToString(), this.cabinasCompradas.Rows[j]["cab_via_id"].ToString()) == 0
                                    )
                                {
                                    dgv_cabina.Rows[j2].DefaultCellStyle.BackColor = Color.Aqua;
                                }
                            }
                        }
                    }

                    dgv_cabina.AllowUserToAddRows = false;
                }
            }
        }