Beispiel #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public bitacora_llamados getObjectbitacora_llamados(System.Int32 myID)
        {
            bitacora_llamados mybitacora_llamados = new bitacora_llamados();
            CnxBase           myBase = new CnxBase();
            string            reqSQL = "SELECT id_evento,fecha,evento,id_operadora,id_carro, id_expediente, tipo FROM bitacora_llamados WHERE (id_evento=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    mybitacora_llamados.id_evento     = Convert.ToInt32(myReader[0]);
                    mybitacora_llamados.fecha         = Convert.ToDateTime(myReader[1]);
                    mybitacora_llamados.evento        = myReader[2].ToString();
                    mybitacora_llamados.id_operadora  = Convert.ToInt32(myReader[3]);
                    mybitacora_llamados.id_carro      = Convert.ToInt32(myReader[4]);
                    mybitacora_llamados.id_expediente = Convert.ToInt32(myReader[5]);
                    mybitacora_llamados.tipo          = Convert.ToString(myReader[6]);
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(mybitacora_llamados);
        }
Beispiel #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(bitacora_llamados mybitacora_llamados)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE bitacora_llamados SET id_evento=" + mybitacora_llamados.id_evento + ",fecha='" + mybitacora_llamados.fecha + "',evento='" + mybitacora_llamados.evento + "',id_operadora=" + mybitacora_llamados.id_operadora + ",id_carro=" + mybitacora_llamados.id_carro + ",tipo='" + mybitacora_llamados.tipo + "' WHERE (id_evento=" + mybitacora_llamados.id_evento + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
        }
Beispiel #3
0
        public void ActualizarClave(int idExpediente, int idCarro, string seis_cero, string seis_tres, string seis_siete, string seis_ocho, string seis_nueve, string seis_dies)
        {
            CnxBase           myBase = new CnxBase();
            NpgsqlConnection  myConn = myBase.OpenConnection(myBase.cnxString);
            bitacora_llamados bll    = new bitacora_llamados();

            if (seis_cero != "")
            {
                if (bll.ExistenciaCarroBitacoraLlamados(idCarro, idExpediente, "6-0"))
                {
                    string reqSQL = "update bitacora_llamados set fecha = '" + seis_cero + "' where id_expediente = " + idExpediente + " and id_carro = " + idCarro + " and evento like '%6-0%'";
                    try
                    {
                        NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn);
                        myCommand.ExecuteNonQuery();
                    }
                    catch (Exception myErr)
                    {
                        throw (new Exception(myErr.ToString() + reqSQL));
                    }
                }
                else
                {
                    InsertarEventoBLL(seis_cero, "6-0", DatosLogin.LoginUsuario, idCarro, idExpediente, "carro");
                }
            }

            if (seis_tres != "")
            {
                if (bll.ExistenciaCarroBitacoraLlamados(idCarro, idExpediente, "6-3"))
                {
                    string reqSQL = "update bitacora_llamados set fecha = '" + seis_tres + "' where id_expediente = " + idExpediente + " and id_carro = " + idCarro + " and evento like '%6-3%'";
                    try
                    {
                        NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn);
                        myCommand.ExecuteNonQuery();
                    }
                    catch (Exception myErr)
                    {
                        throw (new Exception(myErr.ToString() + reqSQL));
                    }
                }
                else
                {
                    InsertarEventoBLL(seis_tres, "6-3", DatosLogin.LoginUsuario, idCarro, idExpediente, "carro");
                }
            }

            if (seis_siete != "")
            {
                if (bll.ExistenciaCarroBitacoraLlamados(idCarro, idExpediente, "6-7"))
                {
                    string reqSQL = "update bitacora_llamados set fecha = '" + seis_siete + "' where id_expediente = " + idExpediente + " and id_carro = " + idCarro + " and evento like '%6-7%'";
                    try
                    {
                        NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn);
                        myCommand.ExecuteNonQuery();
                    }
                    catch (Exception myErr)
                    {
                        throw (new Exception(myErr.ToString() + reqSQL));
                    }
                }
                else
                {
                    InsertarEventoBLL(seis_siete, "6-7", DatosLogin.LoginUsuario, idCarro, idExpediente, "carro");
                }
            }

            if (seis_ocho != "")
            {
                if (bll.ExistenciaCarroBitacoraLlamados(idCarro, idExpediente, "6-8"))
                {
                    string reqSQL = "update bitacora_llamados set fecha = '" + seis_ocho + "' where id_expediente = " + idExpediente + " and id_carro = " + idCarro + " and evento like '%6-8%'";
                    try
                    {
                        NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn);
                        myCommand.ExecuteNonQuery();
                    }
                    catch (Exception myErr)
                    {
                        throw (new Exception(myErr.ToString() + reqSQL));
                    }
                }
                else
                {
                    InsertarEventoBLL(seis_ocho, "6-8", DatosLogin.LoginUsuario, idCarro, idExpediente, "carro");
                }
            }

            if (seis_nueve != "")
            {
                if (bll.ExistenciaCarroBitacoraLlamados(idCarro, idExpediente, "6-9"))
                {
                    string reqSQL = "update bitacora_llamados set fecha = '" + seis_nueve + "' where id_expediente = " + idExpediente + " and id_carro = " + idCarro + " and evento like '%6-9%'";
                    try
                    {
                        NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn);
                        myCommand.ExecuteNonQuery();
                    }
                    catch (Exception myErr)
                    {
                        throw (new Exception(myErr.ToString() + reqSQL));
                    }
                }
                else
                {
                    InsertarEventoBLL(seis_nueve, "6-9", DatosLogin.LoginUsuario, idCarro, idExpediente, "carro");
                }
            }

            if (seis_dies != "")
            {
                if (bll.ExistenciaCarroBitacoraLlamados(idCarro, idExpediente, "6-10"))
                {
                    string reqSQL = "update bitacora_llamados set fecha = '" + seis_dies + "' where id_expediente = " + idExpediente + " and id_carro = " + idCarro + " and evento like '%6-10%'";
                    try
                    {
                        NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn);
                        myCommand.ExecuteNonQuery();
                    }
                    catch (Exception myErr)
                    {
                        throw (new Exception(myErr.ToString() + reqSQL));
                    }
                }
                else
                {
                    InsertarEventoBLL(seis_dies, "6-10", DatosLogin.LoginUsuario, idCarro, idExpediente, "carro");
                }
            }

            myBase.CloseConnection(myConn);
        }
