Beispiel #1
0
        public void OnAsignacionHandler(object sender, DataEventArgs e)
        {
            // cargar el nodo
            var exp  = new e_expedientes();
            var llam = new z_llamados();

            try
            {
                exp  = exp.getObjecte_expedientes(e.Id);
                llam = llam.getObjectz_llamados(exp.codigo_llamado);
                var tn = new LlamadoTreeNode(exp.seis2 + " / " + exp.cero5)
                {
                    ImageKey         = llam.clave,
                    SelectedImageKey = llam.clave,
                    NodeId           = exp.id_expediente,
                    NodeType         = TipoElemento.Expediente
                };
                // carros pedidos

                // agregar al árbol
                treeExpedientes.Nodes.Add(tn);
                treeExpedientes.SelectedNode = tn;
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                MessageBox.Show("No se pudo completar la operación debido a un error de Base de Datos.",
                                "Mensaje de ZEUS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            //CargarExpedientes(_id_operadora);
        }
Beispiel #2
0
        private static bool CheckRestriccionIncendio(int id_expediente)
        {
            var exp = new e_expedientes();

            exp = exp.getObjecte_expedientes(id_expediente);
            var llam = new z_llamados();

            llam = llam.getObjectz_llamados(exp.codigo_principal);

            if (exp.EnIncendio() && llam.rest_incendio)
            {
                var vb = new VistoBueno
                {
                    IdExpediente = id_expediente,
                    Mensaje      = "Este despacho requiere autorización de un oficial.",
                    Text         = "Despacho restringido en Incendio"
                };

                if (vb.ShowDialog() == DialogResult.OK)
                {
                    return(true);
                }
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        public static bool ConfirmarDespacho(List <int> id_carro, int id_expediente, int batallon)
        {
            // cambiar clave!
            // obtener codigo llamado batallon
            var     llam           = new z_llamados();
            DataSet db             = llam.Getz_llamados_incendio();
            int     codigo_llamado = (int)db.Tables[0].Rows[batallon - 1]["codigo_llamado"];

            var exp = new e_expedientes();

            exp = exp.getObjecte_expedientes(id_expediente);
            // actualizar expediente
            exp.codigo_principal = codigo_llamado;
            exp.batallon         = batallon;
            // correlativo
            if (exp.correlativo_iioo == 0)
            {
                exp.correlativo_iioo = exp.GetNextCorrelativoIIOO();
            }
            exp.Update(exp);

            var retValue = ConfirmarDespacho(id_carro, id_expediente, batallon, false);

            return(retValue);
        }
Beispiel #4
0
        private void ListadoGrifos_Load(object sender, EventArgs e)
        {
            // tipos de llamado
            DataSet ds = new z_llamados().Getz_llamados_principal();

            comboTipoLlamado.DisplayMember = "desc";
            comboTipoLlamado.ValueMember   = "codigo_llamado";
            comboTipoLlamado.DataSource    = ds.Tables[0];
            // expediente seleccionado

            /*
             * try
             * {
             *  RemoteZeus rz = StartRPCClient();
             *  int id = rz.get_IdExpediente();
             *  if (id != 0)
             *  {
             *      e_expedientes exp = new e_expedientes().getObjecte_expedientes(id);
             *      comboTipoLlamado.SelectedValue = exp.codigo_principal;
             *      comboDireccion.SelectedValue = id;
             *  }
             * }
             * catch (Exception ex)
             * {
             *  Log.ShowAndLog(ex);
             * }
             */
        }
Beispiel #5
0
        public ArrayList Un_Carro_X_Clave_All(int id_grupo, int bloque, int id_expediente)
        {
            Cursor.Current = Cursors.WaitCursor;
            var       exp               = new e_expedientes();
            var       llam              = new z_llamados();
            int       id_carro_tip      = 0;
            string    sindesp           = "";
            ArrayList list_carros_alist = new ArrayList();

            try
            {
                exp  = exp.getObjecte_expedientes(id_expediente);
                llam = llam.getObjectz_llamados(exp.codigo_principal);
            }
            catch (Exception ex)
            {
                Log.ShowAndLog(ex);
            }

            if (exp.id_area != 0)
            {
                // Obtener el ID de Carro Según Grupo Solicitado
                list_carros_alist = Despacho.Ranking_x_Claves_All(exp.id_expediente, id_grupo.ToString(), bloque);
                // List<int> id_carros = llam.incendio ? Despacho.DespacharBatallon(id_expediente, id_area, llam.codigo_llamado - 50, out sindesp) : Despacho.Despachar(id_expediente, id_area);



                /*
                 * var cd = new ConfirmarDespacho
                 * {
                 *  IdCarros = id_carros,
                 *  IdExpediente = id_expediente,
                 *  IdArea = id_area
                 * };
                 * cd.lblSinDesp.Text += "\n" + sindesp;
                 *
                 * // ******
                 *
                 * // ******************
                 *
                 * cd.ShowDialog();
                 * btnDespachar.Blink = false;
                 * ZeusWin.Actualizar();
                 *
                 * }
                 * else
                 * {
                 * var id_carros = new List<int>();
                 * var cd = new CarroDisponible { IdCarros = id_carros };
                 * if (cd.ShowDialog() == DialogResult.OK)
                 * {
                 *  Despacho.ConfirmarDespacho(id_carros, id_expediente);
                 * }
                 * }
                 * Cursor.Current = Cursors.Default;
                 */
            }
            return(list_carros_alist);
        }
Beispiel #6
0
        /// <summary>
        /// Igual al caso especial Agregar BX, pero para los UT
        /// </summary>
        /// <param name="exp"></param>
        /// <param name="id_carros"></param>
        private static void CBMS_CasoEspecialAgregarUT(e_expedientes exp, ICollection <int> id_carros)
        {
            z_llamados llam = new z_llamados().getObjectz_llamados_id(exp.codigo_principal);

            // verificar 10-0
            if (llam.clave == "10-0")
            {
                // verificar 2 B despachados
                int       cant_b     = 0;
                DataTable tipo_carro = new z_tipo_carro().Getz_tipo_carro().Tables[0];
                DataTable carros     = new z_carros().Getz_carros().Tables[0];
                var       tipo_b     = (int)(tipo_carro.Select("tipo_carro_letra='B'")[0]["id_tipo_carro"]);
                var       columna_b  = (string)(tipo_carro.Select("tipo_carro_letra='B'")[0]["columna_despacho"]);
                var       tipo_ut    = (int)(tipo_carro.Select("tipo_carro_letra='UT'")[0]["id_tipo_carro"]);
                var       carros_b   = new List <int>();

                foreach (int id in id_carros)
                {
                    DataRow dr = carros.Select("id_carro=" + id)[0];
                    if ((int)dr["id_tipo_carro"] == tipo_b)
                    {
                        cant_b++;
                        carros_b.Add(id);
                    }
                }

                if (cant_b >= 2)
                {
                    // obtener primera prioridad B (hecho arriba)
                    DataSet prioridad = new z_prioridad().Getz_prioridad(exp.id_area);
                    // si primer carro == primera prioridad, verificar bx
                    var prim_prioridad = (int)prioridad.Tables[0].Rows[0][columna_b];
                    if ((int)carros.Select("id_carro=" + carros_b[0])[0]["id_compania"] == prim_prioridad)
                    {
                        DataRow[] dr =
                            carros.Select("id_compania = " + prim_prioridad + " and id_tipo_carro=" + tipo_ut +
                                          " and estado=1");
                        // si dr!= null, liberar último B solicitado y agregar ut al despacho
                        if (dr.Length != 0)
                        {
                            // liberar último carro B
                            //Carro.Liberar(carros_b[carros_b.Count-1]);
                            //id_carros.Remove(carros_b[carros_b.Count - 1]);

                            // despachar BX
                            var ut = (int)dr[0]["id_carro"];
                            id_carros.Add(ut);
                            //Carro.MarcarDespachado(ut);
                            z_carros c = new z_carros().getObjectz_carros(ut);
                            //Conductor.FueraServicio(c.id_conductor, c.id_carro);
                            Carro.Despachar(c);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        private static bool CheckRestriccionB(int id_expediente, IEnumerable <int> id_carros)
        {
            // 1: Cantidad de carros b
            var exp = new e_expedientes();

            exp = exp.getObjecte_expedientes(id_expediente);
            var llam = new z_llamados();

            llam = llam.getObjectz_llamados(exp.codigo_principal);
            if (llam.max_b == 0)
            {
                return(true);
            }

            var     carros = new e_carros_usados();
            int     cant   = 0;
            DataSet ds     = carros.Gete_carros_exp(id_expediente);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                var c = new z_carros();
                c = c.getObjectz_carros((int)dr["id_carro"]);
                if (c.id_tipo_carro == 1)
                {
                    cant++;
                }
            }

            // carros actuales
            foreach (int id in id_carros)
            {
                var c = new z_carros();
                c = c.getObjectz_carros(id);
                if (c.id_tipo_carro == 1)
                {
                    cant++;
                }
            }

            if (cant > llam.max_b)
            {
                var vb = new VistoBueno
                {
                    IdExpediente = id_expediente,
                    Mensaje      = "La cantidad de carros permitida para esta clave ha sido superada."
                };

                if (vb.ShowDialog() == DialogResult.OK)
                {
                    return(true);
                }
                return(false);
            }
            return(true);
        }
Beispiel #8
0
        private static void CheckBatallon(int id_expediente, IEnumerable <int> id_carros)
        {
            var exp = new e_expedientes();

            exp = exp.getObjecte_expedientes(id_expediente);
            List <int> s;
            int        id_mayor = 0;
            var        cu       = new e_carros_usados();

            // no hay batallones para áreas
            if (exp.id_area == 0)
            {
                return;
            }
            // revisar si esta combinación de carros+los actuales superan un batallón

            var     llam = new z_llamados();
            DataSet ds   = llam.Getz_llamados_incendio();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                // cantidad de carros
                CantidadCarros cc = ObtenerCantidadCarros(exp.id_area, (int)dr["codigo_llamado"], out s);
                var            ca = new CantidadCarros();
                // sumar
                DataSet de = cu.Gete_carros_exp(id_expediente);
                foreach (DataRow dw in de.Tables[0].Rows)
                {
                    var carro = new z_carros();
                    carro = carro.getObjectz_carros((int)dw["id_carro"]);
                    ca.Cantidad[carro.id_tipo_carro - 1]++;
                }
                // carros actuales
                foreach (int i in id_carros)
                {
                    var carro = new z_carros();
                    carro = carro.getObjectz_carros(i);
                    ca.Cantidad[carro.id_tipo_carro - 1]++;
                }
                // comparar
                if (ca >= cc)
                {
                    id_mayor = (int)dr["codigo_llamado"];
                }
            }
            if (id_mayor != 0)
            {
                // avisar
                MessageBox.Show("Se han superado los carros para un batallón. Se cambiará la clave.");
                // cambiar clave
                exp.codigo_principal = id_mayor;
                exp.Update(exp);
            }
        }
        private void CarroEspecialidad_Load(object sender, EventArgs e)
        {
            Icon = Icon.FromHandle(Resources.asignacion_carro_especialidad_32.GetHicon());
            var     llam = new z_llamados();
            DataSet ds   = llam.Getz_llamados_principal();

            comboClaves.DataSource = ds.Tables[0];

            // expediente seleccionado
            if (ZeusWin.IdExpediente != 0)
            {
                e_expedientes exp = new e_expedientes().getObjecte_expedientes(zeusWin.IdExpediente);
                comboClaves.SelectedValue     = exp.codigo_principal;
                comboExpediente.SelectedValue = exp.id_expediente;
            }
        }
Beispiel #10
0
 protected override void Mostrar(int id)
 {
     try
     {
         z_llamados llam = new z_llamados().getObjectz_llamados_id(id);
         textCodigo.Text       = llam.codigo_llamado.ToString();
         textClave.Text        = llam.clave;
         textDescripcion.Text  = llam.descripcion;
         numericMaxB.Value     = llam.max_b;
         checkIncendio.Checked = llam.incendio;
         checkRestr.Checked    = llam.rest_incendio;
     }
     catch (Exception ex)
     {
         Log.ShowAndLog(ex);
     }
 }
Beispiel #11
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex != -1)
     {
         try
         {
             listActuales.DisplayMember = "desc";
             listActuales.ValueMember   = "id_llamado";
             Source = new z_llamados().Getz_llamados_clave((string)comboBox1.SelectedValue).Tables[0];
         }
         catch (Exception ex)
         {
             Log.ShowAndLog(ex);
         }
     }
     else
     {
         Source = null;
     }
 }
Beispiel #12
0
 protected override void Actualizar()
 {
     try
     {
         z_llamados llam = new z_llamados().getObjectz_llamados_id((int)listActuales.SelectedValue);
         llam.clave          = textClave.Text;
         llam.codigo_llamado = int.Parse(textCodigo.Text);
         llam.descripcion    = textDescripcion.Text;
         llam.incendio       = checkIncendio.Checked;
         llam.rest_incendio  = checkRestr.Checked;
         llam.max_b          = (int)numericMaxB.Value;
         llam.modifyz_llamados(llam);
         comboBox1.DataSource = new z_llamados().Getz_llamados_principal().Tables[0];
         BitacoraGestion.NuevoEvento(zeusWin.IdOperadora, zeusWin.IdAval, "Modificación Tabla Llamados");
         MessageBox.Show("Operación realizada correctamente.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         Log.ShowAndLog(ex);
     }
 }
Beispiel #13
0
 private void comboClaves_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboClaves.SelectedIndex != -1)
     {
         try
         {
             listActuales.DisplayMember = "desc";
             listActuales.ValueMember   = "codigo_llamado";
             Source =
                 new z_llamados().Getz_llamados_clave(
                     (string)((DataRowView)comboClaves.SelectedItem).Row["clave"]).Tables[0];
         }
         catch (Exception ex)
         {
             Log.ShowAndLog(ex);
         }
     }
     else
     {
         listActuales.DataSource = null;
     }
 }
Beispiel #14
0
        protected override void Insertar()
        {
            try
            {
                var llam = new z_llamados
                {
                    clave          = textClave.Text,
                    codigo_llamado = int.Parse(textCodigo.Text),
                    descripcion    = textDescripcion.Text,
                    incendio       = checkIncendio.Checked,
                    rest_incendio  = checkRestr.Checked,
                    max_b          = ((int)numericMaxB.Value)
                };
                llam.addz_llamados(llam);
                comboBox1.DataSource = new z_llamados().Getz_llamados_principal().Tables[0];
                BitacoraGestion.NuevoEvento(zeusWin.IdOperadora, zeusWin.IdAval, "Inserción Tabla Llamados");

                MessageBox.Show("Operación realizada correctamente.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                Log.ShowAndLog(ex);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Si ocurre un llamado 10-2, 10-8 o 10-9 en alguna de las áreas correspondiente a compañías que cuentan con ‘B’ y ‘BX’,
        /// debe ser despachado el ‘BX’ en lugar del ‘B’ que indica la pauta. Si al momento del despacho de alguna de estas claves
        /// (10-2, 10-8 o 10-9), el ‘BX’ se encuentra fuera de servicio, debe ser despachado el ‘B’ de la misma compañía en caso que
        /// se encuentre disponible o el ‘B’ de la compañía que corresponda según la prioridad.
        /// </summary>
        /// <param name="exp"></param>
        /// <param name="id_carros"></param>
        private static void CBMS_CasoEspecialBXporB(e_expedientes exp, ICollection <int> id_carros)
        {
            // verificar llamado 10-2, 10-8 o 10-9
            DataTable llamados = new z_llamados().Getz_llamados().Tables[0];

            DataRow[] res =
                llamados.Select("codigo_llamado=" + exp.codigo_principal +
                                " and (clave='10-2' or clave='10-8' or clave='10-9')");
            if (res.Length != 0)
            {
                // verificar que no haya BX
                //bool salio_bx = false;
                int  compania          = exp.id_area / 100;
                bool compania_tiene_bx = false;
                //bool bx_en_llamado_es_de_compañia = false;
                //int id_bx = 0;
                z_carros  bx         = null;
                DataTable tipo_carro = new z_tipo_carro().Getz_tipo_carro().Tables[0];
                DataTable carros     = new z_carros().Getz_carros().Tables[0];
                int       tipo_b     = (int)(tipo_carro.Select("tipo_carro_letra='B'")[0]["id_tipo_carro"]);
                int       tipo_bx    = (int)(tipo_carro.Select("tipo_carro_letra='BX'")[0]["id_tipo_carro"]);

                // salio un bx?
                foreach (int id in id_carros)
                {
                    DataRow dr = carros.Select("id_carro=" + id)[0];
                    if ((int)dr["id_tipo_carro"] == tipo_bx)
                    {
                        //salio_bx = true;
                        //id_bx = id;
                        bx = new z_carros().getObjectz_carros(id);
                        break;
                    }
                }

                // compañia tiene bx?
                foreach (DataRow dr in carros.Select("id_tipo_carro=" + tipo_bx))
                {
                    if ((int)dr["id_compania"] == compania)
                    {
                        compania_tiene_bx = true;
                        break;
                    }
                }
                // si salio el bx que no era, o no salio bx, (liberar bx y) asignar B segun prioridad
                if ((bx != null && bx.id_compania != compania && compania_tiene_bx) || bx == null && compania_tiene_bx)
                {
                    // liberar BX si habia
                    if (bx != null)
                    {
                        Carro.Liberar(bx.id_carro);
                        id_carros.Remove(bx.id_carro);
                    }
                    // obtener carro B
                    z_carros carro_b = Despacho.ObtenerCarro(tipo_b, exp.id_area);
                    if (carro_b.id_carro != 0)
                    {
                        Carro.Despachar(carro_b);
                        //Conductor.FueraServicio(carro_b.id_conductor, carro_b.id_carro);
                        id_carros.Add(carro_b.id_carro);
                    }
                }
            }
        }
        private void MostrarInfo(e_expedientes exp)
        {
            textArea.Text            = exp.id_area.ToString();
            textBatallon.Text        = exp.batallon.ToString();
            text62.Text              = exp.seis2;
            text05.Text              = exp.cero5;
            textComuna.SelectedValue = exp.comuna;
            textGeoz.Text            = exp.geoz;
            textCasa.Text            = exp.casa;
            textBlock.Text           = exp.block;
            textVilla.Text           = exp.poblacion_villa;
            textTelefono.Text        = exp.telefono;
            textQuienLlama.Text      = exp.quien_llama;
            textFechaHoraAlarma.Text = exp.fecha.ToString();
            textAsisten.Text         = exp.asisiten.ToString();
            // correlativos
            textCorrelativo.Text = exp.correlativo.ToString();
            if (exp.correlativo_iioo != 0)
            {
                textCorrelativoIIOO.Text = exp.correlativo_iioo.ToString();
            }
            else
            {
                textCorrelativoIIOO.Text = "";
            }
            if (exp.correlativo_redtic != 0)
            {
                textCorrelativoRedTIC.Text = exp.correlativo_redtic.ToString();
            }
            else
            {
                textCorrelativoRedTIC.Text = "";
            }

            textFechaHoraRetirada.Text = exp.fecha_retirada != DateTime.MinValue ? exp.fecha_retirada.ToString() : "";

            textOrigen.Text        = exp.origen;
            textCausa.Text         = exp.causa;
            textObservaciones.Text = exp.observaciones;

            piso.Text = exp.Piso;
            asistenciaCompania.Text      = exp.AsistenciaPorCompania;
            informeIngresado.Text        = exp.InformeIngresado;
            volCompanias.Text            = exp.AsistenciaVoluntariosOtrasCompanias;
            lesionadosActosServicio.Text = exp.LesionadosActoServicio;
            origenAlarma.Text            = exp.OrigenAlamarma;


            // clave
            z_llamados llam = new z_llamados().getObjectz_llamados(exp.codigo_llamado);

            textClave.Text = llam.clave + " " + llam.descripcion;

            // oficial a cargo
            //if (exp.id_voluntario != 0)
            //{
            //    z_cargos cargo = new z_cargos().getObjectz_cargos(exp.id_voluntario);
            //    z_voluntarios vol = new z_voluntarios();
            //    vol = vol.getObjectz_voluntarios(cargo.id_voluntario);
            //    textACargo.Text = vol.apellidos + " " + vol.nombres;
            //}
            //else
            //{
            //    textACargo.Text = "Ninguno";
            //}
            textACargoLlamado.Text = exp.cargo_llamado;
            textACargoInforme.Text = exp.cargo_informe;
            textCiaCargoInf.Text   = exp.cia_cargo_informe;
        }
        private void ConfirmarDespacho_Load(object sender, EventArgs e)
        {
            try
            {
                var exp = new e_expedientes();
                exp = exp.getObjecte_expedientes(IdExpediente);

                z_carros carro = new z_carros();



                // cargar datos

                var llam = new z_llamados();
                llam = llam.getObjectz_llamados(exp.codigo_llamado);
                // formatear texto
                lblClave.Text = "";
                // batallon?
                if (Batallon != 0)
                {
                    switch (Batallon)
                    {
                    case 1:
#if CBMS
                        lblClave.Text = "Sale Primer Batallón de Incendio.\n";
#elif CBQN
                        lblClave.Text = "Sale Incendio.\n";
#endif
                        break;

                    case 2:
#if CBMS
                        lblClave.Text = "Sale Segundo Batallón de Incendio.\n";
#elif CBQN
                        lblClave.Text = "Sale Alarma General.\n";
#endif
                        break;

                    case 3:
                        lblClave.Text = "Sale Tercer Batallón de Incendio.\n";
                        break;

                    case 4:
                        lblClave.Text = "Sale Cuarto Batallón de Incendio.\n";
                        break;
                    }
                }
                if (AlarmaGeneral)
                {
#if CBMS
                    // TODO: poner texto para alarma
#elif CBQN
                    lblClave.Text = "Sale Alarma General.\n";
#endif
                }
                if (Agregando)
                {
                    tableLayoutPanel1.SetRow(lblArea, 4);
                    tableLayoutPanel1.SetRow(lbl05, 3);
                    tableLayoutPanel1.SetRow(lblClave, 2);
                    tableLayoutPanel1.SetRow(tableCarros, 1);
                    tableLayoutPanel1.SetRow(lblExtra, 0);
                    lblExtra.Text = "Sale:";
                    lblClave.Text = "A: ";
                }

                lblClave.Text += llam.clave; // +" " + llam.descripcion;
                lbl05.Text     = ToLower(exp.seis2 + " Y " + exp.cero5);

                //### Motrar Sector del Despacho
                string StrSector   = exp.comuna;
                string AsTitleCase = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(StrSector.ToLower());

                lblArea.Text = "Área de Referencia " + exp.id_area + "\n\n" + AsTitleCase;
                MostrarCarros(exp.codigo_principal);

#if CBMS
                // consola
                axShockwaveFlash1.LoadMovie(0, Application.StartupPath + "\\Consola\\Consola.swf");
#elif CBQN
                int width = axShockwaveFlash1.Width;
                axShockwaveFlash1.Dispose();
                Width -= width;
#endif
            }
            catch (Exception ex)
            {
                Log.ShowAndLog(ex);
            }
        }
        private void btnDespachar_Click(object sender, EventArgs e)
        {
            //### Confirmar si hay Carros para Despachar
            if (IdCarros.Count > 0)
            {
                z_carros carros = new z_carros();
                exp = exp.getObjecte_expedientes(IdExpediente);

                DatosLogin.LogPrimerDespacho = false;

                //### Sólo Si es el Primer Despacho, Actualiza la Hora del Expediente.
                if (exp.material_despachado == "")
                {
                    exp.ActualizarFechaExpediente(IdExpediente);
                    DatosLogin.LogPrimerDespacho = true;
                }

                //### Asigna el Estado NOTEMPORAL a los Carros que se Despacharán.
                for (int a = 0; a < IdCarros.Count; a++)
                {
                    carros.actualizarZcarrosLlamadoEspecifico(IdCarros[a], IdExpediente);
                }


                if (confirmado)
                {
                    DialogResult = DialogResult.OK;
                    Close();
                    return;
                }

                try
                {
                    if (AlarmaGeneral)
                    {
                        Despacho.ConfirmarDespacho(IdCarros, IdExpediente, true);
                    }
                    else
                    {
                        if (Batallon != 0)
                        {
                            Despacho.ConfirmarDespacho(IdCarros, IdExpediente, Batallon);
                        }
                        else
                        {
                            Despacho.ConfirmarDespacho(IdCarros, IdExpediente);
                        }
                    }
                    confirmado          = true;
                    btnDespachar.Text   = "Cerrar";
                    btnAgregar.Enabled  = false;
                    btnCancelar.Enabled = false;
                }
                catch (Exception ex)
                {
                    Log.ShowAndLog(ex);
                }

                //### Asigna la Hora de 6-0 a los Carros Despachados
                for (int i = 0; i < IdCarros.Count; i++)
                {
                    BitacoraLlamado.NuevoEvento(exp.id_expediente, IdCarros[i],
                                                BitacoraLlamado.Carro,
                                                "6-0");
                }


                string StIdCarro     = "";
                string StIdConductor = "";

                string CDString      = "";
                string CDStringFinal = "";
                for (int x = 0; x < IdCarros.Count; x++)
                {
                    CDString += carros.ObtenerNombreCarro(IdCarros[x]) + ",";

                    carros         = carros.getObjectz_carros(IdCarros[x]);
                    StIdCarro     += carros.id_carro + ",";
                    StIdConductor += carros.id_conductor + ",";
                }
                CDString     += "#";
                CDStringFinal = CDString.Replace(",#", "");

                StIdCarro     += "#";
                StIdCarro      = StIdCarro.Replace(",#", "");
                StIdConductor += "#";
                StIdConductor  = StIdConductor.Replace(",#", "");



                int TipoTw = 2; //### Para Despachos debe ser Valor 2


                //############################################################
                //### Insertar Servicio por Carro Despachado JSON MULTIPLE ###
                //############################################################
                //                 public z_servicio(int id_carro, DateTime fecha, int estado, int id_conductor, string motivo_fuera_servicio)
                //z_servicio servicio = new z_servicio(99, System.DateTime.Now, 4, 99, "Despacho de carros: Se genera el despacho de los carros " + CDStringFinal + "");
                //servicio.Insert(servicio);
                //string strIdCarros, string strIdConductores, string strCarros

                //### Insert Multiple en Z_SERVICIOS
                z_servicio servicio = new z_servicio();
                servicio.InsertMultiple(StIdCarro, StIdConductor, CDString);

                //### JSON Multiple en servicio
                if (carros.GetParametroPrioridad(6) == "TRUE")
                {
                    JsonServicioClaves jsc = new JsonServicioClaves();
                    jsc.JsonServicioHoraMultipleJSON(StIdCarro, 4, StIdConductor, "En Acto", "Azul", false);

                    //### Actualiz Todos los Carros   :)
                    jsc.JsonServicioHoraMultipleJSON_TodosLosCarros();
                }



                //###########################
                //### Publicar en Twitter ###
                //###########################
                if (carros.GetParametroPrioridad(1) == "TRUE")
                {
                    if (CDStringFinal != "#")
                    {
                        System.Diagnostics.Process proceso = new System.Diagnostics.Process();
                        proceso.StartInfo.FileName       = @"C:\ZEUS_CBMS\New_App_Twitter\App_Twitter_Mod.exe";
                        proceso.StartInfo.Arguments      = TipoTw.ToString() + " " + IdExpediente.ToString() + " " + DatosLogin.InvokeTwitter.ToString() + " " + CDStringFinal;
                        proceso.StartInfo.CreateNoWindow = true;
                        proceso.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                        proceso.Start();
                    }
                }



                //#################
                //### App VIPER ###
                //#################
                var llam = new z_llamados();
                llam = llam.getObjectz_llamados(exp.codigo_llamado);


                //############################
                //### Producción CBMS ########
                //############################
                //# ID Usuario
                string text3 = "\"uEpZYQpJz2;"; //"\"6jD2ex00SN;";
                //# Password
                text3 += "M29vzK1BEg;";         //"a057ldMhGm;";



                //# Expediente
                text3 += exp.id_expediente.ToString() + ";";
                //# Fecha
                text3 += exp.fecha.ToString() + ";";

                ////# Clave con 0-4 para 10-12
                //if (llam.clave.ToString() == "10-12")
                //{
                //    text3 += llam.clave.ToString() + " A " + exp.cero4_10_12.ToString() + ";";
                //}
                //else
                //{
                text3 += llam.clave.ToString() + ";";
                //}

                //# Calle
                text3 += exp.seis2.ToString() + ";";
                //# Esquina
                text3 += exp.cero5.ToString() + ";";
                //# Carros
                text3 += CDStringFinal + ";";
                //# ID Area
                text3 += exp.id_area.ToString() + ";";
                //# Comuna
                text3 += exp.comuna.ToString() + ";";
                //# O-4
                text3 += exp.OrigenAlamarma.ToString() + ";";
                //# Latitud
                string[] array = exp.e_lat_long.ToString().Split(',');
                text3 += array[0].ToString() + ";";
                //# Longitud
                text3 += array[1].ToString() + ";";
                //# Incendio
                if (DatosLogin.InvokeTwitter == "FT1")
                {
                    text3 += "";
                }

                //if (DatosLogin.InvokeTwitter == "FT2")
                //{
                //    int intPrincipal = Convert.ToInt32(exp.codigo_principal.ToString());
                //    if (intPrincipal > 49)
                //    {
                //        text3 += "SALE A INCENDIO ";
                //    }
                //    else
                //    {
                //        text3 += "SALE";
                //    }
                //}

                ////### Incendios Estructural
                //if (DatosLogin.InvokeTwitter == "FT3")
                //{
                //    text3 += "INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT4")
                //{
                //    text3 += "2da ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT5")
                //{
                //    text3 += "3ra ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT6")
                //{
                //    text3 += "4ta ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT7")
                //{
                //    text3 += "5ta ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT8")
                //{
                //    text3 += "6ta ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT9")
                //{
                //    text3 += "7ma ALARMA DE INCENDIO";
                //}

                ////### Incendios Forestal
                //if (DatosLogin.InvokeTwitter == "FT3F")
                //{
                //    text3 += "INCENDIO FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT4F")
                //{
                //    text3 += "2da ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT5F")
                //{
                //    text3 += "3ra ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT6F")
                //{
                //    text3 += "4ta ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT7F")
                //{
                //    text3 += "5ta ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT8F")
                //{
                //    text3 += "6ta ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT9F")
                //{
                //    text3 += "7ma ALARMA FORESTAL";
                //}



                if (DatosLogin.InvokeTwitter == "FT2")
                {
                    int intPrincipal = Convert.ToInt32(exp.codigo_principal.ToString());
                    if (intPrincipal > 49)
                    {
                        text3 += "SALE A BATALLON DE INCENDIO ";
                    }
                    else
                    {
                        text3 += "SALE";
                    }
                }

                //### Incendios Estructural
                if (DatosLogin.InvokeTwitter == "FT3")
                {
                    text3 += "1er BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT4")
                {
                    text3 += "2do BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT5")
                {
                    text3 += "3er BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT6")
                {
                    text3 += "4to BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT7")
                {
                    text3 += "5to BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT8")
                {
                    text3 += "6to BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT9")
                {
                    text3 += "7mo BATALLON DE INCENDIO ";
                }

                //### Incendios Forestal
                if (DatosLogin.InvokeTwitter == "FT3F")
                {
                    text3 += "INCENDIO FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT4F")
                {
                    text3 += "2da ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT5F")
                {
                    text3 += "3ra ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT6F")
                {
                    text3 += "4ta ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT7F")
                {
                    text3 += "5ta ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT8F")
                {
                    text3 += "6ta ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT9F")
                {
                    text3 += "7ma ALARMA FORESTAL";
                }



                //# Terminar Argumento
                text3 += "\"";


                //### Chequear si esta habilitado VIPER
                if (carros.GetParametroPrioridad(2) == "TRUE")
                {
                    System.Diagnostics.Process proceso2 = new System.Diagnostics.Process();
                    proceso2.StartInfo.FileName       = @"C:\ZEUS_CBMS\Viper\viper - Acceso directo";
                    proceso2.StartInfo.Arguments      = text3;
                    proceso2.StartInfo.CreateNoWindow = true;
                    proceso2.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                    proceso2.Start();
                }



                //###########################
                //###   JSON Emergencia   ###
                //###########################
                //var llam = new z_llamados();
                //llam = llam.getObjectz_llamados(exp.codigo_llamado);
                string   sector_r = exp.comuna.ToString().Replace("/", "-");
                string[] array2   = exp.e_lat_long.ToString().Split(',');
                //string CarrosSlach = CDStringFinal.Replace(",", "/");   //### NOMBRES de Carros
                string CarrosSlach = StIdCarro.Replace(",", "/");         //### ID de Carros

                string[] GetFechaHora = exp.fecha.ToString().Split(' ');

                JsonEmergencia emergencia = new JsonEmergencia();
                emergencia.expediente  = exp.id_expediente.ToString();
                emergencia.correlativo = exp.correlativo.ToString();
                emergencia.fecha       = GetFechaHora[0].ToString();
                emergencia.hora        = GetFechaHora[1].ToString();

                emergencia.id_acto     = exp.codigo_principal.ToString();
                emergencia.id_llamado  = llam.codigo_llamado.ToString();
                emergencia.calle       = exp.seis2.ToString().Replace("Ñ", "N");
                emergencia.casa        = exp.casa.ToString();
                emergencia.block       = exp.block.ToString();
                emergencia.piso        = exp.Piso.ToString();
                emergencia.villa       = exp.comuna.ToString().Replace("Ñ", "N");
                emergencia.area        = exp.id_area.ToString();
                emergencia.comuna      = exp.comuna_real.ToString().Replace("Ñ", "N");
                emergencia.esquina     = exp.cero5.ToString();
                emergencia.carros      = CarrosSlach.Replace("Ñ", "N");
                emergencia.casa        = exp.casa.ToString();
                emergencia.esquina     = exp.cero5.ToString().Replace("Ñ", "N");
                emergencia.quien_llama = exp.quien_llama.ToString().Replace("Ñ", "N");
                emergencia.telefono    = exp.telefono.ToString();
                emergencia.estado      = exp.activo.ToString();
                emergencia.operadora   = DatosLogin.NomUsuario.ToString().Replace("Ñ", "N");
                emergencia.latitud     = array2[0].ToString();
                emergencia.longitud    = array2[1].ToString();
                //# Tono de Llamado
                string strTono = "";
                if (Batallon != 0)
                {
                    strTono         = "1";
                    emergencia.acto = "BATALLON DE INCENDIO";
                }
                else
                {
                    strTono         = new e_expedientes().Get_Id_Tono(exp.codigo_principal.ToString());
                    emergencia.acto = llam.clave.ToString();
                }
                emergencia.tono = strTono;

                //### Incluir Notificación ZEUS Alerta
                if (carros.GetParametroPrioridad(8).Equals("TRUE"))
                {
                    emergencia.mobile = true;
                }
                else
                {
                    emergencia.mobile = false;
                }

                string json   = JsonConvert.SerializeObject(emergencia);
                string json_2 = json.Replace("\"", "%");
                string json_3 = json_2.Replace(" ", "?");

                if (carros.GetParametroPrioridad(6).Equals("TRUE"))
                {
                    System.Diagnostics.Process proceso2 = new System.Diagnostics.Process();
                    proceso2.StartInfo.FileName       = @"C:\ZEUS_CBMS\Apolo\emergencias.py";
                    proceso2.StartInfo.Arguments      = json_3.ToString();
                    proceso2.StartInfo.CreateNoWindow = true;
                    proceso2.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                    proceso2.Start();
                    //MessageBox.Show(json_3, "Json ZEUS            :)");
                }

                //### Escribir JSON MultiPuestaServicio
                string       fic = @"C:\ZEUS_CBMS\ZTablasApolo\JsonExpediente_" + System.DateTime.Now.ToString("yyyyMMddhhmmss") + ".txt";
                StreamWriter sw  = new StreamWriter(fic);
                sw.WriteLine("JSON Despacho ZEUS");
                sw.WriteLine("");
                sw.WriteLine(json_3);
                sw.Close();



                //######################## OJO
                //### Tonos Selectivos ### Agregar esta linea "using System.Linq;"
                //######################## para Distinct()
                string strParametros = "";
                if (Batallon > 0)
                {
                    //# Tono de Incendio
                    strParametros = "100,90,50";
                }
                else
                {
                    //# Tonos Selectivos
                    int[] IdCias = new int[IdCarros.Count];
                    for (int x = 0; x < IdCarros.Count; x++)
                    {
                        carros    = carros.getObjectz_carros(IdCarros[x]);
                        IdCias[x] = carros.id_compania;
                    }
                    //# Ordenar y Eliminar Compañias Repetidas
                    Array.Sort(IdCias);
                    //if (IdCias.Length > 1)
                    //{
                    //    IEnumerable<int> IdCiasUnico = IdCias.Distinct();
                    //}
                    //else
                    //{
                    //    IEnumerable<int> IdCiasUnico = IdCias;
                    //}


                    List <int> IdCiasUnico = new List <int>();
                    foreach (int i in IdCias)
                    {
                        if (!IdCiasUnico.Contains(i))
                        {
                            IdCiasUnico.Add(i);
                        }
                    }

                    //# Agrupa Tipo de Llamado
                    int ClavPrincipal  = exp.codigo_principal;
                    int TonoDelLlamado = 0;
                    if (EsLlamadoComandancia(ClavPrincipal))
                    {
                        TonoDelLlamado = 70;
                    }
                    if (EsRescate(ClavPrincipal))
                    {
                        TonoDelLlamado = 60;
                    }
                    if (EsOtrosServicios(ClavPrincipal))
                    {
                        TonoDelLlamado = 80;
                    }

                    //# Crear el String de Parámetro
                    foreach (int c in IdCiasUnico)
                    {
                        strParametros += c.ToString() + ",";
                    }

                    strParametros = "99," + strParametros + TonoDelLlamado;
                } //Fin If

                //MessageBox.Show("ParamSelectivo:  " + strParametros, "Tonos ZEUS");
                //### Activar Tonos
                if (carros.GetParametroPrioridad(3).Equals("TRUE"))
                {
                    System.Diagnostics.Process proceso2 = new System.Diagnostics.Process();
                    proceso2.StartInfo.FileName       = @"C:\ZEUS_CBMS\Tonos\TonosDesdeZeus.exe";
                    proceso2.StartInfo.Arguments      = strParametros;
                    proceso2.StartInfo.CreateNoWindow = true;
                    proceso2.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                    proceso2.Start();
                }
            } //# Fin IF Si hay Carros
            else
            {
                MessageBox.Show("No hay Carros Seleccionados para ser Despachados", "ZEUS");
            } //# Fin IF Si hay Carros
        }
Beispiel #19
0
        private void btnDespachar_Click(object sender, EventArgs e)
        {
            DatosLogin.InvokeTwitter = "FT1";
            Cursor.Current           = Cursors.WaitCursor;
            var    exp     = new e_expedientes();
            var    llam    = new z_llamados();
            string sindesp = "";

            try
            {
                exp  = exp.getObjecte_expedientes(id_expediente);
                llam = llam.getObjectz_llamados(exp.codigo_principal);
            }
            catch (Exception ex)
            {
                Log.ShowAndLog(ex);
            }

            bloque_hora = recIDHORA();

            string NuevoBloque = Convert.ToString(bloque_hora);


            // ################################
            // ### Coordenadas para Twitter ###
            // ################################
            string strTw_X    = (Math.Truncate(exp.puntoX)).ToString();
            string strTw_Y    = (Math.Truncate(exp.puntoY)).ToString();
            string strLatLong = exp.Utm_2_LatLong(strTw_X, strTw_Y);
            string strURL     = "https://maps.google.cl/maps?q=";
            string strZOOM    = "&t=m&z=17";
            string strPlano   = strURL + strLatLong + strZOOM;

            // ### Agregar en el expediente el link del Plano
            exp.AgregarPlanoTwitter(id_expediente, strPlano);

            // ### Agregar en el expediente las coordenadas Lat Long
            exp.AgregarLatLongWeb(id_expediente, strLatLong);



            if (exp.id_area != 0)
            {
                // verificar si es despacho normal o despacho de incendio
                List <int> id_carros = Despacho.ranking(id_expediente, id_area, bloque_hora);
                //List<int> id_carros = Despacho.Despachar(id_expediente, id_area);


                //##################################
                //### Módulo Agregar B en 10-3-1 ###
                //##################################
                var DxD  = new DespachoPorDistancia();
                int IdMM = DxD.LlamadoEnRadioDeCia(id_expediente);
                if (IdMM > 0)
                {
                    //### Despachar Carro si esta Disponible
                    int intCarro26 = DespachoPorDistancia.DespachoPorDosSeis(IdMM);
                    if (intCarro26 > 0)
                    {
                        id_carros.Add(intCarro26);
                    }
                }



                // ### Si no hay carros, no se muestra la ventana de preparar despacho.
                // ### Esto ocurre porque para la intersección ingresada, Commander no
                // ### entrego un Ranking valido (todos los carros tienen Ranking = 1).
                if (id_carros.Count > 0)
                {
                    var cd = new ConfirmarDespacho
                    {
                        IdCarros     = id_carros,
                        IdExpediente = id_expediente,
                        IdArea       = id_area
                    };
                    cd.lblSinDesp.Text += "\n" + sindesp;


                    // ******

                    // ******************

                    cd.ShowDialog();
                    btnDespachar.Blink = false;
                    ZeusWin.Actualizar();
                }
            }
            else
            {
                var id_carros = new List <int>();
                var cd        = new CarroDisponible {
                    IdCarros = id_carros
                };
                if (cd.ShowDialog() == DialogResult.OK)
                {
                    Despacho.ConfirmarDespacho(id_carros, id_expediente);
                }
            }
            Cursor.Current = Cursors.Default;
        }
Beispiel #20
0
        private static bool ConfirmarDespacho(List <int> id_carro, int id_expediente, int batallon, bool despachandoTodo)
        {
            // verificar restricciones
            if (!CheckRestriccionIncendio(id_expediente) || !CheckRestriccionB(id_expediente, id_carro))
            {
                return(false);
            }


            e_expedientes exp      = new e_expedientes().getObjecte_expedientes(id_expediente);
            var           c        = new z_carros();
            var           carros   = new e_carros_usados();
            string        material = "";

            foreach (int id in id_carro)
            {
                if (id == 0)
                {
                    continue;
                }
                // marcar carro!
                carros = carros.getObjecte_carros_usados(id);
                if (carros.id_carro == 0)
                {
                    carros.id_carro      = id;
                    carros.id_expediente = id_expediente;
                    carros.seis          = "6-0R";
                    carros.Insert(carros);
                }
                else
                {
                    carros.id_expediente = id_expediente;
                    carros.seis          = "6-0R";
                    carros.Update(carros);
                }

                // agregar a lista!
                c         = c.getObjectz_carros(id);
                material += "," + c.nombre;
            }
            exp.material_despachado = (exp.material_despachado + material).Trim(',');
            material = material.Trim(',');
            exp.Update(exp);

            // agregar información a bitácora
            // verificar si es primer despacho para agregar información de despacho
            if (carros.getCantidad(exp.id_expediente) == 0)
            {
                var llam = new z_llamados();
                llam = llam.getObjectz_llamados(exp.codigo_principal);
                BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Llamado,
                                            "LLAMADO: " + llam.clave + " " + llam.descripcion);
                llam = llam.getObjectz_llamados(exp.codigo_llamado);
                BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Llamado,
                                            "SUBCLASIFICACION: " + llam.clave + " " + llam.descripcion);
                BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Llamado,
                                            "0-5: " + exp.cero5);
            }
            if (batallon >= 1 && batallon <= 4)
            {
#if CBMS
                BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Incendio, "Despacho " + batallon + " Batallón Incendio");
#elif CBQN
                BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Incendio,
                                            "Despacho Incendio");
#endif
            }
            if (despachandoTodo)
            {
#if CBMS
                BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Incendio,
                                            "Despacho 5° Batallón de Incendio");
#elif CBQN
                BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Incendio,
                                            "Despacho Alarma General");
#endif
            }

            BitacoraLlamado.NuevoEvento(exp.id_expediente, 0, BitacoraLlamado.Despacho,
                                        "CARROS: " + material);

#if CBQN
            // dar 6-0 inmediatamente
            if ((batallon >= 1 && batallon <= 4) || despachandoTodo)
            {
                // registrar 6-0 inmediatamente, sin of. a cargo ni num de vols
                foreach (int i in id_carro)
                {
                    var cen = new CarroEnLlamado(i);
                    cen.Clave6_0(0, 0, null);
                }
            }
#endif

            // avisar
            if (OnDespacho != null)
            {
                OnDespacho(null, new DespachoEventArgs(id_expediente, id_carro));
            }
            return(true);
        }
