Example #1
0
        /// <summary>
        /// Método Público encargado de Guardar la Dirección
        /// </summary>
        /// <returns></returns>
        public RetornoOperacion GuardaDireccion()
        {   //Declarando Variable de Retorno
            RetornoOperacion result = new RetornoOperacion();

            //Evaluando Estatus
            if (gvUbicaciones.SelectedIndex != -1)
            {     //Instanciando Ubicación con los Valores Obtenidos
                using (SAT_CL.Global.Direccion dir = new SAT_CL.Global.Direccion(Convert.ToInt32(gvUbicaciones.SelectedDataKey["Id"])))
                { //Validando que exista la Dirección
                    if (dir.id_direccion != 0)
                    {
                        //Obteniendo Resultado de la Edición
                        result = dir.EditaDireccion(Convert.ToByte(ddlTipoUbicacion.SelectedValue),
                                                    txtCalle.Text.ToUpper(), txtNoExt.Text.ToUpper(), txtNoInt.Text.ToUpper(), txtColonia.Text.ToUpper(),
                                                    txtLocalidad.Text.ToUpper(), txtMunicipio.Text.ToUpper(), txtReferencia.Text.ToUpper(),
                                                    Convert.ToInt32(ddlIDSTA.SelectedValue), Convert.ToInt32(ddlPais.SelectedValue),
                                                    txtCP.Text.ToUpper(), ((SAT_CL.Seguridad.Usuario)Session["usuario"]).id_usuario);
                    }
                    else//Instanciando Exception
                    {
                        result = new RetornoOperacion("No se encontro la Dirección en BD");
                    }
                }
            }
            else
            {         //Validando que existe una Dirección Previa
                if (this._id_direccion != 0)
                {     //Instanciando Ubicación con los Valores Obtenidos
                    using (SAT_CL.Global.Direccion dir = new SAT_CL.Global.Direccion(this._id_direccion))
                    { //Validando que exista la Dirección
                        if (dir.id_direccion != 0)
                        {
                            //Obteniendo Resultado de la Edición
                            result = dir.EditaDireccion(Convert.ToByte(ddlTipoUbicacion.SelectedValue),
                                                        txtCalle.Text.ToUpper(), txtNoExt.Text.ToUpper(), txtNoInt.Text.ToUpper(), txtColonia.Text.ToUpper(),
                                                        txtLocalidad.Text.ToUpper(), txtMunicipio.Text.ToUpper(), txtReferencia.Text.ToUpper(),
                                                        Convert.ToInt32(ddlIDSTA.SelectedValue), Convert.ToInt32(ddlPais.SelectedValue),
                                                        txtCP.Text.ToUpper(), ((SAT_CL.Seguridad.Usuario)Session["usuario"]).id_usuario);
                        }
                        else//Instanciando Exception
                        {
                            result = new RetornoOperacion("No se encontro la Dirección en BD");
                        }
                    }
                }
                else//Obteniendo Resultado de la Inserción
                {
                    result = SAT_CL.Global.Direccion.InsertaDireccion(Convert.ToByte(ddlTipoUbicacion.SelectedValue),
                                                                      txtCalle.Text.ToUpper(), txtNoExt.Text.ToUpper(), txtNoInt.Text.ToUpper(), txtColonia.Text.ToUpper(),
                                                                      txtLocalidad.Text.ToUpper(), txtMunicipio.Text.ToUpper(), txtReferencia.Text.ToUpper(),
                                                                      Convert.ToInt32(ddlIDSTA.SelectedValue), Convert.ToInt32(ddlPais.SelectedValue),
                                                                      txtCP.Text.ToUpper(), ((SAT_CL.Seguridad.Usuario)Session["usuario"]).id_usuario);
                }
            }
            //Verificando si la Operación es Exitosa
            if (result.OperacionExitosa)
            {
                //Inicializando Control
                InicializaControl();
            }
            //Mostrando Mensaje
            ScriptServer.MuestraNotificacion(btnAceptar, result, ScriptServer.PosicionNotificacion.AbajoDerecha);
            //Devolviendo Resultado Obtenido
            return(result);
        }