private void bt_actualizar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtCodigo.Text) || string.IsNullOrWhiteSpace(txtDireccion.Text) || string.IsNullOrWhiteSpace(txtLatitud.Text) || string.IsNullOrWhiteSpace(txtLongitud.Text) || string.IsNullOrWhiteSpace(txtNombre.Text) ||
                string.IsNullOrWhiteSpace(txtTelefono.Text))
            {
                MessageBox.Show("Hay Uno o mas Campos Vacios!", "Campos Vacios!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            else
            {
                sucursal psucursal = new sucursal();
                psucursal.CodSucursal      = txtCodigo.Text.Trim();
                psucursal.NombreSucursal   = txtNombre.Text.Trim();
                psucursal.TelefonoSucursal = Convert.ToInt32(txtTelefono.Text.Trim());
                psucursal.Latitud          = Convert.ToDouble(txtLatitud.Text);
                psucursal.Longitud         = Convert.ToDouble(txtLongitud.Text);
                psucursal.DireccionSucural = txtDireccion.Text.Trim();

                int resultado = BDconsultas.ActualizarSucursal(psucursal);
                if (resultado > 0)
                {
                    MessageBox.Show("Sucursal Actualizada Con Exito!!", "Actualizado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Limpiar();
                }
                else
                {
                    MessageBox.Show("No se pudo actualizar la sucursal", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
예제 #2
0
        public static List <sucursal> BuscarSucursales()
        {
            List <sucursal> _lista   = new List <sucursal>();
            MySqlConnection conexion = BDcomun.ObtenerConexion();


            MySqlCommand    _comando = new MySqlCommand(String.Format("SELECT * FROM sucursal "), conexion);
            MySqlDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                sucursal psucursal = new sucursal();
                psucursal.CodSucursal      = _reader.GetString(0);
                psucursal.NombreSucursal   = _reader.GetString(1);
                psucursal.DireccionSucural = _reader.GetString(2);
                psucursal.Latitud          = _reader.GetDouble(3);
                psucursal.Longitud         = _reader.GetDouble(4);
                psucursal.TelefonoSucursal = _reader.GetInt32(5);


                _lista.Add(psucursal);
            }

            conexion.Close();
            return(_lista);
        }
예제 #3
0
        public static int AgregarSucursal(sucursal psucursal)
        {
            int             retorno  = 0;
            MySqlConnection conexion = BDcomun.ObtenerConexion();

            MySqlCommand comando = new MySqlCommand(string.Format("Insert into sucursal (CodSucursal, NombreSucursal, DireccionSucursal, Latitud, Longitud, Telefonosucursal) values ('{0}','{1}','{2}','{3}','{4}','{5}')",
                                                                  psucursal.CodSucursal, psucursal.NombreSucursal, psucursal.DireccionSucural, psucursal.Latitud, psucursal.Longitud, psucursal.TelefonoSucursal), BDcomun.ObtenerConexion());

            retorno = comando.ExecuteNonQuery();
            conexion.Close();
            return(retorno);
        }
예제 #4
0
        public static int ActualizarSucursal(sucursal pactusuc)
        {
            int             retorno  = 0;
            MySqlConnection conexion = BDcomun.ObtenerConexion();

            MySqlCommand comando = new MySqlCommand(string.Format("Update sucursal set  NombreSucursal='{0}', DireccionSucursal='{1}', Latitud='{2}', Longitud='{3}', TelefonoSucursal='{4}' where CodSucursal={5}",
                                                                  pactusuc.NombreSucursal, pactusuc.DireccionSucural, pactusuc.Latitud, pactusuc.Longitud, pactusuc.TelefonoSucursal, pactusuc.CodSucursal), conexion);

            retorno = comando.ExecuteNonQuery();
            conexion.Close();

            return(retorno);
        }
예제 #5
0
        private void bt_seleccionar_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 1)
            {
                string codigosucursal = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value);
                SucursalSeleccionada = BDconsultas.ObtenerSucursal(codigosucursal);

                this.Close();
            }
            else
            {
                MessageBox.Show("Debe de seleccionar una fila");
            }
        }
 private void MENU_DISTANCIAS_Load(object sender, EventArgs e)
 {
     coordenadas              = BDconsultas.ObtenerLat(label2.Text);
     LatInicial               = coordenadas.Latitud;
     LngInicial               = coordenadas.Longitud;
     gMapControl1.DragButton  = MouseButtons.Left;
     gMapControl1.CanDragMap  = true;
     gMapControl1.MapProvider = GMapProviders.GoogleMap;
     gMapControl1.Position    = new PointLatLng(LatInicial, LngInicial);
     gMapControl1.MinZoom     = 0;
     gMapControl1.MaxZoom     = 24;
     gMapControl1.Zoom        = 9;
     gMapControl1.AutoScroll  = true;
     dataGridView1.Columns.Add("Distancia", "DISTANCIA");
 }
        private void btdistancias_Click(object sender, EventArgs e)
        {
            coordenadas = BDconsultas.ObtenerLat(label2.Text);
            LatInicial  = coordenadas.Latitud;
            LngInicial  = coordenadas.Longitud;
            //Empezamos la formula de distancia entre dos puntos d(P1, P2)=raiz((x2-x1)^2 + (y2-y1)^2)
            double x2        = Convert.ToDouble(dataGridView1.CurrentRow.Cells[3].Value.ToString());
            double x1        = LatInicial;
            double y2        = Convert.ToDouble(dataGridView1.CurrentRow.Cells[4].Value.ToString());
            double y1        = LngInicial;
            double x         = x2 - x1;
            double y         = y2 - y1;
            double resultado = Math.Sqrt((Math.Pow(x, 2)) + (Math.Pow(y, 2)));

            dataGridView1.CurrentRow.Cells[6].Value = (resultado);
        }
예제 #8
0
        public static sucursal ObtenerLat(string coordenadas)
        {
            sucursal        psuc     = new sucursal();
            MySqlConnection conexion = BDcomun.ObtenerConexion();

            MySqlCommand    _comando = new MySqlCommand(String.Format("SELECT Latitud, Longitud FROM sucursal where CodSucursal = {0} ", coordenadas), conexion);
            MySqlDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                psuc.Latitud  = _reader.GetDouble(0);
                psuc.Longitud = _reader.GetDouble(1);
            }

            conexion.Close();
            return(psuc);
        }
예제 #9
0
        public static sucursal ObtenerSucursal(string pCodigoSucursal)
        {
            sucursal        psucursal = new sucursal();
            MySqlConnection conexion  = BDcomun.ObtenerConexion();

            MySqlCommand    _comando = new MySqlCommand(String.Format("SELECT * FROM sucursal where CodSucursal = {0} ", pCodigoSucursal), conexion);
            MySqlDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                psucursal.CodSucursal      = _reader.GetString(0);
                psucursal.NombreSucursal   = _reader.GetString(1);
                psucursal.DireccionSucural = _reader.GetString(2);
                psucursal.Latitud          = _reader.GetDouble(3);
                psucursal.Longitud         = _reader.GetDouble(4);
                psucursal.TelefonoSucursal = _reader.GetInt32(5);
            }

            conexion.Close();
            return(psucursal);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            MENU_BORRARSUCURSAL buscar = new MENU_BORRARSUCURSAL();

            buscar.ShowDialog();

            if (buscar.SucursalSeleccionada != null)

            {
                sucursalactual    = buscar.SucursalSeleccionada;
                txtCodigo.Text    = buscar.SucursalSeleccionada.CodSucursal;
                txtDireccion.Text = buscar.SucursalSeleccionada.DireccionSucural;
                txtLatitud.Text   = Convert.ToString(buscar.SucursalSeleccionada.Latitud);
                txtLongitud.Text  = Convert.ToString(buscar.SucursalSeleccionada.Longitud);
                txtNombre.Text    = buscar.SucursalSeleccionada.NombreSucursal;
                txtTelefono.Text  = Convert.ToString(buscar.SucursalSeleccionada.TelefonoSucursal);

                bt_actualizar.Enabled = true;
                bt_eliminar.Enabled   = true;
                Habilitar();
                bt_guardar.Enabled = false;
            }
        }