Beispiel #21
0
        public static List <int> DespacharBatallon(int id_expediente, int id_area, int batallon, out string sindesp)
        {
            // 6
            var sinDespacho = new List <int>();
            var idDespacho  = new List <int>();
            var companias   = new List <int>();
            var R           = new List <int>();
            var cu          = new e_carros_usados();

            sindesp = "";

            // tipos de carro
            try
            {
                // obtener codigo llamado batallon
                var     llam           = new z_llamados();
                DataSet db             = llam.Getz_llamados_incendio();
                int     codigo_llamado = (int)db.Tables[0].Rows[batallon - 1]["codigo_llamado"];

                CantidadCarros cantidad = ObtenerCantidadCarros(id_area, codigo_llamado, out idDespacho);
                // cantidad de carros
                var actual = new CantidadCarros();
                // sumar
                DataSet de = cu.Gete_carros_exp(id_expediente);
                foreach (DataRow dw in de.Tables[0].Rows)
                {
                    var carro = new z_carros();
                    carro = carro.getObjectz_carros((int)dw["id_carro"]);
                    actual.Cantidad[carro.id_tipo_carro - 1]++;
                }
                // restar carros actuales
                cantidad = cantidad - actual;

                OrdenarCarros(cantidad, codigo_llamado);
                for (int i = 0; i < cantidad.Cantidad.GetLength(0); i++)
                {
                    while (cantidad.Cantidad[i] > 0)
                    {
                        // obtener carro verificando 0-11
                        z_carros carro = batallon > 2 ? ObtenerCarro(cantidad.Id_tipo[i], id_area, true) : ObtenerCarro(cantidad.Id_tipo[i], id_area);

                        if (carro.id_carro != 0)
                        {
                            // es r?
                            if (carro.id_tipo_carro == 7)
                            {
                                R.Add(carro.id_carro);
                            }
                            else
                            {
                                if (!companias.Contains(carro.id_compania))
                                {
                                    companias.Add(carro.id_compania);
                                }
                            }
                            idDespacho.Add(carro.id_carro);
                            // disminuir
                            cantidad.Cantidad[i]--;
                        }
                        else
                        {
                            sinDespacho.Add(cantidad.Id_tipo[i]);
                            break;
                        }
                    }
                }

                for (int i = 0; i < cantidad.Id_tipo.Length; i++)
                {
                    if (cantidad.Cantidad[i] != 0)
                    {
                        z_tipo_carro tipo = new z_tipo_carro().getObjectz_tipo_carro(cantidad.Id_tipo[i]);

                        //sindesp += tipo.tipo_carro_letra + ": " + cantidad.Cantidad[i] + "; ";
                        sindesp += cantidad.Cantidad[i] + " " + tipo.tipo_carro_letra + "; ";
                    }
                }
            }
            catch (Exception e)
            {
                Log.Write(e);
                MessageBox.Show("No se pudo completar la operación debido a un error de Base de Datos.",
                                "Mensaje de ZEUS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            // verificar r en compañia
            var c    = new z_carros();
            int sinR = 0;

            foreach (int id in R)
            {
                bool encompania = false;
                c = c.getObjectz_carros(id);
                foreach (int comp in companias)
                {
                    if (comp == c.id_compania)
                    {
                        encompania = true;
                    }
                }
                if (!encompania)
                {
                    // liberar carro
                    var l = new List <int> {
                        id
                    };
                    CancelarDespacho(l);
                    idDespacho.Remove(id);
                    sinR++;
                }
            }
            if (sinR != 0)
            {
                sindesp += sinR + " R";
            }
            return(idDespacho);
        }