Beispiel #4
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(bitacora_llamados mybitacora_llamados, bool fecha_servidor)
        {
            CnxBase myBase = new CnxBase();

            if (mybitacora_llamados.id_expediente > 0)
            {
                /* MODIFICACIONES DE MARCOS PONCE --> DESDE ABAJO */

                if (mybitacora_llamados.evento == "6-3")
                {
                    // Consultar por el expediente
                    string SQL_coordenadas = "SELECT \"puntoX\",\"puntoY\" FROM e_expedientes WHERE id_expediente = " + mybitacora_llamados.id_expediente;
                    try
                    {
                        NpgsqlConnection  myConn             = myBase.OpenConnection(myBase.cnxString);
                        DataSet           ds_coor_emergencia = new DataSet();
                        NpgsqlDataAdapter da_coor_emergencia = new NpgsqlDataAdapter(SQL_coordenadas, myConn);
                        da_coor_emergencia.Fill(ds_coor_emergencia);
                        foreach (DataRow r_coor_emergencia in ds_coor_emergencia.Tables[0].Rows)
                        {
                            CoordenadaX = Convert.ToDecimal(r_coor_emergencia["puntoX"].ToString());
                            CoordenadaY = Convert.ToDecimal(r_coor_emergencia["puntoY"].ToString());
                        }

                        string SQL_update_coordenadas_carros = "UPDATE z_carros SET carro_x = " + Convert.ToInt32(CoordenadaX) + ", carro_y = " + Convert.ToInt32(CoordenadaY) + " WHERE id_carro = " + mybitacora_llamados.id_carro;
                        try
                        {
                            NpgsqlCommand myCommand = new NpgsqlCommand(SQL_update_coordenadas_carros, myConn);
                            myCommand.ExecuteNonQuery();
                            myBase.CloseConnection(myConn);
                        }
                        catch (Exception myErr)
                        {
                            throw (new Exception(myErr.ToString() + SQL_update_coordenadas_carros));
                        }
                    }
                    catch (Exception myErr)
                    {
                        throw (new Exception(myErr.ToString() + SQL_coordenadas));
                    }

                    // Insertar en la tabla carros las coordenadas de la emergencia del expediente.
                }
            }

            //CnxBase myBase = new CnxBase();

            /* MODIFICACIONES DE MARCOS PONCE --> DESDE ARRIBA */

            string reqSQL = "INSERT INTO bitacora_llamados (fecha,evento,id_operadora,id_carro, id_expediente, tipo) VALUES ('" + (fecha_servidor ? "now" : mybitacora_llamados.fecha.ToString()) + "','" + mybitacora_llamados.evento + "'," + mybitacora_llamados.id_operadora + "," + mybitacora_llamados.id_carro + "," + mybitacora_llamados.id_expediente + ",'" + mybitacora_llamados.tipo + "')";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
        }